aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-05-08 13:03:24 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-08 18:04:57 +0000
commit26368c33007191205669bb227d6e7b915ba06f9e (patch)
treed20aba98d72739676cb159470aac65496b89472a /src
parent8e45b4f3a3d34d20ec9a13692f3e4de94997145c (diff)
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 <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapProcShader.cpp2
-rw-r--r--src/core/SkShader.cpp14
-rw-r--r--src/effects/gradients/SkGradientShader.cpp7
3 files changed, 10 insertions, 13 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3472bf0638..b7bd39c197 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -205,7 +205,7 @@ SkShader::Context* SkBitmapProcLegacyShader::MakeContext(
{
SkMatrix totalInverse;
// Do this first, so we know the matrix can be inverted.
- if (!shader.computeTotalInverse(rec, &totalInverse)) {
+ if (!shader.computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, &totalInverse)) {
return nullptr;
}
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();
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 9ecc84ec65..0c8eacdf46 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -353,12 +353,7 @@ bool SkGradientShaderBase::onAppendStages(
const SkMatrix* localM) const
{
SkMatrix matrix;
- if (!this->computeTotalInverse(ContextRec(paint,
- ctm,
- localM,
- ContextRec::kPM4f_DstType, // doesn't matter here
- dstCS),
- &matrix)) {
+ if (!this->computeTotalInverse(ctm, localM, &matrix)) {
return false;
}