8 #ifndef SkTextBlob_DEFINED
9 #define SkTextBlob_DEFINED
17 #include "include/private/base/SkDebug.h"
18 #include "include/private/base/SkTemplates.h"
59 uint32_t
uniqueID()
const {
return fUniqueID; }
76 const SkPaint* paint =
nullptr)
const;
120 return MakeFromText(
string, strlen(
string), font, encoding);
151 const SkPoint pos[],
const SkFont& font,
215 #ifdef SK_UNTIL_CRBUG_1187654_IS_FIXED
216 const uint32_t* fClusterIndex_forTest;
217 int fUtf8Size_forTest;
218 const char* fUtf8_forTest;
240 const RunRecord* fRunRecord;
246 enum GlyphPositioning : uint8_t;
254 void operator delete(
void* p);
255 void*
operator new(size_t);
256 void*
operator new(size_t,
void* p);
258 static unsigned ScalarsPerGlyph(GlyphPositioning pos);
260 using PurgeDelegate = void (*)(uint32_t blobID, uint32_t cacheID);
264 void notifyAddedToCache(uint32_t cacheID, PurgeDelegate purgeDelegate)
const {
265 fCacheID.store(cacheID);
266 fPurgeDelegate.store(purgeDelegate);
269 friend class sktext::GlyphRunList;
271 friend class SkTextBlobPriv;
272 friend class SkTextBlobRunIterator;
275 const uint32_t fUniqueID;
276 mutable std::atomic<uint32_t> fCacheID;
277 mutable std::atomic<PurgeDelegate> fPurgeDelegate;
279 SkDEBUGCODE(
size_t fStorageSize;)
335 SkPoint*
points()
const {
return reinterpret_cast<SkPoint*
>(pos); }
361 const SkRect* bounds =
nullptr);
385 const SkRect* bounds =
nullptr);
408 const SkRect* bounds =
nullptr);
438 int textByteCount,
const SkRect* bounds =
nullptr);
463 const SkRect* bounds =
nullptr);
487 const SkRect* bounds =
nullptr);
491 const SkRect* bounds =
nullptr);
494 void reserve(
size_t size);
495 void allocInternal(
const SkFont& font, SkTextBlob::GlyphPositioning positioning,
496 int count,
int textBytes, SkPoint offset,
const SkRect* bounds);
497 bool mergeRun(
const SkFont& font, SkTextBlob::GlyphPositioning positioning,
498 uint32_t count, SkPoint offset);
499 void updateDeferredBounds();
501 static SkRect ConservativeRunBounds(
const SkTextBlob::RunRecord&);
502 static SkRect TightRunBounds(
const SkTextBlob::RunRecord&);
504 friend class SkTextBlobPriv;
505 friend class SkTextBlobBuilderPriv;
507 skia_private::AutoTMalloc<uint8_t> fStorage;
513 bool fDeferredBounds;
SkTextEncoding
Definition: SkFontTypes.h:11
@ kUTF8
uses bytes to represent UTF-8 or ASCII
float SkScalar
Definition: SkScalar.h:14
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:171
SkData holds an immutable data buffer.
Definition: SkData.h:25
SkFont controls options applied when drawing and measuring text.
Definition: SkFont.h:36
Definition: SkRefCnt.h:160
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
Definition: SkRefCnt.h:119
Helper class for constructing SkTextBlob.
Definition: SkTextBlob.h:290
SkTextBlobBuilder()
Constructs empty SkTextBlobBuilder.
const RunBuffer & allocRunTextRSXform(const SkFont &font, int count, int textByteCount, const SkRect *bounds=nullptr)
const RunBuffer & allocRunText(const SkFont &font, int count, SkScalar x, SkScalar y, int textByteCount, const SkRect *bounds=nullptr)
Returns run with storage for glyphs, text, and clusters.
const RunBuffer & allocRun(const SkFont &font, int count, SkScalar x, SkScalar y, const SkRect *bounds=nullptr)
Returns run with storage for glyphs.
const RunBuffer & allocRunPos(const SkFont &font, int count, const SkRect *bounds=nullptr)
Returns run with storage for glyphs and SkPoint positions.
const RunBuffer & allocRunTextPosH(const SkFont &font, int count, SkScalar y, int textByteCount, const SkRect *bounds=nullptr)
Returns run with storage for glyphs, positions along baseline, text, and clusters.
const RunBuffer & allocRunPosH(const SkFont &font, int count, SkScalar y, const SkRect *bounds=nullptr)
Returns run with storage for glyphs and positions along baseline.
sk_sp< SkTextBlob > make()
Returns SkTextBlob built from runs of glyphs added by builder.
~SkTextBlobBuilder()
Deletes data allocated internally by SkTextBlobBuilder.
const RunBuffer & allocRunRSXform(const SkFont &font, int count)
const RunBuffer & allocRunTextPos(const SkFont &font, int count, int textByteCount, const SkRect *bounds=nullptr)
Returns run with storage for glyphs, SkPoint positions, text, and clusters.
Definition: SkTextBlob.h:209
bool next(Run *)
Returns true for each "run" inside the textblob, setting the Run fields (if not null).
bool experimentalNext(ExperimentalRun *)
SkTextBlob combines multiple text runs into an immutable container.
Definition: SkTextBlob.h:41
static sk_sp< SkTextBlob > MakeFromPosText(const void *text, size_t byteLength, const SkPoint pos[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Returns a textblob built from a single run of text with positions.
int getIntercepts(const SkScalar bounds[2], SkScalar intervals[], const SkPaint *paint=nullptr) const
Returns the number of intervals that intersect bounds.
const SkRect & bounds() const
Returns conservative bounding box.
Definition: SkTextBlob.h:53
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Creates SkTextBlob with a single run.
Definition: SkTextBlob.h:115
uint32_t uniqueID() const
Returns a non-zero value unique among all text blobs.
Definition: SkTextBlob.h:59
static sk_sp< SkTextBlob > MakeFromRSXform(const void *text, size_t byteLength, const SkRSXform xform[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static sk_sp< SkTextBlob > MakeFromPosTextH(const void *text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Returns a textblob built from a single run of text with x-positions and a single y value.
static sk_sp< SkTextBlob > Deserialize(const void *data, size_t size, const SkDeserialProcs &procs)
Recreates SkTextBlob that was serialized into data.
sk_sp< SkData > serialize(const SkSerialProcs &procs) const
Returns storage containing SkData describing SkTextBlob, using optional custom encoders.
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Creates SkTextBlob with a single run.
size_t serialize(const SkSerialProcs &procs, void *memory, size_t memory_size) const
Writes data to allow later reconstruction of SkTextBlob.
The SkTypeface class specifies the typeface and intrinsic style of a font.
Definition: SkTypeface.h:52
Definition: SkCanvas.h:42
Definition: SkSerialProcs.h:97
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
Definition: SkSerialProcs.h:86
RunBuffer supplies storage for glyphs and positions within a run.
Definition: SkTextBlob.h:328
SkRSXform * xforms() const
Definition: SkTextBlob.h:336
SkScalar * pos
storage for glyph positions in run
Definition: SkTextBlob.h:330
char * utf8text
storage for text UTF-8 code units in run
Definition: SkTextBlob.h:331
SkGlyphID * glyphs
storage for glyph indexes in run
Definition: SkTextBlob.h:329
SkPoint * points() const
Definition: SkTextBlob.h:335
uint32_t * clusters
storage for glyph clusters (index of UTF-8 code unit)
Definition: SkTextBlob.h:332
Definition: SkTextBlob.h:231
SkFont font
Definition: SkTextBlob.h:232
const SkPoint * positions
Definition: SkTextBlob.h:235
int count
Definition: SkTextBlob.h:233
const uint16_t * glyphs
Definition: SkTextBlob.h:234
Definition: SkTextBlob.h:211
SkTypeface * fTypeface
Definition: SkTextBlob.h:212
int fGlyphCount
Definition: SkTextBlob.h:213
const uint16_t * fGlyphIndices
Definition: SkTextBlob.h:214