Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Unified Diff: src/core/SkLocalMatrixShader.cpp

Issue 1553743002: change factory to method, to parallel pattern in imagefilters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SamplePatch.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLocalMatrixShader.cpp
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index ce5a7cad713a22f00992a6054ef5c0041712b4ad..336f1c49cfece6907224bf8be973f93e4ffed459 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -10,11 +10,11 @@
SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
- SkAutoTUnref<SkShader> shader(buffer.readShader());
- if (!shader.get()) {
+ SkAutoTUnref<SkShader> baseShader(buffer.readShader());
+ if (!baseShader) {
return nullptr;
}
- return SkShader::CreateLocalMatrixShader(shader, lm);
+ return baseShader->newWithLocalMatrix(lm);
}
void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
@@ -47,24 +47,21 @@ void SkLocalMatrixShader::toString(SkString* str) const {
}
#endif
-SkShader* SkShader::CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) {
- if (nullptr == proxy) {
- return nullptr;
- }
-
+SkShader* SkShader::newWithLocalMatrix(const SkMatrix& localMatrix) const {
if (localMatrix.isIdentity()) {
- return SkRef(proxy);
+ return SkRef(const_cast<SkShader*>(this));
}
const SkMatrix* lm = &localMatrix;
+ SkShader* baseShader = const_cast<SkShader*>(this);
SkMatrix otherLocalMatrix;
- SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocalMatrix));
- if (otherProxy.get()) {
+ SkAutoTUnref<SkShader> proxy(this->refAsALocalMatrixShader(&otherLocalMatrix));
+ if (proxy) {
otherLocalMatrix.preConcat(localMatrix);
lm = &otherLocalMatrix;
- proxy = otherProxy.get();
+ baseShader = proxy.get();
}
- return new SkLocalMatrixShader(proxy, *lm);
+ return new SkLocalMatrixShader(baseShader, *lm);
}
« no previous file with comments | « samplecode/SamplePatch.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698