To avoid undefined int underflow behavior.
BUG=skia:6017
R=mtklein@google.com,reed@google.com
Change-Id: Ib707ad5e1d87eda70525c56db14849c4164c5640
Reviewed-on: https://skia-review.googlesource.com/5861
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
biasY = s.fFilterOneY >> 1;
}
- fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX);
- fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY);
+ // punt to unsigned for defined underflow behavior
+ fX = (SkFractionalInt)((uint64_t)SkScalarToFractionalInt(pt.x()) -
+ (uint64_t)SkFixedToFractionalInt(biasX));
+ fY = (SkFractionalInt)((uint64_t)SkScalarToFractionalInt(pt.y()) -
+ (uint64_t)SkFixedToFractionalInt(biasY));
if (scalarPoint) {
scalarPoint->set(pt.x() - SkFixedToScalar(biasX),