Non-substantive GPU text changes
This CL pulls some cleanup changes out of the omnibus GPU text CL. It:
Removes the unused GrTextStrike::removeID method
Removes the unused GrTextStrike::countGlyphs method
Removes the GrTextureStrike::fAtlasedGlyphs member variable
Adds an "int SkSpan::count() const" helper method
Change-Id: I88eefd929a5576093de58af85582567d8df5610a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280706
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Herb Derby <herb@google.com>
diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp
index a37b42a..9ae1a18 100644
--- a/src/atlastext/SkAtlasTextTarget.cpp
+++ b/src/atlastext/SkAtlasTextTarget.cpp
@@ -222,7 +222,6 @@
}
void GrAtlasTextOp::executeForTextTarget(SkAtlasTextTarget* target) {
- FlushInfo flushInfo;
auto& context = target->context()->internal();
auto atlasManager = context.grContext()->priv().getAtlasManager();
auto resourceProvider = context.grContext()->priv().resourceProvider();
@@ -239,10 +238,12 @@
subRun->translateVerticesIfNeeded(fGeoData[i].fDrawMatrix, fGeoData[i].fDrawOrigin);
GrTextBlob::VertexRegenerator regenerator(
resourceProvider, fGeoData[i].fSubRunPtr, &context, atlasManager);
- int subRunEnd = subRun->fGlyphs.size();
+ int subRunEnd = subRun->fGlyphs.count();
for (int subRunIndex = 0; subRunIndex < subRunEnd;) {
auto [ok, glyphsRegenerated] = regenerator.regenerate(subRunIndex, subRunEnd);
- if (!ok) { break; }
+ if (!ok) {
+ break;
+ }
context.recordDraw(subRun->quadStart(subRunIndex), glyphsRegenerated,
fGeoData[i].fDrawMatrix, target->handle());
diff --git a/src/core/SkSpan.h b/src/core/SkSpan.h
index 3baaab5..06d9201 100644
--- a/src/core/SkSpan.h
+++ b/src/core/SkSpan.h
@@ -36,6 +36,7 @@
constexpr auto crbegin() const { return std::make_reverse_iterator(this->cend()); }
constexpr auto crend() const { return std::make_reverse_iterator(this->cbegin()); }
constexpr T* data() const { return fPtr; }
+ constexpr int count() const { return SkTo<int>(fSize); }
constexpr size_t size() const { return fSize; }
constexpr bool empty() const { return fSize == 0; }
constexpr size_t size_bytes() const { return fSize * sizeof(T); }
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index 8338e05..01024c6 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -367,7 +367,7 @@
// Where the subRun begins and ends relative to totalGlyphsRegened.
int subRunBegin = totalGlyphsRegened;
- int subRunEnd = subRunBegin + (int)subRun->fGlyphs.size();
+ int subRunEnd = subRunBegin + subRun->fGlyphs.count();
// Draw all the glyphs in the subRun.
while (totalGlyphsRegened < subRunEnd) {
@@ -379,7 +379,9 @@
auto[ok, glyphsRegenerated] = regenerator.regenerate(drawBegin, drawEnd);
// There was a problem allocating the glyph in the atlas. Bail.
- if(!ok) { return; }
+ if (!ok) {
+ return;
+ }
// Update all the vertices for glyphsRegenerate glyphs.
if (glyphsRegenerated > 0) {
diff --git a/src/gpu/text/GrStrikeCache.cpp b/src/gpu/text/GrStrikeCache.cpp
index 46fa61d..0dab676 100644
--- a/src/gpu/text/GrStrikeCache.cpp
+++ b/src/gpu/text/GrStrikeCache.cpp
@@ -139,16 +139,6 @@
GrTextStrike::GrTextStrike(const SkDescriptor& key)
: fFontScalerKey(key) {}
-void GrTextStrike::removeID(GrDrawOpAtlas::PlotLocator plotLocator) {
- fCache.foreach([this, plotLocator](GrGlyph** glyph){
- if ((*glyph)->fPlotLocator == plotLocator) {
- (*glyph)->fPlotLocator = GrDrawOpAtlas::kInvalidPlotLocator;
- fAtlasedGlyphs--;
- SkASSERT(fAtlasedGlyphs >= 0);
- }
- });
-}
-
GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(const SkGlyph& skGlyph,
GrMaskFormat expectedMaskFormat,
bool isScaledGlyph,
@@ -194,7 +184,6 @@
grGlyph->fAtlasLocation.fY += 1;
}
SkASSERT(grGlyph->fPlotLocator != GrDrawOpAtlas::kInvalidPlotLocator);
- fAtlasedGlyphs++;
}
return result;
}
diff --git a/src/gpu/text/GrStrikeCache.h b/src/gpu/text/GrStrikeCache.h
index ad320eb..0520634 100644
--- a/src/gpu/text/GrStrikeCache.h
+++ b/src/gpu/text/GrStrikeCache.h
@@ -46,12 +46,6 @@
GrAtlasManager*,
GrGlyph*);
- // testing
- int countGlyphs() const { return fCache.count(); }
-
- // remove any references to this plot
- void removeID(GrDrawOpAtlas::PlotLocator);
-
private:
struct HashTraits {
// GetKey and Hash for the the hash table.
@@ -67,8 +61,6 @@
SkAutoDescriptor fFontScalerKey;
SkArenaAlloc fAlloc{512};
- int fAtlasedGlyphs{0};
-
friend class GrStrikeCache;
};
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index a4cc0ca..2e005cd 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -531,7 +531,7 @@
target->drawShape(clip, runPaint, ctm, shape);
}
} else {
- int glyphCount = subRun->fGlyphs.size();
+ int glyphCount = subRun->fGlyphs.count();
if (0 == glyphCount) {
continue;
}
@@ -853,7 +853,7 @@
auto [success, glyphsPlacedInAtlas] = this->updateTextureCoordinates(begin, end);
// Update atlas generation if there are no more glyphs to put in the atlas.
- if (success && begin + glyphsPlacedInAtlas == (int)fSubRun->fGlyphs.size()) {
+ if (success && begin + glyphsPlacedInAtlas == fSubRun->fGlyphs.count()) {
// Need to get the freshest value of the atlas' generation because
// updateTextureCoordinates may have changed it.
fSubRun->fAtlasGeneration = fFullAtlasManager->atlasGeneration(fSubRun->maskFormat());
@@ -861,7 +861,7 @@
return {success, glyphsPlacedInAtlas};
} else {
// The atlas hasn't changed, so our texture coordinates are still valid.
- if (end == (int)fSubRun->fGlyphs.size()) {
+ if (end == fSubRun->fGlyphs.count()) {
// The atlas hasn't changed and the texture coordinates are all still valid. Update
// all the plots used to the new use token.
fFullAtlasManager->setUseTokenBulk(*fSubRun->bulkUseToken(),