// V27: Remove SkUnitMapper from gradients (and skia).
// V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap.
// V29: Removed SaveFlags parameter from save().
+ // V30: Remove redundant SkMatrix from SkLocalMatrixShader.
// Note: If the picture version needs to be increased then please follow the
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
// Only SKPs within the min/current picture version range (inclusive) can be read.
static const uint32_t MIN_PICTURE_VERSION = 19;
- static const uint32_t CURRENT_PICTURE_VERSION = 29;
+ static const uint32_t CURRENT_PICTURE_VERSION = 30;
mutable uint32_t fUniqueID;
kColorShaderNoBool_Version = 26,
kNoUnitMappers_Version = 27,
kNoMoreBitmapFlatten_Version = 28,
+ kSimplifyLocalMatrix_Version = 30,
};
/**
/**
* Returns the local matrix.
+ *
+ * FIXME: This can be incorrect for a Shader with its own local matrix
+ * that is also wrapped via CreateLocalMatrixShader.
*/
const SkMatrix& getLocalMatrix() const { return fLocalMatrix; }
/**
* Returns true if the local matrix is not an identity matrix.
+ *
+ * FIXME: This can be incorrect for a Shader with its own local matrix
+ * that is also wrapped via CreateLocalMatrixShader.
*/
bool hasLocalMatrix() const { return !fLocalMatrix.isIdentity(); }
private:
SkMatrix fLocalMatrix;
-
+
+ // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer constructor.
+ friend class SkLocalMatrixShader;
+
typedef SkFlattenable INHERITED;
};
#include "SkLocalMatrixShader.h"
SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) {
- buffer.readMatrix(&fProxyLocalMatrix);
+ if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) {
+ buffer.readMatrix(&(INHERITED::fLocalMatrix));
+ }
fProxyShader.reset(buffer.readShader());
if (NULL == fProxyShader.get()) {
sk_throw();
void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- buffer.writeMatrix(fProxyLocalMatrix);
buffer.writeFlattenable(fProxyShader.get());
}
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);
}
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 {
virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
GrColor* grColor, GrEffect** grEffect) const SK_OVERRIDE {
- SkMatrix tmp = fProxyLocalMatrix;
+ SkMatrix tmp = this->getLocalMatrix();
if (localMatrix) {
tmp.preConcat(*localMatrix);
}
virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const SK_OVERRIDE {
if (localMatrix) {
- *localMatrix = fProxyLocalMatrix;
+ *localMatrix = this->getLocalMatrix();
}
return SkRef(fProxyShader.get());
}
private:
SkAutoTUnref<SkShader> fProxyShader;
- SkMatrix fProxyLocalMatrix;
typedef SkShader INHERITED;
};