From 52ceaea51d93bf5ac42d83fa9458da6e1c08a0b5 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Mon, 13 Jul 2020 13:03:23 -0400 Subject: [PATCH] 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 Reviewed-by: Robert Phillips --- src/gpu/text/GrTextBlob.cpp | 61 ++++++++++++++++++------------------- src/gpu/text/GrTextBlob.h | 2 -- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index ec99422784..bbc01390ed 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -832,37 +832,6 @@ GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourcePro , fFullAtlasManager(fullAtlasManager) , fSubRun(subRun) { } -std::tuple 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 GrTextBlob::VertexRegenerator::regenerate(int begin, int end) { uint64_t currentAtlasGen = fFullAtlasManager->atlasGeneration(fSubRun->maskFormat()); @@ -871,7 +840,35 @@ std::tuple 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()) { diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index ad459abaf2..b6bbb391a5 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -219,8 +219,6 @@ public: std::tuple regenerate(int begin, int end); private: - // Return {success, number of glyphs regenerated} - std::tuple updateTextureCoordinates(int begin, int end); GrResourceProvider* fResourceProvider; GrDeferredUploadTarget* fUploadTarget;