| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SkASSERT(s.fInvKy == 0); | 54 SkASSERT(s.fInvKy == 0); |
| 55 | 55 |
| 56 PREAMBLE(s); | 56 PREAMBLE(s); |
| 57 | 57 |
| 58 const unsigned maxX = s.fPixmap.width() - 1; | 58 const unsigned maxX = s.fPixmap.width() - 1; |
| 59 const SkFixed one = s.fFilterOneX; | 59 const SkFixed one = s.fFilterOneX; |
| 60 const SkFractionalInt dx = s.fInvSxFractionalInt; | 60 const SkFractionalInt dx = s.fInvSxFractionalInt; |
| 61 SkFractionalInt fx; | 61 SkFractionalInt fx; |
| 62 | 62 |
| 63 { | 63 { |
| 64 SkPoint pt; | 64 const SkBitmapProcStateAutoMapper mapper(s, x ,y); |
| 65 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 65 const SkFixed fy = mapper.y() - (s.fFilterOneY >> 1); |
| 66 SkIntToScalar(y) + SK_ScalarHalf, &pt); | |
| 67 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1) | |
| 68 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY()); | |
| 69 const unsigned maxY = s.fPixmap.height() - 1; | 66 const unsigned maxY = s.fPixmap.height() - 1; |
| 70 // compute our two Y values up front | 67 // compute our two Y values up front |
| 71 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); | 68 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); |
| 72 // now initialize fx | 69 // now initialize fx |
| 73 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1) | 70 fx = SkFixedToFractionalInt(mapper.x() - (one >> 1)); |
| 74 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX()); | |
| 75 } | 71 } |
| 76 | 72 |
| 77 #ifdef CHECK_FOR_DECAL | 73 #ifdef CHECK_FOR_DECAL |
| 78 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { | 74 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { |
| 79 decal_filter_scale(xy, SkFractionalIntToFixed(fx), | 75 decal_filter_scale(xy, SkFractionalIntToFixed(fx), |
| 80 SkFractionalIntToFixed(dx), count); | 76 SkFractionalIntToFixed(dx), count); |
| 81 } else | 77 } else |
| 82 #endif | 78 #endif |
| 83 { | 79 { |
| 84 do { | 80 do { |
| 85 SkFixed fixedFx = SkFractionalIntToFixed(fx); | 81 SkFixed fixedFx = SkFractionalIntToFixed(fx); |
| 86 *xy++ = PACK_FILTER_X_NAME(fixedFx, maxX, one PREAMBLE_ARG_X); | 82 *xy++ = PACK_FILTER_X_NAME(fixedFx, maxX, one PREAMBLE_ARG_X); |
| 87 fx += dx; | 83 fx += dx; |
| 88 } while (--count != 0); | 84 } while (--count != 0); |
| 89 } | 85 } |
| 90 } | 86 } |
| 91 | 87 |
| 92 void AFFINE_FILTER_NAME(const SkBitmapProcState& s, | 88 void AFFINE_FILTER_NAME(const SkBitmapProcState& s, |
| 93 uint32_t xy[], int count, int x, int y) { | 89 uint32_t xy[], int count, int x, int y) { |
| 94 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 90 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
| 95 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 91 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 96 SkMatrix::kScale_Mask | | 92 SkMatrix::kScale_Mask | |
| 97 SkMatrix::kAffine_Mask)) == 0); | 93 SkMatrix::kAffine_Mask)) == 0); |
| 98 | 94 |
| 99 PREAMBLE(s); | 95 PREAMBLE(s); |
| 100 SkPoint srcPt; | 96 const SkBitmapProcStateAutoMapper mapper(s, x ,y); |
| 101 s.fInvProc(s.fInvMatrix, | |
| 102 SkIntToScalar(x) + SK_ScalarHalf, | |
| 103 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | |
| 104 | 97 |
| 105 SkFixed oneX = s.fFilterOneX; | 98 SkFixed oneX = s.fFilterOneX; |
| 106 SkFixed oneY = s.fFilterOneY; | 99 SkFixed oneY = s.fFilterOneY; |
| 107 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1) | 100 SkFixed fx = mapper.x() - (oneX >> 1); |
| 108 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX()); | 101 SkFixed fy = mapper.y() - (oneY >> 1); |
| 109 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1) | |
| 110 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY()); | |
| 111 SkFixed dx = s.fInvSx; | 102 SkFixed dx = s.fInvSx; |
| 112 SkFixed dy = s.fInvKy; | 103 SkFixed dy = s.fInvKy; |
| 113 unsigned maxX = s.fPixmap.width() - 1; | 104 unsigned maxX = s.fPixmap.width() - 1; |
| 114 unsigned maxY = s.fPixmap.height() - 1; | 105 unsigned maxY = s.fPixmap.height() - 1; |
| 115 | 106 |
| 116 do { | 107 do { |
| 117 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y); | 108 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y); |
| 118 fy += dy; | 109 fy += dy; |
| 119 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X); | 110 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X); |
| 120 fx += dx; | 111 fx += dx; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #undef PERSP_FILTER_NAME | 151 #undef PERSP_FILTER_NAME |
| 161 | 152 |
| 162 #undef PREAMBLE | 153 #undef PREAMBLE |
| 163 #undef PREAMBLE_PARAM_X | 154 #undef PREAMBLE_PARAM_X |
| 164 #undef PREAMBLE_PARAM_Y | 155 #undef PREAMBLE_PARAM_Y |
| 165 #undef PREAMBLE_ARG_X | 156 #undef PREAMBLE_ARG_X |
| 166 #undef PREAMBLE_ARG_Y | 157 #undef PREAMBLE_ARG_Y |
| 167 | 158 |
| 168 #undef TILEX_LOW_BITS | 159 #undef TILEX_LOW_BITS |
| 169 #undef TILEY_LOW_BITS | 160 #undef TILEY_LOW_BITS |
| OLD | NEW |