8 #ifndef SkTextBlob_DEFINED
9 #define SkTextBlob_DEFINED
11 #include "../private/SkTemplates.h"
12 #include "../private/SkAtomics.h"
34 uint32_t
uniqueID()
const {
return fUniqueID; }
50 static const SkTextBlob* CreateFromBuffer(SkReadBuffer& buffer) {
51 return MakeFromBuffer(buffer).release();
54 enum GlyphPositioning : uint8_t {
55 kDefault_Positioning = 0,
56 kHorizontal_Positioning = 1,
70 void operator delete(
void* p) { sk_free(p); }
71 void*
operator new(size_t) {
72 SkFAIL(
"All blobs are created by placement new.");
73 return sk_malloc_throw(0);
75 void*
operator new(size_t,
void* p) {
return p; }
77 static unsigned ScalarsPerGlyph(GlyphPositioning pos);
81 void notifyAddedToCache()
const {
82 fAddedToCache.store(
true);
85 friend class GrTextBlobCache;
87 friend class SkTextBlobRunIterator;
90 const uint32_t fUniqueID;
91 mutable SkAtomic<bool> fAddedToCache;
93 SkDEBUGCODE(
size_t fStorageSize;)
170 const SkRect* bounds = NULL);
171 const RunBuffer& allocRun(
const SkPaint& font,
int count, SkScalar x, SkScalar y,
172 const SkRect* bounds = NULL) {
173 return this->allocRunText(font, count, x, y, 0,
SkString(), bounds);
193 const RunBuffer& allocRunTextPosH(
const SkPaint& font,
int count, SkScalar y,
195 const SkRect* bounds = NULL);
196 const RunBuffer& allocRunPosH(
const SkPaint& font,
int count, SkScalar y,
197 const SkRect* bounds = NULL) {
198 return this->allocRunTextPosH(font, count, y, 0,
SkString(), bounds);
218 const RunBuffer& allocRunTextPos(
const SkPaint& font,
int count,
220 const SkRect* bounds = NULL);
221 const RunBuffer& allocRunPos(
const SkPaint& font,
int count,
222 const SkRect* bounds = NULL) {
223 return this->allocRunTextPos(font, count, 0,
SkString(), bounds);
227 void reserve(
size_t size);
228 void allocInternal(
const SkPaint& font, SkTextBlob::GlyphPositioning positioning,
229 int count,
int textBytes,
SkPoint offset,
const SkRect* bounds);
230 bool mergeRun(
const SkPaint& font, SkTextBlob::GlyphPositioning positioning,
232 void updateDeferredBounds();
234 static SkRect ConservativeRunBounds(
const SkTextBlob::RunRecord&);
235 static SkRect TightRunBounds(
const SkTextBlob::RunRecord&);
237 SkAutoTMalloc<uint8_t> fStorage;
243 bool fDeferredBounds;
246 RunBuffer fCurrentRunBuffer;
249 #endif // SkTextBlob_DEFINED
SkTextBlob combines multiple text runs into an immutable, ref-counted structure.
Definition: SkTextBlob.h:24
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:299
Definition: SkPoint.h:156
const SkRect & bounds() const
Returns a conservative blob bounding box.
Definition: SkTextBlob.h:29
Definition: SkRefCnt.h:125
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition: SkPaint.h:45
Glyph and position buffers associated with a run.
Definition: SkTextBlob.h:140
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:246
Helper class for constructing SkTextBlobs.
Definition: SkTextBlob.h:105
Definition: SkWriteBuffer.h:27
uint32_t uniqueID() const
Return a non-zero, unique value representing the text blob.
Definition: SkTextBlob.h:34
Definition: SkRefCnt.h:209
Light weight class for managing strings.
Definition: SkString.h:121