From 26368c33007191205669bb227d6e7b915ba06f9e Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 8 May 2017 13:03:24 -0400 Subject: Minimize computeTotalInverse()'s inputs The helper doesn't need a full context rec - it only looks at the CTM and external local matrix. Pass these explicitly instead. Change-Id: I6a5884f65cd383c2df0e8d83c9086789bd96f345 Reviewed-on: https://skia-review.googlesource.com/15870 Reviewed-by: Mike Klein Commit-Queue: Florin Malita --- src/core/SkShader.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core/SkShader.cpp') diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index f6865d9a31..203209799f 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -70,10 +70,12 @@ void SkShader::flatten(SkWriteBuffer& buffer) const { } } -bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse) const { - SkMatrix total = SkMatrix::Concat(*rec.fMatrix, fLocalMatrix); - if (rec.fLocalMatrix) { - total.preConcat(*rec.fLocalMatrix); +bool SkShader::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); @@ -92,7 +94,7 @@ bool SkShader::asLuminanceColor(SkColor* colorPtr) const { } SkShader::Context* SkShader::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const { - if (!this->computeTotalInverse(rec, nullptr)) { + if (!this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)) { return nullptr; } return this->onMakeContext(rec, alloc); @@ -103,7 +105,7 @@ SkShader::Context::Context(const SkShader& shader, const ContextRec& rec) { // Because the context parameters must be valid at this point, we know that the matrix is // invertible. - SkAssertResult(fShader.computeTotalInverse(rec, &fTotalInverse)); + SkAssertResult(fShader.computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, &fTotalInverse)); fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse); fPaintAlpha = rec.fPaint->getAlpha(); -- cgit v1.2.3