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 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 SkAutoTUnref<SkShader> shader(buffer.readShader()); | 13 SkAutoTUnref<SkShader> shader(buffer.readShader()); |
14 if (!shader.get()) { | 14 if (!shader.get()) { |
15 return NULL; | 15 return nullptr; |
16 } | 16 } |
17 return SkShader::CreateLocalMatrixShader(shader, lm); | 17 return SkShader::CreateLocalMatrixShader(shader, lm); |
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, |
(...skipping 15 matching lines...) Expand all Loading... |
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::CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& loc
alMatrix) { | 50 SkShader* SkShader::CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& loc
alMatrix) { |
51 if (NULL == proxy) { | 51 if (nullptr == proxy) { |
52 return NULL; | 52 return nullptr; |
53 } | 53 } |
54 | 54 |
55 if (localMatrix.isIdentity()) { | 55 if (localMatrix.isIdentity()) { |
56 return SkRef(proxy); | 56 return SkRef(proxy); |
57 } | 57 } |
58 | 58 |
59 const SkMatrix* lm = &localMatrix; | 59 const SkMatrix* lm = &localMatrix; |
60 | 60 |
61 SkMatrix otherLocalMatrix; | 61 SkMatrix otherLocalMatrix; |
62 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); | 62 SkAutoTUnref<SkShader> otherProxy(proxy->refAsALocalMatrixShader(&otherLocal
Matrix)); |
63 if (otherProxy.get()) { | 63 if (otherProxy.get()) { |
64 otherLocalMatrix.preConcat(localMatrix); | 64 otherLocalMatrix.preConcat(localMatrix); |
65 lm = &otherLocalMatrix; | 65 lm = &otherLocalMatrix; |
66 proxy = otherProxy.get(); | 66 proxy = otherProxy.get(); |
67 } | 67 } |
68 | 68 |
69 return new SkLocalMatrixShader(proxy, *lm); | 69 return new SkLocalMatrixShader(proxy, *lm); |
70 } | 70 } |
OLD | NEW |