Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3152)

Unified Diff: src/gpu/GrAtlasTextContext.cpp

Issue 1257603005: Minimize retrieving SkGlyph in GrTextContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | src/gpu/GrBatchFontCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlasTextContext.cpp
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index e20ca4bb7ffd07c84d3cdf689dce05aeab32494e..cc4e86b926e4beb9215ab3f8ae80a8f973b22fb8 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -890,10 +890,7 @@ void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex
if (glyph.fWidth) {
this->bmpAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kCoverage_MaskStyle),
+ glyph,
Sk48Dot16FloorToInt(fx),
Sk48Dot16FloorToInt(fy),
color,
@@ -960,10 +957,7 @@ void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
if (glyph.fWidth) {
this->bmpAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kCoverage_MaskStyle),
+ glyph,
Sk48Dot16FloorToInt(fx),
Sk48Dot16FloorToInt(fy),
color,
@@ -998,10 +992,7 @@ void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
this->bmpAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kCoverage_MaskStyle),
+ glyph,
Sk48Dot16FloorToInt(fx),
Sk48Dot16FloorToInt(fy),
color,
@@ -1026,10 +1017,7 @@ void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf); //halfSampleY;
this->bmpAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kCoverage_MaskStyle),
+ glyph,
Sk48Dot16FloorToInt(fx),
Sk48Dot16FloorToInt(fy),
color,
@@ -1054,10 +1042,7 @@ void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf); //halfSampleY;
this->bmpAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kCoverage_MaskStyle),
+ glyph,
Sk48Dot16FloorToInt(fx),
Sk48Dot16FloorToInt(fy),
color,
@@ -1183,10 +1168,7 @@ void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd
if (!this->dfAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kDistance_MaskStyle),
+ glyph,
x, y, color, fontScaler, clipRect,
textRatio, viewMatrix)) {
// couldn't append, send to fallback
@@ -1216,10 +1198,7 @@ void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd
if (!this->dfAppendGlyph(blob,
runIndex,
- GrGlyph::Pack(glyph.getGlyphID(),
- glyph.getSubXFixed(),
- glyph.getSubYFixed(),
- GrGlyph::kDistance_MaskStyle),
+ glyph,
x - advanceX, y - advanceY, color,
fontScaler,
clipRect,
@@ -1239,7 +1218,7 @@ void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd
}
void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
- GrGlyph::PackedID packed,
+ const SkGlyph& skGlyph,
int vx, int vy, GrColor color, GrFontScaler* scaler,
const SkIRect& clipRect) {
Run& run = blob->fRuns[runIndex];
@@ -1248,7 +1227,11 @@ void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
run.fStrike.reset(SkRef(fCurrStrike));
}
- GrGlyph* glyph = fCurrStrike->getGlyph(packed, scaler);
+ GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
+ skGlyph.getSubXFixed(),
+ skGlyph.getSubYFixed(),
+ GrGlyph::kCoverage_MaskStyle);
+ GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler);
if (!glyph) {
return;
}
@@ -1274,7 +1257,7 @@ void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
// If the glyph is too large we fall back to paths
if (glyph->fTooLargeForAtlas) {
- this->appendGlyphPath(blob, glyph, scaler, SkIntToScalar(vx), SkIntToScalar(vy));
+ this->appendGlyphPath(blob, glyph, scaler, skGlyph, SkIntToScalar(vx), SkIntToScalar(vy));
return;
}
@@ -1300,7 +1283,7 @@ void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
}
bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
- GrGlyph::PackedID packed,
+ const SkGlyph& skGlyph,
SkScalar sx, SkScalar sy, GrColor color,
GrFontScaler* scaler,
const SkIRect& clipRect,
@@ -1311,7 +1294,11 @@ bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
run.fStrike.reset(SkRef(fCurrStrike));
}
- GrGlyph* glyph = fCurrStrike->getGlyph(packed, scaler);
+ GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
+ skGlyph.getSubXFixed(),
+ skGlyph.getSubYFixed(),
+ GrGlyph::kDistance_MaskStyle);
+ GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler);
if (!glyph) {
return true;
}
@@ -1350,7 +1337,7 @@ bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
// TODO combine with the above
// If the glyph is too large we fall back to paths
if (glyph->fTooLargeForAtlas) {
- this->appendGlyphPath(blob, glyph, scaler, sx - dx, sy - dy);
+ this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy);
return true;
}
@@ -1367,17 +1354,16 @@ bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
}
inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph,
- GrFontScaler* scaler, SkScalar x, SkScalar y) {
+ GrFontScaler* scaler, const SkGlyph& skGlyph,
+ SkScalar x, SkScalar y) {
if (NULL == glyph->fPath) {
- SkPath* path = SkNEW(SkPath);
- if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
- // flag the glyph as being dead?
- SkDELETE(path);
+ const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
+ if (!glyphPath) {
return;
}
- glyph->fPath = path;
+
+ glyph->fPath = SkNEW_ARGS(SkPath, (*glyphPath));
}
- SkASSERT(glyph->fPath);
blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y));
}
@@ -1686,27 +1672,30 @@ public:
for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) {
if (regenerateTextureCoords) {
size_t glyphOffset = glyphIdx + info.fGlyphStartIndex;
- GrGlyph* glyph;
+
+ GrGlyph* glyph = blob->fGlyphs[glyphOffset];
+ GrGlyph::PackedID id = glyph->fPackedID;
+ const SkGlyph& skGlyph = scaler->grToSkGlyph(id);
if (regenerateGlyphs) {
// Get the id from the old glyph, and use the new strike to lookup
// the glyph.
- glyph = blob->fGlyphs[glyphOffset];
- blob->fGlyphs[glyphOffset] = strike->getGlyph(glyph->fPackedID,
- scaler);
+ blob->fGlyphs[glyphOffset] = strike->getGlyph(skGlyph, id, scaler);
}
glyph = blob->fGlyphs[glyphOffset];
SkASSERT(glyph);
- SkASSERT(glyph->fMaskFormat == this->maskFormat());
+ SkASSERT(id == glyph->fPackedID &&
+ glyph->fMaskFormat == this->maskFormat());
if (!fFontCache->hasGlyph(glyph) &&
- !strike->addGlyphToAtlas(batchTarget, glyph, scaler)) {
+ !strike->addGlyphToAtlas(batchTarget, glyph, scaler, skGlyph)) {
this->flush(batchTarget, &flushInfo);
batchTarget->initDraw(gp, pipeline);
brokenRun = glyphIdx > 0;
SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(batchTarget,
glyph,
- scaler);
+ scaler,
+ skGlyph);
SkASSERT(success);
}
fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseToken, glyph,
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | src/gpu/GrBatchFontCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698