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

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 14018020: use forward matrix to determine if we can ignore scale part of a matrix (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
===================================================================
--- src/core/SkBitmapProcState.cpp (revision 8685)
+++ src/core/SkBitmapProcState.cpp (working copy)
@@ -41,6 +41,7 @@
return false;
}
if (mask & SkMatrix::kScale_Mask) {
+#if 0
SkScalar sx = matrix[SkMatrix::kMScaleX];
SkScalar sy = matrix[SkMatrix::kMScaleY];
int w = bitmap.width();
@@ -48,6 +49,14 @@
int sw = SkScalarRound(SkScalarMul(sx, SkIntToScalar(w)));
int sh = SkScalarRound(SkScalarMul(sy, SkIntToScalar(h)));
return sw == w && sh == h;
+#else
+ SkRect src, dst;
+ bitmap.getBounds(&src);
+ matrix.mapRect(&dst, src);
+ SkIRect idst;
+ dst.round(&idst);
+ return idst.width() == bitmap.width() && idst.height() == bitmap.height();
+#endif
}
// if we got here, we're either kTranslate_Mask or identity
return true;
@@ -81,6 +90,11 @@
return (dimension & ~0x3FFF) == 0;
}
+static bool matrix_only_scale_translate(const SkMatrix& m) {
robertphillips 2013/04/15 19:43:02 This is done as "if (mask <= (SkMatrix::kTranslate
reed1 2013/04/15 20:00:26 Done.
+ unsigned mask = SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask;
+ return 0 == (m.getType() & ~mask);
+}
+
bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) {
return false;
@@ -120,7 +134,7 @@
}
// wack our matrix to exactly no-scale, if we're really close to begin with
- {
+ if (false) {
bool fixupMatrix = clamp_clamp ?
just_trans_clamp(*m, *fBitmap) : just_trans_general(*m);
if (fixupMatrix) {
@@ -139,6 +153,20 @@
}
}
}
+ if (matrix_only_scale_translate(*m)) {
+ SkMatrix forward;
+ if (m->invert(&forward)) {
+ if (clamp_clamp ? just_trans_clamp(forward, *fBitmap)
+ : just_trans_general(forward)) {
+ SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX());
+ SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY());
+ fUnitInvMatrix.setTranslate(tx, ty);
+ m = &fUnitInvMatrix;
+ // now the following code will sniff m, and decide to take the
+ // fast case (since m is purely translate).
+ }
+ }
+ }
// Below this point, we should never refer to the inv parameter, since we
// may be using a munged version for "our" inverse.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698