Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index 751435921627cf5cef6920bed2965b233b983558..e0d0370f24f4a39420e30c7165bbbae85739dace 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 "GrPaintStyle.h" |
#include "SkGrTexturePixelRef.h" |
@@ -455,6 +456,8 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
CHECK_FOR_ANNOTATION(paint); |
CHECK_SHOULD_DRAW(draw, false); |
+ GrPaintStyle style; |
+ |
bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |
SkScalar width = paint.getStrokeWidth(); |
@@ -466,9 +469,17 @@ 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; |
} |
+ |
+ SkPathEffect* pe = paint.getPathEffect(); |
+ SkPathEffect::DashInfo info; |
+ if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
+ usePath = true; |
+ } |
+ |
if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect()) { |
#if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
if (doStroke) { |
@@ -494,13 +505,27 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
GrPaint grPaint; |
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
+ |
+ SkStrokeRec stroke(paint); |
+ style.setStrokeRec(&stroke); |
+ |
+ SkAutoTArray<SkScalar> intervals(info.fCount); |
+ if (pe) { |
+ info.fIntervals = intervals.get(); |
+ pe->asADash(&info); |
+ style.setDashInfo(&info); |
+ } |
+ fContext->drawRect(grPaint, rect, &style); |
+ /* |
if (!doStroke) { |
fContext->drawRect(grPaint, rect); |
} else { |
SkStrokeRec stroke(paint); |
- fContext->drawRect(grPaint, rect, &stroke); |
+ style.setStrokeRec(&stroke); |
+ fContext->drawRect(grPaint, rect, &style); |
} |
+ */ |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -512,8 +537,10 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
GrPaint grPaint; |
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
- |
+ |
+ GrPaintStyle style; |
SkStrokeRec stroke(paint); |
+ style.setStrokeRec(&stroke); |
if (paint.getMaskFilter()) { |
// try to hit the fast path for drawing filtered round rects |
@@ -542,14 +569,34 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
} |
- if (paint.getMaskFilter() || paint.getPathEffect()) { |
+ bool usePath = false; |
+ |
+ if (paint.getMaskFilter()) { |
+ usePath = true; |
+ } |
+ |
+ SkPathEffect* pe = paint.getPathEffect(); |
+ SkPathEffect::DashInfo info; |
+ if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
+ usePath = true; |
+ } |
+ |
+ if (usePath) { |
SkPath path; |
path.addRRect(rect); |
this->drawPath(draw, path, paint, NULL, true); |
return; |
} |
+ |
+ SkAutoTArray<SkScalar> intervals(info.fCount); |
+ if (pe) { |
+ info.fIntervals = intervals.get(); |
+ pe->asADash(&info); |
+ style.setDashInfo(&info); |
+ } |
+ |
- fContext->drawRRect(grPaint, rect, stroke); |
+ fContext->drawRRect(grPaint, rect, style); |
} |
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
@@ -590,6 +637,12 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
if (paint.getMaskFilter() || paint.getPathEffect()) { |
usePath = true; |
} |
+ |
+ SkPathEffect* pe = paint.getPathEffect(); |
+ SkPathEffect::DashInfo info; |
+ if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
+ usePath = true; |
+ } |
if (usePath) { |
SkPath path; |
@@ -600,9 +653,19 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
GrPaint grPaint; |
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
+ |
+ GrPaintStyle style; |
+ SkAutoTArray<SkScalar> intervals(info.fCount); |
+ if (pe) { |
+ info.fIntervals = intervals.get(); |
+ pe->asADash(&info); |
+ style.setDashInfo(&info); |
+ } |
+ |
SkStrokeRec stroke(paint); |
+ style.setStrokeRec(&stroke); |
- fContext->drawOval(grPaint, oval, stroke); |
+ fContext->drawOval(grPaint, oval, style); |
} |
#include "SkMaskFilter.h" |
@@ -678,7 +741,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 GrPaintStyle& style, |
bool doAA, |
GrAutoScratchTexture* mask) { |
GrTextureDesc desc; |
@@ -723,7 +786,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, style); |
return true; |
} |
@@ -770,7 +833,9 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
// at this point we're done with prePathMatrix |
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
+ GrPaintStyle style; |
SkStrokeRec stroke(paint); |
+ style.setStrokeRec(&stroke); |
SkPathEffect* pathEffect = paint.getPathEffect(); |
const SkRect* cullRect = NULL; // TODO: what is our bounds? |
if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &stroke, |
@@ -820,7 +885,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, style, |
grPaint.isAntiAlias(), &mask)) { |
GrTexture* filtered; |
@@ -847,14 +912,14 @@ 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 : |
- SkPaint::kFill_Style; |
- draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *draw.fClip, &grPaint, |
- style); |
+ SkPaint::Style paintStyle = stroke.isHairlineStyle() ? SkPaint::kStroke_Style : |
+ SkPaint::kFill_Style; |
+ draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), |
+ *draw.fClip, &grPaint, paintStyle); |
return; |
} |
- fContext->drawPath(grPaint, *pathPtr, stroke); |
+ fContext->drawPath(grPaint, *pathPtr, style); |
} |
static const int kBmpSmallTileSize = 1 << 10; |