Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 8d3f75ade08cd9eb3ee8131422174087b1b26d27..1bfcf1434c459f74ce9d4a1a72a7803d5aa9bd62 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -17,6 +17,7 @@ |
| #include "GrDistanceFieldTextContext.h" |
| #include "GrLayerCache.h" |
| #include "GrPictureUtils.h" |
| +#include "GrStrokeInfo.h" |
| #include "SkGrTexturePixelRef.h" |
| @@ -466,9 +467,11 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
| (paint.getStrokeJoin() == SkPaint::kRound_Join || |
| (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmpty())); |
| // another two reasons we might need to call drawPath... |
| - if (paint.getMaskFilter() || paint.getPathEffect()) { |
| + |
| + if (paint.getMaskFilter()) { |
| usePath = true; |
| } |
| + |
| if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect()) { |
| #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| if (doStroke) { |
| @@ -485,6 +488,13 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
| usePath = true; |
| } |
| + GrStrokeInfo strokeInfo(paint); |
| + |
| + SkPathEffect* pe = paint.getPathEffect(); |
|
robertphillips
2014/06/05 18:28:02
NULL != pe ?
|
| + if (!usePath && pe && !strokeInfo.setDashInfo(pe)) { |
| + usePath = true; |
| + } |
| + |
| if (usePath) { |
| SkPath path; |
| path.addRect(rect); |
| @@ -494,13 +504,13 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
| GrPaint grPaint; |
| SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| - |
| - if (!doStroke) { |
| - fContext->drawRect(grPaint, rect); |
| - } else { |
| - SkStrokeRec stroke(paint); |
| - fContext->drawRect(grPaint, rect, &stroke); |
| + |
| + SkAutoTArray<SkScalar> intervals(strokeInfo.dashCount()); |
| + if (strokeInfo.isDashed()) { |
| + strokeInfo.setDashInfo(pe, intervals.get()); |
| } |
| + |
| + fContext->drawRect(grPaint, rect, &strokeInfo); |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -512,8 +522,8 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| GrPaint grPaint; |
| SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| - |
| - SkStrokeRec stroke(paint); |
| + |
| + GrStrokeInfo strokeInfo(paint); |
| if (paint.getMaskFilter()) { |
| // try to hit the fast path for drawing filtered round rects |
| @@ -532,7 +542,8 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| return; |
| } |
| if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint, |
| - stroke, devRRect)) { |
| + strokeInfo.getStrokeRec(), |
| + devRRect)) { |
| return; |
| } |
| } |
| @@ -542,14 +553,30 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| } |
| - if (paint.getMaskFilter() || paint.getPathEffect()) { |
| + bool usePath = false; |
| + |
| + if (paint.getMaskFilter()) { |
| + usePath = true; |
| + } |
| + |
|
bsalomon
2014/06/05 19:22:54
else {
SkPathEffect* pe = paint.getPathEffect(
|
| + SkPathEffect* pe = paint.getPathEffect(); |
|
robertphillips
2014/06/05 18:28:02
NULL != pe ?
|
| + if (!usePath && pe && !strokeInfo.setDashInfo(pe)) { |
| + usePath = true; |
| + } |
| + |
| + if (usePath) { |
| SkPath path; |
| path.addRRect(rect); |
| this->drawPath(draw, path, paint, NULL, true); |
| return; |
| } |
| + |
| + SkAutoTArray<SkScalar> intervals(strokeInfo.dashCount()); |
|
bsalomon
2014/06/05 19:22:54
This feels kinda ugly to me. Can StrokeInfo own th
|
| + if (strokeInfo.isDashed()) { |
| + strokeInfo.setDashInfo(pe, intervals.get()); |
| + } |
| - fContext->drawRRect(grPaint, rect, stroke); |
| + fContext->drawRRect(grPaint, rect, strokeInfo); |
| } |
| void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| @@ -590,6 +617,13 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| if (paint.getMaskFilter() || paint.getPathEffect()) { |
| usePath = true; |
| } |
| + |
| + GrStrokeInfo strokeInfo(paint); |
| + |
| + SkPathEffect* pe = paint.getPathEffect(); |
|
robertphillips
2014/06/05 18:28:02
NULL != pe ?
|
| + if (!usePath && pe && !strokeInfo.setDashInfo(pe)) { |
| + usePath = true; |
| + } |
| if (usePath) { |
| SkPath path; |
| @@ -600,9 +634,13 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| GrPaint grPaint; |
| SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| - SkStrokeRec stroke(paint); |
| - fContext->drawOval(grPaint, oval, stroke); |
| + SkAutoTArray<SkScalar> intervals(strokeInfo.dashCount()); |
| + if (strokeInfo.isDashed()) { |
| + strokeInfo.setDashInfo(pe, intervals.get()); |
| + } |
| + |
| + fContext->drawOval(grPaint, oval, strokeInfo); |
| } |
| #include "SkMaskFilter.h" |
| @@ -678,7 +716,7 @@ bool draw_with_mask_filter(GrContext* context, const SkPath& devPath, |
| bool create_mask_GPU(GrContext* context, |
| const SkRect& maskRect, |
| const SkPath& devPath, |
| - const SkStrokeRec& stroke, |
| + const GrStrokeInfo& strokeInfo, |
| bool doAA, |
| GrAutoScratchTexture* mask) { |
| GrTextureDesc desc; |
| @@ -723,7 +761,7 @@ bool create_mask_GPU(GrContext* context, |
| SkMatrix translate; |
| translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
| am.set(context, translate); |
| - context->drawPath(tempPaint, devPath, stroke); |
| + context->drawPath(tempPaint, devPath, strokeInfo); |
| return true; |
| } |
| @@ -770,22 +808,24 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
| // at this point we're done with prePathMatrix |
| SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| - SkStrokeRec stroke(paint); |
| + GrStrokeInfo strokeInfo(paint); |
| SkPathEffect* pathEffect = paint.getPathEffect(); |
| const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| - if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &stroke, |
| + SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); |
| + if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, strokePtr, |
| cullRect)) { |
| pathPtr = effectPath.get(); |
| pathIsMutable = true; |
| } |
| + const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
| if (paint.getMaskFilter()) { |
| if (!stroke.isHairlineStyle()) { |
| SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); |
| if (stroke.applyToPath(strokedPath, *pathPtr)) { |
| pathPtr = strokedPath; |
| pathIsMutable = true; |
| - stroke.setFillStyle(); |
| + strokeInfo.setFillStyle(); |
| } |
| } |
| @@ -820,7 +860,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
| GrAutoScratchTexture mask; |
| - if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, |
| + if (create_mask_GPU(fContext, maskRect, *devPathPtr, strokeInfo, |
| grPaint.isAntiAlias(), &mask)) { |
| GrTexture* filtered; |
| @@ -848,13 +888,13 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
| // draw the mask on the CPU - this is a fallthrough path in case the |
| // GPU path fails |
| SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style : |
|
robertphillips
2014/06/05 18:28:02
Fix this alignment?
|
| - SkPaint::kFill_Style; |
| - draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *draw.fClip, &grPaint, |
| - style); |
| + SkPaint::kFill_Style; |
| + draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), |
| + *draw.fClip, &grPaint, style); |
| return; |
| } |
| - fContext->drawPath(grPaint, *pathPtr, stroke); |
| + fContext->drawPath(grPaint, *pathPtr, strokeInfo); |
| } |
| static const int kBmpSmallTileSize = 1 << 10; |