aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcState.h
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-02-03 05:44:21 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-03 05:44:21 -0800
commit2404f03413bc9b4fa3f556c64642e57507092d8d (patch)
treede08b8a947abd698523fb3712b27edf265cd4d59 /src/core/SkBitmapProcState.h
parent15691a055db9b68c9b48f589e48d8a85888cf83f (diff)
Use SkBitmapProcStateAutoMapper for filter samplers also
Observation: filter procs are also biased by s.fFilterOne{X,Y} / 2. They all do something along these lines: s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &srcPt); SkFixed fx = SkScalarToFixed(srcPt.fX) - (s.fFilterOneX >> 1); SkFixed fy = SkScalarToFixed(srcPt.fY) - (s.fFilterOneX >> 1); It's trivial to extend SkBitmapProcStateAutoMapper to handle this internally, and convert everyone off explicit mapping. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1661613002 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review URL: https://codereview.chromium.org/1661613002
Diffstat (limited to 'src/core/SkBitmapProcState.h')
-rw-r--r--src/core/SkBitmapProcState.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 0ae8cf2856..fca7dc0a3e 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -189,7 +189,6 @@ void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
uint32_t xy[], int count, int x, int y);
// Helper class for mapping the middle of pixel (x, y) into SkFractionalInt bitmap space.
-// TODO: filtered version which applies a fFilterOne{X,Y}/2 bias instead of epsilon?
class SkBitmapProcStateAutoMapper {
public:
SkBitmapProcStateAutoMapper(const SkBitmapProcState& s, int x, int y,
@@ -199,12 +198,19 @@ public:
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
- // 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.
- // We scale it to persist SkFractionalInt -> SkFixed conversions.
- const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0);
- const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0);
+ SkFixed biasX, biasY;
+ if (s.fFilterLevel == kNone_SkFilterQuality) {
+ // 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.
+ // We scale it to persist SkFractionalInt -> SkFixed conversions.
+ biasX = (s.fInvMatrix.getScaleX() > 0);
+ biasY = (s.fInvMatrix.getScaleY() > 0);
+ } else {
+ biasX = s.fFilterOneX >> 1;
+ biasY = s.fFilterOneY >> 1;
+ }
+
fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX);
fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY);