aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcState.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-01-30 10:06:46 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-30 10:06:46 -0800
commit653c12d773def4d25cbdb78072b84404a5d80957 (patch)
tree6c2b4f5dd2c03fb6a99875cd77e7a8313b697820 /src/core/SkBitmapProcState.cpp
parente645965a7c8bc1f439fa4d7655e8c9fda0b969ca (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.cpp')
-rw-r--r--src/core/SkBitmapProcState.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 3c3f3a54b7..c4b29392f1 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -586,24 +586,36 @@ static void DoNothing_shaderproc(const void*, int x, int y,
}
bool SkBitmapProcState::setupForTranslate() {
+#ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
SkPoint pt;
fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt);
+ const SkScalar too_big = SkIntToScalar(1 << 30);
+ if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
+ return false;
+ }
+
+ fFilterOneX = SkScalarFloorToInt(pt.fX);
+ fFilterOneY = SkScalarFloorToInt(pt.fY);
+#else
+ SkBitmapProcStateAutoMapper mapper(*this, 0, 0);
+
/*
* 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);
- if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
+ if (mapper.isOverflow()) {
return false;
}
// Since we know we're not filtered, we re-purpose these fields allow
// us to go from device -> src coordinates w/ just an integer add,
// rather than running through the inverse-matrix
- fFilterOneX = SkScalarFloorToInt(pt.fX);
- fFilterOneY = SkScalarFloorToInt(pt.fY);
+ fFilterOneX = SkFractionalIntToInt(mapper.x());
+ fFilterOneY = SkFractionalIntToInt(mapper.y());
+#endif
+
return true;
}