Revert "Calculate strike in path case"

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>

TBR=mtklein@google.com,herb@google.com

Change-Id: I218871efeff921663d4a2f26e04b4e0e41ca42ab
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/192831
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-02-15 16:24:24 +00:00 committed by Skia Commit-Bot
parent 28bafb01c9
commit 5f5a016b1b
2 changed files with 59 additions and 73 deletions

View File

@ -331,32 +331,16 @@ 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, typename CreatorT>
template <typename ProcessPathsT>
void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
const SkPaint& runPaint, const SkFont& runFont, CreatorT&& strikeCreator,
const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& viewMatrix,
SkStrikeInterface* strike, const SkGlyphRun& glyphRun,
SkPoint origin, const SkPaint& runPaint, const SkMatrix& viewMatrix, SkScalar textScale,
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;
@ -391,14 +375,14 @@ void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
if (glyphCount > 0) {
processPaths(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
strike.get(),
strikeToSourceRatio);
}
strike,
textScale);
}
if (!fARGBGlyphsIDs.empty()) {
this->processARGBFallback(
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, strikeToSourceRatio,
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, textScale,
std::move(argbFallback));
}
@ -838,6 +822,15 @@ 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,
@ -852,18 +845,8 @@ 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(
runPaint, runFont, std::move(creator),
glyphRun, origin, viewMatrix,
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
std::move(processPath), std::move(argbFallback));
} else {
// Ensure the blob is set for bitmaptext
@ -1039,10 +1022,14 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
SkPoint origin, const SkPaint& runPaint) {
TRACE_EVENT0("skia", "SkTextBlobCacheDiffCanvas::processGlyphRunForPaths");
auto creator = [this]
(const SkDescriptor& desc, SkScalerContextEffects effects, const SkTypeface& typeface) {
return SkScopedStrike{fStrikeServer->getOrCreateCache(desc, typeface, effects)};
};
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);
// This processor is empty because all changes to the cache are tracked through
// getGlyphMetrics and decideCouldDrawFromPath.
@ -1052,8 +1039,7 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
ARGBHelper argbFallback{runMatrix, surfaceProps(), fStrikeServer};
fPainter.drawGlyphRunAsPathWithARGBFallback(
runPaint, glyphRun.font(), std::move(creator),
glyphRun, origin, runMatrix,
glyphCacheState, glyphRun, origin, runPaint, runMatrix, textScale,
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, typename CreatorT>
template <typename ProcessPathsT>
void drawGlyphRunAsPathWithARGBFallback(
const SkPaint& runPaint, const SkFont& runFont, CreatorT&& strikeCreator,
const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& viewMatrix,
SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
SkPoint origin, const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar textScale,
ProcessPathsT&& processPaths, ARGBFallback&& fallbackARGB);
template <typename PerEmptyT, typename PerSDFT, typename PerPathT>