aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkBitSet.h
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-08-18 14:22:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-18 14:22:52 -0700
commit530032a18e373ee673ae96fdbfa1fae6292f8f08 (patch)
tree5edb6e14ca33bf75d3d7b1df73da47be56337b3a /src/utils/SkBitSet.h
parent9637ea91b88ff8f8e95325bfc41417ffc4d5ee0b (diff)
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
Diffstat (limited to 'src/utils/SkBitSet.h')
-rw-r--r--src/utils/SkBitSet.h18
1 files changed, 15 insertions, 3 deletions
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<typename T>
+ void setAll(T* array, int len) {
+ static_assert(std::is_integral<T>::value, "T is integral");
+ for (int i = 0; i < len; ++i) {
+ this->set(static_cast<int>(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<typename T>
void exportTo(SkTDArray<T>* array) const {
+ static_assert(std::is_integral<T>::value, "T is integral");
SkASSERT(array);
uint32_t* data = reinterpret_cast<uint32_t*>(fBitData.get());
for (unsigned int i = 0; i < fDwordCount; ++i) {