aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcState.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-08-15 15:44:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-15 20:36:47 +0000
commit3ad19e59571f1a2952209b1e25ff54f0da52acf4 (patch)
tree55eb18404171208c891588fe693b980070b4358a /src/core/SkBitmapProcState.cpp
parent03776fc0d7eaf3f05886d7eaf6c2563c8fc2dfb1 (diff)
Skip bilerp for integral-translate-only matrices (!clamp-clamp case)
We've landed https://skia-review.googlesource.com/24126 to restore this optimization, but we check too late: for non-clamp/clamp cases we'd already adjusted the matrix scale, so the optimization never kicks in. Relocate the integral translation check before all other matrix adjustments. BUG=chromium:744674 Change-Id: I395d327c3ddf74dc6d23bb8aee782ec62a7373f1 Reviewed-on: https://skia-review.googlesource.com/34840 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkBitmapProcState.cpp')
-rw-r--r--src/core/SkBitmapProcState.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 500118edb4..4b7990c2ee 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -100,38 +100,48 @@ bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) {
SkASSERT(fFilterQuality <= kLow_SkFilterQuality);
SkASSERT(fPixmap.addr());
- // Most of the scanline procs deal with "unit" texture coordinates, as this
- // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generate
- // those, we divide the matrix by its dimensions here.
- //
- // We don't do this if we're either trivial (can ignore the matrix) or clamping
- // in both X and Y since clamping to width,height is just as easy as to 0xFFFF.
-
- if (fTileModeX != SkShader::kClamp_TileMode ||
- fTileModeY != SkShader::kClamp_TileMode) {
- fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height());
- }
+#ifdef SK_SUPPORT_LEGACY_BILERP2
+ bool integral_translate_only = false;
+#else
+ bool integral_translate_only = just_trans_integral(fInvMatrix);
+#endif
+ if (!integral_translate_only) {
+ // Most of the scanline procs deal with "unit" texture coordinates, as this
+ // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generate
+ // those, we divide the matrix by its dimensions here.
+ //
+ // We don't do this if we're either trivial (can ignore the matrix) or clamping
+ // in both X and Y since clamping to width,height is just as easy as to 0xFFFF.
+
+ if (fTileModeX != SkShader::kClamp_TileMode ||
+ fTileModeY != SkShader::kClamp_TileMode) {
+ fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height());
+ }
- // Now that all possible changes to the matrix have taken place, check
- // to see if we're really close to a no-scale matrix. If so, explicitly
- // set it to be so. Subsequent code may inspect this matrix to choose
- // a faster path in this case.
+ // Now that all possible changes to the matrix have taken place, check
+ // to see if we're really close to a no-scale matrix. If so, explicitly
+ // set it to be so. Subsequent code may inspect this matrix to choose
+ // a faster path in this case.
- // This code will only execute if the matrix has some scale component;
- // if it's already pure translate then we won't do this inversion.
+ // This code will only execute if the matrix has some scale component;
+ // if it's already pure translate then we won't do this inversion.
- if (matrix_only_scale_translate(fInvMatrix)) {
- SkMatrix forward;
- if (fInvMatrix.invert(&forward) && just_trans_general(forward)) {
- fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTranslateY());
+ if (matrix_only_scale_translate(fInvMatrix)) {
+ SkMatrix forward;
+ if (fInvMatrix.invert(&forward) && just_trans_general(forward)) {
+ fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTranslateY());
+ }
}
+
+ // Recompute the flag after matrix adjustments.
+ integral_translate_only = just_trans_integral(fInvMatrix);
}
fInvType = fInvMatrix.getType();
if (kLow_SkFilterQuality == fFilterQuality &&
(!valid_for_filtering(fPixmap.width() | fPixmap.height()) ||
- just_trans_integral(fInvMatrix))) {
+ integral_translate_only)) {
fFilterQuality = kNone_SkFilterQuality;
}