diff options
author | fmalita <fmalita@chromium.org> | 2016-01-30 10:06:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-30 10:06:46 -0800 |
commit | 653c12d773def4d25cbdb78072b84404a5d80957 (patch) | |
tree | 6c2b4f5dd2c03fb6a99875cd77e7a8313b697820 /src/core/SkBitmapProcState.h | |
parent | e645965a7c8bc1f439fa4d7655e8c9fda0b969ca (diff) |
Add sampler bias for the nofilter/translate specializations
Convert SkBitmapProcState::setupForTranslate() to use
SkBitmapProcStateAutoMapper. This adds bias for the translate procs:
Clamp_S32_D32_nofilter_trans_shaderproc,
Repeat_S32_D32_nofilter_trans_shaderproc
Since the original impl checks for int overflow, extend
SkBitmapProcStateAutoMapper to detect this condition.
BUG=chromium:581870
R=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1642273002
Review URL: https://codereview.chromium.org/1642273002
Diffstat (limited to 'src/core/SkBitmapProcState.h')
-rw-r--r-- | src/core/SkBitmapProcState.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 3f1d699cf2..5e680befd2 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -206,13 +206,27 @@ public: const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0); fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); + + /* + * (see SkBitmapProcState::setupForTranslate, which is the only user of this flag) + * + * if the translate is larger than our ints, we can get random results, or + * worse, we might get 0x80000000, which wreaks havoc on us, since we can't + * negate it. + */ + const SkScalar too_big = SkIntToScalar(1 << 30); + fOverflow = SkScalarAbs(pt.x() - SkFixedToScalar(biasX)) > too_big + || SkScalarAbs(pt.y() - SkFixedToScalar(biasY)) > too_big; } SkFractionalInt x() const { return fX; } SkFractionalInt y() const { return fY; } + bool isOverflow() const { return fOverflow; } + private: SkFractionalInt fX, fY; + bool fOverflow; }; #endif |