Index: src/gpu/GrStencilAndCoverTextContext.cpp |
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp |
index a2abfa7fa98bb8df5ab0e680d83392071a35bac4..ed7236888db74d97d73beb7ad5c1e3f4e46c4a7b 100644 |
--- a/src/gpu/GrStencilAndCoverTextContext.cpp |
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp |
@@ -55,8 +55,10 @@ bool GrStencilAndCoverTextContext::canDraw(const GrRenderTarget* rt, |
if (skPaint.getMaskFilter()) { |
return false; |
} |
- if (skPaint.getPathEffect()) { |
- return false; |
+ if (SkPathEffect* pe = skPaint.getPathEffect()) { |
+ if (pe->asADash(NULL) != SkPathEffect::kDash_DashType) { |
+ return false; |
+ } |
} |
// No hairlines unless we can map the 1 px width to the object space. |
@@ -220,7 +222,7 @@ void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt, |
static GrPathRange* get_gr_glyphs(GrContext* ctx, |
const SkTypeface* typeface, |
const SkDescriptor* desc, |
- const SkStrokeRec& stroke) { |
+ const GrStrokeInfo& stroke) { |
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
GrUniqueKey key; |
GrUniqueKey::Builder builder(&key, kDomain, 4); |
@@ -273,7 +275,7 @@ void GrStencilAndCoverTextContext::init(GrRenderTarget* rt, |
// The whole shape (including stroke) will be baked into the glyph outlines. Make |
// NVPR just fill the baked shapes. |
- fStroke = SkStrokeRec(SkStrokeRec::kFill_InitStyle); |
+ fStroke = GrStrokeInfo(SkStrokeRec::kFill_InitStyle); |
fTextRatio = fTextInverseRatio = 1.0f; |
@@ -298,21 +300,22 @@ void GrStencilAndCoverTextContext::init(GrRenderTarget* rt, |
} else { |
// Don't bake strokes into the glyph outlines. We will stroke the glyphs |
// using the GPU instead. This is the fast path. |
- fStroke = SkStrokeRec(fSkPaint); |
+ fStroke = GrStrokeInfo(fSkPaint); |
+ SkStrokeRec* strokeRec = fStroke.getStrokeRecPtr(); |
fSkPaint.setStyle(SkPaint::kFill_Style); |
- if (fStroke.isHairlineStyle()) { |
+ if (strokeRec->isHairlineStyle()) { |
// Approximate hairline stroke. |
SkScalar strokeWidth = SK_Scalar1 / |
(SkVector::Make(fContextInitialMatrix.getScaleX(), |
fContextInitialMatrix.getSkewY()).length()); |
- fStroke.setStrokeStyle(strokeWidth, false /*strokeAndFill*/); |
+ strokeRec->setStrokeStyle(strokeWidth, false /*strokeAndFill*/); |
} else if (fSkPaint.isFakeBoldText() && |
#ifdef SK_USE_FREETYPE_EMBOLDEN |
kMaxPerformance_RenderMode == renderMode && |
#endif |
- SkStrokeRec::kStroke_Style != fStroke.getStyle()) { |
+ SkStrokeRec::kStroke_Style != strokeRec->getStyle()) { |
// Instead of baking fake bold into the glyph outlines, do it with the GPU stroke. |
SkScalar fakeBoldScale = SkScalarInterpFunc(fSkPaint.getTextSize(), |
@@ -320,23 +323,22 @@ void GrStencilAndCoverTextContext::init(GrRenderTarget* rt, |
kStdFakeBoldInterpValues, |
kStdFakeBoldInterpLength); |
SkScalar extra = SkScalarMul(fSkPaint.getTextSize(), fakeBoldScale); |
- fStroke.setStrokeStyle(fStroke.needToApply() ? fStroke.getWidth() + extra : extra, |
+ strokeRec->setStrokeStyle(strokeRec->needToApply() ? strokeRec->getWidth() + extra : extra, |
true /*strokeAndFill*/); |
fSkPaint.setFakeBoldText(false); |
} |
bool canUseRawPaths; |
- |
- if (otherBackendsWillDrawAsPaths || kMaxPerformance_RenderMode == renderMode) { |
+ if (!fStroke.isDashed() && (otherBackendsWillDrawAsPaths || kMaxPerformance_RenderMode == renderMode)) { |
egdaniel
2015/05/05 19:48:44
100 chars
Kimmo Kinnunen
2015/05/06 08:30:25
Done.
|
// We can draw the glyphs from canonically sized paths. |
fTextRatio = fSkPaint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; |
fTextInverseRatio = SkPaint::kCanonicalTextSizeForPaths / fSkPaint.getTextSize(); |
// Compensate for the glyphs being scaled by fTextRatio. |
- if (!fStroke.isFillStyle()) { |
- fStroke.setStrokeStyle(fStroke.getWidth() / fTextRatio, |
- SkStrokeRec::kStrokeAndFill_Style == fStroke.getStyle()); |
+ if (!strokeRec->isFillStyle()) { |
+ strokeRec->setStrokeStyle(strokeRec->getWidth() / fTextRatio, |
+ SkStrokeRec::kStrokeAndFill_Style == strokeRec->getStyle()); |
} |
fSkPaint.setLinearText(true); |
@@ -448,7 +450,7 @@ void GrStencilAndCoverTextContext::flush() { |
SkPaint skPaintFallback(fSkPaint); |
if (!fUsingDeviceSpaceGlyphs) { |
- fStroke.applyToPaint(&skPaintFallback); |
+ fStroke.getStrokeRecPtr()->applyToPaint(&skPaintFallback); |
} |
skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already been accounted for. |
skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |