aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GlyphRunTest.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-06-22 17:05:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-25 16:05:25 +0000
commited55419d859b6acce893841d71584a612aeb31d3 (patch)
tree4d55e0c534161b299b3f74d7484a7ddec0451aab /tests/GlyphRunTest.cpp
parent86d87d2e69c31af9c1ff8e60ca1a1e10f0b3264c (diff)
Use indices into the vectors shared by runs
With multiple runs, the shared vectors were moving out from under the pointers in earlier runs. Change-Id: I486d2e603e18ea7effc0dbdbc7c5d3c545278703 Reviewed-on: https://skia-review.googlesource.com/137222 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tests/GlyphRunTest.cpp')
-rw-r--r--tests/GlyphRunTest.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/tests/GlyphRunTest.cpp b/tests/GlyphRunTest.cpp
index ca97404e7c..cd2a221719 100644
--- a/tests/GlyphRunTest.cpp
+++ b/tests/GlyphRunTest.cpp
@@ -44,7 +44,8 @@ DEF_TEST(GlyphRunBasic, reporter) {
}
DEF_TEST(GlyphRunBlob, reporter) {
- constexpr uint16_t count = 10;
+ constexpr uint16_t count = 5;
+ constexpr int runCount = 2;
auto tf = SkTypeface::MakeFromName("monospace", SkFontStyle());
@@ -57,14 +58,14 @@ DEF_TEST(GlyphRunBlob, reporter) {
font.setTextSize(1u);
SkTextBlobBuilder blobBuilder;
- for (int runNum = 0; runNum < 2; runNum++) {
+ for (int runNum = 0; runNum < runCount; runNum++) {
const auto& runBuffer = blobBuilder.allocRunPosH(font, count, runNum);
SkASSERT(runBuffer.utf8text == nullptr);
SkASSERT(runBuffer.clusters == nullptr);
for (int i = 0; i < count; i++) {
- runBuffer.glyphs[i] = static_cast<SkGlyphID>(i + runNum * 10);
- runBuffer.pos[i] = SkIntToScalar(i + runNum * 10);
+ runBuffer.glyphs[i] = static_cast<SkGlyphID>(i + runNum * count);
+ runBuffer.pos[i] = SkIntToScalar(i + runNum * count);
}
}
@@ -78,9 +79,21 @@ DEF_TEST(GlyphRunBlob, reporter) {
auto runList = runBuilder.useGlyphRunList();
- REPORTER_ASSERT(reporter, runList->size() == 2);
+ REPORTER_ASSERT(reporter, runList->size() == runCount);
+ int runIndex = 0;
for (auto& run : *runList) {
- REPORTER_ASSERT(reporter, run.runSize() == 10);
- REPORTER_ASSERT(reporter, run.uniqueSize() == 10);
+ REPORTER_ASSERT(reporter, run.runSize() == count);
+ REPORTER_ASSERT(reporter, run.uniqueSize() == count);
+
+ int index = 0;
+ for (auto p : run.positions()) {
+ if (p.x() != runIndex * count + index) {
+ ERRORF(reporter, "x: %g != k: %d", p.x(), runIndex * count + index);
+ break;
+ }
+ index += 1;
+ }
+
+ runIndex += 1;
}
} \ No newline at end of file