aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphRun.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-07-11 20:03:13 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-11 20:03:19 +0000
commitba383208043a69666ada6c22757e656927fd6bfc (patch)
tree8bd47a9fc8ac1d120477941e82575cb448ade186 /src/core/SkGlyphRun.cpp
parent143cf8e5994c54aa8c1b721f7af1d3fc9fd83602 (diff)
Revert "Use simple buffers instead of vectors"
This reverts commit b188da121c1575caa6b0b9755e3f80a6b5e44611. Reason for revert: Patch on a rollback Original change's description: > Use simple buffers instead of vectors > > Start using simple buffers, these will be used for > multiple runs latter on. > > Change-Id: I8dadbed036b7a60d708c49b84bb5e3bb3710f704 > Reviewed-on: https://skia-review.googlesource.com/140578 > Reviewed-by: Mike Klein <mtklein@google.com> > Commit-Queue: Herb Derby <herb@google.com> TBR=mtklein@google.com,herb@google.com Change-Id: I51d9ad9bc0fd7efb93e5db4dc504d8dc31e7cfb4 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/140802 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.cpp')
-rw-r--r--src/core/SkGlyphRun.cpp72
1 files changed, 23 insertions, 49 deletions
diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp
index 85de9ba197..6791cf3ab2 100644
--- a/src/core/SkGlyphRun.cpp
+++ b/src/core/SkGlyphRun.cpp
@@ -91,7 +91,7 @@ SkSpan<const SkGlyphID> SkGlyphIDSet::uniquifyGlyphIDs(
// If the following bzero becomes a performance problem, the memory can be marked as
// initialized for valgrind and msan.
// valgrind = VALGRIND_MAKE_MEM_DEFINED(fUniverseToUnique, universeSize * sizeof(SkGlyphID))
- // msan = sk_msan_mark_initialized(fUniverseToUnique, universeSize * sizeof(SkGlyphID))
+ // msan = sk_msan_assert_initialized(fUniverseToUnique, universeSize * sizeof(SkGlyphID))
sk_bzero(fUniverseToUnique, universeSize * sizeof(SkGlyphID));
}
@@ -166,12 +166,10 @@ SkGlyphRun* SkGlyphRunBuilder::useGlyphRun() {
void SkGlyphRunBuilder::initialize(size_t totalRunSize) {
fUniqueID = 0;
- if (totalRunSize > fMaxTotalRunSize) {
- fMaxTotalRunSize = totalRunSize;
- fUniqueGlyphIDIndices.reset(fMaxTotalRunSize);
- fPositions.reset(fMaxTotalRunSize);
- fUniqueGlyphIDs.reset(fMaxTotalRunSize);
- }
+ // Using resize is temporary until simpler buffers are in place.
+ fDenseIndex.resize(totalRunSize);
+ fPositions.resize(totalRunSize);
+ fUniqueGlyphIDs.resize(totalRunSize);
// Be sure to clean up the last run before we reuse it.
fScratchGlyphRun.~SkGlyphRun();
@@ -205,7 +203,7 @@ SkSpan<const SkGlyphID> SkGlyphRunBuilder::addDenseAndUnique(
auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint);
auto glyphUniverseSize = typeface->countGlyphs();
uniquifiedGlyphIDs = fGlyphIDSet.uniquifyGlyphIDs(
- glyphUniverseSize, glyphIDs, fUniqueGlyphIDs, fUniqueGlyphIDIndices);
+ glyphUniverseSize, glyphIDs, fUniqueGlyphIDs.data(), fDenseIndex.data());
}
return uniquifiedGlyphIDs;
@@ -215,23 +213,21 @@ void SkGlyphRunBuilder::makeGlyphRun(
const SkPaint& runPaint,
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) {
// Ignore empty runs.
- if (!glyphIDs.empty()) {
+ if (!fDenseIndex.empty()) {
SkPaint glyphRunPaint{runPaint};
glyphRunPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
glyphRunPaint.setTextAlign(SkPaint::kLeft_Align);
new ((void*)&fScratchGlyphRun) SkGlyphRun{
std::move(glyphRunPaint),
- uniqueGlyphIDIndices,
+ SkSpan<const uint16_t>{fDenseIndex},
positions,
glyphIDs,
- uniqueGlyphIDs,
+ SkSpan<const SkGlyphID>{fUniqueGlyphIDs},
text,
clusters
};
@@ -242,11 +238,9 @@ void SkGlyphRunBuilder::drawText(
const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, SkPoint origin,
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
- auto runSize = glyphIDs.size();
-
auto unqiueGlyphIDs = this->addDenseAndUnique(paint, glyphIDs);
- fScratchAdvances.resize(runSize);
+ fScratchAdvances.resize(fUniqueGlyphIDs.size());
{
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint);
cache->getAdvances(unqiueGlyphIDs, fScratchAdvances.data());
@@ -254,9 +248,9 @@ void SkGlyphRunBuilder::drawText(
SkPoint endOfLastGlyph = origin;
- for (size_t i = 0; i < runSize; i++) {
+ for (size_t i = 0; i < fDenseIndex.size(); i++) {
fPositions[i] = endOfLastGlyph;
- endOfLastGlyph += fScratchAdvances[fUniqueGlyphIDIndices[i]];
+ endOfLastGlyph += fScratchAdvances[fDenseIndex[i]];
}
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
@@ -264,64 +258,44 @@ void SkGlyphRunBuilder::drawText(
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
len.scale(SK_ScalarHalf);
}
- for (auto& pt : SkSpan<SkPoint>{fPositions, runSize}) {
- pt -= len;
+ for (size_t i = 0; i < fDenseIndex.size(); i++) {
+ fPositions[i] -= len;
}
}
- this->makeGlyphRun(
- paint,
- glyphIDs,
- SkSpan<const SkPoint>{fPositions, runSize},
- SkSpan<const uint16_t>{fUniqueGlyphIDIndices, runSize},
- unqiueGlyphIDs,
- text,
- clusters);
+ this->makeGlyphRun(paint, glyphIDs, SkSpan<const SkPoint>{fPositions}, text, clusters);
}
void SkGlyphRunBuilder::drawPosTextH(const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs,
const SkScalar* xpos, SkScalar constY,
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.
#ifdef SK_DEBUG
this->addDenseAndUnique(paint, glyphIDs);
#endif
- auto posCursor = fPositions.get();
- for (auto x : SkSpan<const SkScalar>{xpos, runSize}) {
- *posCursor++ = SkPoint::Make(x, constY);
+ for (size_t i = 0; i < fDenseIndex.size(); i++) {
+ fPositions[i] = SkPoint::Make(xpos[i], constY);
}
- this->makeGlyphRun(
- paint,
- glyphIDs,
- SkSpan<const SkPoint>{fPositions, runSize},
- SkSpan<const uint16_t>{},
- SkSpan<const SkGlyphID>{},
- text,
- clusters);
+ this->makeGlyphRun(paint, glyphIDs, SkSpan<const SkPoint>{fPositions}, text, clusters);
}
void SkGlyphRunBuilder::drawPosText(const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs,
const SkPoint* pos,
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.
#ifdef SK_DEBUG
this->addDenseAndUnique(paint, glyphIDs);
#endif
- this->makeGlyphRun(
- paint,
- glyphIDs,
- SkSpan<const SkPoint>{pos, runSize},
- SkSpan<const uint16_t>{},
- SkSpan<const SkGlyphID>{},
- text,
- clusters);
+ for (size_t i = 0; i < fDenseIndex.size(); i++) {
+ fPositions[i] = pos[i];
+ }
+
+ this->makeGlyphRun(paint, glyphIDs, SkSpan<const SkPoint>{fPositions}, text, clusters);
}