Fixing the drawing of blurred shodows for hairline paths with software rendering
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
diff --git a/include/core/SkDraw.h b/include/core/SkDraw.h
index 0ec37b3..925a21d 100644
--- a/include/core/SkDraw.h
+++ b/include/core/SkDraw.h
@@ -77,7 +77,8 @@
*/
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,
diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h
index 12de01b..9a470a4 100644
--- a/include/core/SkMaskFilter.h
+++ b/include/core/SkMaskFilter.h
@@ -12,6 +12,7 @@
#include "SkFlattenable.h"
#include "SkMask.h"
+#include "SkPaint.h"
class SkBlitter;
class SkBounder;
@@ -103,7 +104,8 @@
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;
};
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 74d10b6..914950c 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -985,11 +985,14 @@
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 @@
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 @@
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 @@
}
if (SkMask::kJustComputeBounds_CreateMode != mode) {
- draw_into_mask(*mask, devPath);
+ draw_into_mask(*mask, devPath, style);
}
return true;
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index 42d07a6..75e38ce 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -21,11 +21,12 @@
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);
diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp
index d5023b3..0a0a959 100644
--- a/src/core/SkRasterizer.cpp
+++ b/src/core/SkRasterizer.cpp
@@ -43,6 +43,7 @@
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);
}
diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp
index f287087..c803b7a 100644
--- a/src/device/xps/SkXPSDevice.cpp
+++ b/src/device/xps/SkXPSDevice.cpp
@@ -1784,7 +1784,8 @@
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;
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 81263d1..8899b42 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -74,7 +74,8 @@
SkMask mask;
if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(),
&matrix, &mask,
- SkMask::kJustComputeBounds_CreateMode)) {
+ SkMask::kJustComputeBounds_CreateMode,
+ SkPaint::kFill_Style)) {
return false;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9113fba..750a4aa 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -899,7 +899,8 @@
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);