OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef SkTextBlob_DEFINED | 8 #ifndef SkTextBlob_DEFINED |
9 #define SkTextBlob_DEFINED | 9 #define SkTextBlob_DEFINED |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 /** | 25 /** |
26 * Returns the blob bounding box. | 26 * Returns the blob bounding box. |
27 */ | 27 */ |
28 const SkRect& bounds() const { return fBounds; } | 28 const SkRect& bounds() const { return fBounds; } |
29 | 29 |
30 /** | 30 /** |
31 * Return a non-zero, unique value representing the text blob. | 31 * Return a non-zero, unique value representing the text blob. |
32 */ | 32 */ |
33 uint32_t uniqueID() const; | 33 uint32_t uniqueID() const; |
34 | 34 |
| 35 /** |
| 36 * Serialize to a buffer. |
| 37 */ |
| 38 void flatten(SkWriteBuffer&) const; |
| 39 |
| 40 /** |
| 41 * Recreate an SkTextBlob that was serialized into a buffer. |
| 42 * |
| 43 * @param SkReadBuffer Serialized blob data. |
| 44 * @return A new SkTextBlob representing the serialized data, or NULL if th
e buffer is |
| 45 * invalid. |
| 46 */ |
| 47 static const SkTextBlob* CreateFromBuffer(SkReadBuffer&); |
| 48 |
35 private: | 49 private: |
36 enum GlyphPositioning { | 50 enum GlyphPositioning { |
37 kDefault_Positioning = 0, // Default glyph advances -- zero scalars
per glyph. | 51 kDefault_Positioning = 0, // Default glyph advances -- zero scalars
per glyph. |
38 kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar p
er glyph. | 52 kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar p
er glyph. |
39 kFull_Positioning = 2 // Point positioning -- two scalars per g
lyph. | 53 kFull_Positioning = 2 // Point positioning -- two scalars per g
lyph. |
40 }; | 54 }; |
41 | 55 |
42 class RunIterator { | 56 class RunIterator { |
43 public: | 57 public: |
44 RunIterator(const SkTextBlob* blob); | 58 RunIterator(const SkTextBlob* blob); |
(...skipping 18 matching lines...) Expand all Loading... |
63 uint32_t count; | 77 uint32_t count; |
64 uint32_t glyphStart; // index into fGlyphBuffer | 78 uint32_t glyphStart; // index into fGlyphBuffer |
65 uint32_t posStart; // index into fPosBuffer | 79 uint32_t posStart; // index into fPosBuffer |
66 SkPoint offset; // run offset (unsued for fully positioned
glyphs) | 80 SkPoint offset; // run offset (unsued for fully positioned
glyphs) |
67 SkPaint font; | 81 SkPaint font; |
68 GlyphPositioning positioning; | 82 GlyphPositioning positioning; |
69 }; | 83 }; |
70 | 84 |
71 SkTextBlob(uint16_t* glyphs, SkScalar* pos, const SkTArray<Run>* runs, const
SkRect& bounds); | 85 SkTextBlob(uint16_t* glyphs, SkScalar* pos, const SkTArray<Run>* runs, const
SkRect& bounds); |
72 | 86 |
73 void flatten(SkWriteBuffer&) const; | |
74 static const SkTextBlob* CreateFromBuffer(SkReadBuffer&); | |
75 | |
76 static unsigned ScalarsPerGlyph(GlyphPositioning pos); | 87 static unsigned ScalarsPerGlyph(GlyphPositioning pos); |
77 | 88 |
78 friend class SkCanvas; | 89 friend class SkCanvas; |
79 friend class SkPictureData; | |
80 friend class SkTextBlobBuilder; | 90 friend class SkTextBlobBuilder; |
81 friend class TextBlobTester; | 91 friend class TextBlobTester; |
82 | 92 |
83 const SkAutoTMalloc<uint16_t> fGlyphBuffer; | 93 const SkAutoTMalloc<uint16_t> fGlyphBuffer; |
84 const SkAutoTMalloc<SkScalar> fPosBuffer; | 94 const SkAutoTMalloc<SkScalar> fPosBuffer; |
85 | 95 |
86 // SkTArray required here for run font destruction. | 96 // SkTArray required here for run font destruction. |
87 SkAutoTDelete<const SkTArray<Run> > fRuns; | 97 SkAutoTDelete<const SkTArray<Run> > fRuns; |
88 const SkRect fBounds; | 98 const SkRect fBounds; |
89 | 99 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 SkTDArray<SkScalar> fPosBuffer; | 190 SkTDArray<SkScalar> fPosBuffer; |
181 SkTArray<SkTextBlob::Run>* fRuns; | 191 SkTArray<SkTextBlob::Run>* fRuns; |
182 | 192 |
183 SkRect fBounds; | 193 SkRect fBounds; |
184 bool fDeferredBounds; | 194 bool fDeferredBounds; |
185 | 195 |
186 RunBuffer fCurrentRunBuffer; | 196 RunBuffer fCurrentRunBuffer; |
187 }; | 197 }; |
188 | 198 |
189 #endif // SkTextBlob_DEFINED | 199 #endif // SkTextBlob_DEFINED |
OLD | NEW |