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

Unified Diff: src/core/SkMatrixUtils.h

Issue 1569873003: Revert of SkTreatAsSprite should take AA into account (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « src/core/SkMatrix.cpp ('k') | tests/DrawBitmapRectTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrixUtils.h
diff --git a/src/core/SkMatrixUtils.h b/src/core/SkMatrixUtils.h
index 0e01fbe95399f3b4d2d21fe47cf3350d4eb7870d..d1b6658d073bac5c3603f806e5f36e441bbf319e 100644
--- a/src/core/SkMatrixUtils.h
+++ b/src/core/SkMatrixUtils.h
@@ -8,20 +8,37 @@
#ifndef SkMatrixUtils_DEFINED
#define SkMatrixUtils_DEFINED
-#include "SkSize.h"
-
-class SkMatrix;
-class SkPaint;
+#include "SkMatrix.h"
/**
- * Given a matrix, size and paint, return true if the computed dst-rect would
+ * Number of subpixel bits used in skia's bilerp.
+ * See SkBitmapProcState_procs.h and SkBitmapProcState_filter.h
+ */
+#define kSkSubPixelBitsForBilerp 4
+
+/**
+ * Given a matrix and width/height, return true if the computed dst-rect would
* align such that there is a 1-to-1 coorspondence between src and dst pixels.
* This can be called by drawing code to see if drawBitmap can be turned into
* drawSprite (which is faster).
*
- * The src-rect is defined to be { 0, 0, size.width(), size.height() }
+ * The src-rect is defined to be { 0, 0, width, height }
+ *
+ * The "closeness" test is based on the subpixelBits parameter. Pass 0 for
+ * round-to-nearest behavior (e.g. nearest neighbor sampling). Pass the number
+ * of subpixel-bits to simulate filtering.
*/
-bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint);
+bool SkTreatAsSprite(const SkMatrix&, int width, int height,
+ unsigned subpixelBits);
+
+/**
+ * Calls SkTreatAsSprite() with default subpixelBits value to match Skia's
+ * filter-bitmap implementation (i.e. kSkSubPixelBitsForBilerp).
+ */
+static inline bool SkTreatAsSpriteFilter(const SkMatrix& matrix,
+ int width, int height) {
+ return SkTreatAsSprite(matrix, width, height, kSkSubPixelBitsForBilerp);
+}
/** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by
the cosine and sine of the rotation angle), followed by a non-uniform scale,
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | tests/DrawBitmapRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698