diff options
author | 2013-01-07 14:26:40 +0000 | |
---|---|---|
committer | 2013-01-07 14:26:40 +0000 | |
commit | e3453cbd20d00d685131a09d9141b1c70f0c5710 (patch) | |
tree | 23a998ded5198b71634b695dc3760eee4bca5a2e /src/gpu/GrContext.cpp | |
parent | d68bc309bbc3f0f4c3107cf4fa60ce1ff4847b75 (diff) |
This CL introduces a new path renderer.
Here are the characteristics :
- It uses the original path, before stroking
- It supports traight lines only (no curves)
- It supports butt or square caps only
- It supports miter or bevel joins only
- No AA support
Support for these will be added step by step later on.
A first pass at the benchmarks on my linux machine gave me these approximate speed improvements (running all bench with the option '--forceAA 0') :
path_stroke_small_long_line 4X
path_stroke_small_sawtooth 4X
path_stroke_big_rect 4X
path_stroke_small_rect 6X
path_stroke_big_triangle 4X
path_stroke_small_triangle 10X
lines_1_BW 1.5X
dashline_2_square 1.5X
dashline_1_square 1.5X
Also note that I can't submit this code until GrDrawTarget::isOpaque() is implemented, unless I just disable my renderer completely for now.
BUG=chromium:135111
TEST=The following gms are affected and may require rebaselining : lineclosepath, linepath, strokes_poly
Review URL: https://codereview.appspot.com/7026049
git-svn-id: http://skia.googlecode.com/svn/trunk@7047 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r-- | src/gpu/GrContext.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 12fbeb6e31..5961aaf8ff 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1063,24 +1063,15 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok return; } - const SkPath* pathPtr = &path; - SkPath tmpPath; - SkStrokeRec strokeRec(stroke); - if (!strokeRec.isHairlineStyle()) { - if (strokeRec.applyToPath(&tmpPath, *pathPtr)) { - pathPtr = &tmpPath; - strokeRec.setFillStyle(); - } - } - SkRect ovalRect; - if (!pathPtr->isInverseFillType() && pathPtr->isOval(&ovalRect)) { - SkScalar width = strokeRec.isHairlineStyle() ? 0 : -SK_Scalar1; + if ((stroke.isHairlineStyle() || stroke.isFillStyle()) && !path.isInverseFillType() && + path.isOval(&ovalRect)) { + SkScalar width = stroke.isHairlineStyle() ? 0 : -SK_Scalar1; this->drawOval(paint, ovalRect, width); return; } - this->internalDrawPath(paint, *pathPtr, strokeRec); + this->internalDrawPath(paint, path, stroke); } void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) { @@ -1109,7 +1100,23 @@ void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, const GrPathRendererChain::DrawType type = prAA ? GrPathRendererChain::kColorAntiAlias_DrawType : GrPathRendererChain::kColor_DrawType; - GrPathRenderer* pr = this->getPathRenderer(path, stroke, target, true, type); + const SkPath* pathPtr = &path; + SkPath tmpPath; + SkStrokeRec strokeRec(stroke); + + // Try a 1st time without stroking the path and without allowing the SW renderer + GrPathRenderer* pr = this->getPathRenderer(*pathPtr, strokeRec, target, false, type); + + if ((NULL == pr) && !strokeRec.isHairlineStyle()) { + // It didn't work the 1st time, so try again with the stroked path + if (strokeRec.applyToPath(&tmpPath, *pathPtr)) { + pathPtr = &tmpPath; + strokeRec.setFillStyle(); + } + // This time, allow SW renderer + pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type); + } + if (NULL == pr) { #if GR_DEBUG GrPrintf("Unable to find path renderer compatible with path.\n"); @@ -1117,7 +1124,7 @@ void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, const return; } - pr->drawPath(path, stroke, target, prAA); + pr->drawPath(*pathPtr, strokeRec, target, prAA); } //////////////////////////////////////////////////////////////////////////////// |