'SK_SUPPORT_LEGACY_CLIP_REGIONOPS',
'SK_SUPPORT_LEGACY_SHADER_ISABITMAP',
'SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES',
+ 'SK_SUPPORT_LEGACY_SHADER_ASALOCALMATRIXSHADER',
],
},
}
static sk_sp<SkShader> MakePictureShader(sk_sp<SkPicture> src, TileMode tmx, TileMode tmy,
const SkMatrix* localMatrix, const SkRect* tile);
+#ifdef SK_SUPPORT_LEGACY_SHADER_ASALOCALMATRIXSHADER
/**
* If this shader can be represented by another shader + a localMatrix, return that shader
* and, if not NULL, the localMatrix. If not, return NULL and ignore the localMatrix parameter.
* Note: the returned shader (if not NULL) will have been ref'd, and it is the responsibility
* of the caller to balance that with unref() when they are done.
*/
- virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const;
+ SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const {
+ return this->makeAsALocalMatrixShader(localMatrix).release();
+ }
+#endif
+ /**
+ * If this shader can be represented by another shader + a localMatrix, return that shader and
+ * the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
+ */
+ virtual sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const;
SK_TO_STRING_VIRT()
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
"SK_SUPPORT_LEGACY_XFERMODE_OBJECT",
"SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES",
+ "SK_SUPPORT_LEGACY_SHADER_ASALOCALMATRIXSHADER",
]
################################################################################
const SkMatrix* lm = &localMatrix;
- SkShader* baseShader = const_cast<SkShader*>(this);
+ sk_sp<SkShader> baseShader;
SkMatrix otherLocalMatrix;
- SkAutoTUnref<SkShader> proxy(this->refAsALocalMatrixShader(&otherLocalMatrix));
+ sk_sp<SkShader> proxy(this->makeAsALocalMatrixShader(&otherLocalMatrix));
if (proxy) {
otherLocalMatrix.preConcat(localMatrix);
lm = &otherLocalMatrix;
- baseShader = proxy.get();
+ baseShader = proxy;
+ } else {
+ baseShader = sk_ref_sp(const_cast<SkShader*>(this));
}
- return sk_make_sp<SkLocalMatrixShader>(baseShader, *lm);
+ return sk_make_sp<SkLocalMatrixShader>(std::move(baseShader), *lm);
}
class SkLocalMatrixShader : public SkShader {
public:
- SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix)
+ SkLocalMatrixShader(sk_sp<SkShader> proxy, const SkMatrix& localMatrix)
: INHERITED(&localMatrix)
- , fProxyShader(SkRef(proxy))
+ , fProxyShader(std::move(proxy))
{}
GradientType asAGradient(GradientInfo* info) const override {
sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
- SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
+ sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const override {
if (localMatrix) {
*localMatrix = this->getLocalMatrix();
}
- return SkRef(fProxyShader.get());
+ return fProxyShader;
}
SK_TO_STRING_OVERRIDE()
#endif
private:
- SkAutoTUnref<SkShader> fProxyShader;
+ sk_sp<SkShader> fProxyShader;
typedef SkShader INHERITED;
};
}
#endif
-SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
+sk_sp<SkShader> SkShader::makeAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
}