| 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 sk_sp<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->makeWithLocalMatrix(lm).release(); | 17 return baseShader->makeWithLocalMatrix(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, |
| 26 void* storage) const { | 26 void* storage) const { |
| 27 ContextRec newRec(rec); | 27 ContextRec newRec(rec); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 sk_make_sp<SkLocalMatrixShader>(baseShader, *lm); | 66 return sk_make_sp<SkLocalMatrixShader>(baseShader, *lm); |
| 67 } | 67 } |
| OLD | NEW |