Revert "Remove unique glyph IDs from glyph runs"

This reverts commit 2d123ad73f.

Reason for revert: Android roll?

Original change's description:
> Remove unique glyph IDs from glyph runs
> 
> The unique calculation is to costly to do for SkTextBlobs every
> time because there may be a cache hit in the GrTextBlob cache.
> In the future I will move the unique ID calculation to the GrTextBlob
> creation.
> 
> Change-Id: I7e10e8f22a3bc729fab12b2cf7e9732441be7f31
> Reviewed-on: https://skia-review.googlesource.com/c/164623
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=mtklein@google.com,herb@google.com

Change-Id: I8424e12e1ad1abd9e40699aa34e1062f5c7bf94a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/165060
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2018-10-25 15:21:51 +00:00 committed by Skia Commit-Bot
parent 7d98846985
commit 5a284e56d8
8 changed files with 158 additions and 65 deletions

View File

@ -30,12 +30,16 @@ static SkTypeface::Encoding convert_encoding(SkPaint::TextEncoding encoding) {
// -- SkGlyphRun -----------------------------------------------------------------------------------
SkGlyphRun::SkGlyphRun(const SkPaint& basePaint,
const SkRunFont& runFont,
SkSpan<const uint16_t> denseIndices,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const SkGlyphID> uniqueGlyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters)
: fPositions{positions}
: fUniqueGlyphIDIndices{denseIndices}
, fPositions{positions}
, fGlyphIDs{glyphIDs}
, fUniqueGlyphIDs{uniqueGlyphIDs}
, fText{text}
, fClusters{clusters}
, fRunPaint{basePaint, runFont} {}
@ -46,8 +50,10 @@ void SkGlyphRun::eachGlyphToGlyphRun(SkGlyphRun::PerGlyph perGlyph) {
SkGlyphRun run{
fRunPaint,
SkRunFont{fRunPaint},
SkSpan<const uint16_t>{}, // No dense indices for now.
SkSpan<const SkPoint>{&point, 1},
SkSpan<const SkGlyphID>{&glyphID, 1},
SkSpan<const SkGlyphID>{},
SkSpan<const char>{},
SkSpan<const uint32_t>{}
};
@ -192,6 +198,8 @@ void SkGlyphRunBuilder::drawTextAtOrigin(
SkRunFont{paint},
glyphIDs,
positions,
SkSpan<const uint16_t>{}, // no dense indices for now.,
SkSpan<const SkGlyphID>{},
SkSpan<const char>{},
SkSpan<const uint32_t>{});
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
@ -202,7 +210,8 @@ void SkGlyphRunBuilder::drawText(
auto glyphIDs = textToGlyphIDs(paint, bytes, byteLength);
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawText(paint, SkRunFont{paint}, glyphIDs, origin, fPositions);
this->simplifyDrawText(paint, SkRunFont{paint}, glyphIDs, origin,
fUniqueGlyphIDIndices, fUniqueGlyphIDs, fPositions);
}
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
@ -215,7 +224,8 @@ void SkGlyphRunBuilder::drawPosTextH(const SkPaint& paint, const void* bytes,
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawPosTextH(
paint, SkRunFont{paint}, glyphIDs, xpos, constY, fPositions);
paint, SkRunFont{paint}, glyphIDs, xpos, constY,
fUniqueGlyphIDIndices, fUniqueGlyphIDs, fPositions);
}
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
@ -226,7 +236,8 @@ void SkGlyphRunBuilder::drawPosText(const SkPaint& paint, const void* bytes,
auto glyphIDs = textToGlyphIDs(paint, bytes, byteLength);
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos);
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos,
fUniqueGlyphIDIndices, fUniqueGlyphIDs);
}
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
@ -242,7 +253,9 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
// Pre-size all the buffers so they don't move during processing.
this->initialize(totalGlyphs);
uint16_t* currentDenseIndices = fUniqueGlyphIDIndices;
SkPoint* currentPositions = fPositions;
SkGlyphID* currentUniqueGlyphIDs = fUniqueGlyphIDs;
for (SkTextBlobRunIterator it(&blob); !it.done(); it.next()) {
// applyFontToPaint() always overwrites the exact same attributes,
@ -254,28 +267,34 @@ 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: {
this->simplifyDrawText(
paint, it.runFont(), glyphIDs, offset, currentPositions,
uniqueGlyphIDsSize = this->simplifyDrawText(
paint, it.runFont(), glyphIDs, offset,
currentDenseIndices, currentUniqueGlyphIDs, currentPositions,
text, clusters);
}
break;
case SkTextBlobRunIterator::kHorizontal_Positioning: {
auto constY = offset.y();
this->simplifyDrawPosTextH(
paint, it.runFont(), glyphIDs, it.pos(), constY, currentPositions,
uniqueGlyphIDsSize = this->simplifyDrawPosTextH(
paint, it.runFont(), glyphIDs, it.pos(), constY,
currentDenseIndices, currentUniqueGlyphIDs, currentPositions,
text, clusters);
}
break;
case SkTextBlobRunIterator::kFull_Positioning:
this->simplifyDrawPosText(
uniqueGlyphIDsSize = this->simplifyDrawPosText(
paint, it.runFont(), glyphIDs, (const SkPoint*)it.pos(),
currentDenseIndices, currentUniqueGlyphIDs,
text, clusters);
break;
}
currentDenseIndices += runSize;
currentPositions += runSize;
currentUniqueGlyphIDs += uniqueGlyphIDsSize;
}
this->makeGlyphRunList(paint, &blob, origin);
@ -285,7 +304,8 @@ void SkGlyphRunBuilder::drawGlyphPos(
const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos) {
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos);
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos,
fUniqueGlyphIDIndices, fUniqueGlyphIDs);
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
}
}
@ -298,7 +318,9 @@ void SkGlyphRunBuilder::initialize(size_t totalRunSize) {
if (totalRunSize > fMaxTotalRunSize) {
fMaxTotalRunSize = totalRunSize;
fUniqueGlyphIDIndices.reset(fMaxTotalRunSize);
fPositions.reset(fMaxTotalRunSize);
fUniqueGlyphIDs.reset(fMaxTotalRunSize);
}
fGlyphRunListStorage.clear();
@ -324,11 +346,33 @@ SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
}
}
SkSpan<const SkGlyphID> SkGlyphRunBuilder::addDenseAndUnique(
const SkPaint& paint,
SkSpan<const SkGlyphID> glyphIDs,
uint16_t* uniqueGlyphIDIndices,
SkGlyphID* uniqueGlyphIDs) {
SkSpan<const SkGlyphID> uniquifiedGlyphIDs;
if (!glyphIDs.empty()) {
auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint);
auto glyphUniverseSize = typeface->countGlyphs();
// There better be glyphs in the font if we want to uniqify.
if (glyphUniverseSize > 0) {
uniquifiedGlyphIDs = fGlyphIDSet.uniquifyGlyphIDs(
glyphUniverseSize, glyphIDs, uniqueGlyphIDs, uniqueGlyphIDIndices);
}
}
return uniquifiedGlyphIDs;
}
void SkGlyphRunBuilder::makeGlyphRun(
const SkPaint& basePaint,
const SkRunFont& runFont,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const SkPoint> positions,
SkSpan<const uint16_t> uniqueGlyphIDIndices,
SkSpan<const SkGlyphID> uniqueGlyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters) {
@ -337,8 +381,10 @@ void SkGlyphRunBuilder::makeGlyphRun(
fGlyphRunListStorage.emplace_back(
basePaint,
runFont,
uniqueGlyphIDIndices,
positions,
glyphIDs,
uniqueGlyphIDs,
text,
clusters);
}
@ -352,53 +398,62 @@ void SkGlyphRunBuilder::makeGlyphRunList(
paint, blob, origin, SkSpan<SkGlyphRun>{fGlyphRunListStorage}};
}
SkPoint SkGlyphRunBuilder::simplifyDrawText(
size_t SkGlyphRunBuilder::simplifyDrawText(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
SkPoint origin, SkPoint* positions,
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
SkPoint origin, uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer,
SkPoint* positions, SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
SkASSERT(!glyphIDs.empty());
auto runSize = glyphIDs.size();
SkPaint runPaint{paint, runFont};
fScratchAdvances.resize(runSize);
{
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(runPaint);
cache->getAdvances(glyphIDs, fScratchAdvances.data());
}
auto unqiueGlyphIDs = this->addDenseAndUnique(
runPaint, glyphIDs, uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer);
SkPoint endOfLastGlyph = origin;
for (size_t i = 0; i < runSize; i++) {
positions[i] = endOfLastGlyph;
endOfLastGlyph += fScratchAdvances[i];
}
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
SkVector len = endOfLastGlyph - origin;
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
len.scale(SK_ScalarHalf);
if (!unqiueGlyphIDs.empty()) {
fScratchAdvances.resize(runSize);
{
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(runPaint);
cache->getAdvances(unqiueGlyphIDs, fScratchAdvances.data());
}
for (auto& pt : SkSpan<SkPoint>{positions, runSize}) {
pt -= len;
SkPoint endOfLastGlyph = origin;
for (size_t i = 0; i < runSize; i++) {
positions[i] = endOfLastGlyph;
endOfLastGlyph += fScratchAdvances[uniqueGlyphIDIndicesBuffer[i]];
}
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
SkVector len = endOfLastGlyph - origin;
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
len.scale(SK_ScalarHalf);
}
for (auto& pt : SkSpan<SkPoint>{positions, runSize}) {
pt -= len;
}
}
this->makeGlyphRun(
paint,
runFont,
glyphIDs,
SkSpan<const SkPoint>{positions, runSize},
SkSpan<const uint16_t>{uniqueGlyphIDIndicesBuffer, runSize},
unqiueGlyphIDs,
text,
clusters);
}
this->makeGlyphRun(
paint,
runFont,
glyphIDs,
SkSpan<const SkPoint>{positions, runSize},
text,
clusters);
return endOfLastGlyph;
return unqiueGlyphIDs.size();
}
void SkGlyphRunBuilder::simplifyDrawPosTextH(
size_t SkGlyphRunBuilder::simplifyDrawPosTextH(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
const SkScalar* xpos, SkScalar constY,
uint16_t* uniqueGlyphIDIndicesBuffer, SkGlyphID* uniqueGlyphIDsBuffer, SkPoint* positions,
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
auto posCursor = positions;
@ -406,19 +461,34 @@ void SkGlyphRunBuilder::simplifyDrawPosTextH(
*posCursor++ = SkPoint::Make(x, constY);
}
simplifyDrawPosText(paint, runFont, glyphIDs, positions, text, clusters);
return simplifyDrawPosText(paint, runFont, glyphIDs, positions,
uniqueGlyphIDIndicesBuffer, uniqueGlyphIDsBuffer,
text, clusters);
}
void SkGlyphRunBuilder::simplifyDrawPosText(
size_t SkGlyphRunBuilder::simplifyDrawPosText(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
const SkPoint* pos, SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
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,
text,
clusters);
return uniqueGlyphIDs.size();
}

View File

@ -87,8 +87,10 @@ public:
SkGlyphRun() = default;
SkGlyphRun(const SkPaint& basePaint,
const SkRunFont& runFont,
SkSpan<const uint16_t> denseIndices,
SkSpan<const SkPoint> positions,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const SkGlyphID> uniqueGlyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters);
@ -105,17 +107,21 @@ public:
size_t runSize() const { return fGlyphIDs.size(); }
SkSpan<const SkPoint> positions() const { return fPositions.toConst(); }
SkSpan<const SkGlyphID> glyphsIDs() const { return fGlyphIDs; }
SkSpan<const SkGlyphID> shuntGlyphsIDs() const { return fGlyphIDs; }
const SkPaint& paint() const { return fRunPaint; }
SkPaint* mutablePaint() { return &fRunPaint; }
SkSpan<const uint32_t> clusters() const { return fClusters; }
SkSpan<const char> text() const { return fText; }
private:
// Positions relative to the list's origin.
//
const SkSpan<const uint16_t> fUniqueGlyphIDIndices;
//
const SkSpan<const SkPoint> fPositions;
// This is temporary while converting from the old per glyph code to the bulk code.
const SkSpan<const SkGlyphID> fGlyphIDs;
// The unique glyphs from fGlyphIDs.
const SkSpan<const SkGlyphID> fUniqueGlyphIDs;
// Original text from SkTextBlob if present. Will be empty of not present.
const SkSpan<const char> fText;
// Original clusters from SkTextBlob if present. Will be empty if not present.
@ -134,7 +140,6 @@ class SkGlyphRunList {
public:
SkGlyphRunList();
// Blob maybe null.
SkGlyphRunList(
const SkPaint& paint,
@ -203,45 +208,61 @@ private:
SkSpan<const SkGlyphID> textToGlyphIDs(
const SkPaint& paint, const void* bytes, size_t byteLength);
// Returns the span of unique glyph IDs.
SkSpan<const SkGlyphID> addDenseAndUnique(
const SkPaint& paint,
SkSpan<const SkGlyphID> glyphIDs,
uint16_t* uniqueGlyphIDIndices,
SkGlyphID* uniqueGlyphIDs);
void makeGlyphRun(
const SkPaint& basePaint,
const SkRunFont& runFont,
SkSpan<const SkGlyphID> glyphIDs,
SkSpan<const SkPoint> positions,
SkSpan<const uint16_t> uniqueGlyphIDIndices,
SkSpan<const SkGlyphID> uniqueGlyphIDs,
SkSpan<const char> text,
SkSpan<const uint32_t> clusters);
void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin);
// Return the end of the last glyph for measurement.
SkPoint simplifyDrawText(
size_t simplifyDrawText(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
SkPoint origin, SkPoint* positions,
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>{});
void simplifyDrawPosTextH(
size_t simplifyDrawPosTextH(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
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>{});
void simplifyDrawPosText(
size_t simplifyDrawPosText(
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
const SkPoint* pos,
const SkPoint* pos, uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs,
SkSpan<const char> text = SkSpan<const char>{},
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
size_t fMaxTotalRunSize{0};
SkAutoTMalloc<uint16_t> fUniqueGlyphIDIndices;
SkAutoTMalloc<SkPoint> fPositions;
SkAutoTMalloc<SkGlyphID> fUniqueGlyphIDs;
std::vector<SkGlyphRun> fGlyphRunListStorage;
SkGlyphRunList fGlyphRunList;
// Used as a temporary for preparing using utfN text. This implies that only one run of
// glyph ids will ever be needed because blobs are already glyph based.
std::vector<SkGlyphID> fScratchGlyphIDs;
// Used as temporary storage for calculating positions for drawText.
std::vector<SkPoint> fScratchAdvances;
// Used for collecting the set of unique glyphs.
SkGlyphIDSet fGlyphIDSet;
};
template <typename PerGlyphPos>

View File

@ -153,7 +153,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsSubpixelMask(
matrix.mapPoints(fPositions, glyphRun.positions().data(), runSize);
const SkPoint* positionCursor = fPositions;
for (auto glyphID : glyphRun.glyphsIDs()) {
for (auto glyphID : glyphRun.shuntGlyphsIDs()) {
auto position = *positionCursor++;
if (SkScalarsAreFinite(position.fX, position.fY)) {
const SkGlyph& glyph = cache->getGlyphMetrics(glyphID, position);
@ -181,7 +181,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsFullpixelMask(
matrix.mapPoints(fPositions, glyphRun.positions().data(), runSize);
const SkPoint* positionCursor = fPositions;
for (auto glyphID : glyphRun.glyphsIDs()) {
for (auto glyphID : glyphRun.shuntGlyphsIDs()) {
auto position = *positionCursor++;
if (SkScalarsAreFinite(position.fX, position.fY)) {
const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID);

View File

@ -150,7 +150,7 @@ void SkGlyphRunListPainter::forEachMappedDrawableGlyph(
mapping.mapPoints(fPositions, glyphRun.positions().data(), runSize);
const SkPoint* mappedPtCursor = fPositions;
const SkPoint* ptCursor = glyphRun.positions().data();
for (auto glyphID : glyphRun.glyphsIDs()) {
for (auto glyphID : glyphRun.shuntGlyphsIDs()) {
auto mappedPt = *mappedPtCursor++;
auto pt = origin + *ptCursor++;
if (SkScalarsAreFinite(mappedPt.x(), mappedPt.y())) {
@ -234,7 +234,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsSDFWithARGBFallback(
SkScalar maxFallbackDimension{-SK_ScalarInfinity};
const SkPoint* positionCursor = glyphRun.positions().data();
for (auto glyphID : glyphRun.glyphsIDs()) {
for (auto glyphID : glyphRun.shuntGlyphsIDs()) {
const SkGlyph& glyph = cache->getGlyphMetrics(glyphID, {0, 0});
SkPoint glyphPos = origin + *positionCursor++;
if (glyph.fMaskFormat == SkMask::kSDF_Format || glyph.isEmpty()) {

View File

@ -28,7 +28,7 @@ static bool is_reversed(const uint32_t* clusters, uint32_t count) {
SkClusterator::SkClusterator(const SkGlyphRun& run)
: fClusters(run.clusters().data())
, fUtf8Text(run.text().data())
, fGlyphCount(SkToU32(run.glyphsIDs().size()))
, fGlyphCount(SkToU32(run.shuntGlyphsIDs().size()))
, fTextByteLength(SkToU32(run.text().size()))
{
if (fClusters) {

View File

@ -1038,8 +1038,8 @@ void SkPDFDevice::drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset)
SkPath path;
SkASSERT(paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding);
paint.getPosTextPath(glyphRun.glyphsIDs().data(),
glyphRun.glyphsIDs().size() * sizeof(SkGlyphID),
paint.getPosTextPath(glyphRun.shuntGlyphsIDs().data(),
glyphRun.shuntGlyphsIDs().size() * sizeof(SkGlyphID),
glyphRun.positions().data(),
&path);
path.offset(offset.x(), offset.y());
@ -1088,8 +1088,8 @@ static bool needs_new_font(SkPDFFont* font, SkGlyphID gid, SkGlyphCache* cache,
void SkPDFDevice::internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset) {
const SkGlyphID* glyphs = glyphRun.glyphsIDs().data();
uint32_t glyphCount = SkToU32(glyphRun.glyphsIDs().size());
const SkGlyphID* glyphs = glyphRun.shuntGlyphsIDs().data();
uint32_t glyphCount = SkToU32(glyphRun.shuntGlyphsIDs().size());
SkPaint srcPaint{glyphRun.paint()};
srcPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
srcPaint.setTextAlign(SkPaint::kLeft_Align);

View File

@ -872,7 +872,7 @@ public:
const SkPaint& paint = glyphRun.paint();
auto runSize = glyphRun.runSize();
SkAutoSTArray<64, SkUnichar> unichars(runSize);
paint.glyphsToUnichars(glyphRun.glyphsIDs().data(), runSize, unichars.get());
paint.glyphsToUnichars(glyphRun.shuntGlyphsIDs().data(), runSize, unichars.get());
auto positions = glyphRun.positions();
for (size_t i = 0; i < runSize; ++i) {
this->appendUnichar(unichars[i], positions[i]);

View File

@ -493,8 +493,10 @@ static SkGlyphRun make_run(size_t len, const SkGlyphID* glyphs, SkPoint* pos,
SkPaint paint, const uint32_t* clusters,
size_t utf8TextByteLength, const char* utf8Text) {
return SkGlyphRun(paint, SkRunFont{paint},
SkSpan<const uint16_t>{}, // No dense indices for now.
SkSpan<const SkPoint>{pos, len},
SkSpan<const SkGlyphID>{glyphs, len},
SkSpan<const SkGlyphID>{},
SkSpan<const char>{utf8Text, utf8TextByteLength},
SkSpan<const uint32_t>{clusters, len});
}