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 <mtklein@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
aedc9d2add
commit
1648976008
@ -267,10 +267,9 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
|
||||
const SkPoint& offset = it.offset();
|
||||
auto glyphIDs = SkSpan<const SkGlyphID>{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<SkGlyphRun>{fGlyphRunListStorage}};
|
||||
}
|
||||
|
||||
size_t SkGlyphRunBuilder::simplifyDrawText(
|
||||
void SkGlyphRunBuilder::simplifyDrawText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer,
|
||||
SkPoint* positions, SkSpan<const char> text, SkSpan<const uint32_t> 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<SkPoint>{positions, runSize}) {
|
||||
pt -= len;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this->makeGlyphRun(
|
||||
@ -441,16 +435,14 @@ size_t SkGlyphRunBuilder::simplifyDrawText(
|
||||
runFont,
|
||||
glyphIDs,
|
||||
SkSpan<const SkPoint>{positions, runSize},
|
||||
SkSpan<const uint16_t>{uniqueGlyphIDIndicesBuffer, runSize},
|
||||
unqiueGlyphIDs,
|
||||
SkSpan<const uint16_t>{},
|
||||
SkSpan<const SkGlyphID>{},
|
||||
text,
|
||||
clusters);
|
||||
}
|
||||
|
||||
return unqiueGlyphIDs.size();
|
||||
}
|
||||
|
||||
size_t SkGlyphRunBuilder::simplifyDrawPosTextH(
|
||||
void SkGlyphRunBuilder::simplifyDrawPosTextH(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> 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<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
auto runSize = glyphIDs.size();
|
||||
|
||||
// The dense indices are not used by the rest of the stack yet.
|
||||
SkSpan<const SkGlyphID> 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<const SkPoint>{pos, runSize},
|
||||
SkSpan<const SkGlyphID>{uniqueGlyphIDIndicesBuffer, runSize},
|
||||
uniqueGlyphIDs,
|
||||
SkSpan<const uint16_t>{},
|
||||
SkSpan<const SkGlyphID>{},
|
||||
text,
|
||||
clusters);
|
||||
return uniqueGlyphIDs.size();
|
||||
}
|
||||
|
@ -222,19 +222,19 @@ private:
|
||||
|
||||
void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin);
|
||||
|
||||
size_t simplifyDrawText(
|
||||
void simplifyDrawText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin,uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs,
|
||||
SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
size_t simplifyDrawPosTextH(
|
||||
void simplifyDrawPosTextH(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkScalar* xpos, SkScalar constY,
|
||||
uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
size_t simplifyDrawPosText(
|
||||
void simplifyDrawPosText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos, uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
|
Loading…
Reference in New Issue
Block a user