aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-11-24 07:56:59 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-24 07:56:59 -0800
commitff55b49c297251f6cc3a0f8b2ca059833629ae17 (patch)
tree795d92dcdb85c759667dd1f7dcb41d14c0f971a2 /src/gpu/SkGpuDevice.cpp
parent7b94c1479fc4ab3b7526808ac83c73f48d3cd721 (diff)
Sniff out rects, ovals & rrects in SkGpuDevice::drawPath
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp46
1 files changed, 33 insertions, 13 deletions
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);