Fixup rendering of empty paths (including inverted fills)
Add GM and Sample that draw empty paths with various styles and fills
Review URL: http://codereview.appspot.com/5185047/
git-svn-id: http://skia.googlecode.com/svn/trunk@2414 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrTypes.h b/gpu/include/GrTypes.h
index af43c1f..8bbdecf 100644
--- a/gpu/include/GrTypes.h
+++ b/gpu/include/GrTypes.h
@@ -435,7 +435,7 @@
kPathFillCount
};
-static inline GrPathFill NonInvertedFill(GrPathFill fill) {
+static inline GrPathFill GrNonInvertedFill(GrPathFill fill) {
static const GrPathFill gNonInvertedFills[] = {
kWinding_PathFill, // kWinding_PathFill
kEvenOdd_PathFill, // kEvenOdd_PathFill
@@ -452,7 +452,7 @@
return gNonInvertedFills[fill];
}
-static inline bool IsFillInverted(GrPathFill fill) {
+static inline bool GrIsFillInverted(GrPathFill fill) {
static const bool gIsFillInverted[] = {
false, // kWinding_PathFill
false, // kEvenOdd_PathFill
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index e0c7b55..d9fb9e8 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -1445,6 +1445,16 @@
void GrContext::drawPath(const GrPaint& paint, const GrPath& path,
GrPathFill fill, const GrPoint* translate) {
+ if (path.isEmpty()) {
+#if GR_DEBUG
+ GrPrintf("Empty path should have been caught by canvas.\n");
+#endif
+ if (GrIsFillInverted(fill)) {
+ this->drawPaint(paint);
+ }
+ return;
+ }
+
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
// An Assumption here is that path renderer would use some form of tweaking
@@ -1503,7 +1513,7 @@
}
}
this->cleanupOffscreenAA(target, pr, &record);
- if (IsFillInverted(fill) && bound != clipIBounds) {
+ if (GrIsFillInverted(fill) && bound != clipIBounds) {
GrDrawTarget::AutoDeviceCoordDraw adcd(target, stageMask);
GrRect rect;
if (clipIBounds.fTop < bound.fTop) {
diff --git a/gpu/src/GrGpu.cpp b/gpu/src/GrGpu.cpp
index 7b98ffa..850fa60 100644
--- a/gpu/src/GrGpu.cpp
+++ b/gpu/src/GrGpu.cpp
@@ -596,8 +596,8 @@
fillInverted = false;
} else {
fill = clip.getPathFill(c);
- fillInverted = IsFillInverted(fill);
- fill = NonInvertedFill(fill);
+ fillInverted = GrIsFillInverted(fill);
+ fill = GrNonInvertedFill(fill);
clipPath = &clip.getPath(c);
pr = this->getClipPathRenderer(*clipPath, fill);
if (NULL == pr) {
diff --git a/gpu/src/GrTesselatedPathRenderer.cpp b/gpu/src/GrTesselatedPathRenderer.cpp
index 5d544f2..3c4bb01 100644
--- a/gpu/src/GrTesselatedPathRenderer.cpp
+++ b/gpu/src/GrTesselatedPathRenderer.cpp
@@ -366,7 +366,7 @@
}
}
- bool inverted = IsFillInverted(fFill);
+ bool inverted = GrIsFillInverted(fFill);
if (inverted) {
maxPts += 4;
subpathCnt++;