| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkMath.h" | 9 #include "SkMath.h" |
| 10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 48 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 49 SkMatrix::kScale_Mask)) == 0); | 49 SkMatrix::kScale_Mask)) == 0); |
| 50 | 50 |
| 51 PREAMBLE(s); | 51 PREAMBLE(s); |
| 52 // we store y, x, x, x, x, x | 52 // we store y, x, x, x, x, x |
| 53 | 53 |
| 54 const unsigned maxX = s.fBitmap->width() - 1; | 54 const unsigned maxX = s.fBitmap->width() - 1; |
| 55 SkFractionalInt fx; | 55 SkFractionalInt fx; |
| 56 { | 56 { |
| 57 SkPoint pt; | 57 SkPoint pt; |
| 58 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 58 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
| 59 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 59 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
| 60 fx = SkScalarToFractionalInt(pt.fY); | 60 fx = SkScalarToFractionalInt(pt.fY); |
| 61 const unsigned maxY = s.fBitmap->height() - 1; | 61 const unsigned maxY = s.fBitmap->height() - 1; |
| 62 *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); | 62 *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); |
| 63 fx = SkScalarToFractionalInt(pt.fX); | 63 fx = SkScalarToFractionalInt(pt.fX); |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (0 == maxX) { | 66 if (0 == maxX) { |
| 67 // all of the following X values must be 0 | 67 // all of the following X values must be 0 |
| 68 memset(xy, 0, count * sizeof(uint16_t)); | 68 memset(xy, 0, count * sizeof(uint16_t)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s, | 110 void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s, |
| 111 uint32_t xy[], int count, int x, int y) { | 111 uint32_t xy[], int count, int x, int y) { |
| 112 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 112 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
| 113 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 113 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 114 SkMatrix::kScale_Mask | | 114 SkMatrix::kScale_Mask | |
| 115 SkMatrix::kAffine_Mask)) == 0); | 115 SkMatrix::kAffine_Mask)) == 0); |
| 116 | 116 |
| 117 PREAMBLE(s); | 117 PREAMBLE(s); |
| 118 SkPoint srcPt; | 118 SkPoint srcPt; |
| 119 s.fInvProc(*s.fInvMatrix, | 119 s.fInvProc(s.fInvMatrix, |
| 120 SkIntToScalar(x) + SK_ScalarHalf, | 120 SkIntToScalar(x) + SK_ScalarHalf, |
| 121 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 121 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 122 | 122 |
| 123 SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); | 123 SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); |
| 124 SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); | 124 SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); |
| 125 SkFractionalInt dx = s.fInvSxFractionalInt; | 125 SkFractionalInt dx = s.fInvSxFractionalInt; |
| 126 SkFractionalInt dy = s.fInvKyFractionalInt; | 126 SkFractionalInt dy = s.fInvKyFractionalInt; |
| 127 int maxX = s.fBitmap->width() - 1; | 127 int maxX = s.fBitmap->width() - 1; |
| 128 int maxY = s.fBitmap->height() - 1; | 128 int maxY = s.fBitmap->height() - 1; |
| 129 | 129 |
| 130 for (int i = count; i > 0; --i) { | 130 for (int i = count; i > 0; --i) { |
| 131 *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fy), maxY) << 16) | | 131 *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fy), maxY) << 16) | |
| 132 TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); | 132 TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); |
| 133 fx += dx; fy += dy; | 133 fx += dx; fy += dy; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, | 137 void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, |
| 138 uint32_t* SK_RESTRICT xy, | 138 uint32_t* SK_RESTRICT xy, |
| 139 int count, int x, int y) { | 139 int count, int x, int y) { |
| 140 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); | 140 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); |
| 141 | 141 |
| 142 PREAMBLE(s); | 142 PREAMBLE(s); |
| 143 int maxX = s.fBitmap->width() - 1; | 143 int maxX = s.fBitmap->width() - 1; |
| 144 int maxY = s.fBitmap->height() - 1; | 144 int maxY = s.fBitmap->height() - 1; |
| 145 | 145 |
| 146 SkPerspIter iter(*s.fInvMatrix, | 146 SkPerspIter iter(s.fInvMatrix, |
| 147 SkIntToScalar(x) + SK_ScalarHalf, | 147 SkIntToScalar(x) + SK_ScalarHalf, |
| 148 SkIntToScalar(y) + SK_ScalarHalf, count); | 148 SkIntToScalar(y) + SK_ScalarHalf, count); |
| 149 | 149 |
| 150 while ((count = iter.next()) != 0) { | 150 while ((count = iter.next()) != 0) { |
| 151 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 151 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
| 152 while (--count >= 0) { | 152 while (--count >= 0) { |
| 153 *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) | | 153 *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) | |
| 154 TILEX_PROCF(srcXY[0], maxX); | 154 TILEX_PROCF(srcXY[0], maxX); |
| 155 srcXY += 2; | 155 srcXY += 2; |
| 156 } | 156 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 181 | 181 |
| 182 PREAMBLE(s); | 182 PREAMBLE(s); |
| 183 | 183 |
| 184 const unsigned maxX = s.fBitmap->width() - 1; | 184 const unsigned maxX = s.fBitmap->width() - 1; |
| 185 const SkFixed one = s.fFilterOneX; | 185 const SkFixed one = s.fFilterOneX; |
| 186 const SkFractionalInt dx = s.fInvSxFractionalInt; | 186 const SkFractionalInt dx = s.fInvSxFractionalInt; |
| 187 SkFractionalInt fx; | 187 SkFractionalInt fx; |
| 188 | 188 |
| 189 { | 189 { |
| 190 SkPoint pt; | 190 SkPoint pt; |
| 191 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 191 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
| 192 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 192 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
| 193 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); | 193 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); |
| 194 const unsigned maxY = s.fBitmap->height() - 1; | 194 const unsigned maxY = s.fBitmap->height() - 1; |
| 195 // compute our two Y values up front | 195 // compute our two Y values up front |
| 196 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); | 196 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); |
| 197 // now initialize fx | 197 // now initialize fx |
| 198 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; | 198 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; |
| 199 } | 199 } |
| 200 | 200 |
| 201 #ifdef CHECK_FOR_DECAL | 201 #ifdef CHECK_FOR_DECAL |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 | 215 |
| 216 void AFFINE_FILTER_NAME(const SkBitmapProcState& s, | 216 void AFFINE_FILTER_NAME(const SkBitmapProcState& s, |
| 217 uint32_t xy[], int count, int x, int y) { | 217 uint32_t xy[], int count, int x, int y) { |
| 218 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 218 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
| 219 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 219 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 220 SkMatrix::kScale_Mask | | 220 SkMatrix::kScale_Mask | |
| 221 SkMatrix::kAffine_Mask)) == 0); | 221 SkMatrix::kAffine_Mask)) == 0); |
| 222 | 222 |
| 223 PREAMBLE(s); | 223 PREAMBLE(s); |
| 224 SkPoint srcPt; | 224 SkPoint srcPt; |
| 225 s.fInvProc(*s.fInvMatrix, | 225 s.fInvProc(s.fInvMatrix, |
| 226 SkIntToScalar(x) + SK_ScalarHalf, | 226 SkIntToScalar(x) + SK_ScalarHalf, |
| 227 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 227 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 228 | 228 |
| 229 SkFixed oneX = s.fFilterOneX; | 229 SkFixed oneX = s.fFilterOneX; |
| 230 SkFixed oneY = s.fFilterOneY; | 230 SkFixed oneY = s.fFilterOneY; |
| 231 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); | 231 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); |
| 232 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); | 232 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); |
| 233 SkFixed dx = s.fInvSx; | 233 SkFixed dx = s.fInvSx; |
| 234 SkFixed dy = s.fInvKy; | 234 SkFixed dy = s.fInvKy; |
| 235 unsigned maxX = s.fBitmap->width() - 1; | 235 unsigned maxX = s.fBitmap->width() - 1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 247 uint32_t* SK_RESTRICT xy, int count, | 247 uint32_t* SK_RESTRICT xy, int count, |
| 248 int x, int y) { | 248 int x, int y) { |
| 249 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); | 249 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); |
| 250 | 250 |
| 251 PREAMBLE(s); | 251 PREAMBLE(s); |
| 252 unsigned maxX = s.fBitmap->width() - 1; | 252 unsigned maxX = s.fBitmap->width() - 1; |
| 253 unsigned maxY = s.fBitmap->height() - 1; | 253 unsigned maxY = s.fBitmap->height() - 1; |
| 254 SkFixed oneX = s.fFilterOneX; | 254 SkFixed oneX = s.fFilterOneX; |
| 255 SkFixed oneY = s.fFilterOneY; | 255 SkFixed oneY = s.fFilterOneY; |
| 256 | 256 |
| 257 SkPerspIter iter(*s.fInvMatrix, | 257 SkPerspIter iter(s.fInvMatrix, |
| 258 SkIntToScalar(x) + SK_ScalarHalf, | 258 SkIntToScalar(x) + SK_ScalarHalf, |
| 259 SkIntToScalar(y) + SK_ScalarHalf, count); | 259 SkIntToScalar(y) + SK_ScalarHalf, count); |
| 260 | 260 |
| 261 while ((count = iter.next()) != 0) { | 261 while ((count = iter.next()) != 0) { |
| 262 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 262 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
| 263 do { | 263 do { |
| 264 *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY, | 264 *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY, |
| 265 oneY PREAMBLE_ARG_Y); | 265 oneY PREAMBLE_ARG_Y); |
| 266 *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX, | 266 *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX, |
| 267 oneX PREAMBLE_ARG_X); | 267 oneX PREAMBLE_ARG_X); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 294 #undef PERSP_FILTER_NAME | 294 #undef PERSP_FILTER_NAME |
| 295 | 295 |
| 296 #undef PREAMBLE | 296 #undef PREAMBLE |
| 297 #undef PREAMBLE_PARAM_X | 297 #undef PREAMBLE_PARAM_X |
| 298 #undef PREAMBLE_PARAM_Y | 298 #undef PREAMBLE_PARAM_Y |
| 299 #undef PREAMBLE_ARG_X | 299 #undef PREAMBLE_ARG_X |
| 300 #undef PREAMBLE_ARG_Y | 300 #undef PREAMBLE_ARG_Y |
| 301 | 301 |
| 302 #undef TILEX_LOW_BITS | 302 #undef TILEX_LOW_BITS |
| 303 #undef TILEY_LOW_BITS | 303 #undef TILEY_LOW_BITS |
| OLD | NEW |