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 <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Herb Derby 2019-04-11 14:25:27 -04:00 committed by Skia Commit-Bot
parent 3bad19cfc2
commit c562de0b50

View File

@ -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<const SkGlyphPos> 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<const SkGlyphPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
strike.get(),
strikeToSourceRatio);
}
// processSourcePaths must be called even if there are no glyphs to make sure runs
// are set correctly.
process->processSourcePaths(
SkSpan<const SkGlyphPos>{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<const SkGlyphPos>{fGlyphPos, SkTo<size_t>(glyphsWithMaskCount)},
strike.get());
SkSpan<const SkGlyphPos>{fGlyphPos, glyphsWithMaskCount}, strike.get());
if (!fPaths.empty()) {
process->processDevicePaths(SkSpan<const SkGlyphPos>{fPaths});
}
}
// fGlyphPos will be reused here.
if (!fARGBGlyphsIDs.empty()) {
this->processARGBFallback(maxFallbackDimension / viewMatrix.getMaxScale(),