OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkPDFFont_DEFINED | 9 #ifndef SkPDFFont_DEFINED |
10 #define SkPDFFont_DEFINED | 10 #define SkPDFFont_DEFINED |
11 | 11 |
12 #include "SkAdvancedTypefaceMetrics.h" | 12 #include "SkAdvancedTypefaceMetrics.h" |
13 #include "SkBitSet.h" | 13 #include "SkBitSet.h" |
14 #include "SkPDFTypes.h" | 14 #include "SkPDFTypes.h" |
15 #include "SkTDArray.h" | 15 #include "SkTDArray.h" |
16 #include "SkTypeface.h" | 16 #include "SkTypeface.h" |
17 | 17 |
18 class SkPDFCanon; | 18 class SkPDFCanon; |
19 class SkPDFFont; | 19 class SkPDFFont; |
20 | 20 |
21 class SkPDFGlyphSet : SkNoncopyable { | 21 class SkPDFGlyphSet : SkNoncopyable { |
22 public: | 22 public: |
23 SkPDFGlyphSet(); | 23 SkPDFGlyphSet(); |
| 24 SkPDFGlyphSet(SkPDFGlyphSet&& o) : fBitSet(std::move(o.fBitSet)) {} |
24 | 25 |
25 void set(const uint16_t* glyphIDs, int numGlyphs); | 26 void set(const uint16_t* glyphIDs, int numGlyphs); |
26 bool has(uint16_t glyphID) const; | 27 bool has(uint16_t glyphID) const; |
27 void merge(const SkPDFGlyphSet& usage); | |
28 void exportTo(SkTDArray<uint32_t>* glyphIDs) const; | 28 void exportTo(SkTDArray<uint32_t>* glyphIDs) const; |
29 | 29 |
30 private: | 30 private: |
31 SkBitSet fBitSet; | 31 SkBitSet fBitSet; |
32 }; | 32 }; |
33 | 33 |
34 class SkPDFGlyphSetMap : SkNoncopyable { | 34 class SkPDFGlyphSetMap : SkNoncopyable { |
35 public: | 35 public: |
36 struct FontGlyphSetPair { | 36 struct FontGlyphSetPair : SkNoncopyable { |
37 FontGlyphSetPair(SkPDFFont* font, SkPDFGlyphSet* glyphSet); | 37 FontGlyphSetPair() : fFont(nullptr) {} |
38 | 38 FontGlyphSetPair(FontGlyphSetPair&& o) |
| 39 : fFont(o.fFont) |
| 40 , fGlyphSet(std::move(o.fGlyphSet)) { |
| 41 o.fFont = nullptr; |
| 42 } |
39 SkPDFFont* fFont; | 43 SkPDFFont* fFont; |
40 SkPDFGlyphSet* fGlyphSet; | 44 SkPDFGlyphSet fGlyphSet; |
41 }; | 45 }; |
42 | 46 |
43 SkPDFGlyphSetMap(); | 47 SkPDFGlyphSetMap(); |
44 ~SkPDFGlyphSetMap(); | 48 ~SkPDFGlyphSetMap(); |
45 | 49 |
46 const FontGlyphSetPair* begin() const { return fMap.begin(); } | 50 const FontGlyphSetPair* begin() const { return fMap.begin(); } |
47 const FontGlyphSetPair* end() const { return fMap.end(); } | 51 const FontGlyphSetPair* end() const { return fMap.end(); } |
48 | 52 |
49 void merge(const SkPDFGlyphSetMap& usage); | |
50 void reset(); | |
51 | |
52 void noteGlyphUsage(SkPDFFont* font, const uint16_t* glyphIDs, | 53 void noteGlyphUsage(SkPDFFont* font, const uint16_t* glyphIDs, |
53 int numGlyphs); | 54 int numGlyphs); |
54 | 55 |
55 private: | 56 private: |
56 SkPDFGlyphSet* getGlyphSetForFont(SkPDFFont* font); | 57 SkPDFGlyphSet* getGlyphSetForFont(SkPDFFont* font); |
57 | 58 |
58 SkTDArray<FontGlyphSetPair> fMap; | 59 SkTArray<FontGlyphSetPair> fMap; |
59 }; | 60 }; |
60 | 61 |
61 | 62 |
62 /** \class SkPDFFont | 63 /** \class SkPDFFont |
63 A PDF Object class representing a font. The font may have resources | 64 A PDF Object class representing a font. The font may have resources |
64 attached to it in order to embed the font. SkPDFFonts are canonicalized | 65 attached to it in order to embed the font. SkPDFFonts are canonicalized |
65 so that resource deduplication will only include one copy of a font. | 66 so that resource deduplication will only include one copy of a font. |
66 This class uses the same pattern as SkPDFGraphicState, a static weak | 67 This class uses the same pattern as SkPDFGraphicState, a static weak |
67 reference to each instantiated class. | 68 reference to each instantiated class. |
68 */ | 69 */ |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 uint16_t fLastGlyphID; | 194 uint16_t fLastGlyphID; |
194 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; | 195 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; |
195 sk_sp<SkPDFDict> fDescriptor; | 196 sk_sp<SkPDFDict> fDescriptor; |
196 | 197 |
197 SkAdvancedTypefaceMetrics::FontType fFontType; | 198 SkAdvancedTypefaceMetrics::FontType fFontType; |
198 | 199 |
199 typedef SkPDFDict INHERITED; | 200 typedef SkPDFDict INHERITED; |
200 }; | 201 }; |
201 | 202 |
202 #endif | 203 #endif |
OLD | NEW |