OLD | NEW |
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 if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) { | 11 if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) { |
12 buffer.readMatrix(&(INHERITED::fLocalMatrix)); | 12 buffer.readMatrix(&(INHERITED::fLocalMatrix)); |
13 } | 13 } |
14 fProxyShader.reset(buffer.readShader()); | 14 fProxyShader.reset(buffer.readShader()); |
15 if (NULL == fProxyShader.get()) { | 15 if (NULL == fProxyShader.get()) { |
16 sk_throw(); | 16 sk_throw(); |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { | 20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { |
21 this->INHERITED::flatten(buffer); | 21 this->INHERITED::flatten(buffer); |
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); |
28 SkMatrix tmp; | 28 SkMatrix tmp; |
29 if (rec.fLocalMatrix) { | 29 if (rec.fLocalMatrix) { |
30 tmp.setConcat(this->getLocalMatrix(), *rec.fLocalMatrix); | 30 tmp.setConcat(*rec.fLocalMatrix, this->getLocalMatrix()); |
31 newRec.fLocalMatrix = &tmp; | 31 newRec.fLocalMatrix = &tmp; |
32 } else { | 32 } else { |
33 newRec.fLocalMatrix = &this->getLocalMatrix(); | 33 newRec.fLocalMatrix = &this->getLocalMatrix(); |
34 } | 34 } |
35 return fProxyShader->createContext(newRec, storage); | 35 return fProxyShader->createContext(newRec, storage); |
36 } | 36 } |
37 | 37 |
38 #ifndef SK_IGNORE_TO_STRING | 38 #ifndef SK_IGNORE_TO_STRING |
39 void SkLocalMatrixShader::toString(SkString* str) const { | 39 void SkLocalMatrixShader::toString(SkString* str) const { |
40 str->append("SkLocalMatrixShader: ("); | 40 str->append("SkLocalMatrixShader: ("); |
(...skipping 16 matching lines...) Expand all Loading... |
57 SkMatrix otherLocalMatrix; | 57 SkMatrix otherLocalMatrix; |
58 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); | 58 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); |
59 if (otherProxy.get()) { | 59 if (otherProxy.get()) { |
60 otherLocalMatrix.preConcat(localMatrix); | 60 otherLocalMatrix.preConcat(localMatrix); |
61 lm = &otherLocalMatrix; | 61 lm = &otherLocalMatrix; |
62 proxy = otherProxy.get(); | 62 proxy = otherProxy.get(); |
63 } | 63 } |
64 | 64 |
65 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm)); | 65 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm)); |
66 } | 66 } |
OLD | NEW |