Index: src/gpu/text/GrStencilAndCoverTextContext.cpp |
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp |
index cc018845f66eda1b5160267d4d4180159e5ed183..c2c1c569e8eb915b1a77693aab6cde3b19ba58f8 100644 |
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp |
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp |
@@ -235,18 +235,6 @@ |
} |
} |
-static inline int style_key_cnt(const GrStyle& style) { |
- int cnt = GrStyle::KeySize(style, GrStyle::Apply::kPathEffectAndStrokeRec); |
- // We should be able to make a key because we filtered out arbitrary path effects. |
- SkASSERT(cnt > 0); |
- return cnt; |
-} |
- |
-static inline void write_style_key(uint32_t* dst, const GrStyle& style) { |
- // Pass 1 for the scale since the GPU will apply the style not GrStyle::applyToPath(). |
- GrStyle::WriteKey(dst, style, GrStyle::Apply::kPathEffectAndStrokeRec, SK_Scalar1); |
-} |
- |
const GrStencilAndCoverTextContext::TextBlob& |
GrStencilAndCoverTextContext::findOrCreateTextBlob(const SkTextBlob* skBlob, |
const SkPaint& skPaint) { |
@@ -265,11 +253,11 @@ |
fCacheSize += blob->cpuMemorySize(); |
return *blob; |
} else { |
- GrStyle style(skPaint); |
+ GrStrokeInfo stroke(skPaint); |
SkSTArray<4, uint32_t, true> key; |
- key.reset(1 + style_key_cnt(style)); |
+ key.reset(1 + stroke.computeUniqueKeyFragmentData32Cnt()); |
key[0] = skBlob->uniqueID(); |
- write_style_key(&key[1], style); |
+ stroke.asUniqueKeyFragment(&key[1]); |
if (TextBlob** found = fBlobKeyCache.find(key)) { |
fLRUList.remove(*found); |
fLRUList.addToTail(*found); |
@@ -365,48 +353,41 @@ |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
GrStencilAndCoverTextContext::TextRun::TextRun(const SkPaint& fontAndStroke) |
- : fStyle(fontAndStroke), |
+ : fStroke(fontAndStroke), |
fFont(fontAndStroke), |
fTotalGlyphCount(0), |
fFallbackGlyphCount(0), |
fDetachedGlyphCache(nullptr), |
fLastDrawnGlyphsID(SK_InvalidUniqueID) { |
SkASSERT(fFont.getTextSize() > 0); |
- SkASSERT(!fStyle.hasNonDashPathEffect()); // Arbitrary path effects not supported. |
- SkASSERT(!fStyle.isSimpleHairline()); // Hairlines are not supported. |
+ SkASSERT(!fStroke.isHairlineStyle()); // Hairlines are not supported. |
// Setting to "fill" ensures that no strokes get baked into font outlines. (We use the GPU path |
// rendering API for stroking). |
fFont.setStyle(SkPaint::kFill_Style); |
- if (fFont.isFakeBoldText() && fStyle.isSimpleFill()) { |
- const SkStrokeRec& stroke = fStyle.strokeRec(); |
+ if (fFont.isFakeBoldText() && SkStrokeRec::kStroke_Style != fStroke.getStyle()) { |
// Instead of letting fake bold get baked into the glyph outlines, do it with GPU stroke. |
SkScalar fakeBoldScale = SkScalarInterpFunc(fFont.getTextSize(), |
kStdFakeBoldInterpKeys, |
kStdFakeBoldInterpValues, |
kStdFakeBoldInterpLength); |
SkScalar extra = SkScalarMul(fFont.getTextSize(), fakeBoldScale); |
- |
- SkStrokeRec strokeRec(SkStrokeRec::kFill_InitStyle); |
- strokeRec.setStrokeStyle(stroke.needToApply() ? stroke.getWidth() + extra : extra, |
- true /*strokeAndFill*/); |
- fStyle = GrStyle(strokeRec, fStyle.pathEffect()); |
+ fStroke.setStrokeStyle(fStroke.needToApply() ? fStroke.getWidth() + extra : extra, |
+ true /*strokeAndFill*/); |
+ |
fFont.setFakeBoldText(false); |
} |
- if (!fFont.getPathEffect() && !fStyle.isDashed()) { |
- const SkStrokeRec& stroke = fStyle.strokeRec(); |
+ if (!fFont.getPathEffect() && !fStroke.isDashed()) { |
// We can draw the glyphs from canonically sized paths. |
fTextRatio = fFont.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; |
fTextInverseRatio = SkPaint::kCanonicalTextSizeForPaths / fFont.getTextSize(); |
// Compensate for the glyphs being scaled by fTextRatio. |
- if (!fStyle.isSimpleFill()) { |
- SkStrokeRec strokeRec(SkStrokeRec::kFill_InitStyle); |
- strokeRec.setStrokeStyle(stroke.getWidth() / fTextRatio, |
- SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()); |
- fStyle = GrStyle(strokeRec, fStyle.pathEffect()); |
+ if (!fStroke.isFillStyle()) { |
+ fStroke.setStrokeStyle(fStroke.getWidth() / fTextRatio, |
+ SkStrokeRec::kStrokeAndFill_Style == fStroke.getStyle()); |
} |
fFont.setLinearText(true); |
@@ -426,7 +407,7 @@ |
} |
// Generate the key that will be used to cache the GPU glyph path objects. |
- if (fUsingRawGlyphPaths && fStyle.isSimpleFill()) { |
+ if (fUsingRawGlyphPaths && fStroke.isFillStyle()) { |
static const GrUniqueKey::Domain kRawFillPathGlyphDomain = GrUniqueKey::GenerateDomain(); |
const SkTypeface* typeface = fFont.getTypeface(); |
@@ -435,30 +416,24 @@ |
} else { |
static const GrUniqueKey::Domain kPathGlyphDomain = GrUniqueKey::GenerateDomain(); |
- int styleDataCount = GrStyle::KeySize(fStyle, GrStyle::Apply::kPathEffectAndStrokeRec); |
- // Key should be valid since we opted out of drawing arbitrary path effects. |
- SkASSERT(styleDataCount >= 0); |
+ int strokeDataCount = fStroke.computeUniqueKeyFragmentData32Cnt(); |
if (fUsingRawGlyphPaths) { |
const SkTypeface* typeface = fFont.getTypeface(); |
- GrUniqueKey::Builder builder(&fGlyphPathsKey, kPathGlyphDomain, 2 + styleDataCount); |
+ GrUniqueKey::Builder builder(&fGlyphPathsKey, kPathGlyphDomain, 2 + strokeDataCount); |
reinterpret_cast<uint32_t&>(builder[0]) = typeface ? typeface->uniqueID() : 0; |
- reinterpret_cast<uint32_t&>(builder[1]) = styleDataCount; |
- if (styleDataCount) { |
- write_style_key(&builder[2], fStyle); |
- } |
+ reinterpret_cast<uint32_t&>(builder[1]) = strokeDataCount; |
+ fStroke.asUniqueKeyFragment(&builder[2]); |
} else { |
SkGlyphCache* glyphCache = this->getGlyphCache(); |
const SkTypeface* typeface = glyphCache->getScalerContext()->getTypeface(); |
const SkDescriptor* desc = &glyphCache->getDescriptor(); |
int descDataCount = (desc->getLength() + 3) / 4; |
GrUniqueKey::Builder builder(&fGlyphPathsKey, kPathGlyphDomain, |
- 2 + styleDataCount + descDataCount); |
+ 2 + strokeDataCount + descDataCount); |
reinterpret_cast<uint32_t&>(builder[0]) = typeface ? typeface->uniqueID() : 0; |
- reinterpret_cast<uint32_t&>(builder[1]) = styleDataCount | (descDataCount << 16); |
- if (styleDataCount) { |
- write_style_key(&builder[2], fStyle); |
- } |
- memcpy(&builder[2 + styleDataCount], desc, desc->getLength()); |
+ reinterpret_cast<uint32_t&>(builder[1]) = strokeDataCount | (descDataCount << 16); |
+ fStroke.asUniqueKeyFragment(&builder[2]); |
+ memcpy(&builder[2 + strokeDataCount], desc, desc->getLength()); |
} |
} |
} |
@@ -566,13 +541,13 @@ |
if (fUsingRawGlyphPaths) { |
SkScalerContextEffects noeffects; |
glyphs = ctx->resourceProvider()->createGlyphs(fFont.getTypeface(), noeffects, |
- nullptr, fStyle); |
+ nullptr, fStroke); |
} else { |
SkGlyphCache* cache = this->getGlyphCache(); |
glyphs = ctx->resourceProvider()->createGlyphs(cache->getScalerContext()->getTypeface(), |
cache->getScalerContext()->getEffects(), |
&cache->getDescriptor(), |
- fStyle); |
+ fStroke); |
} |
ctx->resourceProvider()->assignUniqueKeyToResource(fGlyphPathsKey, glyphs); |
} |
@@ -646,9 +621,9 @@ |
if (fFallbackTextBlob) { |
SkPaint fallbackSkPaint(originalSkPaint); |
- fStyle.strokeRec().applyToPaint(&fallbackSkPaint); |
- if (!fStyle.isSimpleFill()) { |
- fallbackSkPaint.setStrokeWidth(fStyle.strokeRec().getWidth() * fTextRatio); |
+ fStroke.applyToPaint(&fallbackSkPaint); |
+ if (!fStroke.isFillStyle()) { |
+ fallbackSkPaint.setStrokeWidth(fStroke.getWidth() * fTextRatio); |
} |
fallbackTextContext->drawTextBlob(ctx, dc, pipelineBuilder->clip(), fallbackSkPaint, |