Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 675823002: Fix the way we patch up the matrix for scaled images that aren't (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: don't tile the new GM Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« gm/tiledscaledbitmap.cpp ('K') | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index b1b50b0c329af9eb727f5710353fb742b1c075d7..656e0c4ca0b2fca68fb3c5624104adba113f2146 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -131,8 +131,6 @@ static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) {
bool SkBitmapProcState::possiblyScaleImage() {
SkASSERT(NULL == fBitmap);
- fAdjustedMatrix = false;
-
if (fFilterLevel <= SkPaint::kLow_FilterLevel) {
return false;
}
@@ -198,19 +196,10 @@ bool SkBitmapProcState::possiblyScaleImage() {
SkASSERT(fScaledBitmap.getPixels());
fBitmap = &fScaledBitmap;
- // set the inv matrix type to translate-only;
- fInvMatrix.setTranslate(fInvMatrix.getTranslateX() / fInvMatrix.getScaleX(),
- fInvMatrix.getTranslateY() / fInvMatrix.getScaleY());
-
-#ifndef SK_IGNORE_PROPER_FRACTIONAL_SCALING
- // reintroduce any fractional scaling missed by our integral scale done above.
+ // clean up the inverse matrix by incorporating the scale we just performed.
- float fractionalScaleX = roundedDestWidth/trueDestWidth;
- float fractionalScaleY = roundedDestHeight/trueDestHeight;
-
- fInvMatrix.postScale(fractionalScaleX, fractionalScaleY);
-#endif
- fAdjustedMatrix = true;
+ fInvMatrix.postScale(roundedDestWidth / fOrigBitmap.width(),
+ roundedDestHeight / fOrigBitmap.height());
// Set our filter level to low -- the only post-filtering this
// image might require is some interpolation if the translation
@@ -374,8 +363,15 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
SkShader::kClamp_TileMode == fTileModeY;
- if (!(fAdjustedMatrix || clampClamp || trivialMatrix)) {
- fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
+ // 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 (!(clampClamp || trivialMatrix)) {
+ fInvMatrix.postIDiv(fBitmap->width(), fBitmap->height());
}
// Now that all possible changes to the matrix have taken place, check
« gm/tiledscaledbitmap.cpp ('K') | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698