Index: src/core/SkBitmapProcState.h |
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h |
index 3f1d699cf22be6203c1430c5b789f1fd1b5806c3..5e680befd258a2ab85ce8f07597e444696973f93 100644 |
--- a/src/core/SkBitmapProcState.h |
+++ b/src/core/SkBitmapProcState.h |
@@ -206,13 +206,27 @@ public: |
const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0); |
fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); |
fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); |
+ |
+ /* |
+ * (see SkBitmapProcState::setupForTranslate, which is the only user of this flag) |
+ * |
+ * if the translate is larger than our ints, we can get random results, or |
+ * worse, we might get 0x80000000, which wreaks havoc on us, since we can't |
+ * negate it. |
+ */ |
+ const SkScalar too_big = SkIntToScalar(1 << 30); |
+ fOverflow = SkScalarAbs(pt.x() - SkFixedToScalar(biasX)) > too_big |
+ || SkScalarAbs(pt.y() - SkFixedToScalar(biasY)) > too_big; |
} |
SkFractionalInt x() const { return fX; } |
SkFractionalInt y() const { return fY; } |
+ bool isOverflow() const { return fOverflow; } |
+ |
private: |
SkFractionalInt fX, fY; |
+ bool fOverflow; |
}; |
#endif |