diff options
author | Hal Canary <halcanary@google.com> | 2018-07-23 10:50:49 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-23 15:14:24 +0000 |
commit | 98caedd213775b61d93a320909e947735c626968 (patch) | |
tree | 89d5a6867a44c99d315e9063fc2ae19043485058 /tests | |
parent | 5e6cd2affe41af71399c247fcd144e8d28a3ec16 (diff) |
SkPDF: only draw text with SkglyphRuns
Change-Id: I24e79c73a9c65a5d6a974bf52b0d0aee21be07db
Reviewed-on: https://skia-review.googlesource.com/142695
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PDFPrimitivesTest.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index f23c8e34df..ab34f884ab 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -16,6 +16,7 @@ #include "SkData.h" #include "SkDeflate.h" #include "SkDocument.h" +#include "SkGlyphRun.h" #include "SkImageEncoder.h" #include "SkImageFilterPriv.h" #include "SkMakeUnique.h" @@ -488,14 +489,30 @@ DEF_TEST(SkPDF_Primitives_Color, reporter) { } } +static SkGlyphRun make_run(size_t len, const SkGlyphID* glyphs, const SkPoint* pos, + SkPaint paint, const uint32_t* clusters, + size_t utf8TextByteLength, const char* utf8Text) { + return SkGlyphRun(std::move(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}); +} + DEF_TEST(SkPDF_Clusterator, reporter) { SkPaint paint; paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); { - const uint32_t clusters[11] = { 3, 2, 2, 1, 0, 4, 4, 7, 6, 6, 5 }; - const SkGlyphID glyphs[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + constexpr unsigned len = 11; + const uint32_t clusters[len] = { 3, 2, 2, 1, 0, 4, 4, 7, 6, 6, 5 }; + const SkGlyphID glyphs[len] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + const SkPoint pos[len] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}; const char text[] = "abcdefgh"; - SkClusterator clusterator(glyphs, sizeof(glyphs), paint, clusters, strlen(text), text); + SkGlyphRun run = make_run(len, glyphs, pos, paint, clusters, strlen(text), text); + SkClusterator clusterator(run); SkClusterator::Cluster expectations[] = { {&text[3], 1, 0, 1}, {&text[2], 1, 1, 2}, @@ -512,10 +529,13 @@ DEF_TEST(SkPDF_Clusterator, reporter) { } } { - const uint32_t clusters[5] = { 0, 1, 4, 5, 6 }; - const SkGlyphID glyphs[5] = { 43, 167, 79, 79, 82, }; + constexpr unsigned len = 5; + const uint32_t clusters[len] = { 0, 1, 4, 5, 6 }; + const SkGlyphID glyphs[len] = { 43, 167, 79, 79, 82, }; + const SkPoint pos[len] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}; const char text[] = "Ha\xCC\x8A" "llo"; - SkClusterator clusterator(glyphs, sizeof(glyphs), paint, clusters, strlen(text), text); + SkGlyphRun run = make_run(len, glyphs, pos, paint, clusters, strlen(text), text); + SkClusterator clusterator(run); SkClusterator::Cluster expectations[] = { {&text[0], 1, 0, 1}, {&text[1], 3, 1, 1}, |