From 7e97b0bad0d80901a19922323343a19d69f34b0b Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 31 Jul 2015 15:18:08 -0700 Subject: [PATCH] Move strike to subrun in GrAtlasTextContext BUG=skia: Committed: https://skia.googlesource.com/skia/+/77d89f7dd243a17452d3a5f16a98622993e6bdd9 Review URL: https://codereview.chromium.org/1257253005 --- src/gpu/GrAtlasTextBlob.h | 15 ++++++++++++++- src/gpu/GrAtlasTextContext.cpp | 19 ++++++++++++------- src/gpu/GrBatchAtlas.h | 5 +++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gpu/GrAtlasTextBlob.h b/src/gpu/GrAtlasTextBlob.h index 502177d..63f9185 100644 --- a/src/gpu/GrAtlasTextBlob.h +++ b/src/gpu/GrAtlasTextBlob.h @@ -78,6 +78,19 @@ struct GrAtlasTextBlob : public SkRefCnt { , fGlyphStartIndex(0) , fGlyphEndIndex(0) , fDrawAsDistanceFields(false) {} + SubRunInfo(const SubRunInfo& that) + : fBulkUseToken(that.fBulkUseToken) + , fStrike(SkSafeRef(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 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 fStrike; SkAutoTUnref fTypeface; SkRect fVertexBounds; SkSTArray fSubRunInfo; diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index f597639..6f8d119 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -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); diff --git a/src/gpu/GrBatchAtlas.h b/src/gpu/GrBatchAtlas.h index ce3e40a..96d2298 100644 --- a/src/gpu/GrBatchAtlas.h +++ b/src/gpu/GrBatchAtlas.h @@ -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)) { -- 2.7.4