Fixing the drawing of blurred shodows for hairline paths with software rendering
authorjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 4 Apr 2012 15:16:51 +0000 (15:16 +0000)
committerjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 4 Apr 2012 15:16:51 +0000 (15:16 +0000)
BUG=http://code.google.com/p/chromium/issues/detail?id=121251
REVIEW=http://codereview.appspot.com/5981053/

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

include/core/SkDraw.h
include/core/SkMaskFilter.h
src/core/SkDraw.cpp
src/core/SkMaskFilter.cpp
src/core/SkRasterizer.cpp
src/device/xps/SkXPSDevice.cpp
src/effects/SkLayerRasterizer.cpp
src/gpu/SkGpuDevice.cpp

index 0ec37b30923af4618001428746cbf18cf61f8fe0..925a21d145c7d91bcc12d07e76a9ebad1f22c290 100644 (file)
@@ -77,7 +77,8 @@ public:
     */
     static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
                            SkMaskFilter* filter, const SkMatrix* filterMatrix,
-                           SkMask* mask, SkMask::CreateMode mode);
+                           SkMask* mask, SkMask::CreateMode mode,
+                           SkPaint::Style style);
 
     enum RectType {
         kHair_RectType,
index 12de01b0bbd35837e987d0bc3519a18916c6da58..9a470a40af6f33bc77d1f2b30215f989af45b9ff 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "SkFlattenable.h"
 #include "SkMask.h"
+#include "SkPaint.h"
 
 class SkBlitter;
 class SkBounder;
@@ -103,7 +104,8 @@ private:
      This method is not exported to java.
      */
     bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix,
-                    const SkRasterClip&, SkBounder*, SkBlitter* blitter);
+                    const SkRasterClip&, SkBounder*, SkBlitter* blitter,
+                    SkPaint::Style style);
 
     typedef SkFlattenable INHERITED;
 };
index 74d10b689162c0a538569459a412b2a3a8e20bd8..914950c2af27b452ed5e2e95e5706dce5248dd41 100644 (file)
@@ -985,11 +985,14 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
 
     SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, *paint);
 
-    // how does filterPath() know to fill or hairline the path??? <mrr>
-    if (paint->getMaskFilter() &&
-            paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC,
-                                               fBounder, blitter.get())) {
-        return; // filterPath() called the blitter, so we're done
+    if (paint->getMaskFilter()) {
+        SkPaint::Style style = doFill ? SkPaint::kFill_Style : 
+            SkPaint::kStroke_Style;
+        if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC,
+                                               fBounder, blitter.get(),
+                                               style)) {
+            return; // filterPath() called the blitter, so we're done
+        }
     }
 
     if (fBounder && !fBounder->doPath(*devPathPtr, *paint, doFill)) {
@@ -2585,7 +2588,8 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds,
     return true;
 }
 
-static void draw_into_mask(const SkMask& mask, const SkPath& devPath) {
+static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
+                           SkPaint::Style style) {
     SkBitmap        bm;
     SkDraw          draw;
     SkRasterClip    clip;
@@ -2605,12 +2609,14 @@ static void draw_into_mask(const SkMask& mask, const SkPath& devPath) {
     draw.fMatrix    = &matrix;
     draw.fBounder   = NULL;
     paint.setAntiAlias(true);
+    paint.setStyle(style);
     draw.drawPath(devPath, paint);
 }
 
 bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
                         SkMaskFilter* filter, const SkMatrix* filterMatrix,
-                        SkMask* mask, SkMask::CreateMode mode) {
+                        SkMask* mask, SkMask::CreateMode mode,
+                        SkPaint::Style style) {
     if (SkMask::kJustRenderImage_CreateMode != mode) {
         if (!compute_bounds(devPath, clipBounds, filter, filterMatrix, &mask->fBounds))
             return false;
@@ -2629,7 +2635,7 @@ bool SkDraw::DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
     }
 
     if (SkMask::kJustComputeBounds_CreateMode != mode) {
-        draw_into_mask(*mask, devPath);
+        draw_into_mask(*mask, devPath, style);
     }
 
     return true;
index 42d07a6db03b88dfda9b83456e89a9e5b293a472..75e38ce7344493113c02115e6e5a2c2ea74a1ce8 100644 (file)
@@ -21,11 +21,12 @@ bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&,
 
 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
                               const SkRasterClip& clip, SkBounder* bounder,
-                              SkBlitter* blitter) {
+                              SkBlitter* blitter, SkPaint::Style style) {
     SkMask  srcM, dstM;
 
     if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
-                            SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
+                            SkMask::kComputeBoundsAndRenderImage_CreateMode,
+                            style)) {
         return false;
     }
     SkAutoMaskFreeImage autoSrc(srcM.fImage);
index d5023b30448a6fe5d6b0592561bdcd49efb02012..0a0a959452815db9a10d947a33497578dbb79442 100644 (file)
@@ -43,6 +43,7 @@ bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
     SkPath  devPath;
     
     fillPath.transform(matrix, &devPath);
-    return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode);
+    return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode,
+                              SkPaint::kFill_Style);
 }
 
index f2870872040a40b40e6d16bc974ae02a5f9b56a8..c803b7a29b11bd0a13a34b9ce54730bd5cfe4b40 100644 (file)
@@ -1784,7 +1784,8 @@ void SkXPSDevice::drawPath(const SkDraw& d,
                         filter,  //just to compute how much to draw.
                         &matrix,
                         &rasteredMask,
-                        SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
+                        SkMask::kComputeBoundsAndRenderImage_CreateMode,
+                        SkPaint::kFill_Style)) {
 
             SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage);
             mask = &rasteredMask;
index 81263d13d1f3a66f41bb47a7c0ac44dbf54e0e73..8899b4216a40be9a5ed16a697387d9c18c6701ce 100644 (file)
@@ -74,7 +74,8 @@ static bool compute_bounds(const SkDeque& layers, const SkPath& path,
         SkMask  mask;
         if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(),
                                 &matrix, &mask,
-                                SkMask::kJustComputeBounds_CreateMode)) {
+                                SkMask::kJustComputeBounds_CreateMode,
+                                SkPaint::kFill_Style)) {
             return false;
         }
 
index 9113fba23615bbfc77e9f4236f3ebb785b1125bc..750a4aa80fe65b91c0d4c284448667e6b6195627 100644 (file)
@@ -899,7 +899,8 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& path,
     SkMask  srcM, dstM;
 
     if (!SkDraw::DrawToMask(path, &clip.getBounds(), filter, &matrix, &srcM,
-                            SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
+                            SkMask::kComputeBoundsAndRenderImage_CreateMode,
+                            SkPaint::kFill_Style)) {
         return false;
     }
     SkAutoMaskFreeImage autoSrc(srcM.fImage);