Index: src/core/SkBitmapProcState.h |
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h |
index 2ce76bc83ec7527f5797a8a55d5d5b53fd58cfa4..395da46c4fd7539e9017f123193839729793faf0 100644 |
--- a/src/core/SkBitmapProcState.h |
+++ b/src/core/SkBitmapProcState.h |
@@ -12,6 +12,7 @@ |
#include "SkBitmapController.h" |
#include "SkBitmapFilter.h" |
#include "SkBitmapProvider.h" |
+#include "SkFloatBits.h" |
#include "SkMatrix.h" |
#include "SkMipMap.h" |
#include "SkPaint.h" |
@@ -24,6 +25,18 @@ typedef SkFixed3232 SkFractionalInt; |
#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 ? -1 : 0; |
reed1
2015/12/14 21:50:07
seems like this >= version might be faster (certai
f(malita)
2015/12/15 14:34:13
Done.
|
+ return (static_cast<uint32_t>(SkFloat2Bits(SkScalarToFloat(scale))) >> 31) - 1; |
+#else |
+ return 0; |
+#endif |
+} |
+ |
class SkPaint; |
struct SkBitmapProcState { |