From c562de0b50ce972b563ab9e8ca295aa7cbec634f Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 11 Apr 2019 14:25:27 -0400 Subject: [PATCH] Convert GPU path handling to using prepareForDrawing Small cleanup in the mask case to remove cast. Change-Id: I0867fa80372cc917eae7c1ca84beafd699d8a349 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207705 Auto-Submit: Herb Derby Commit-Queue: Herb Derby Reviewed-by: Ben Wagner --- src/core/SkGlyphRunPainter.cpp | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index a0dd674330..0fa9dcb55f 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -505,32 +505,34 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi fStrikeCache->findOrCreateScopedStrike( *ad.getDesc(), effects,*pathFont.getTypefaceOrDefault()); - int glyphCount = 0; - for (size_t i = 0; i < glyphRun.runSize(); i++) { - SkGlyphID glyphID = glyphRun.glyphsIDs()[i]; - SkPoint glyphSourcePosition = fPositions[i]; + SkSpan glyphPosSpan = strike->prepareForDrawing( + glyphRun.glyphsIDs().data(), fPositions, glyphRun.runSize(), 0, fGlyphPos); - // Use outline from {0, 0} because all transforms including subpixel translation - // happen during drawing. - const SkGlyph& glyph = strike->getGlyphMetrics(glyphID, {0, 0}); + // As opposed to SDF and mask, path handling puts paths in fGlyphPos instead of fPaths. + size_t glyphsWithPathCount = 0; + for (const SkGlyphPos& glyphPos : glyphPosSpan) { + const SkGlyph& glyph = *glyphPos.glyph; + SkPoint position = glyphPos.position; if (glyph.isEmpty()) { // do nothing } else if (glyph.fMaskFormat != SkMask::kARGB32_Format && strike->decideCouldDrawFromPath(glyph)) { - fGlyphPos[glyphCount++] = {i, &glyph, glyphSourcePosition}; + // Place paths in fGlyphPos + fGlyphPos[glyphsWithPathCount++] = glyphPos; } else { - addFallback(glyph, glyphSourcePosition); + addFallback(glyph, position); } } if (process) { - if (glyphCount > 0) { - process->processSourcePaths( - SkSpan{fGlyphPos, SkTo(glyphCount)}, - strike.get(), - strikeToSourceRatio); - } + // processSourcePaths must be called even if there are no glyphs to make sure runs + // are set correctly. + process->processSourcePaths( + SkSpan{fGlyphPos, glyphsWithPathCount}, + strike.get(), + strikeToSourceRatio); } + // fGlyphPos will be reused here. if (!fARGBGlyphsIDs.empty()) { this->processARGBFallback(maxFallbackDimension * strikeToSourceRatio, @@ -588,12 +590,12 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi // processDeviceMasks must be called even if there are no glyphs to make sure runs // are set correctly. process->processDeviceMasks( - SkSpan{fGlyphPos, SkTo(glyphsWithMaskCount)}, - strike.get()); + SkSpan{fGlyphPos, glyphsWithMaskCount}, strike.get()); if (!fPaths.empty()) { process->processDevicePaths(SkSpan{fPaths}); } } + // fGlyphPos will be reused here. if (!fARGBGlyphsIDs.empty()) { this->processARGBFallback(maxFallbackDimension / viewMatrix.getMaxScale(),