From 0983268dd52150fb968fb10bed2e8541095f12a1 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 17 Jul 2017 16:26:57 -0400 Subject: [PATCH] Skip bilerp for integral-translate-only matrices BUG=chromium:744674 Change-Id: I053a0c26b0f644faa11f469b8a6486302a5efae6 Reviewed-on: https://skia-review.googlesource.com/24126 Commit-Queue: Florin Malita Reviewed-by: Mike Reed --- src/core/SkBitmapProcState.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 3e7bc880a5..0e534274ef 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -61,6 +61,18 @@ static bool just_trans_general(const SkMatrix& matrix) { && SkScalarNearlyZero(matrix[SkMatrix::kMScaleY] - SK_Scalar1, tol); } +/** + * Determine if the matrix can be treated as integral-only-translate, + * for the purpose of filtering. + */ +static bool just_trans_integral(const SkMatrix& m) { + static constexpr SkScalar tol = SK_Scalar1 / 256; + + return m.getType() <= SkMatrix::kTranslate_Mask + && SkScalarNearlyEqual(m.getTranslateX(), SkScalarRoundToScalar(m.getTranslateX()), tol) + && SkScalarNearlyEqual(m.getTranslateY(), SkScalarRoundToScalar(m.getTranslateY()), tol); +} + static bool valid_for_filtering(unsigned dimension) { // for filtering, width and height must fit in 14bits, since we use steal // 2 bits from each to store our 4bit subpixel data @@ -118,12 +130,11 @@ bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) { fInvType = fInvMatrix.getType(); if (kLow_SkFilterQuality == fFilterQuality && - !valid_for_filtering(fPixmap.width() | fPixmap.height())) { + (!valid_for_filtering(fPixmap.width() | fPixmap.height()) || + just_trans_integral(fInvMatrix))) { fFilterQuality = kNone_SkFilterQuality; } - // TODO: skip bilerp for integral translates - return true; }