Move path leaf loop to drawer
This CL makes GPU and Raster use the same path drawing interface. When
I get the main body of regenerate over into the glyph run system, I
I can refactor a lot of annoyingly similar code away.
Change-Id: I6bd2e6119570062695d6943565749d85555b03fa
Reviewed-on: https://skia-review.googlesource.com/144350
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 6017742..966f3c2 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -169,21 +169,20 @@
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
pathPaint, &props, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
- const SkPoint* positionCursor = glyphRun.positions().data();
- for (auto glyphID : glyphRun.shuntGlyphsIDs()) {
- const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID);
- SkPoint loc = origin + *positionCursor++;
- if (glyph.fWidth > 0) {
- if (glyph.fMaskFormat == SkMask::kARGB32_Format) {
- fallbackTextHelper.appendText(glyph, glyphID, loc);
- } else {
- const SkPath* path = cache->findPath(glyph);
- if (path != nullptr) {
- cacheBlob->appendPathGlyph(runIndex, *path, loc.fX, loc.fY, matrixScale, false);
- }
+ auto drawOnePath =
+ [&fallbackTextHelper, matrixScale, runIndex, cacheBlob]
+ (const SkPath* path, const SkGlyph& glyph, SkPoint position) {
+ if (glyph.fMaskFormat == SkMask::kARGB32_Format) {
+ fallbackTextHelper.appendText(glyph, glyph.getGlyphID(), position);
+ } else {
+ if (path != nullptr) {
+ cacheBlob->appendPathGlyph(
+ runIndex, *path, position.fX, position.fY, matrixScale, false);
}
}
- }
+ };
+
+ glyphDrawer->drawUsingPaths(glyphRun, origin, cache.get(), drawOnePath);
fallbackTextHelper.drawText(
cacheBlob, runIndex, glyphCache, props, runPaint, scalerContextFlags);