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