aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2014-07-10 16:37:28 -0400
committerLeon Scroggins III <scroggo@google.com>2014-07-10 17:57:54 -0400
commit3e629e16548e45750fcad5e7a28bbf6dfc8571ef (patch)
tree659a9c90f7b4624cfcc977f57025180678446e5a
parent541513a7e3c569a1b2531c9dbb1d93d493ab3b01 (diff)
downloadskia-3e629e16548e45750fcad5e7a28bbf6dfc8571ef.tar.gz
Use SkShader's localMat for SkLocalMatrixShader.
Cherry-pick of https://codereview.chromium.org/386693003/ Instead of setting SkShader::fLocalMatrix to Identity and storing a separate SkMatrix inside SkLocalMatrixShader, reuse SkShader::fLocalMatrix. Conflicts: src/core/SkLocalMatrixShader.h BUG:14315916 Change-Id: I673801444f0a8fd4f192b5b7effdde1aa83e702b
-rw-r--r--src/core/SkLocalMatrixShader.cpp6
-rw-r--r--src/core/SkLocalMatrixShader.h9
2 files changed, 6 insertions, 9 deletions
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index 53580e6ac9..afa782801d 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -8,7 +8,6 @@
#include "SkLocalMatrixShader.h"
SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) {
- buffer.readMatrix(&fProxyLocalMatrix);
fProxyShader.reset(buffer.readShader());
if (NULL == fProxyShader.get()) {
sk_throw();
@@ -17,7 +16,6 @@ SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe
void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- buffer.writeMatrix(fProxyLocalMatrix);
buffer.writeFlattenable(fProxyShader.get());
}
@@ -26,10 +24,10 @@ SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec,
ContextRec newRec(rec);
SkMatrix tmp;
if (rec.fLocalMatrix) {
- tmp.setConcat(fProxyLocalMatrix, *rec.fLocalMatrix);
+ tmp.setConcat(this->getLocalMatrix(), *rec.fLocalMatrix);
newRec.fLocalMatrix = &tmp;
} else {
- newRec.fLocalMatrix = &fProxyLocalMatrix;
+ newRec.fLocalMatrix = &this->getLocalMatrix();
}
return fProxyShader->createContext(newRec, storage);
}
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 1143f062d3..66d0c33e33 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -15,8 +15,8 @@
class SkLocalMatrixShader : public SkShader {
public:
SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix)
- : fProxyShader(SkRef(proxy))
- , fProxyLocalMatrix(localMatrix)
+ : INHERITED(&localMatrix)
+ , fProxyShader(SkRef(proxy))
{}
virtual size_t contextSize() const SK_OVERRIDE {
@@ -36,7 +36,7 @@ public:
virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
GrColor* grColor, GrEffectRef** grEffect) const SK_OVERRIDE {
- SkMatrix tmp = fProxyLocalMatrix;
+ SkMatrix tmp = this->getLocalMatrix();
if (localMatrix) {
tmp.preConcat(*localMatrix);
}
@@ -55,7 +55,7 @@ public:
virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const SK_OVERRIDE {
if (localMatrix) {
- *localMatrix = fProxyLocalMatrix;
+ *localMatrix = this->getLocalMatrix();
}
return SkRef(fProxyShader.get());
}
@@ -70,7 +70,6 @@ protected:
private:
SkAutoTUnref<SkShader> fProxyShader;
- SkMatrix fProxyLocalMatrix;
typedef SkShader INHERITED;
};