Sampler bias for all nofilter flavors
Instead of a piecemeal approach to sampler bias (http://crrev.com/1642273002,
http://crrev.com/1539083002), audit all nofilter procs (grep "fInvProc(")
and convert them to SkBitmapProcStateAutoMapper.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1656833002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
R=reed@google.com
Review URL: https://codereview.chromium.org/1656833002
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 163bc88..f62f4f0 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -492,21 +492,17 @@
int yTemp;
if (s.fInvType > SkMatrix::kTranslate_Mask) {
- // TODO(fmalita): looks like another SkBitmapProcStateAutoMapper customer
- SkPoint pt;
- s.fInvProc(s.fInvMatrix,
- SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf,
- &pt);
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
+
// When the matrix has a scale component the setup code in
// chooseProcs multiples the inverse matrix by the inverse of the
// bitmap's width and height. Since this method is going to do
// its own tiling and sampling we need to undo that here.
if (SkShader::kClamp_TileMode != s.fTileModeX ||
SkShader::kClamp_TileMode != s.fTileModeY) {
- yTemp = SkScalarFloorToInt(pt.fY * s.fPixmap.height());
+ yTemp = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
} else {
- yTemp = SkScalarFloorToInt(pt.fY);
+ yTemp = SkFractionalIntToInt(mapper.y());
}
} else {
yTemp = s.fFilterOneY + y;
@@ -528,20 +524,14 @@
#ifdef SK_DEBUG
{
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
int iY2;
- if (s.fInvType > SkMatrix::kTranslate_Mask) {
- SkPoint pt;
- s.fInvProc(s.fInvMatrix,
- SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf,
- &pt);
- if (SkShader::kClamp_TileMode != s.fTileModeX ||
- SkShader::kClamp_TileMode != s.fTileModeY) {
- pt.fY *= s.fPixmap.height();
- }
- iY2 = SkScalarFloorToInt(pt.fY);
+
+ if (s.fInvType > SkMatrix::kTranslate_Mask &&
+ (SkShader::kClamp_TileMode != s.fTileModeX ||
+ SkShader::kClamp_TileMode != s.fTileModeY)) {
+ iY2 = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
} else {
- const SkBitmapProcStateAutoMapper mapper(s, x, y);
iY2 = SkFractionalIntToInt(mapper.y());
}
diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp
index 1c4b7b6..d7457ec 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -328,14 +328,11 @@
static int nofilter_trans_preamble(const SkBitmapProcState& s, uint32_t** xy,
int x, int y) {
- SkPoint pt;
- s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &pt);
- **xy = s.fIntTileProcY(SkScalarToFixed(pt.fY) >> 16,
- s.fPixmap.height());
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
+ **xy = s.fIntTileProcY(SkFractionalIntToInt(mapper.y()), s.fPixmap.height());
*xy += 1; // bump the ptr
// return our starting X position
- return SkScalarToFixed(pt.fX) >> 16;
+ return SkFractionalIntToInt(mapper.x());
}
static void clampx_nofilter_trans(const SkBitmapProcState& s,
diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h
index fbb2a1e..4546f70 100644
--- a/src/opts/SkBitmapProcState_matrix_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_neon.h
@@ -38,13 +38,10 @@
const unsigned maxX = s.fPixmap.width() - 1;
SkFractionalInt fx;
{
- SkPoint pt;
- s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &pt);
- fx = SkScalarToFractionalInt(pt.fY);
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
const unsigned maxY = s.fPixmap.height() - 1;
- *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY);
- fx = SkScalarToFractionalInt(pt.fX);
+ *xy++ = TILEY_PROCF(SkFractionalIntToFixed(mapper.y()), maxY);
+ fx = mapper.x();
}
if (0 == maxX) {
@@ -118,13 +115,10 @@
SkMatrix::kAffine_Mask)) == 0);
PREAMBLE(s);
- SkPoint srcPt;
- s.fInvProc(s.fInvMatrix,
- SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
- SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX);
- SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
+ SkFractionalInt fx = mapper.x();
+ SkFractionalInt fy = mapper.y();
SkFractionalInt dx = s.fInvSxFractionalInt;
SkFractionalInt dy = s.fInvKyFractionalInt;
int maxX = s.fPixmap.width() - 1;
diff --git a/src/opts/SkBitmapProcState_opts_SSE2.cpp b/src/opts/SkBitmapProcState_opts_SSE2.cpp
index cffe962..b5da8e2 100644
--- a/src/opts/SkBitmapProcState_opts_SSE2.cpp
+++ b/src/opts/SkBitmapProcState_opts_SSE2.cpp
@@ -374,14 +374,10 @@
// we store y, x, x, x, x, x
const unsigned maxX = s.fPixmap.width() - 1;
- SkFixed fx;
- SkPoint pt;
- s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &pt);
- fx = SkScalarToFixed(pt.fY);
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
const unsigned maxY = s.fPixmap.height() - 1;
- *xy++ = SkClampMax(fx >> 16, maxY);
- fx = SkScalarToFixed(pt.fX);
+ *xy++ = SkClampMax(SkFractionalIntToInt(mapper.y()), maxY);
+ SkFixed fx = SkFractionalIntToFixed(mapper.x());
if (0 == maxX) {
// all of the following X values must be 0
@@ -565,13 +561,10 @@
SkMatrix::kScale_Mask |
SkMatrix::kAffine_Mask)) == 0);
- SkPoint srcPt;
- s.fInvProc(s.fInvMatrix,
- SkIntToScalar(x) + SK_ScalarHalf,
- SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
+ const SkBitmapProcStateAutoMapper mapper(s, x, y);
- SkFixed fx = SkScalarToFixed(srcPt.fX);
- SkFixed fy = SkScalarToFixed(srcPt.fY);
+ SkFixed fx = SkFractionalIntToFixed(mapper.x());
+ SkFixed fy = SkFractionalIntToFixed(mapper.y());
SkFixed dx = s.fInvSx;
SkFixed dy = s.fInvKy;
int maxX = s.fPixmap.width() - 1;