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 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
10 SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe
r) { | 11 SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe
r) { |
11 if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) { | 12 if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) { |
12 buffer.readMatrix(&(INHERITED::fLocalMatrix)); | 13 buffer.readMatrix(&(INHERITED::fLocalMatrix)); |
13 } | 14 } |
14 fProxyShader.reset(buffer.readShader()); | 15 fProxyShader.reset(buffer.readShader()); |
15 if (NULL == fProxyShader.get()) { | 16 if (NULL == fProxyShader.get()) { |
16 sk_throw(); | 17 sk_throw(); |
17 } | 18 } |
18 } | 19 } |
| 20 #endif |
| 21 |
| 22 SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) { |
| 23 SkMatrix lm; |
| 24 buffer.readMatrix(&lm); |
| 25 SkAutoTUnref<SkShader> shader(buffer.readShader()); |
| 26 if (!shader.get()) { |
| 27 return NULL; |
| 28 } |
| 29 return SkShader::CreateLocalMatrixShader(shader, lm); |
| 30 } |
19 | 31 |
20 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { | 32 void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const { |
21 this->INHERITED::flatten(buffer); | 33 buffer.writeMatrix(this->getLocalMatrix()); |
22 buffer.writeFlattenable(fProxyShader.get()); | 34 buffer.writeFlattenable(fProxyShader.get()); |
23 } | 35 } |
24 | 36 |
25 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec, | 37 SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec, |
26 void* storage) const { | 38 void* storage) const { |
27 ContextRec newRec(rec); | 39 ContextRec newRec(rec); |
28 SkMatrix tmp; | 40 SkMatrix tmp; |
29 if (rec.fLocalMatrix) { | 41 if (rec.fLocalMatrix) { |
30 tmp.setConcat(*rec.fLocalMatrix, this->getLocalMatrix()); | 42 tmp.setConcat(*rec.fLocalMatrix, this->getLocalMatrix()); |
31 newRec.fLocalMatrix = &tmp; | 43 newRec.fLocalMatrix = &tmp; |
(...skipping 25 matching lines...) Expand all Loading... |
57 SkMatrix otherLocalMatrix; | 69 SkMatrix otherLocalMatrix; |
58 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); | 70 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); |
59 if (otherProxy.get()) { | 71 if (otherProxy.get()) { |
60 otherLocalMatrix.preConcat(localMatrix); | 72 otherLocalMatrix.preConcat(localMatrix); |
61 lm = &otherLocalMatrix; | 73 lm = &otherLocalMatrix; |
62 proxy = otherProxy.get(); | 74 proxy = otherProxy.get(); |
63 } | 75 } |
64 | 76 |
65 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm)); | 77 return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm)); |
66 } | 78 } |
OLD | NEW |