diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-05 19:57:55 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-05 19:57:55 +0000 |
commit | fa6ac938e64fe11b442d05fe8a90ddac2d1951f9 (patch) | |
tree | 09e1bfdb59c0549a9cff72d1551376a25e262ce7 /gpu | |
parent | 322878907f6c5c5fb8abdbce7d348a3cd66ff2fa (diff) |
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
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/include/GrTypes.h | 4 | ||||
-rw-r--r-- | gpu/src/GrContext.cpp | 12 | ||||
-rw-r--r-- | gpu/src/GrGpu.cpp | 4 | ||||
-rw-r--r-- | gpu/src/GrTesselatedPathRenderer.cpp | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/gpu/include/GrTypes.h b/gpu/include/GrTypes.h index af43c1f540..8bbdecf7dc 100644 --- a/gpu/include/GrTypes.h +++ b/gpu/include/GrTypes.h @@ -435,7 +435,7 @@ enum GrPathFill { 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 @@ static inline GrPathFill NonInvertedFill(GrPathFill fill) { 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 e0c7b5559f..d9fb9e85c8 100644 --- a/gpu/src/GrContext.cpp +++ b/gpu/src/GrContext.cpp @@ -1445,6 +1445,16 @@ void GrContext::drawVertices(const GrPaint& paint, 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 @@ void GrContext::drawPath(const GrPaint& paint, const GrPath& path, } } 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 7b98ffa0b0..850fa60c4e 100644 --- a/gpu/src/GrGpu.cpp +++ b/gpu/src/GrGpu.cpp @@ -596,8 +596,8 @@ bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) { 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 5d544f2912..3c4bb0100c 100644 --- a/gpu/src/GrTesselatedPathRenderer.cpp +++ b/gpu/src/GrTesselatedPathRenderer.cpp @@ -366,7 +366,7 @@ void GrTesselatedPathRenderer::drawPath(GrDrawTarget::StageBitfield stages) { } } - bool inverted = IsFillInverted(fFill); + bool inverted = GrIsFillInverted(fFill); if (inverted) { maxPts += 4; subpathCnt++; |