restore lost optimization when the shader can report const_in_y
accidentally lost we I landed https://codereview.chromium.org/1556003003
BUG=575905
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1576083002
Review URL: https://codereview.chromium.org/1576083002
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index e5b577a..804c688 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -99,6 +99,11 @@
SkBitmapProvider(fRawBitmap), rec, storage);
}
+static bool only_scale_and_translate(const SkMatrix& matrix) {
+ unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
+ return (matrix.getType() & ~mask) == 0;
+}
+
SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkShader& shader,
const ContextRec& rec,
SkBitmapProcState* state)
@@ -109,6 +114,10 @@
if (fState->fPixmap.isOpaque() && (255 == this->getPaintAlpha())) {
fFlags |= kOpaqueAlpha_Flag;
}
+
+ if (1 == fState->fPixmap.height() && only_scale_and_translate(this->getTotalInverse())) {
+ fFlags |= kConstInY32_Flag;
+ }
}
SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() {