Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPDFGlyphUse.h
Go to the documentation of this file.
1// Copyright 2018 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3#ifndef SkPDFGlyphUse_DEFINED
4#define SkPDFGlyphUse_DEFINED
5
8
10public:
11 SkPDFGlyphUse() : fBitSet(0) {}
13 : fBitSet(lastGlyph - firstNonZero + 2)
14 , fFirstNonZero(firstNonZero)
15 , fLastGlyph(lastGlyph) { SkASSERT(firstNonZero >= 1); }
16 ~SkPDFGlyphUse() = default;
19
20 SkGlyphID firstNonZero() const { return fFirstNonZero; }
21 SkGlyphID lastGlyph() const { return fLastGlyph; }
22 void set(SkGlyphID gid) { fBitSet.set(this->toCode(gid)); }
23 bool has(SkGlyphID gid) const { return fBitSet.test(this->toCode(gid)); }
24
25 template<typename FN>
26 void getSetValues(FN f) const {
27 if (fFirstNonZero == 1) {
28 return fBitSet.forEachSetIndex(std::move(f));
29 }
30 uint16_t offset = fFirstNonZero - 1;
31 fBitSet.forEachSetIndex([&f, offset](unsigned v) { f(v == 0 ? v : v + offset); });
32 }
33
34private:
35 SkBitSet fBitSet;
36 SkGlyphID fFirstNonZero = 0;
37 SkGlyphID fLastGlyph = 0;
38
39 uint16_t toCode(SkGlyphID gid) const {
40 if (gid == 0 || fFirstNonZero == 1) {
41 return gid;
42 }
43 SkASSERT(gid >= fFirstNonZero && gid <= fLastGlyph);
44 return gid - fFirstNonZero + 1;
45 }
46 SkPDFGlyphUse(const SkPDFGlyphUse&) = delete;
47 SkPDFGlyphUse& operator=(const SkPDFGlyphUse&) = delete;
48};
49#endif // SkPDFGlyphUse_DEFINED
#define SkASSERT(cond)
Definition SkAssert.h:116
uint16_t SkGlyphID
Definition SkTypes.h:179
void set(size_t index)
Definition SkBitSet.h:41
bool test(size_t index) const
Definition SkBitSet.h:66
void forEachSetIndex(FN f) const
Definition SkBitSet.h:77
SkPDFGlyphUse(SkPDFGlyphUse &&)=default
void set(SkGlyphID gid)
SkGlyphID lastGlyph() const
SkPDFGlyphUse(SkGlyphID firstNonZero, SkGlyphID lastGlyph)
SkPDFGlyphUse & operator=(SkPDFGlyphUse &&)=default
~SkPDFGlyphUse()=default
SkGlyphID firstNonZero() const
bool has(SkGlyphID gid) const
void getSetValues(FN f) const
Point offset