aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcState.h
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-12-15 06:48:48 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-15 06:48:48 -0800
commitaed4d32de937a8f2733924eb848cc287e8d04087 (patch)
tree0c7708b50a7459708dc3f9a9613b6900a292d3b5 /src/core/SkBitmapProcState.h
parent11f457e1627be775cfa26d71307dbd6073f9269c (diff)
SkBitmapProcState rounding bias
Epsilon bias to keep bitmap sample rounding consistent with geometry rounding. Also update the GM to draw an outer border + drop uninteresting scales in favor of negative scale variants. BUG=skia:4680,skia:4649 R=reed@google.com,caryclark@google.com,mtklein@google.com Review URL: https://codereview.chromium.org/1527633002
Diffstat (limited to 'src/core/SkBitmapProcState.h')
-rw-r--r--src/core/SkBitmapProcState.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 2ce76bc83e..e6e7a3f393 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,17 @@ 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);
+#else
+ return 0;
+#endif
+}
+
class SkPaint;
struct SkBitmapProcState {