Chromium Code Reviews| Index: src/gpu/GrContext.cpp |
| diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
| index 66588c46bce32c1f161e52ce532e3ca2d8ecf6a9..58e5691fccc736a8eab929ec3942fbfe551fe034 100644 |
| --- a/src/gpu/GrContext.cpp |
| +++ b/src/gpu/GrContext.cpp |
| @@ -21,12 +21,14 @@ |
| #include "GrLayerCache.h" |
| #include "GrOvalRenderer.h" |
| #include "GrPathRenderer.h" |
| +#include "GrPaintStyle.h" |
| #include "GrPathUtils.h" |
| #include "GrResourceCache.h" |
| #include "GrSoftwarePathRenderer.h" |
| #include "GrStencilBuffer.h" |
| #include "GrTextStrike.h" |
| #include "GrTracing.h" |
| +#include "SkDashPathPriv.h" |
| #include "SkGr.h" |
| #include "SkRTConf.h" |
| #include "SkRRect.h" |
| @@ -775,7 +777,7 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po |
| void GrContext::drawRect(const GrPaint& paint, |
| const SkRect& rect, |
| - const SkStrokeRec* stroke, |
| + const GrPaintStyle* style, |
| const SkMatrix* matrix) { |
| AutoRestoreEffects are; |
| AutoCheckFlush acf(this); |
| @@ -783,6 +785,22 @@ void GrContext::drawRect(const GrPaint& paint, |
| GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); |
| + SkStrokeRec* stroke = style ? style->getStrokeRec() : NULL; |
| + |
| + if (style && style->hasDashInfo()) { |
| + const SkPathEffect::DashInfo* info = style->getDashInfo(); |
| + SkTLazy<SkPath> effectPath; |
| + SkPath path; |
| + path.addRect(rect); |
| + SkPath* pathPtr = &path; |
| + const SkRect* cullRect = NULL; |
| + if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, cullRect, *info)) { |
|
bsalomon
2014/06/04 19:05:05
I think this should just call drawPath with the un
egdaniel
2014/06/05 17:18:15
done
|
| + pathPtr = effectPath.get(); |
| + } |
| + this->drawPath(paint, *pathPtr, *style); |
| + return; |
| + } |
| + |
| SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); |
| SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
| if (NULL != matrix) { |
| @@ -1006,7 +1024,7 @@ void GrContext::drawVertices(const GrPaint& paint, |
| void GrContext::drawRRect(const GrPaint& paint, |
| const SkRRect& rrect, |
| - const SkStrokeRec& stroke) { |
| + const GrPaintStyle& style) { |
| if (rrect.isEmpty()) { |
| return; |
| } |
| @@ -1017,10 +1035,26 @@ void GrContext::drawRRect(const GrPaint& paint, |
| GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); |
| - if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stroke)) { |
| + SkStrokeRec* stroke = style.getStrokeRec(); |
| + |
| + if (style.hasDashInfo()) { |
| + const SkPathEffect::DashInfo* info = style.getDashInfo(); |
| + SkTLazy<SkPath> effectPath; |
| SkPath path; |
| path.addRRect(rrect); |
| - this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
| + SkPath* pathPtr = &path; |
| + const SkRect* cullRect = NULL; |
| + if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, cullRect, *info)) { |
| + pathPtr = effectPath.get(); |
| + } |
| + this->drawPath(paint, *pathPtr, style); |
| + return; |
| + } |
| + |
| + if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, *stroke)) { |
| + SkPath path; |
| + path.addRRect(rrect); |
| + this->internalDrawPath(target, paint.isAntiAlias(), path, *stroke); |
| } |
| } |
| @@ -1054,7 +1088,7 @@ void GrContext::drawDRRect(const GrPaint& paint, |
| void GrContext::drawOval(const GrPaint& paint, |
| const SkRect& oval, |
| - const SkStrokeRec& stroke) { |
| + const GrPaintStyle& style) { |
| if (oval.isEmpty()) { |
| return; |
| } |
| @@ -1065,10 +1099,26 @@ void GrContext::drawOval(const GrPaint& paint, |
| GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); |
| - if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke)) { |
| + SkStrokeRec* stroke = style.getStrokeRec(); |
| + |
| + if (style.hasDashInfo()) { |
| + const SkPathEffect::DashInfo* info = style.getDashInfo(); |
| + SkTLazy<SkPath> effectPath; |
| + SkPath path; |
| + path.addOval(oval); |
| + SkPath* pathPtr = &path; |
| + const SkRect* cullRect = NULL; |
| + if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, cullRect, *info)) { |
| + pathPtr = effectPath.get(); |
| + } |
| + this->drawPath(paint, *pathPtr, style); |
| + return; |
| + } |
| + |
| + if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, *stroke)) { |
| SkPath path; |
| path.addOval(oval); |
| - this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
| + this->internalDrawPath(target, paint.isAntiAlias(), path, *stroke); |
| } |
| } |
| @@ -1127,7 +1177,7 @@ static bool is_nested_rects(GrDrawTarget* target, |
| return true; |
| } |
| -void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) { |
| +void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrPaintStyle& style) { |
| if (path.isEmpty()) { |
| if (path.isInverseFillType()) { |
| @@ -1148,14 +1198,16 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok |
| GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); |
| + const SkStrokeRec* stroke = style.getStrokeRec(); |
| + |
| bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->isMultisampled(); |
| - if (useCoverageAA && stroke.getWidth() < 0 && !path.isConvex()) { |
| + if (useCoverageAA && stroke->getWidth() < 0 && !path.isConvex()) { |
| // Concave AA paths are expensive - try to avoid them for special cases |
| bool useVertexCoverage; |
| SkRect rects[2]; |
| - if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { |
| + if (is_nested_rects(target, path, *stroke, rects, &useVertexCoverage)) { |
| SkMatrix origViewMatrix = drawState->getViewMatrix(); |
| GrDrawState::AutoViewMatrixRestore avmr; |
| if (!avmr.setIdentity(target->drawState())) { |
| @@ -1174,8 +1226,8 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok |
| bool isOval = path.isOval(&ovalRect); |
| if (!isOval || path.isInverseFillType() |
| - || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect, stroke)) { |
| - this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
| + || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect, *stroke)) { |
| + this->internalDrawPath(target, paint.isAntiAlias(), path, *stroke); |
| } |
| } |