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 --- src/utils/SkBitSet.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/utils/SkBitSet.h') diff --git a/src/utils/SkBitSet.h b/src/utils/SkBitSet.h index 6882752bc0..1e35c9120f 100644 --- a/src/utils/SkBitSet.h +++ b/src/utils/SkBitSet.h @@ -17,10 +17,11 @@ public: /** NumberOfBits must be greater than zero. */ explicit SkBitSet(int numberOfBits); - explicit SkBitSet(const SkBitSet& source); - explicit SkBitSet(SkBitSet&&); + SkBitSet(const SkBitSet&) = delete; + SkBitSet(SkBitSet&&); + SkBitSet& operator=(const SkBitSet&) = delete; + SkBitSet& operator=(SkBitSet&& rhs); - SkBitSet& operator=(const SkBitSet& rhs); bool operator==(const SkBitSet& rhs); bool operator!=(const SkBitSet& rhs); @@ -39,6 +40,15 @@ public: *chunk &= ~mask; } } + void set(int index) { this->setBit(index, true); } + + template + void setAll(T* array, int len) { + static_assert(std::is_integral::value, "T is integral"); + for (int i = 0; i < len; ++i) { + this->set(static_cast(array[i])); + } + } /** Test if bit index is set. */ @@ -46,6 +56,7 @@ public: uint32_t mask = 1 << (index & 31); return SkToBool(*this->internalGet(index) & mask); } + bool has(int index) const { return this->isBitSet(index); } /** Or bits from source. false is returned if this doesn't have the same * bit count as source. @@ -56,6 +67,7 @@ public: */ template void exportTo(SkTDArray* array) const { + static_assert(std::is_integral::value, "T is integral"); SkASSERT(array); uint32_t* data = reinterpret_cast(fBitData.get()); for (unsigned int i = 0; i < fDwordCount; ++i) { -- cgit v1.2.3