From 16489760087bbbb5a071c8360f877e46e79fe167 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 25 Oct 2018 12:47:10 -0400 Subject: [PATCH] Remove use of unique glyphs from the SkGlyphRunBuilder I have determined that the uniquify calculation can only happen when needed when regenerating the GrTextBlob data. Change-Id: I142e6dedc3b2e6ab5d0b969a8e7c02deec32e912 Reviewed-on: https://skia-review.googlesource.com/c/165023 Reviewed-by: Mike Klein Commit-Queue: Herb Derby --- src/core/SkGlyphRun.cpp | 49 ++++++++++++++--------------------------- src/core/SkGlyphRun.h | 6 ++--- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp index 9ae21c01a50b6..ee19c0edc48ff 100644 --- a/src/core/SkGlyphRun.cpp +++ b/src/core/SkGlyphRun.cpp @@ -267,10 +267,9 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo const SkPoint& offset = it.offset(); auto glyphIDs = SkSpan{it.glyphs(), runSize}; - size_t uniqueGlyphIDsSize = 0; switch (it.positioning()) { case SkTextBlobRunIterator::kDefault_Positioning: { - uniqueGlyphIDsSize = this->simplifyDrawText( + this->simplifyDrawText( paint, it.runFont(), glyphIDs, offset, currentDenseIndices, currentUniqueGlyphIDs, currentPositions, text, clusters); @@ -278,14 +277,14 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo break; case SkTextBlobRunIterator::kHorizontal_Positioning: { auto constY = offset.y(); - uniqueGlyphIDsSize = this->simplifyDrawPosTextH( + this->simplifyDrawPosTextH( paint, it.runFont(), glyphIDs, it.pos(), constY, currentDenseIndices, currentUniqueGlyphIDs, currentPositions, text, clusters); } break; case SkTextBlobRunIterator::kFull_Positioning: - uniqueGlyphIDsSize = this->simplifyDrawPosText( + this->simplifyDrawPosText( paint, it.runFont(), glyphIDs, (const SkPoint*)it.pos(), currentDenseIndices, currentUniqueGlyphIDs, text, clusters); @@ -294,7 +293,6 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo currentDenseIndices += runSize; currentPositions += runSize; - currentUniqueGlyphIDs += uniqueGlyphIDsSize; } this->makeGlyphRunList(paint, &blob, origin); @@ -398,7 +396,7 @@ void SkGlyphRunBuilder::makeGlyphRunList( paint, blob, origin, SkSpan{fGlyphRunListStorage}}; } -size_t SkGlyphRunBuilder::simplifyDrawText( +void SkGlyphRunBuilder::simplifyDrawText( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, SkPoint origin, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer, SkPoint* positions, SkSpan text, SkSpan clusters) { @@ -408,21 +406,18 @@ size_t SkGlyphRunBuilder::simplifyDrawText( SkPaint runPaint{paint, runFont}; - auto unqiueGlyphIDs = this->addDenseAndUnique( - runPaint, glyphIDs, uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer); - - if (!unqiueGlyphIDs.empty()) { + if (!glyphIDs.empty()) { fScratchAdvances.resize(runSize); { auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(runPaint); - cache->getAdvances(unqiueGlyphIDs, fScratchAdvances.data()); + cache->getAdvances(glyphIDs, fScratchAdvances.data()); } SkPoint endOfLastGlyph = origin; for (size_t i = 0; i < runSize; i++) { positions[i] = endOfLastGlyph; - endOfLastGlyph += fScratchAdvances[uniqueGlyphIDIndicesBuffer[i]]; + endOfLastGlyph += fScratchAdvances[i]; } if (paint.getTextAlign() != SkPaint::kLeft_Align) { @@ -433,7 +428,6 @@ size_t SkGlyphRunBuilder::simplifyDrawText( for (auto& pt : SkSpan{positions, runSize}) { pt -= len; } - } this->makeGlyphRun( @@ -441,16 +435,14 @@ size_t SkGlyphRunBuilder::simplifyDrawText( runFont, glyphIDs, SkSpan{positions, runSize}, - SkSpan{uniqueGlyphIDIndicesBuffer, runSize}, - unqiueGlyphIDs, + SkSpan{}, + SkSpan{}, text, clusters); } - - return unqiueGlyphIDs.size(); } -size_t SkGlyphRunBuilder::simplifyDrawPosTextH( +void SkGlyphRunBuilder::simplifyDrawPosTextH( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, const SkScalar* xpos, SkScalar constY, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer, SkPoint* positions, @@ -461,34 +453,25 @@ size_t SkGlyphRunBuilder::simplifyDrawPosTextH( *posCursor++ = SkPoint::Make(x, constY); } - return simplifyDrawPosText(paint, runFont, glyphIDs, positions, - uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer, - text, clusters); + simplifyDrawPosText(paint, runFont, glyphIDs, positions, + uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer, + text, clusters); } -size_t SkGlyphRunBuilder::simplifyDrawPosText( +void SkGlyphRunBuilder::simplifyDrawPosText( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, const SkPoint* pos, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer, SkSpan text, SkSpan clusters) { auto runSize = glyphIDs.size(); - // The dense indices are not used by the rest of the stack yet. - SkSpan uniqueGlyphIDs; - #ifdef SK_DEBUG - uniqueGlyphIDs = this->addDenseAndUnique( - paint, glyphIDs, uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer); - #endif - // TODO: when using the unique glyph system have a guard that there are actually glyphs like - // drawText above. this->makeGlyphRun( paint, runFont, glyphIDs, SkSpan{pos, runSize}, - SkSpan{uniqueGlyphIDIndicesBuffer, runSize}, - uniqueGlyphIDs, + SkSpan{}, + SkSpan{}, text, clusters); - return uniqueGlyphIDs.size(); } diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 2b0562b59e131..cdf8cecb58e72 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -222,19 +222,19 @@ class SkGlyphRunBuilder { void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin); - size_t simplifyDrawText( + void simplifyDrawText( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, SkPoint origin,uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, SkPoint* positions, SkSpan text = SkSpan{}, SkSpan clusters = SkSpan{}); - size_t simplifyDrawPosTextH( + void simplifyDrawPosTextH( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, const SkScalar* xpos, SkScalar constY, uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, SkPoint* positions, SkSpan text = SkSpan{}, SkSpan clusters = SkSpan{}); - size_t simplifyDrawPosText( + void simplifyDrawPosText( const SkPaint& paint, const SkRunFont& runFont, SkSpan glyphIDs, const SkPoint* pos, uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, SkSpan text = SkSpan{},