diff options
Diffstat (limited to 'src/shaders/SkShader.cpp')
-rw-r--r-- | src/shaders/SkShader.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/shaders/SkShader.cpp b/src/shaders/SkShader.cpp index 265f22beaa..f3ffd26ef4 100644 --- a/src/shaders/SkShader.cpp +++ b/src/shaders/SkShader.cpp @@ -67,15 +67,26 @@ void SkShaderBase::flatten(SkWriteBuffer& buffer) const { } } +SkTCopyOnFirstWrite<SkMatrix> +SkShaderBase::totalLocalMatrix(const SkMatrix* preLocalMatrix, + const SkMatrix* postLocalMatrix) const { + SkTCopyOnFirstWrite<SkMatrix> m(fLocalMatrix); + + if (preLocalMatrix) { + m.writable()->preConcat(*preLocalMatrix); + } + + if (postLocalMatrix) { + m.writable()->postConcat(*postLocalMatrix); + } + + return m; +} + bool SkShaderBase::computeTotalInverse(const SkMatrix& ctm, const SkMatrix* outerLocalMatrix, SkMatrix* totalInverse) const { - SkMatrix total = SkMatrix::Concat(ctm, fLocalMatrix); - if (outerLocalMatrix) { - total.preConcat(*outerLocalMatrix); - } - - return total.invert(totalInverse); + return SkMatrix::Concat(ctm, *this->totalLocalMatrix(outerLocalMatrix)).invert(totalInverse); } bool SkShaderBase::asLuminanceColor(SkColor* colorPtr) const { |