inline simple functions in the glyph run builder
This is a refactoring on the way to making glyph runs handle RSXForm. This is a portion of the larger CL: https://skia-review.googlesource.com/c/skia/+/388719 Change-Id: I6fbfe6e865fca9786fe7daf88bf8adf486a944c8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392776 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
14d0096f1d
commit
8960100112
@ -150,54 +150,63 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
|
||||
void SkGlyphRunBuilder::textBlobToGlyphRunListIgnoringRSXForm(
|
||||
const SkTextBlob& blob, SkPoint origin) {
|
||||
// Figure out all the storage needed to pre-size everything below.
|
||||
size_t totalGlyphs = 0;
|
||||
size_t positionsNeeded = 0;
|
||||
for (SkTextBlobRunIterator it(&blob); !it.done(); it.next()) {
|
||||
totalGlyphs += it.glyphCount();
|
||||
if (it.positioning() != SkTextBlobRunIterator::kFull_Positioning) {
|
||||
positionsNeeded += it.glyphCount();
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-size all the buffers so they don't move during processing.
|
||||
this->initialize(totalGlyphs);
|
||||
|
||||
SkPoint* positions = fPositions;
|
||||
this->initialize(positionsNeeded);
|
||||
|
||||
SkPoint* positionCursor = fPositions;
|
||||
for (SkTextBlobRunIterator it(&blob); !it.done(); it.next()) {
|
||||
simplifyTextBlobIgnoringRSXForm(it, positions);
|
||||
positions += it.glyphCount();
|
||||
positionCursor = simplifyTextBlobIgnoringRSXForm(it, positionCursor);
|
||||
}
|
||||
|
||||
if (!this->empty()) {
|
||||
this->makeGlyphRunList(&blob, origin);
|
||||
}
|
||||
this->makeGlyphRunList(&blob, origin);
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyTextBlobIgnoringRSXForm(const SkTextBlobRunIterator& it,
|
||||
SkPoint* positions) {
|
||||
SkPoint* SkGlyphRunBuilder::simplifyTextBlobIgnoringRSXForm(const SkTextBlobRunIterator& it,
|
||||
SkPoint* positionsCursor) {
|
||||
size_t runSize = it.glyphCount();
|
||||
|
||||
auto text = SkSpan<const char>(it.text(), it.textSize());
|
||||
auto clusters = SkSpan<const uint32_t>(it.clusters(), runSize);
|
||||
const SkPoint& offset = it.offset();
|
||||
auto glyphIDs = SkSpan<const SkGlyphID>{it.glyphs(), runSize};
|
||||
|
||||
SkSpan<const SkPoint> positionsSpan;
|
||||
const SkFont& font = it.font();
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlobRunIterator::kDefault_Positioning: {
|
||||
this->simplifyDrawText(
|
||||
it.font(), glyphIDs, offset, positions, text, clusters);
|
||||
positionsSpan = draw_text_positions(font, glyphIDs, it.offset(), positionsCursor);
|
||||
positionsCursor += positionsSpan.size();
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning: {
|
||||
auto constY = offset.y();
|
||||
this->simplifyDrawPosTextH(
|
||||
it.font(), glyphIDs, it.pos(), constY, positions, text, clusters);
|
||||
positionsSpan = SkSpan(positionsCursor, runSize);
|
||||
for (auto x : SkSpan<const SkScalar>{it.pos(), runSize}) {
|
||||
*positionsCursor++ = SkPoint::Make(x, it.offset().y());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kFull_Positioning: {
|
||||
this->simplifyDrawPosText(
|
||||
it.font(), glyphIDs, (const SkPoint*) it.pos(), text, clusters);
|
||||
positionsSpan = SkSpan(it.points(), runSize);
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kRSXform_Positioning: {
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kRSXform_Positioning: break;
|
||||
}
|
||||
|
||||
if (it.positioning() != SkTextBlobRunIterator::kRSXform_Positioning) {
|
||||
this->makeGlyphRun(
|
||||
font,
|
||||
glyphIDs,
|
||||
positionsSpan,
|
||||
SkSpan<const char>(it.text(), it.textSize()),
|
||||
SkSpan<const uint32_t>(it.clusters(), runSize));
|
||||
}
|
||||
|
||||
return positionsCursor;
|
||||
}
|
||||
|
||||
const SkGlyphRunList& SkGlyphRunBuilder::useGlyphRunList() {
|
||||
@ -253,49 +262,3 @@ void SkGlyphRunBuilder::makeGlyphRunList(const SkTextBlob* blob, SkPoint origin)
|
||||
fGlyphRunList.~SkGlyphRunList();
|
||||
new (&fGlyphRunList) SkGlyphRunList{blob, origin, SkSpan(fGlyphRunListStorage)};
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawText(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin, SkPoint* positions,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
SkASSERT(!glyphIDs.empty());
|
||||
|
||||
auto runSize = glyphIDs.size();
|
||||
|
||||
if (!glyphIDs.empty()) {
|
||||
draw_text_positions(font, glyphIDs, origin, positions);
|
||||
this->makeGlyphRun(
|
||||
font,
|
||||
glyphIDs,
|
||||
SkSpan<const SkPoint>{positions, runSize},
|
||||
text,
|
||||
clusters);
|
||||
}
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawPosTextH(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
|
||||
auto posCursor = positions;
|
||||
for (auto x : SkSpan<const SkScalar>{xpos, glyphIDs.size()}) {
|
||||
*posCursor++ = SkPoint::Make(x, constY);
|
||||
}
|
||||
|
||||
simplifyDrawPosText(font, glyphIDs, positions, text, clusters);
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawPosText(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
auto runSize = glyphIDs.size();
|
||||
|
||||
this->makeGlyphRun(
|
||||
font,
|
||||
glyphIDs,
|
||||
SkSpan<const SkPoint>{pos, runSize},
|
||||
text,
|
||||
clusters);
|
||||
}
|
||||
|
@ -127,24 +127,8 @@ private:
|
||||
|
||||
void makeGlyphRunList(const SkTextBlob* blob, SkPoint origin);
|
||||
|
||||
void simplifyDrawText(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin, SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
void simplifyDrawPosTextH(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
void simplifyDrawPosText(
|
||||
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
void simplifyTextBlobIgnoringRSXForm(
|
||||
const SkTextBlobRunIterator& it,
|
||||
SkPoint* positions);
|
||||
SkPoint* simplifyTextBlobIgnoringRSXForm(const SkTextBlobRunIterator& it,
|
||||
SkPoint* positionsCursor);
|
||||
|
||||
size_t fMaxTotalRunSize{0};
|
||||
SkAutoTMalloc<SkPoint> fPositions;
|
||||
|
Loading…
Reference in New Issue
Block a user