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
|
// 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).
|
// 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(
|
void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(
|
||||||
SkStrikeInterface* strike, const SkGlyphRun& glyphRun,
|
SkStrikeInterface* pathCache, const SkGlyphRun& glyphRun,
|
||||||
SkPoint origin, const SkPaint& runPaint, const SkMatrix& viewMatrix, SkScalar textScale,
|
SkPoint origin, const SkPaint& runPaint, const SkMatrix& viewMatrix, SkScalar textScale,
|
||||||
ProcessPathsT&& processPaths, ARGBFallback&& argbFallback) {
|
PerEmptyT&& perEmpty, PerPathT&& perPath, ARGBFallback&& argbFallback) {
|
||||||
fARGBGlyphsIDs.clear();
|
fARGBGlyphsIDs.clear();
|
||||||
fARGBPositions.clear();
|
fARGBPositions.clear();
|
||||||
ScopedBuffers _ = ensureBuffers(glyphRun);
|
|
||||||
SkScalar maxFallbackDimension{-SK_ScalarInfinity};
|
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();
|
const SkPoint* positionCursor = glyphRun.positions().data();
|
||||||
for (auto glyphID : glyphRun.glyphsIDs()) {
|
for (auto glyphID : glyphRun.glyphsIDs()) {
|
||||||
SkPoint glyphPos = origin + *positionCursor++;
|
SkPoint glyphPos = origin + *positionCursor++;
|
||||||
|
const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0});
|
||||||
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()) {
|
if (glyph.isEmpty()) {
|
||||||
emptyGlyphs.push_back(&glyph);
|
perEmpty(glyph, glyphPos);
|
||||||
} else if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
|
} else if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
|
||||||
if (strike->decideCouldDrawFromPath(glyph)) {
|
if (pathCache->decideCouldDrawFromPath(glyph)) {
|
||||||
fGlyphPos[glyphCount++] = {&glyph, glyphPos};
|
perPath(glyph, glyphPos);
|
||||||
} else {
|
} else {
|
||||||
// This happens when a bitmap-only font is forced to scale very large. This
|
// This happens when a bitmap-only font has a very large glyph compared to the
|
||||||
// doesn't happen in practice.
|
// rest of the glyphs. This doesn't happen in practice.
|
||||||
emptyGlyphs.push_back(&glyph);
|
perEmpty(glyph, glyphPos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
|
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()) {
|
if (!fARGBGlyphsIDs.empty()) {
|
||||||
this->processARGBFallback(
|
this->processARGBFallback(
|
||||||
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, textScale,
|
maxFallbackDimension, runPaint, glyphRun.font(), viewMatrix, textScale,
|
||||||
@ -438,14 +420,14 @@ void SkGlyphRunListPainter::drawGlyphRunAsBMPWithPathFallback(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the glyph is not empty, then it will have a pointer to mask data.
|
// 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) {
|
if (glyphCount > 0) {
|
||||||
mapping.mapPoints(fPositions, glyphCount);
|
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()) {
|
if (!fPaths.empty()) {
|
||||||
processPaths(SkSpan<const GlyphAndPos>{fPaths});
|
processPaths(SkSpan<const GlyphAndPos>{fPaths});
|
||||||
@ -831,15 +813,14 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
|
|||||||
pathFont, pathPaint, props,
|
pathFont, pathPaint, props,
|
||||||
scalerContextFlags, SkMatrix::I());
|
scalerContextFlags, SkMatrix::I());
|
||||||
|
|
||||||
|
auto perEmpty = [](const SkGlyph&, SkPoint) {};
|
||||||
|
|
||||||
// Given a glyph that is not ARGB, draw it.
|
// Given a glyph that is not ARGB, draw it.
|
||||||
auto processPath = [run](
|
auto perPath = [textScale, run]
|
||||||
SkSpan<const SkGlyphRunListPainter::GlyphAndPos> paths,
|
(const SkGlyph& glyph, SkPoint position) {
|
||||||
SkStrikeInterface* strike, SkScalar textScale) {
|
// TODO: path should always be set. Remove when proven.
|
||||||
run->setupFont(strike->strikeSpec());
|
if (const SkPath* glyphPath = glyph.path()) {
|
||||||
for (const auto& path : paths) {
|
run->appendPathGlyph(*glyphPath, position, textScale, false);
|
||||||
if (const SkPath* glyphPath = path.glyph->path()) {
|
|
||||||
run->appendPathGlyph(*glyphPath, path.position, textScale, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -847,7 +828,7 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
|
|||||||
|
|
||||||
glyphPainter->drawGlyphRunAsPathWithARGBFallback(
|
glyphPainter->drawGlyphRunAsPathWithARGBFallback(
|
||||||
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
|
pathCache.get(), glyphRun, origin, runPaint, viewMatrix, textScale,
|
||||||
std::move(processPath), std::move(argbFallback));
|
std::move(perEmpty), std::move(perPath), std::move(argbFallback));
|
||||||
} else {
|
} else {
|
||||||
// Ensure the blob is set for bitmaptext
|
// Ensure the blob is set for bitmaptext
|
||||||
this->setHasBitmap();
|
this->setHasBitmap();
|
||||||
@ -1031,16 +1012,20 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
|
|||||||
pathPaint, pathFont, this->surfaceProps(), SkMatrix::I(),
|
pathPaint, pathFont, this->surfaceProps(), SkMatrix::I(),
|
||||||
SkScalerContextFlags::kFakeGammaAndBoostContrast, &effects);
|
SkScalerContextFlags::kFakeGammaAndBoostContrast, &effects);
|
||||||
|
|
||||||
// This processor is empty because all changes to the cache are tracked through
|
auto perEmpty = [glyphCacheState] (const SkGlyph& glyph, SkPoint mappedPt) {
|
||||||
// getGlyphMetrics and decideCouldDrawFromPath.
|
glyphCacheState->addGlyph(glyph.getPackedID(), false);
|
||||||
auto processPaths = [](
|
};
|
||||||
SkSpan<const SkGlyphRunListPainter::GlyphAndPos>, SkStrikeInterface*, SkScalar) { };
|
|
||||||
|
auto perPath = [glyphCacheState](const SkGlyph& glyph, SkPoint position) {
|
||||||
|
const bool asPath = true;
|
||||||
|
glyphCacheState->addGlyph(glyph.getGlyphID(), asPath);
|
||||||
|
};
|
||||||
|
|
||||||
ARGBHelper argbFallback{runMatrix, surfaceProps(), fStrikeServer};
|
ARGBHelper argbFallback{runMatrix, surfaceProps(), fStrikeServer};
|
||||||
|
|
||||||
fPainter.drawGlyphRunAsPathWithARGBFallback(
|
fPainter.drawGlyphRunAsPathWithARGBFallback(
|
||||||
glyphCacheState, glyphRun, origin, runPaint, runMatrix, textScale,
|
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
|
#if SK_SUPPORT_GPU
|
||||||
@ -1110,7 +1095,7 @@ SkGlyphRunListPainter::ScopedBuffers::ScopedBuffers(SkGlyphRunListPainter* paint
|
|||||||
fPainter->fMaxRunSize = size;
|
fPainter->fMaxRunSize = size;
|
||||||
|
|
||||||
fPainter->fPositions.reset(size);
|
fPainter->fPositions.reset(size);
|
||||||
fPainter->fGlyphPos.reset(size);
|
fPainter->fMasks.reset(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,7 +1107,7 @@ SkGlyphRunListPainter::ScopedBuffers::~ScopedBuffers() {
|
|||||||
if (fPainter->fMaxRunSize > 200) {
|
if (fPainter->fMaxRunSize > 200) {
|
||||||
fPainter->fMaxRunSize = 0;
|
fPainter->fMaxRunSize = 0;
|
||||||
fPainter->fPositions.reset();
|
fPainter->fPositions.reset();
|
||||||
fPainter->fGlyphPos.reset();
|
fPainter->fMasks.reset();
|
||||||
fPainter->fPaths.shrink_to_fit();
|
fPainter->fPaths.shrink_to_fit();
|
||||||
fPainter->fARGBGlyphsIDs.shrink_to_fit();
|
fPainter->fARGBGlyphsIDs.shrink_to_fit();
|
||||||
fPainter->fARGBPositions.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
|
// 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
|
// and the position in fallback vectors. After all the glyphs are processed, pass the
|
||||||
// fallback glyphIDs and positions to fallbackARGB.
|
// fallback glyphIDs and positions to fallbackARGB.
|
||||||
template <typename ProcessPathsT>
|
template <typename PerEmptyT, typename PerPath>
|
||||||
void drawGlyphRunAsPathWithARGBFallback(
|
void drawGlyphRunAsPathWithARGBFallback(
|
||||||
SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
|
SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
|
||||||
SkPoint origin, const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar textScale,
|
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>
|
template <typename PerEmptyT, typename PerSDFT, typename PerPathT>
|
||||||
void drawGlyphRunAsSDFWithARGBFallback(
|
void drawGlyphRunAsSDFWithARGBFallback(
|
||||||
@ -171,7 +171,7 @@ private:
|
|||||||
|
|
||||||
int fMaxRunSize{0};
|
int fMaxRunSize{0};
|
||||||
SkAutoTMalloc<SkPoint> fPositions;
|
SkAutoTMalloc<SkPoint> fPositions;
|
||||||
SkAutoTMalloc<GlyphAndPos> fGlyphPos;
|
SkAutoTMalloc<GlyphAndPos> fMasks;
|
||||||
|
|
||||||
std::vector<GlyphAndPos> fPaths;
|
std::vector<GlyphAndPos> fPaths;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user