From 530032a18e373ee673ae96fdbfa1fae6292f8f08 Mon Sep 17 00:00:00 2001 From: halcanary Date: Thu, 18 Aug 2016 14:22:52 -0700 Subject: SkPDF: in-place font subsetting Motivation: gross code simplification, also no bitset lookups at draw time. SkPDFFont owns its glyph useage bitset. SkPDFSubstituteMap goes away. SkPDFObject interface is simplified. SkPDFDocument tracks font usage (as hash set), not glyph usage. SkPDFFont gets a simpler constructor. SkPDFFont has first and last glyph set in constructor, not adjusted later. SkPDFFont implementations are simplified. SkPDFGlyphSet is replaced with simple SkBitSet. SkPDFFont sizes its SkBitSets based on glyph count. SkPDFGlyphSetMap goes away. SkBitSet is now non-copyable. SkBitSet now how utility methods to match old SkPDFGlyphSet. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2253283004 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Release-GDI-Trybot,Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI-Trybot Review-Url: https://codereview.chromium.org/2253283004 --- tests/PDFGlyphsToUnicodeTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests/PDFGlyphsToUnicodeTest.cpp') diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp index b8157caeea..d83ce664bc 100644 --- a/tests/PDFGlyphsToUnicodeTest.cpp +++ b/tests/PDFGlyphsToUnicodeTest.cpp @@ -5,12 +5,14 @@ * found in the LICENSE file. */ +#include "SkBitSet.h" #include "SkData.h" -#include "SkPDFFont.h" #include "SkPDFMakeToUnicodeCmap.h" #include "SkStream.h" #include "Test.h" +static const int kMaximumGlyphCount = SK_MaxU16 + 1; + static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, const char* buffer, size_t len) { sk_sp data(stream.copyToData()); @@ -26,7 +28,7 @@ static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, DEF_TEST(ToUnicode, reporter) { SkTDArray glyphToUnicode; SkTDArray glyphsInSubset; - SkPDFGlyphSet subset; + SkBitSet subset(kMaximumGlyphCount); glyphToUnicode.push(0); // 0 glyphToUnicode.push(0); // 1 @@ -65,7 +67,7 @@ DEF_TEST(ToUnicode, reporter) { glyphToUnicode.push(0x1013); SkDynamicMemoryWStream buffer; - subset.set(glyphsInSubset.begin(), glyphsInSubset.count()); + subset.setAll(glyphsInSubset.begin(), glyphsInSubset.count()); SkPDFAppendCmapSections(glyphToUnicode, &subset, &buffer, true, 0, 0xFFFF); char expectedResult[] = @@ -136,7 +138,7 @@ endbfrange\n"; glyphToUnicode.reset(); glyphsInSubset.reset(); - SkPDFGlyphSet subset2; + SkBitSet subset2(kMaximumGlyphCount); // Test mapping: // I n s t a l @@ -154,7 +156,7 @@ endbfrange\n"; glyphsInSubset.push(0x57); SkDynamicMemoryWStream buffer2; - subset2.set(glyphsInSubset.begin(), glyphsInSubset.count()); + subset2.setAll(glyphsInSubset.begin(), glyphsInSubset.count()); SkPDFAppendCmapSections(glyphToUnicode, &subset2, &buffer2, true, 0, 0xffff); char expectedResult2[] = -- cgit v1.2.3