As part of preliminary groundwork for a chromium fix, this changelist is deprecating GrPathFill so that SkPath::FillType is used everywhere in order to remove some code duplication between Skia and Ganesh.
BUG=chromium:135111
TEST=Try path rendering tests from the gm
Review URL: https://codereview.appspot.com/6875058
git-svn-id: http://skia.googlecode.com/svn/trunk@6693 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 4aad051..02868ef 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -9,6 +9,8 @@
#include "GrDrawState.h"
#include "GrGpu.h"
+#include "SkStroke.h"
+
// TODO: try to remove this #include
#include "GrContext.h"
@@ -30,23 +32,6 @@
return modeMap[op];
}
-////////////////////////////////////////////////////////////////////////////////
-SkPath::FillType gr_fill_to_sk_fill(GrPathFill fill) {
- switch (fill) {
- case kWinding_GrPathFill:
- return SkPath::kWinding_FillType;
- case kEvenOdd_GrPathFill:
- return SkPath::kEvenOdd_FillType;
- case kInverseWinding_GrPathFill:
- return SkPath::kInverseWinding_FillType;
- case kInverseEvenOdd_GrPathFill:
- return SkPath::kInverseEvenOdd_FillType;
- default:
- GrCrash("Unexpected fill.");
- return SkPath::kWinding_FillType;
- }
-}
-
}
/**
@@ -70,22 +55,22 @@
/**
* Draw a single path element of the clip stack into the accumulation bitmap
*/
-void GrSWMaskHelper::draw(const SkPath& path, SkRegion::Op op,
- GrPathFill fill, bool antiAlias, uint8_t alpha) {
+void GrSWMaskHelper::draw(const SkPath& path, const SkStroke& stroke, SkRegion::Op op,
+ bool antiAlias, uint8_t alpha) {
SkPaint paint;
- SkPath tmpPath;
- const SkPath* pathToDraw = &path;
- if (kHairLine_GrPathFill == fill) {
+ SkScalar width = stroke.getWidthIfStroked();
+ if (0 == width) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SK_Scalar1);
} else {
- paint.setStyle(SkPaint::kFill_Style);
- SkPath::FillType skfill = gr_fill_to_sk_fill(fill);
- if (skfill != pathToDraw->getFillType()) {
- tmpPath = *pathToDraw;
- tmpPath.setFillType(skfill);
- pathToDraw = &tmpPath;
+ if (stroke.getDoFill()) {
+ paint.setStyle(SkPaint::kFill_Style);
+ } else {
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeJoin(stroke.getJoin());
+ paint.setStrokeCap(stroke.getCap());
+ paint.setStrokeWidth(width);
}
}
SkXfermode* mode = SkXfermode::Create(op_to_mode(op));
@@ -94,7 +79,7 @@
paint.setAntiAlias(antiAlias);
paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
- fDraw.drawPath(*pathToDraw, paint);
+ fDraw.drawPath(path, paint);
SkSafeUnref(mode);
}
@@ -174,8 +159,8 @@
*/
GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
const SkPath& path,
+ const SkStroke& stroke,
const GrIRect& resultBounds,
- GrPathFill fill,
bool antiAlias,
SkMatrix* matrix) {
GrAutoScratchTexture ast;
@@ -186,7 +171,7 @@
return NULL;
}
- helper.draw(path, SkRegion::kReplace_Op, fill, antiAlias, 0xFF);
+ helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
if (!helper.getTexture(&ast)) {
return NULL;