Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index 5e2ff10f63b3185687eeb7d8b920dd640ac01676..cb19100ce5140e8f6f4a4f4942aec8869b033596 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" |
@@ -437,9 +438,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) { |
@@ -456,6 +459,13 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
usePath = true; |
} |
+ GrStrokeInfo strokeInfo(paint); |
+ |
+ const SkPathEffect* pe = paint.getPathEffect(); |
+ if (!usePath && NULL != pe && !strokeInfo.isDashed()) { |
+ usePath = true; |
+ } |
+ |
if (usePath) { |
SkPath path; |
path.addRect(rect); |
@@ -465,13 +475,8 @@ 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); |
- } |
+ |
+ fContext->drawRect(grPaint, rect, &strokeInfo); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -483,8 +488,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 |
@@ -503,7 +508,8 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
return; |
} |
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint, |
- stroke, devRRect)) { |
+ strokeInfo.getStrokeRec(), |
+ devRRect)) { |
return; |
} |
} |
@@ -513,14 +519,26 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
} |
- if (paint.getMaskFilter() || paint.getPathEffect()) { |
+ bool usePath = false; |
+ |
+ if (paint.getMaskFilter()) { |
+ usePath = true; |
+ } else { |
+ const SkPathEffect* pe = paint.getPathEffect(); |
+ if (NULL != pe && !strokeInfo.isDashed()) { |
+ usePath = true; |
+ } |
+ } |
+ |
+ |
+ if (usePath) { |
SkPath path; |
path.addRRect(rect); |
this->drawPath(draw, path, paint, NULL, true); |
return; |
} |
- |
- fContext->drawRRect(grPaint, rect, stroke); |
+ |
+ fContext->drawRRect(grPaint, rect, strokeInfo); |
} |
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
@@ -556,10 +574,17 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
CHECK_FOR_ANNOTATION(paint); |
CHECK_SHOULD_DRAW(draw, false); |
+ GrStrokeInfo strokeInfo(paint); |
+ |
bool usePath = false; |
// some basic reasons we might need to call drawPath... |
- if (paint.getMaskFilter() || paint.getPathEffect()) { |
+ if (paint.getMaskFilter()) { |
usePath = true; |
+ } else { |
+ const SkPathEffect* pe = paint.getPathEffect(); |
+ if (NULL != pe && !strokeInfo.isDashed()) { |
+ usePath = true; |
+ } |
} |
if (usePath) { |
@@ -571,9 +596,8 @@ 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); |
+ fContext->drawOval(grPaint, oval, strokeInfo); |
} |
#include "SkMaskFilter.h" |
@@ -649,7 +673,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; |
@@ -694,7 +718,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; |
} |
@@ -738,22 +762,25 @@ 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; |
+ strokeInfo.removeDash(); |
} |
+ 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(); |
} |
} |
@@ -788,7 +815,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; |
@@ -817,12 +844,12 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
// GPU path fails |
SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style : |
SkPaint::kFill_Style; |
- draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *draw.fClip, &grPaint, |
- 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; |