diff options
author | robertphillips <robertphillips@google.com> | 2015-11-24 07:56:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-24 07:56:59 -0800 |
commit | ff55b49c297251f6cc3a0f8b2ca059833629ae17 (patch) | |
tree | 795d92dcdb85c759667dd1f7dcb41d14c0f971a2 /src | |
parent | 7b94c1479fc4ab3b7526808ac83c73f48d3cd721 (diff) |
Sniff out rects, ovals & rrects in SkGpuDevice::drawPath
Review URL: https://codereview.chromium.org/1468423002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 9 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 46 |
2 files changed, 35 insertions, 20 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 9da4ea806e..b017b50fea 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -243,13 +243,8 @@ void GrDrawContext::drawRect(const GrClip& clip, RETURN_IF_ABANDONED SkDEBUGCODE(this->validate();) - if (strokeInfo && strokeInfo->isDashed()) { - SkPath path; - path.setIsVolatile(true); - path.addRect(rect); - this->drawPath(clip, paint, viewMatrix, path, *strokeInfo); - return; - } + // Dashing should've been devolved to a path in SkGpuDevice + SkASSERT(!strokeInfo || !strokeInfo->isDashed()); AutoCheckFlush acf(fDrawingManager); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index b8630e5555..803f8a015d 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -469,8 +469,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, /////////////////////////////////////////////////////////////////////////////// -void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, - const SkPaint& paint) { +void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint& paint) { GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext); CHECK_FOR_ANNOTATION(paint); @@ -488,7 +487,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmpty())); // a few other reasons we might need to call drawPath... - if (paint.getMaskFilter() || + if (paint.getMaskFilter() || paint.getPathEffect() || paint.getStyle() == SkPaint::kStrokeAndFill_Style) { // we can't both stroke and fill rects usePath = true; } @@ -497,18 +496,14 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, usePath = true; } - GrStrokeInfo strokeInfo(paint); - - const SkPathEffect* pe = paint.getPathEffect(); - if (!usePath && pe && !strokeInfo.isDashed()) { - usePath = true; - } - if (usePath) { SkPath path; path.setIsVolatile(true); path.addRect(rect); - this->drawPath(draw, path, paint, nullptr, true); + GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, + fClip, path, paint, + *draw.fMatrix, nullptr, + draw.fClip->getBounds(), true); return; } @@ -517,6 +512,8 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, return; } + GrStrokeInfo strokeInfo(paint); + fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); } @@ -564,14 +561,19 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, } } - } if (paint.getMaskFilter() || paint.getPathEffect()) { + // The only mask filter the native rrect drawing code could've handle was taken + // care of above. + // A path effect will presumably transform this rrect into something else. SkPath path; path.setIsVolatile(true); path.addRRect(rect); - this->drawPath(draw, path, paint, nullptr, true); + GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, + fClip, path, paint, + *draw.fMatrix, nullptr, + draw.fClip->getBounds(), true); return; } @@ -656,6 +658,24 @@ static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, const SkPaint& paint, const SkMatrix* prePathMatrix, bool pathIsMutable) { + if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMatrix) { + bool isClosed; + SkRect rect; + if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { + this->drawRect(draw, rect, paint); + return; + } + if (origSrcPath.isOval(&rect)) { + this->drawOval(draw, rect, paint); + return; + } + SkRRect rrect; + if (origSrcPath.isRRect(&rrect)) { + this->drawRRect(draw, rrect, paint); + return; + } + } + CHECK_FOR_ANNOTATION(paint); CHECK_SHOULD_DRAW(draw); GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); |