prepare regenerate to move to SubRun
Move the only method into it's call site. The regenerate call will be moved to SubRun in the next CL. The regenerate call will need different implementations for the different types of SubRun. Change-Id: I5396790211ea26cb96b23e823bd2c41c6c5cbaa5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302268 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
25a1d4f2a0
commit
52ceaea51d
@ -832,37 +832,6 @@ GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourcePro
|
||||
, fFullAtlasManager(fullAtlasManager)
|
||||
, fSubRun(subRun) { }
|
||||
|
||||
std::tuple<bool, int> GrTextBlob::VertexRegenerator::updateTextureCoordinates(
|
||||
const int begin, const int end) {
|
||||
|
||||
SkASSERT(fSubRun->isPrepared());
|
||||
|
||||
SkBulkGlyphMetricsAndImages metricsAndImages{fSubRun->strikeSpec()};
|
||||
|
||||
// Update the atlas information in the GrStrike.
|
||||
auto tokenTracker = fUploadTarget->tokenTracker();
|
||||
auto vertexData = fSubRun->vertexData().subspan(begin, end - begin);
|
||||
int glyphsPlacedInAtlas = 0;
|
||||
for (auto [glyph, pos, rect] : vertexData) {
|
||||
GrGlyph* grGlyph = glyph.grGlyph;
|
||||
SkASSERT(grGlyph != nullptr);
|
||||
|
||||
if (!fFullAtlasManager->hasGlyph(fSubRun->maskFormat(), grGlyph)) {
|
||||
const SkGlyph& skGlyph = *metricsAndImages.glyph(grGlyph->fPackedID);
|
||||
auto code = fFullAtlasManager->addGlyphToAtlas(
|
||||
skGlyph, fSubRun->atlasPadding(), grGlyph, fResourceProvider, fUploadTarget);
|
||||
if (code != GrDrawOpAtlas::ErrorCode::kSucceeded) {
|
||||
return {code != GrDrawOpAtlas::ErrorCode::kError, glyphsPlacedInAtlas};
|
||||
}
|
||||
}
|
||||
fFullAtlasManager->addGlyphToBulkAndSetUseToken(
|
||||
fSubRun->bulkUseToken(), fSubRun->maskFormat(), grGlyph,
|
||||
tokenTracker->nextDrawToken());
|
||||
glyphsPlacedInAtlas++;
|
||||
}
|
||||
|
||||
return {true, glyphsPlacedInAtlas};
|
||||
}
|
||||
|
||||
std::tuple<bool, int> GrTextBlob::VertexRegenerator::regenerate(int begin, int end) {
|
||||
uint64_t currentAtlasGen = fFullAtlasManager->atlasGeneration(fSubRun->maskFormat());
|
||||
@ -871,7 +840,35 @@ std::tuple<bool, int> GrTextBlob::VertexRegenerator::regenerate(int begin, int e
|
||||
// Calculate the texture coordinates for the vertexes during first use (fAtlasGeneration
|
||||
// is set to kInvalidAtlasGeneration) or the atlas has changed in subsequent calls..
|
||||
fSubRun->resetBulkUseToken();
|
||||
auto [success, glyphsPlacedInAtlas] = this->updateTextureCoordinates(begin, end);
|
||||
|
||||
SkASSERT(fSubRun->isPrepared());
|
||||
|
||||
SkBulkGlyphMetricsAndImages metricsAndImages{fSubRun->strikeSpec()};
|
||||
|
||||
// Update the atlas information in the GrStrike.
|
||||
auto tokenTracker = fUploadTarget->tokenTracker();
|
||||
auto vertexData = fSubRun->vertexData().subspan(begin, end - begin);
|
||||
int glyphsPlacedInAtlas = 0;
|
||||
bool success = true;
|
||||
for (auto [glyph, pos, rect] : vertexData) {
|
||||
GrGlyph* grGlyph = glyph.grGlyph;
|
||||
SkASSERT(grGlyph != nullptr);
|
||||
|
||||
if (!fFullAtlasManager->hasGlyph(fSubRun->maskFormat(), grGlyph)) {
|
||||
const SkGlyph& skGlyph = *metricsAndImages.glyph(grGlyph->fPackedID);
|
||||
auto code = fFullAtlasManager->addGlyphToAtlas(
|
||||
skGlyph, fSubRun->atlasPadding(), grGlyph,
|
||||
fResourceProvider, fUploadTarget);
|
||||
if (code != GrDrawOpAtlas::ErrorCode::kSucceeded) {
|
||||
success = code != GrDrawOpAtlas::ErrorCode::kError;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fFullAtlasManager->addGlyphToBulkAndSetUseToken(
|
||||
fSubRun->bulkUseToken(), fSubRun->maskFormat(), grGlyph,
|
||||
tokenTracker->nextDrawToken());
|
||||
glyphsPlacedInAtlas++;
|
||||
}
|
||||
|
||||
// Update atlas generation if there are no more glyphs to put in the atlas.
|
||||
if (success && begin + glyphsPlacedInAtlas == fSubRun->glyphCount()) {
|
||||
|
@ -219,8 +219,6 @@ public:
|
||||
std::tuple<bool, int> regenerate(int begin, int end);
|
||||
|
||||
private:
|
||||
// Return {success, number of glyphs regenerated}
|
||||
std::tuple<bool, int> updateTextureCoordinates(int begin, int end);
|
||||
|
||||
GrResourceProvider* fResourceProvider;
|
||||
GrDeferredUploadTarget* fUploadTarget;
|
||||
|
Loading…
Reference in New Issue
Block a user