Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkTextBlobBuilder Class Reference

Helper class for constructing SkTextBlobs. More...

#include <SkTextBlob.h>

Classes

struct  RunBuffer
 Glyph and position buffers associated with a run. More...
 

Public Member Functions

sk_sp< SkTextBlobmake ()
 Returns an immutable SkTextBlob for the current runs/glyphs, or nullptr if no runs were allocated. More...
 
const RunBufferallocRunText (const SkPaint &font, int count, SkScalar x, SkScalar y, int textByteCount, SkString lang, const SkRect *bounds=NULL)
 Allocates a new default-positioned run and returns its writable glyph buffer for direct manipulation. More...
 
const RunBufferallocRun (const SkPaint &font, int count, SkScalar x, SkScalar y, const SkRect *bounds=NULL)
 
const RunBufferallocRunTextPosH (const SkPaint &font, int count, SkScalar y, int textByteCount, SkString lang, const SkRect *bounds=NULL)
 Allocates a new horizontally-positioned run and returns its writable glyph and position buffers for direct manipulation. More...
 
const RunBufferallocRunPosH (const SkPaint &font, int count, SkScalar y, const SkRect *bounds=NULL)
 
const RunBufferallocRunTextPos (const SkPaint &font, int count, int textByteCount, SkString lang, const SkRect *bounds=NULL)
 Allocates a new fully-positioned run and returns its writable glyph and position buffers for direct manipulation. More...
 
const RunBufferallocRunPos (const SkPaint &font, int count, const SkRect *bounds=NULL)
 

Private Member Functions

void reserve (size_t size)
 
void allocInternal (const SkPaint &font, SkTextBlob::GlyphPositioning positioning, int count, int textBytes, SkPoint offset, const SkRect *bounds)
 
bool mergeRun (const SkPaint &font, SkTextBlob::GlyphPositioning positioning, int count, SkPoint offset)
 
void updateDeferredBounds ()
 

Static Private Member Functions

static SkRect ConservativeRunBounds (const SkTextBlob::RunRecord &)
 
static SkRect TightRunBounds (const SkTextBlob::RunRecord &)
 

Private Attributes

SkAutoTMalloc< uint8_t > fStorage
 
size_t fStorageSize
 
size_t fStorageUsed
 
SkRect fBounds
 
int fRunCount
 
bool fDeferredBounds
 
size_t fLastRun
 
RunBuffer fCurrentRunBuffer
 

Detailed Description

Helper class for constructing SkTextBlobs.

Member Function Documentation

const RunBuffer& SkTextBlobBuilder::allocRunText ( const SkPaint font,
int  count,
SkScalar  x,
SkScalar  y,
int  textByteCount,
SkString  lang,
const SkRect bounds = NULL 
)

Allocates a new default-positioned run and returns its writable glyph buffer for direct manipulation.

Parameters
fontThe font to be used for this run.
countNumber of glyphs.
x,yPosition within the blob.
textByteCountlength of the original UTF-8 text that corresponds to this sequence of glyphs. If 0, text will not be included in the textblob.
langLanguage code, currently unimplemented.
boundsOptional run bounding box. If known in advance (!= NULL), it will be used when computing the blob bounds, to avoid re-measuring.
Returns
A writable glyph buffer, valid until the next allocRun() or build() call. The buffer is guaranteed to hold @ glyphs.
const RunBuffer& SkTextBlobBuilder::allocRunTextPos ( const SkPaint font,
int  count,
int  textByteCount,
SkString  lang,
const SkRect bounds = NULL 
)

Allocates a new fully-positioned run and returns its writable glyph and position buffers for direct manipulation.

Parameters
fontThe font to be used for this run.
countNumber of glyphs.
textByteCountlength of the original UTF-8 text that corresponds to this sequence of glyphs. If 0, text will not be included in the textblob.
langLanguage code, currently unimplemented.
boundsOptional run bounding box. If known in advance (!= NULL), it will be used when computing the blob bounds, to avoid re-measuring.
Returns
Writable glyph and position buffers, valid until the next allocRun() or build() call. The glyph buffer and position buffer are guaranteed to hold @ and 2 * @ elements, respectively.
const RunBuffer& SkTextBlobBuilder::allocRunTextPosH ( const SkPaint font,
int  count,
SkScalar  y,
int  textByteCount,
SkString  lang,
const SkRect bounds = NULL 
)

Allocates a new horizontally-positioned run and returns its writable glyph and position buffers for direct manipulation.

Parameters
fontThe font to be used for this run.
countNumber of glyphs.
yVertical offset within the blob.
textByteCountlength of the original UTF-8 text that corresponds to this sequence of glyphs. If 0, text will not be included in the textblob.
langLanguage code, currently unimplemented.
boundsOptional run bounding box. If known in advance (!= NULL), it will be used when computing the blob bounds, to avoid re-measuring.
Returns
Writable glyph and position buffers, valid until the next allocRun() or build() call. The buffers are guaranteed to hold @ elements.
sk_sp<SkTextBlob> SkTextBlobBuilder::make ( )

Returns an immutable SkTextBlob for the current runs/glyphs, or nullptr if no runs were allocated.

The builder is reset and can be reused.


The documentation for this class was generated from the following file: