Revert of CL/192440 which would not reland cleanly.

This is a revert of the following revert...

This reverts commit b5c1a79b55.

Reason for revert: Based on bad CL 192424

Original change's description:
> Calculate strike in path case
>
> Change-Id: I9036b23df7279003a41f6189117fb7dec784ee2a
> Reviewed-on: https://skia-review.googlesource.com/c/192440
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I322c45b6deb9ffa4cde567f02c55fcd6971fefc1
Reviewed-on: https://skia-review.googlesource.com/c/192882
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Herb Derby 2019-02-15 13:59:46 -05:00 committed by Skia Commit-Bot
parent f2965060c3
commit 5a9c12002e
2 changed files with 75 additions and 61 deletions

View File

@ -332,16 +332,32 @@ void SkGlyphRunListPainter::processARGBFallback(
// Beware! The following code will end up holding two glyph caches at the same time, but they
// will not be the same cache (which would cause two separate caches to be created).
template <typename ProcessPathsT>
template <typename ProcessPathsT, typename CreatorT>
void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
SkStrikeInterface* strike, const SkGlyphRun& glyphRun,
SkPoint origin, const SkPaint& runPaint, const SkMatrix& viewMatrix, SkScalar textScale,
const SkPaint& runPaint, const SkFont& runFont, CreatorT&& strikeCreator,
const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& viewMatrix,
ProcessPathsT&& processPaths, ARGBFallback&& argbFallback) {
fARGBGlyphsIDs.clear();
fARGBPositions.clear();
ScopedBuffers _ = ensureBuffers(glyphRun);
SkScalar maxFallbackDimension{-SK_ScalarInfinity};
// setup our std runPaint, in hopes of getting hits in the cache
SkPaint pathPaint{runPaint};
SkFont pathFont{runFont};
// The factor to get from the size stored in the strike to the size needed for the source.
SkScalar strikeToSourceRatio = pathFont.setupForAsPaths(&pathPaint);
SkAutoDescriptor ad;
SkScalerContextEffects effects;
SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
pathFont, pathPaint, fDeviceProps, fScalerContextFlags, SkMatrix::I(), &ad, &effects);
{
SkScopedStrike strike = strikeCreator(*ad.getDesc(), effects,
*pathFont.getTypefaceOrDefault());
// Four empty glyphs are expected; one for each horizontal subpixel position.
SkSTArray<4, const SkGlyph*> emptyGlyphs;
@ -378,14 +394,14 @@ void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
if (glyphCount > 0) {
processPaths(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
strike,
textScale);
strike.get(),
strikeToSourceRatio);
}
}
if (!fARGBGlyphsIDs.empty()) {
this->processARGBFallback(
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, textScale,
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, strikeToSourceRatio,
std::move(argbFallback));
}
@ -825,15 +841,6 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
// Ensure the blob is set for bitmaptext
this->setHasBitmap();
// setup our std runPaint, in hopes of getting hits in the cache
SkPaint pathPaint{runPaint};
SkFont pathFont{runFont};
SkScalar textScale = pathFont.setupForAsPaths(&pathPaint);
auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive(
pathFont, pathPaint, props,
scalerContextFlags, SkMatrix::I());
// Given a glyph that is not ARGB, draw it.
auto processPath = [run](
SkSpan<const SkGlyphRunListPainter::GlyphAndPos> paths,
@ -848,8 +855,18 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
ARGBFallbackHelper argbFallback{this, run, props, scalerContextFlags, glyphCache};
auto strikeCache = SkStrikeCache::GlobalStrikeCache();
auto creator = [strikeCache]
(const SkDescriptor& desc,
SkScalerContextEffects effects,
const SkTypeface& typeface) {
return strikeCache->findOrCreateScopedStrike(desc, effects, typeface);
};
glyphPainter->drawGlyphRunAsPathWithARGBFallback(
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
runPaint, runFont, std::move(creator),
glyphRun, origin, viewMatrix,
std::move(processPath), std::move(argbFallback));
} else {
// Ensure the blob is set for bitmaptext
@ -1025,14 +1042,10 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
SkPoint origin, const SkPaint& runPaint) {
TRACE_EVENT0("skia", "SkTextBlobCacheDiffCanvas::processGlyphRunForPaths");
SkPaint pathPaint{runPaint};
SkFont pathFont{glyphRun.font()};
SkScalar textScale = SetupForPath(&pathPaint, &pathFont);
SkScalerContextEffects effects;
auto* glyphCacheState = fStrikeServer->getOrCreateCache(
pathPaint, pathFont, this->surfaceProps(), SkMatrix::I(),
SkScalerContextFlags::kFakeGammaAndBoostContrast, &effects);
auto creator = [this]
(const SkDescriptor& desc, SkScalerContextEffects effects, const SkTypeface& typeface) {
return SkScopedStrike{fStrikeServer->getOrCreateCache(desc, typeface, effects)};
};
// This processor is empty because all changes to the cache are tracked through
// getGlyphMetrics and decideCouldDrawFromPath.
@ -1042,7 +1055,8 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
ARGBHelper argbFallback{runMatrix, surfaceProps(), fStrikeServer};
fPainter.drawGlyphRunAsPathWithARGBFallback(
glyphCacheState, glyphRun, origin, runPaint, runMatrix, textScale,
runPaint, glyphRun.font(), std::move(creator),
glyphRun, origin, runMatrix,
std::move(processPaths), std::move(argbFallback));
}

View File

@ -131,10 +131,10 @@ public:
// For each glyph that is not ARGB call perPath. If the glyph is ARGB then store the glyphID
// and the position in fallback vectors. After all the glyphs are processed, pass the
// fallback glyphIDs and positions to fallbackARGB.
template <typename ProcessPathsT>
template <typename ProcessPathsT, typename CreatorT>
void drawGlyphRunAsPathWithARGBFallback(
SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
SkPoint origin, const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar textScale,
const SkPaint& runPaint, const SkFont& runFont, CreatorT&& strikeCreator,
const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& viewMatrix,
ProcessPathsT&& processPaths, ARGBFallback&& fallbackARGB);
template <typename PerEmptyT, typename PerSDFT, typename PerPathT>