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:
parent
28bafb01c9
commit
5f5a016b1b
@ -331,74 +331,58 @@ 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};
|
||||
// Four empty glyphs are expected; one for each horizontal subpixel position.
|
||||
SkSTArray<4, const SkGlyph*> emptyGlyphs;
|
||||
|
||||
// The factor to get from the size stored in the strike to the size needed for the source.
|
||||
SkScalar strikeToSourceRatio = pathFont.setupForAsPaths(&pathPaint);
|
||||
int glyphCount = 0;
|
||||
const SkPoint* positionCursor = glyphRun.positions().data();
|
||||
for (auto glyphID : glyphRun.glyphsIDs()) {
|
||||
SkPoint glyphPos = origin + *positionCursor++;
|
||||
|
||||
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;
|
||||
|
||||
int glyphCount = 0;
|
||||
const SkPoint* positionCursor = glyphRun.positions().data();
|
||||
for (auto glyphID : glyphRun.glyphsIDs()) {
|
||||
SkPoint glyphPos = origin + *positionCursor++;
|
||||
|
||||
if (std::any_of(emptyGlyphs.begin(), emptyGlyphs.end(),
|
||||
[glyphID](const SkGlyph* g) { return g->getGlyphID() == glyphID; })) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const SkGlyph& glyph = strike->getGlyphMetrics(glyphID, glyphPos);
|
||||
if (glyph.isEmpty()) {
|
||||
emptyGlyphs.push_back(&glyph);
|
||||
} else if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
|
||||
if (strike->decideCouldDrawFromPath(glyph)) {
|
||||
fGlyphPos[glyphCount++] = {&glyph, glyphPos};
|
||||
} else {
|
||||
// This happens when a bitmap-only font is forced to scale very large. This
|
||||
// doesn't happen in practice.
|
||||
emptyGlyphs.push_back(&glyph);
|
||||
}
|
||||
} else {
|
||||
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
|
||||
maxFallbackDimension = std::max(maxFallbackDimension, largestDimension);
|
||||
fARGBGlyphsIDs.push_back(glyphID);
|
||||
fARGBPositions.push_back(glyphPos);
|
||||
}
|
||||
if (std::any_of(emptyGlyphs.begin(), emptyGlyphs.end(),
|
||||
[glyphID](const SkGlyph* g) { return g->getGlyphID() == glyphID; })) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (glyphCount > 0) {
|
||||
processPaths(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
|
||||
strike.get(),
|
||||
strikeToSourceRatio);
|
||||
const SkGlyph& glyph = strike->getGlyphMetrics(glyphID, glyphPos);
|
||||
if (glyph.isEmpty()) {
|
||||
emptyGlyphs.push_back(&glyph);
|
||||
} else if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
|
||||
if (strike->decideCouldDrawFromPath(glyph)) {
|
||||
fGlyphPos[glyphCount++] = {&glyph, glyphPos};
|
||||
} else {
|
||||
// This happens when a bitmap-only font is forced to scale very large. This
|
||||
// doesn't happen in practice.
|
||||
emptyGlyphs.push_back(&glyph);
|
||||
}
|
||||
} else {
|
||||
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
|
||||
maxFallbackDimension = std::max(maxFallbackDimension, largestDimension);
|
||||
fARGBGlyphsIDs.push_back(glyphID);
|
||||
fARGBPositions.push_back(glyphPos);
|
||||
}
|
||||
}
|
||||
|
||||
if (glyphCount > 0) {
|
||||
processPaths(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
|
||||
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,19 +845,9 @@ 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,
|
||||
std::move(processPath), std::move(argbFallback));
|
||||
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
|
||||
std::move(processPath), std::move(argbFallback));
|
||||
} else {
|
||||
// Ensure the blob is set for bitmaptext
|
||||
this->setHasBitmap();
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user