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

Side by Side Diff: src/core/SkLocalMatrixShader.cpp

Issue 1782703002: sk_sp versions of newWithColorFilter and newWithLocalMatrix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « src/core/SkColorFilterShader.cpp ('k') | tests/SkColor4fTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLocalMatrixShader.h" 8 #include "SkLocalMatrixShader.h"
9 9
10 SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) { 10 SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
11 SkMatrix lm; 11 SkMatrix lm;
12 buffer.readMatrix(&lm); 12 buffer.readMatrix(&lm);
13 auto baseShader(buffer.readShader()); 13 auto baseShader(buffer.readShader());
14 if (!baseShader) { 14 if (!baseShader) {
15 return nullptr; 15 return nullptr;
16 } 16 }
17 return baseShader->newWithLocalMatrix(lm); 17 return baseShader->makeWithLocalMatrix(lm).release();
18 } 18 }
19 19
20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { 20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
21 buffer.writeMatrix(this->getLocalMatrix()); 21 buffer.writeMatrix(this->getLocalMatrix());
22 buffer.writeFlattenable(fProxyShader.get()); 22 buffer.writeFlattenable(fProxyShader.get());
23 } 23 }
24 24
25 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec, 25 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec,
26 void* storage) const { 26 void* storage) const {
27 ContextRec newRec(rec); 27 ContextRec newRec(rec);
(...skipping 12 matching lines...) Expand all
40 str->append("SkLocalMatrixShader: ("); 40 str->append("SkLocalMatrixShader: (");
41 41
42 fProxyShader->toString(str); 42 fProxyShader->toString(str);
43 43
44 this->INHERITED::toString(str); 44 this->INHERITED::toString(str);
45 45
46 str->append(")"); 46 str->append(")");
47 } 47 }
48 #endif 48 #endif
49 49
50 SkShader* SkShader::newWithLocalMatrix(const SkMatrix& localMatrix) const { 50 sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const {
51 if (localMatrix.isIdentity()) { 51 if (localMatrix.isIdentity()) {
52 return SkRef(const_cast<SkShader*>(this)); 52 return sk_ref_sp(const_cast<SkShader*>(this));
53 } 53 }
54 54
55 const SkMatrix* lm = &localMatrix; 55 const SkMatrix* lm = &localMatrix;
56 56
57 SkShader* baseShader = const_cast<SkShader*>(this); 57 SkShader* baseShader = const_cast<SkShader*>(this);
58 SkMatrix otherLocalMatrix; 58 SkMatrix otherLocalMatrix;
59 SkAutoTUnref<SkShader> proxy(this->refAsALocalMatrixShader(&otherLocalMatrix )); 59 SkAutoTUnref<SkShader> proxy(this->refAsALocalMatrixShader(&otherLocalMatrix ));
60 if (proxy) { 60 if (proxy) {
61 otherLocalMatrix.preConcat(localMatrix); 61 otherLocalMatrix.preConcat(localMatrix);
62 lm = &otherLocalMatrix; 62 lm = &otherLocalMatrix;
63 baseShader = proxy.get(); 63 baseShader = proxy.get();
64 } 64 }
65 65
66 return new SkLocalMatrixShader(baseShader, *lm); 66 return sk_make_sp<SkLocalMatrixShader>(baseShader, *lm);
67 } 67 }
OLDNEW
« no previous file with comments | « src/core/SkColorFilterShader.cpp ('k') | tests/SkColor4fTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698