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 |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
13 #include "SkTArray.h" | 13 #include "SkTArray.h" |
14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
15 | 15 |
16 class SkReadBuffer; | 16 class SkReadBuffer; |
17 class SkWriteBuffer; | 17 class SkWriteBuffer; |
18 | 18 |
19 /** \class SkTextBlob | 19 /** \class SkTextBlob |
20 | 20 |
21 SkTextBlob combines multiple text runs into an immutable, ref-counted struct
ure. | 21 SkTextBlob combines multiple text runs into an immutable, ref-counted struct
ure. |
22 */ | 22 */ |
23 class SK_API SkTextBlob : public SkRefCnt { | 23 class SK_API SkTextBlob : public SkRefCnt { |
24 public: | 24 public: |
25 /** | 25 /** |
26 * Returns the blob bounding box. | 26 * Returns a conservative 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 /** | 35 /** |
36 * Serialize to a buffer. | 36 * Serialize to a buffer. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const RunBuffer& allocRunPos(const SkPaint& font, int count, const SkRect* b
ounds = NULL); | 181 const RunBuffer& allocRunPos(const SkPaint& font, int count, const SkRect* b
ounds = NULL); |
182 | 182 |
183 private: | 183 private: |
184 void reserve(size_t size); | 184 void reserve(size_t size); |
185 void allocInternal(const SkPaint& font, SkTextBlob::GlyphPositioning positio
ning, | 185 void allocInternal(const SkPaint& font, SkTextBlob::GlyphPositioning positio
ning, |
186 int count, SkPoint offset, const SkRect* bounds); | 186 int count, SkPoint offset, const SkRect* bounds); |
187 bool mergeRun(const SkPaint& font, SkTextBlob::GlyphPositioning positioning, | 187 bool mergeRun(const SkPaint& font, SkTextBlob::GlyphPositioning positioning, |
188 int count, SkPoint offset); | 188 int count, SkPoint offset); |
189 void updateDeferredBounds(); | 189 void updateDeferredBounds(); |
190 | 190 |
| 191 static SkRect ConservativeRunBounds(const SkTextBlob::RunRecord&); |
| 192 static SkRect TightRunBounds(const SkTextBlob::RunRecord&); |
| 193 |
191 SkAutoTMalloc<uint8_t> fStorage; | 194 SkAutoTMalloc<uint8_t> fStorage; |
192 size_t fStorageSize; | 195 size_t fStorageSize; |
193 size_t fStorageUsed; | 196 size_t fStorageUsed; |
194 | 197 |
195 SkRect fBounds; | 198 SkRect fBounds; |
196 int fRunCount; | 199 int fRunCount; |
197 bool fDeferredBounds; | 200 bool fDeferredBounds; |
198 size_t fLastRun; // index into fStorage | 201 size_t fLastRun; // index into fStorage |
199 | 202 |
200 RunBuffer fCurrentRunBuffer; | 203 RunBuffer fCurrentRunBuffer; |
201 }; | 204 }; |
202 | 205 |
203 #endif // SkTextBlob_DEFINED | 206 #endif // SkTextBlob_DEFINED |
OLD | NEW |