OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBitmapProcState_DEFINED | 8 #ifndef SkBitmapProcState_DEFINED |
9 #define SkBitmapProcState_DEFINED | 9 #define SkBitmapProcState_DEFINED |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 199 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
200 | 200 |
201 // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are
rounded | 201 // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are
rounded |
202 // consistently WRT geometry. Note that we only need the bias for posit
ive scales: | 202 // consistently WRT geometry. Note that we only need the bias for posit
ive scales: |
203 // for negative scales, the rounding is intrinsically correct. | 203 // for negative scales, the rounding is intrinsically correct. |
204 // We scale it to persist SkFractionalInt -> SkFixed conversions. | 204 // We scale it to persist SkFractionalInt -> SkFixed conversions. |
205 const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0); | 205 const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0); |
206 const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0); | 206 const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0); |
207 fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); | 207 fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); |
208 fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); | 208 fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); |
| 209 |
| 210 /* |
| 211 * (see SkBitmapProcState::setupForTranslate, which is the only user of
this flag) |
| 212 * |
| 213 * if the translate is larger than our ints, we can get random results,
or |
| 214 * worse, we might get 0x80000000, which wreaks havoc on us, since we c
an't |
| 215 * negate it. |
| 216 */ |
| 217 const SkScalar too_big = SkIntToScalar(1 << 30); |
| 218 fOverflow = SkScalarAbs(pt.x() - SkFixedToScalar(biasX)) > too_big |
| 219 || SkScalarAbs(pt.y() - SkFixedToScalar(biasY)) > too_big; |
209 } | 220 } |
210 | 221 |
211 SkFractionalInt x() const { return fX; } | 222 SkFractionalInt x() const { return fX; } |
212 SkFractionalInt y() const { return fY; } | 223 SkFractionalInt y() const { return fY; } |
213 | 224 |
| 225 bool isOverflow() const { return fOverflow; } |
| 226 |
214 private: | 227 private: |
215 SkFractionalInt fX, fY; | 228 SkFractionalInt fX, fY; |
| 229 bool fOverflow; |
216 }; | 230 }; |
217 | 231 |
218 #endif | 232 #endif |
OLD | NEW |