Fix line rendering with TileGrid and Rtree
authorjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 17 Dec 2012 14:38:59 +0000 (14:38 +0000)
committerjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 17 Dec 2012 14:38:59 +0000 (14:38 +0000)
BUG=http://code.google.com/p/skia/issues/detail?id=1014
TEST=gm hairmodes with --tileGrid and --rtree
Review URL: https://codereview.appspot.com/6947056

git-svn-id: http://skia.googlecode.com/svn/trunk@6841 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBBoxRecord.cpp

index 5db77f5f405d060a0672c833d490e9f7f9a993dc..628aa87885fe32cfdb921e78ec065092a076edb5 100644 (file)
@@ -24,6 +24,18 @@ void SkBBoxRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
                               const SkPaint& paint) {
     SkRect bbox;
     bbox.set(pts, count);
+    // Small min width value, just to ensure hairline point bounding boxes aren't empty.
+    // Even though we know hairline primitives are drawn one pixel wide, we do not use a
+    // minimum of 1 because the playback scale factor is unknown at record time. Later
+    // outsets will take care of adding additional padding for antialiasing and rounding out
+    // to integer device coordinates, guaranteeing that the rasterized pixels will be included
+    // in the computed bounds.
+    // Note: The device coordinate outset in SkBBoxHierarchyRecord::handleBBox is currently
+    // done in the recording coordinate space, which is wrong.
+    // http://code.google.com/p/skia/issues/detail?id=1021
+    static const SkScalar kMinWidth = SkFloatToScalar(0.01f); 
+    SkScalar halfStrokeWidth = SkMaxScalar(paint.getStrokeWidth(), kMinWidth) / 2;
+    bbox.outset(halfStrokeWidth, halfStrokeWidth);
     if (this->transformBounds(bbox, &paint)) {
         INHERITED::drawPoints(mode, count, pts, paint);
     }