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;
#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());
}
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,
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) {
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;
// 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
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;