int32_t glyphCount = buffer.read32(); // Since the glyph count can never be zero. There was a buffer reading problem. if (!buffer.validate(glyphCount > 0)) { return std::nullopt;
}
// Make sure we can multiply without overflow in the check below. static constexpr int kMaxCount = (int)(INT_MAX / sizeof(uint32_t)); if (!buffer.validate(glyphCount <= kMaxCount)) { return std::nullopt;
}
// Check for enough bytes to populate the packedGlyphID array. If not enough something has // gone wrong. if (!buffer.validate(glyphCount * sizeof(uint32_t) <= buffer.available())) { return std::nullopt;
}
Variant* variants = alloc->makePODArray<Variant>(glyphCount); for (int i = 0; i < glyphCount; i++) {
variants[i].packedGlyphID = SkPackedGlyphID(buffer.readUInt());
} return GlyphVector{std::move(promise.value()), SkSpan(variants, glyphCount)};
}
void GlyphVector::flatten(SkWriteBuffer& buffer) const { // There should never be a glyph vector with zero glyphs.
SkASSERT(!fGlyphs.empty());
fStrikePromise.flatten(buffer);
// Write out the span of packedGlyphIDs.
buffer.write32(SkTo<int32_t>(fGlyphs.size())); for (Variant variant : fGlyphs) {
buffer.writeUInt(variant.packedGlyphID.value());
}
}
// packedGlyphIDToGlyph must be run in single-threaded mode. // If fSkStrike is not sk_sp<SkStrike> then the conversion to Glyph* has not happened. void GlyphVector::packedGlyphIDToGlyph(StrikeCache* cache) { if (fTextStrike == nullptr) {
SkStrike* strike = fStrikePromise.strike();
fTextStrike = cache->findOrCreateStrike(strike->strikeSpec());
// Get all the atlas locations for each glyph. for (Variant& variant : fGlyphs) {
variant.glyph = fTextStrike->getGlyph(variant.packedGlyphID);
}
// This must be pinned for the Atlas filling to work.
strike->verifyPinnedStrike();
// Drop the ref to the strike so that it can be purged if needed.
fStrikePromise.resetStrike();
}
}
} // namespace sktext::gpu
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.