From 33233a09fef8f848164895d66e7f7731265239da Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 11 Apr 2019 15:12:20 -0400 Subject: [PATCH] Reland "Convert the CPU path case to use prepareForDrawing" This is a reland of 8be917af4313f6021b9b8e5d2b3f4d5712967aa9 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 > Commit-Queue: Herb Derby Change-Id: I307792b443d4738ee2ccb545cc40256bc94cacee Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207887 Reviewed-by: Ben Wagner Commit-Queue: Herb Derby --- src/core/SkGlyphRunPainter.cpp | 49 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index d09788838c..4dc8d8f047 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -166,22 +166,43 @@ void SkGlyphRunListPainter::drawForBitmapDevice( // The sub-pixel position will always happen when transforming to the screen. pathFont.setSubpixel(false); - auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive( - pathFont, pathPaint, props, - fScalerContextFlags, SkMatrix::I()); + SkAutoDescriptor ad; + SkScalerContextEffects effects; + 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 pathsAndPositions; - pathsAndPositions.setReserve(runSize); - SkPoint* positionCursor = fPositions; - for (auto glyphID : glyphRun.glyphsIDs()) { - SkPoint position = *positionCursor++; - if (check_glyph_position(position)) { - const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0}); - if (!glyph.isEmpty()) { - const SkPath* path = pathCache->findPath(glyph); - if (path != nullptr) { - pathsAndPositions.push_back(SkPathPos{path, position}); - } + pathsAndPositions.setReserve(glyphPosSpan.size()); + for (const SkGlyphPos& glyphPos : glyphPosSpan) { + const SkGlyph& glyph = *glyphPos.glyph; + SkPoint position = glyphPos.position; + if (check_glyph_position(position) + && !glyph.isEmpty() + && glyph.fMaskFormat != SkMask::kARGB32_Format + && strike->decideCouldDrawFromPath(glyph)) + { + // 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}); } } }