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

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

Issue 386693003: Use SkShader's localMat for SkLocalMatrixShader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Refine comment. Created 6 years, 5 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/SkLocalMatrixShader.h ('k') | no next file » | 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 SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe r) { 10 SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe r) {
11 buffer.readMatrix(&fProxyLocalMatrix); 11 if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) {
12 buffer.readMatrix(&(INHERITED::fLocalMatrix));
13 }
12 fProxyShader.reset(buffer.readShader()); 14 fProxyShader.reset(buffer.readShader());
13 if (NULL == fProxyShader.get()) { 15 if (NULL == fProxyShader.get()) {
14 sk_throw(); 16 sk_throw();
15 } 17 }
16 } 18 }
17 19
18 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { 20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
19 this->INHERITED::flatten(buffer); 21 this->INHERITED::flatten(buffer);
20 buffer.writeMatrix(fProxyLocalMatrix);
21 buffer.writeFlattenable(fProxyShader.get()); 22 buffer.writeFlattenable(fProxyShader.get());
22 } 23 }
23 24
24 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec, 25 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec,
25 void* storage) const { 26 void* storage) const {
26 ContextRec newRec(rec); 27 ContextRec newRec(rec);
27 SkMatrix tmp; 28 SkMatrix tmp;
28 if (rec.fLocalMatrix) { 29 if (rec.fLocalMatrix) {
29 tmp.setConcat(fProxyLocalMatrix, *rec.fLocalMatrix); 30 tmp.setConcat(this->getLocalMatrix(), *rec.fLocalMatrix);
30 newRec.fLocalMatrix = &tmp; 31 newRec.fLocalMatrix = &tmp;
31 } else { 32 } else {
32 newRec.fLocalMatrix = &fProxyLocalMatrix; 33 newRec.fLocalMatrix = &this->getLocalMatrix();
33 } 34 }
34 return fProxyShader->createContext(newRec, storage); 35 return fProxyShader->createContext(newRec, storage);
35 } 36 }
36 37
37 #ifndef SK_IGNORE_TO_STRING 38 #ifndef SK_IGNORE_TO_STRING
38 void SkLocalMatrixShader::toString(SkString* str) const { 39 void SkLocalMatrixShader::toString(SkString* str) const {
39 str->append("SkLocalMatrixShader: ("); 40 str->append("SkLocalMatrixShader: (");
40 41
41 fProxyShader->toString(str); 42 fProxyShader->toString(str);
42 43
(...skipping 13 matching lines...) Expand all
56 SkMatrix otherLocalMatrix; 57 SkMatrix otherLocalMatrix;
57 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal Matrix)); 58 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal Matrix));
58 if (otherProxy.get()) { 59 if (otherProxy.get()) {
59 otherLocalMatrix.preConcat(localMatrix); 60 otherLocalMatrix.preConcat(localMatrix);
60 lm = &otherLocalMatrix; 61 lm = &otherLocalMatrix;
61 proxy = otherProxy.get(); 62 proxy = otherProxy.get();
62 } 63 }
63 64
64 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm)); 65 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm));
65 } 66 }
OLDNEW
« no previous file with comments | « src/core/SkLocalMatrixShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698