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