Revert "Use bulk interface for paths"
This reverts commit 5b83d05bf4
.
Reason for revert: Unexpected GM changes
Original change's description:
> Use bulk interface for paths
>
> Change-Id: I3a73f3b181542588470e3ce2c03d147423fef5cd
> Reviewed-on: https://skia-review.googlesource.com/c/192424
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
TBR=mtklein@google.com,herb@google.com
Change-Id: Iaf4feba65c7c60ef2d9fea7189a415e6d48c4aa9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/192833
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
112aa2d22e
commit
92d1912142
@ -331,39 +331,28 @@ 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 PerEmptyT, typename PerPathT>
|
||||
void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
|
||||
SkStrikeInterface* strike, const SkGlyphRun& glyphRun,
|
||||
SkStrikeInterface* pathCache, const SkGlyphRun& glyphRun,
|
||||
SkPoint origin, const SkPaint& runPaint, const SkMatrix& viewMatrix, SkScalar textScale,
|
||||
ProcessPathsT&& processPaths, ARGBFallback&& argbFallback) {
|
||||
PerEmptyT&& perEmpty, PerPathT&& perPath, ARGBFallback&& argbFallback) {
|
||||
fARGBGlyphsIDs.clear();
|
||||
fARGBPositions.clear();
|
||||
ScopedBuffers _ = ensureBuffers(glyphRun);
|
||||
SkScalar maxFallbackDimension{-SK_ScalarInfinity};
|
||||
|
||||
// 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);
|
||||
const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0});
|
||||
if (glyph.isEmpty()) {
|
||||
emptyGlyphs.push_back(&glyph);
|
||||
perEmpty(glyph, glyphPos);
|
||||
} else if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
|
||||
if (strike->decideCouldDrawFromPath(glyph)) {
|
||||
fGlyphPos[glyphCount++] = {&glyph, glyphPos};
|
||||
if (pathCache->decideCouldDrawFromPath(glyph)) {
|
||||
perPath(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);
|
||||
// This happens when a bitmap-only font has a very large glyph compared to the
|
||||
// rest of the glyphs. This doesn't happen in practice.
|
||||
perEmpty(glyph, glyphPos);
|
||||
}
|
||||
} else {
|
||||
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
|
||||
@ -373,13 +362,6 @@ void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
|
||||
}
|
||||
}
|
||||
|
||||
if (glyphCount > 0) {
|
||||
processPaths(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)},
|
||||
strike,
|
||||
textScale);
|
||||
}
|
||||
|
||||
|
||||
if (!fARGBGlyphsIDs.empty()) {
|
||||
this->processARGBFallback(
|
||||
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, textScale,
|
||||
@ -438,14 +420,14 @@ void SkGlyphRunListPainter::drawGlyphRunAsBMPWithPathFallback(
|
||||
}
|
||||
} else {
|
||||
// If the glyph is not empty, then it will have a pointer to mask data.
|
||||
fGlyphPos[glyphCount++] = {&glyph, mappedPt};
|
||||
fMasks[glyphCount++] = {&glyph, mappedPt};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (glyphCount > 0) {
|
||||
mapping.mapPoints(fPositions, glyphCount);
|
||||
processMasks(SkSpan<const GlyphAndPos>{fGlyphPos, SkTo<size_t>(glyphCount)}, strike.get());
|
||||
processMasks(SkSpan<const GlyphAndPos>{fMasks, SkTo<size_t>(glyphCount)}, strike.get());
|
||||
}
|
||||
if (!fPaths.empty()) {
|
||||
processPaths(SkSpan<const GlyphAndPos>{fPaths});
|
||||
@ -831,15 +813,14 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
|
||||
pathFont, pathPaint, props,
|
||||
scalerContextFlags, SkMatrix::I());
|
||||
|
||||
auto perEmpty = [](const SkGlyph&, SkPoint) {};
|
||||
|
||||
// Given a glyph that is not ARGB, draw it.
|
||||
auto processPath = [run](
|
||||
SkSpan<const SkGlyphRunListPainter::GlyphAndPos> paths,
|
||||
SkStrikeInterface* strike, SkScalar textScale) {
|
||||
run->setupFont(strike->strikeSpec());
|
||||
for (const auto& path : paths) {
|
||||
if (const SkPath* glyphPath = path.glyph->path()) {
|
||||
run->appendPathGlyph(*glyphPath, path.position, textScale, false);
|
||||
}
|
||||
auto perPath = [textScale, run]
|
||||
(const SkGlyph& glyph, SkPoint position) {
|
||||
// TODO: path should always be set. Remove when proven.
|
||||
if (const SkPath* glyphPath = glyph.path()) {
|
||||
run->appendPathGlyph(*glyphPath, position, textScale, false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -847,7 +828,7 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
|
||||
|
||||
glyphPainter->drawGlyphRunAsPathWithARGBFallback(
|
||||
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
|
||||
std::move(processPath), std::move(argbFallback));
|
||||
std::move(perEmpty), std::move(perPath), std::move(argbFallback));
|
||||
} else {
|
||||
// Ensure the blob is set for bitmaptext
|
||||
this->setHasBitmap();
|
||||
@ -1031,16 +1012,20 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
|
||||
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.
|
||||
auto processPaths = [](
|
||||
SkSpan<const SkGlyphRunListPainter::GlyphAndPos>, SkStrikeInterface*, SkScalar) { };
|
||||
auto perEmpty = [glyphCacheState] (const SkGlyph& glyph, SkPoint mappedPt) {
|
||||
glyphCacheState->addGlyph(glyph.getPackedID(), false);
|
||||
};
|
||||
|
||||
auto perPath = [glyphCacheState](const SkGlyph& glyph, SkPoint position) {
|
||||
const bool asPath = true;
|
||||
glyphCacheState->addGlyph(glyph.getGlyphID(), asPath);
|
||||
};
|
||||
|
||||
ARGBHelper argbFallback{runMatrix, surfaceProps(), fStrikeServer};
|
||||
|
||||
fPainter.drawGlyphRunAsPathWithARGBFallback(
|
||||
glyphCacheState, glyphRun, origin, runPaint, runMatrix, textScale,
|
||||
std::move(processPaths), std::move(argbFallback));
|
||||
std::move(perEmpty), std::move(perPath), std::move(argbFallback));
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
@ -1110,7 +1095,7 @@ SkGlyphRunListPainter::ScopedBuffers::ScopedBuffers(SkGlyphRunListPainter* paint
|
||||
fPainter->fMaxRunSize = size;
|
||||
|
||||
fPainter->fPositions.reset(size);
|
||||
fPainter->fGlyphPos.reset(size);
|
||||
fPainter->fMasks.reset(size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1122,7 +1107,7 @@ SkGlyphRunListPainter::ScopedBuffers::~ScopedBuffers() {
|
||||
if (fPainter->fMaxRunSize > 200) {
|
||||
fPainter->fMaxRunSize = 0;
|
||||
fPainter->fPositions.reset();
|
||||
fPainter->fGlyphPos.reset();
|
||||
fPainter->fMasks.reset();
|
||||
fPainter->fPaths.shrink_to_fit();
|
||||
fPainter->fARGBGlyphsIDs.shrink_to_fit();
|
||||
fPainter->fARGBPositions.shrink_to_fit();
|
||||
|
@ -131,11 +131,11 @@ 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 PerEmptyT, typename PerPath>
|
||||
void drawGlyphRunAsPathWithARGBFallback(
|
||||
SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
|
||||
SkPoint origin, const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar textScale,
|
||||
ProcessPathsT&& processPaths, ARGBFallback&& fallbackARGB);
|
||||
PerEmptyT&& perEmpty, PerPath&& perPath, ARGBFallback&& fallbackARGB);
|
||||
|
||||
template <typename PerEmptyT, typename PerSDFT, typename PerPathT>
|
||||
void drawGlyphRunAsSDFWithARGBFallback(
|
||||
@ -171,7 +171,7 @@ private:
|
||||
|
||||
int fMaxRunSize{0};
|
||||
SkAutoTMalloc<SkPoint> fPositions;
|
||||
SkAutoTMalloc<GlyphAndPos> fGlyphPos;
|
||||
SkAutoTMalloc<GlyphAndPos> fMasks;
|
||||
|
||||
std::vector<GlyphAndPos> fPaths;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user