Reland "Convert the CPU path case to use prepareForDrawing"

This is a reland of 8be917af43

Original change's description:
> Convert the CPU path case to use prepareForDrawing
>
> Change-Id: I5babfc7f1fa9784d81896d5c036e3b50c2af8ca0
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207760
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I307792b443d4738ee2ccb545cc40256bc94cacee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207887
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-04-11 15:12:20 -04:00 committed by Skia Commit-Bot
parent 69f54f8f0f
commit 33233a09fe

View File

@ -166,22 +166,43 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
// The sub-pixel position will always happen when transforming to the screen. // The sub-pixel position will always happen when transforming to the screen.
pathFont.setSubpixel(false); pathFont.setSubpixel(false);
auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive( SkAutoDescriptor ad;
pathFont, pathPaint, props, SkScalerContextEffects effects;
fScalerContextFlags, SkMatrix::I()); SkScalerContext::CreateDescriptorAndEffectsUsingPaint(pathFont,
pathPaint,
props,
fScalerContextFlags,
SkMatrix::I(),
&ad,
&effects);
SkScopedStrike strike =
fStrikeCache->findOrCreateScopedStrike(
*ad.getDesc(), effects,*pathFont.getTypefaceOrDefault());
auto glyphPosSpan = strike->prepareForDrawing(
glyphRun.glyphsIDs().data(), fPositions, glyphRun.runSize(), 0, fGlyphPos);
SkTDArray<SkPathPos> pathsAndPositions; SkTDArray<SkPathPos> pathsAndPositions;
pathsAndPositions.setReserve(runSize); pathsAndPositions.setReserve(glyphPosSpan.size());
SkPoint* positionCursor = fPositions; for (const SkGlyphPos& glyphPos : glyphPosSpan) {
for (auto glyphID : glyphRun.glyphsIDs()) { const SkGlyph& glyph = *glyphPos.glyph;
SkPoint position = *positionCursor++; SkPoint position = glyphPos.position;
if (check_glyph_position(position)) { if (check_glyph_position(position)
const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0}); && !glyph.isEmpty()
if (!glyph.isEmpty()) { && glyph.fMaskFormat != SkMask::kARGB32_Format
const SkPath* path = pathCache->findPath(glyph); && strike->decideCouldDrawFromPath(glyph))
if (path != nullptr) { {
pathsAndPositions.push_back(SkPathPos{path, position}); // Only draw a path if it exists, and this is not a color glyph.
} pathsAndPositions.push_back(SkPathPos{glyph.path(), position});
} else {
// TODO: this is here to have chrome layout tests pass. Remove this when
// fallback for CPU works.
if (check_glyph_position(position)
&& !glyph.isEmpty()
&& strike->decideCouldDrawFromPath(glyph))
{
pathsAndPositions.push_back(SkPathPos{glyph.path(), position});
} }
} }
} }