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

Unified Diff: src/core/SkBitmapProcState.h

Issue 1531423003: Revert of Repeating SkBitmapProcState rounding bias (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.h
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 342da78c052ff933378058dd2f3ffa77ab72e0d1..e6e7a3f393661ff729a2abecde11d62950b5e6a6 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -24,6 +24,17 @@
#define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x)
#define SkFixedToFractionalInt(x) SkFixedToFixed3232(x)
#define SkFractionalIntToInt(x) SkFixed3232ToInt(x)
+
+// Applying a fixed point (SkFixed, SkFractionalInt) epsilon bias ensures that the inverse-mapped
+// bitmap coordinates are rounded consistently WRT geometry. Note that we only have to do this
+// when the scale is positive - for negative scales we're already rounding in the right direction.
+static inline int bitmap_sampler_inv_bias(SkScalar scale) {
+#ifndef SK_SUPPORT_LEGACY_BITMAP_SAMPLER_BIAS
+ return -(scale > 0);
+#else
+ return 0;
+#endif
+}
class SkPaint;
@@ -201,32 +212,4 @@
void S32_D16_filter_DXDY(const SkBitmapProcState& s,
const uint32_t* xy, int count, uint16_t* colors);
-// Helper class for mapping the middle of pixel (x, y) into SkFixed bitmap space.
-class SkBitmapProcStateAutoMapper {
-public:
- SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y) {
- SkPoint pt;
- s.fInvProc(s.fInvMatrix,
- SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &pt);
-
-#ifndef SK_SUPPORT_LEGACY_BITMAP_SAMPLER_BIAS
- // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are rounded
- // consistently WRT geometry. Note that we only need the bias for positive scales:
- // for negative scales, the rounding is intrinsically correct.
- fX = SkScalarToFixed(pt.x()) - (s.fInvMatrix.getScaleX() > 0);
- fY = SkScalarToFixed(pt.y()) - (s.fInvMatrix.getScaleY() > 0);
-#else
- fX = SkScalarToFixed(pt.x());
- fY = SkScalarToFixed(pt.y());
-#endif
- }
-
- SkFixed x() const { return fX; }
- SkFixed y() const { return fY; }
-
-private:
- SkFixed fX, fY;
-};
-
-#endif
+#endif
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698