diff options
author | 2016-10-24 11:36:21 -0400 | |
---|---|---|
committer | 2016-10-24 16:40:01 +0000 | |
commit | a8834bb323302bc18f373ad18214d9d96e7af4c9 (patch) | |
tree | 12fe68a37dfb625f36acd31fb99acfbec69c169d /src/core | |
parent | a3f79c0b42d4b3d761694976665f44939ea86014 (diff) |
SkShader* refAs... to sk_sp<SkShader> makeAs...
There appear to be no existing overriders of the refAs.. method outside
Skia.
Change-Id: Iab174e83023093b4d7fc0bd8907666b66ddb1eea
Reviewed-on: https://skia-review.googlesource.com/3746
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkLocalMatrixShader.cpp | 10 | ||||
-rw-r--r-- | src/core/SkLocalMatrixShader.h | 10 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp index cdd7533273..506fd3e71a 100644 --- a/src/core/SkLocalMatrixShader.cpp +++ b/src/core/SkLocalMatrixShader.cpp @@ -70,14 +70,16 @@ sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const 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); } diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index 849d9af91d..6bffb491fb 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -16,9 +16,9 @@ class GrFragmentProcessor; 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 { @@ -29,11 +29,11 @@ public: 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() @@ -58,7 +58,7 @@ protected: #endif private: - SkAutoTUnref<SkShader> fProxyShader; + sk_sp<SkShader> fProxyShader; typedef SkShader INHERITED; }; diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 15d7f4cda4..c452d078af 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -230,7 +230,7 @@ sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(const AsFPArgs&) const } #endif -SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { +sk_sp<SkShader> SkShader::makeAsALocalMatrixShader(SkMatrix*) const { return nullptr; } |