Move appending of large glyphs into GrAtlasTextBlob
BUG=skia:
Review URL: https://codereview.chromium.org/1517563002
diff --git a/src/gpu/GrAtlasTextBlob.cpp b/src/gpu/GrAtlasTextBlob.cpp
index 1cd25e7..aa50cbf 100644
--- a/src/gpu/GrAtlasTextBlob.cpp
+++ b/src/gpu/GrAtlasTextBlob.cpp
@@ -11,7 +11,16 @@
const SkRect& positions,
GrColor color,
GrBatchTextStrike* strike,
- GrGlyph* glyph) {
+ GrGlyph* glyph,
+ GrFontScaler* scaler, const SkGlyph& skGlyph,
+ SkScalar x, SkScalar y, SkScalar scale, bool applyVM) {
+
+ // If the glyph is too large we fall back to paths
+ if (glyph->fTooLargeForAtlas) {
+ this->appendLargeGlyph(glyph, scaler, skGlyph, x, y, scale, applyVM);
+ return;
+ }
+
Run& run = fRuns[runIndex];
GrMaskFormat format = glyph->fMaskFormat;
@@ -86,6 +95,19 @@
subRun->glyphAppended();
}
+void GrAtlasTextBlob::appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& skGlyph,
+ SkScalar x, SkScalar y, SkScalar scale, bool applyVM) {
+ if (nullptr == glyph->fPath) {
+ const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
+ if (!glyphPath) {
+ return;
+ }
+
+ glyph->fPath = new SkPath(*glyphPath);
+ }
+ fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, applyVM));
+}
+
bool GrAtlasTextBlob::mustRegenerate(SkScalar* outTransX, SkScalar* outTransY,
const SkPaint& paint,
GrColor color, const SkMaskFilter::BlurRec& blurRec,
diff --git a/src/gpu/GrAtlasTextBlob.h b/src/gpu/GrAtlasTextBlob.h
index 3ec3c44..35f6428 100644
--- a/src/gpu/GrAtlasTextBlob.h
+++ b/src/gpu/GrAtlasTextBlob.h
@@ -283,11 +283,15 @@
}
}
+ // Appends a glyph to the blob. If the glyph is too large, the glyph will be appended
+ // as a path.
void appendGlyph(int runIndex,
const SkRect& positions,
GrColor color,
GrBatchTextStrike* strike,
- GrGlyph* glyph);
+ GrGlyph* glyph,
+ GrFontScaler* scaler, const SkGlyph& skGlyph,
+ SkScalar x, SkScalar y, SkScalar scale, bool applyVM);
static size_t GetVertexStride(GrMaskFormat maskFormat) {
switch (maskFormat) {
@@ -314,6 +318,9 @@
static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&);
size_t fSize;
#endif
+private:
+ void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& skGlyph,
+ SkScalar x, SkScalar y, SkScalar scale, bool applyVM);
};
#endif
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 615f709..153d0fe 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -889,19 +889,14 @@
int width = glyph->fBounds.width();
int height = glyph->fBounds.height();
- // If the glyph is too large we fall back to paths
- if (glyph->fTooLargeForAtlas) {
- this->appendGlyphPath(blob, glyph, scaler, skGlyph, SkIntToScalar(vx), SkIntToScalar(vy));
- return;
- }
-
SkRect r;
r.fLeft = SkIntToScalar(x);
r.fTop = SkIntToScalar(y);
r.fRight = r.fLeft + SkIntToScalar(width);
r.fBottom = r.fTop + SkIntToScalar(height);
- blob->appendGlyph(runIndex, r, color, fCurrStrike, glyph);
+ blob->appendGlyph(runIndex, r, color, fCurrStrike, glyph, scaler, skGlyph,
+ SkIntToScalar(vx), SkIntToScalar(vy), 1.0f, false);
}
bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
@@ -941,32 +936,11 @@
sy += dy;
SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height);
- // TODO combine with the above
- // If the glyph is too large we fall back to paths
- if (glyph->fTooLargeForAtlas) {
- this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy, scale, true);
- return true;
- }
-
- blob->appendGlyph(runIndex, glyphRect, color, fCurrStrike, glyph);
+ blob->appendGlyph(runIndex, glyphRect, color, fCurrStrike, glyph, scaler, skGlyph,
+ sx - dx, sy - dy, scale, true);
return true;
}
-inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph,
- GrFontScaler* scaler, const SkGlyph& skGlyph,
- SkScalar x, SkScalar y, SkScalar scale,
- bool applyVM) {
- if (nullptr == glyph->fPath) {
- const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
- if (!glyphPath) {
- return;
- }
-
- glyph->fPath = new SkPath(*glyphPath);
- }
- blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, applyVM));
-}
-
void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc,
const SkTextBlobRunIterator& it,
const GrClip& clip, const SkPaint& skPaint,
diff --git a/src/gpu/GrAtlasTextContext.h b/src/gpu/GrAtlasTextContext.h
index c85740d..20f747f 100644
--- a/src/gpu/GrAtlasTextContext.h
+++ b/src/gpu/GrAtlasTextContext.h
@@ -62,9 +62,6 @@
bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar sx, SkScalar sy,
GrColor color, GrFontScaler*, SkScalar textRatio,
const SkMatrix& viewMatrix);
- inline void appendGlyphPath(GrAtlasTextBlob*, GrGlyph*, GrFontScaler*, const SkGlyph&,
- SkScalar x, SkScalar y, SkScalar scale = 1.0f,
- bool applyVM = false);
inline void flushRunAsPaths(GrDrawContext*,
const SkTextBlobRunIterator&, const GrClip& clip,