Move strike to subrun in GrAtlasTextContext

BUG=skia:

Review URL: https://codereview.chromium.org/1257253005
This commit is contained in:
joshualitt 2015-07-31 13:58:27 -07:00 committed by Commit bot
parent 7568d0b15e
commit 77d89f7dd2
3 changed files with 31 additions and 8 deletions

View File

@ -78,6 +78,19 @@ struct GrAtlasTextBlob : public SkRefCnt {
, fGlyphStartIndex(0)
, fGlyphEndIndex(0)
, fDrawAsDistanceFields(false) {}
SubRunInfo(const SubRunInfo& that)
: fBulkUseToken(that.fBulkUseToken)
, fStrike(SkRef(that.fStrike.get()))
, fAtlasGeneration(that.fAtlasGeneration)
, fVertexStartIndex(that.fVertexStartIndex)
, fVertexEndIndex(that.fVertexEndIndex)
, fGlyphStartIndex(that.fGlyphStartIndex)
, fGlyphEndIndex(that.fGlyphEndIndex)
, fTextRatio(that.fTextRatio)
, fMaskFormat(that.fMaskFormat)
, fDrawAsDistanceFields(that.fDrawAsDistanceFields)
, fUseLCDText(that.fUseLCDText) {
}
// Distance field text cannot draw coloremoji, and so has to fall back. However,
// though the distance field text and the coloremoji may share the same run, they
// will have different descriptors. If fOverrideDescriptor is non-NULL, then it
@ -86,6 +99,7 @@ struct GrAtlasTextBlob : public SkRefCnt {
// significantly, and then the subrun could just have a refed pointer to the
// correct descriptor.
GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
SkAutoTUnref<GrBatchTextStrike> fStrike;
uint64_t fAtlasGeneration;
size_t fVertexStartIndex;
size_t fVertexEndIndex;
@ -110,7 +124,6 @@ struct GrAtlasTextBlob : public SkRefCnt {
return newSubRun;
}
static const int kMinSubRuns = 1;
SkAutoTUnref<GrBatchTextStrike> fStrike;
SkAutoTUnref<SkTypeface> fTypeface;
SkRect fVertexBounds;
SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo;

View File

@ -1221,7 +1221,6 @@ void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
Run& run = blob->fRuns[runIndex];
if (!fCurrStrike) {
fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
run.fStrike.reset(SkRef(fCurrStrike));
}
GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
@ -1263,6 +1262,9 @@ void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
PerSubRunInfo* subRun = &run.fSubRunInfo.back();
if (run.fInitialized && subRun->fMaskFormat != format) {
subRun = &run.push_back();
subRun->fStrike.reset(SkRef(fCurrStrike));
} else if (!run.fInitialized) {
subRun->fStrike.reset(SkRef(fCurrStrike));
}
run.fInitialized = true;
@ -1288,7 +1290,6 @@ bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
Run& run = blob->fRuns[runIndex];
if (!fCurrStrike) {
fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
run.fStrike.reset(SkRef(fCurrStrike));
}
GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
@ -1339,6 +1340,10 @@ bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
}
PerSubRunInfo* subRun = &run.fSubRunInfo.back();
if (!run.fInitialized) {
subRun->fStrike.reset(SkRef(fCurrStrike));
}
run.fInitialized = true;
SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat);
subRun->fMaskFormat = kA8_GrMaskFormat;
@ -1603,7 +1608,7 @@ public:
uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat);
bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlasGen ||
run.fStrike->isAbandoned();
info.fStrike->isAbandoned();
bool regenerateColors;
if (usesDistanceFields) {
regenerateColors = !isLCD && run.fColor != args.fColor;
@ -1651,15 +1656,15 @@ public:
desc = newDesc;
cache = SkGlyphCache::DetachCache(run.fTypeface, desc);
scaler = GrTextContext::GetGrFontScaler(cache);
strike = run.fStrike;
strike = info.fStrike;
typeface = run.fTypeface;
}
if (run.fStrike->isAbandoned()) {
if (info.fStrike->isAbandoned()) {
regenerateGlyphs = true;
strike = fFontCache->getStrike(scaler);
} else {
strike = run.fStrike;
strike = info.fStrike;
}
}
@ -1732,7 +1737,7 @@ public:
run.fColor = args.fColor;
if (regenerateTextureCoords) {
if (regenerateGlyphs) {
run.fStrike.reset(SkRef(strike));
info.fStrike.reset(SkRef(strike));
}
info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAtlasGeneration :
fFontCache->atlasGeneration(maskFormat);

View File

@ -67,6 +67,11 @@ public:
class BulkUseTokenUpdater {
public:
BulkUseTokenUpdater() : fPlotAlreadyUpdated(0) {}
BulkUseTokenUpdater(const BulkUseTokenUpdater& that)
: fPlotsToUpdate(that.fPlotsToUpdate)
, fPlotAlreadyUpdated(that.fPlotAlreadyUpdated) {
}
void add(AtlasID id) {
int index = GrBatchAtlas::GetIndexFromID(id);
if (!this->find(index)) {