aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkScan_Hairline.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-18 21:19:26 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-18 21:19:26 +0000
commitbb39a297727fd70ba6b690b8bdfc62200854df86 (patch)
tree188985c5e3d30fc26c923ed44f7b5c102c998647 /src/core/SkScan_Hairline.cpp
parenta4b0d139e34e9d06bff0828adfb66fdfed9141c4 (diff)
mirror 3713 for non-antialiased-hairlines. clamp lines to 32K to avoid fixedpoint overflow
fixes crbug.com/123105 git-svn-id: http://skia.googlecode.com/svn/trunk@3729 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkScan_Hairline.cpp')
-rw-r--r--src/core/SkScan_Hairline.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index 412ec03186..ffdf92f1fa 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -33,6 +33,11 @@ static void vertline(int y, int stopy, SkFixed fx, SkFixed dx,
} while (++y < stopy);
}
+static bool canConvertFDot6ToFixed(SkFDot6 x) {
+ const int maxDot6 = SK_MaxS32 >> (16 - 6);
+ return SkAbs32(x) <= maxDot6;
+}
+
void SkScan::HairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
const SkRegion* clip, SkBlitter* blitter) {
SkBlitterClipper clipper;
@@ -40,6 +45,19 @@ void SkScan::HairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
SkIRect clipR, ptsR;
SkPoint pts[2] = { pt0, pt1 };
+#ifdef SK_SCALAR_IS_FLOAT
+ // We have to pre-clip the line to fit in a SkFixed, so we just chop
+ // the line. TODO find a way to actually draw beyond that range.
+ {
+ SkRect fixedBounds;
+ const SkScalar max = SkIntToScalar(32767);
+ fixedBounds.set(-max, -max, max, max);
+ if (!SkLineClipper::IntersectLine(pts, fixedBounds, pts)) {
+ return;
+ }
+ }
+#endif
+
if (clip) {
// Perform a clip in scalar space, so we catch huge values which might
// be missed after we convert to SkFDot6 (overflow)
@@ -53,7 +71,12 @@ void SkScan::HairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
SkFDot6 y0 = SkScalarToFDot6(pts[0].fY);
SkFDot6 x1 = SkScalarToFDot6(pts[1].fX);
SkFDot6 y1 = SkScalarToFDot6(pts[1].fY);
-
+
+ SkASSERT(canConvertFDot6ToFixed(x0));
+ SkASSERT(canConvertFDot6ToFixed(y0));
+ SkASSERT(canConvertFDot6ToFixed(x1));
+ SkASSERT(canConvertFDot6ToFixed(y1));
+
if (clip) {
// now perform clipping again, as the rounding to dot6 can wiggle us
// our rects are really dot6 rects, but since we've already used