Skia
2DGraphicsLibrary
|
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps. More...
#include <SkPaint.h>
Classes | |
struct | FontMetrics |
Public Types | |
enum | Hinting { kNo_Hinting = 0, kSlight_Hinting = 1, kNormal_Hinting = 2, kFull_Hinting = 3 } |
Specifies the level of hinting to be performed. More... | |
enum | Flags { kAntiAlias_Flag = 0x01, kDither_Flag = 0x04, kFakeBoldText_Flag = 0x20, kLinearText_Flag = 0x40, kSubpixelText_Flag = 0x80, kDevKernText_Flag = 0x100, kLCDRenderText_Flag = 0x200, kEmbeddedBitmapText_Flag = 0x400, kAutoHinting_Flag = 0x800, kVerticalText_Flag = 0x1000, kGenA8FromLCD_Flag = 0x2000, kAllFlags = 0xFFFF } |
Specifies the bit values that are stored in the paint's flags. More... | |
enum | Style { kFill_Style, kStroke_Style, kStrokeAndFill_Style } |
Styles apply to rect, oval, path, and text. More... | |
enum | { kStyleCount = kStrokeAndFill_Style + 1 } |
enum | Cap { kButt_Cap, kRound_Cap, kSquare_Cap, kLast_Cap = kSquare_Cap, kDefault_Cap = kButt_Cap } |
Cap enum specifies the settings for the paint's strokecap. More... | |
enum | Join { kMiter_Join, kRound_Join, kBevel_Join, kLast_Join = kBevel_Join, kDefault_Join = kMiter_Join } |
Join enum specifies the settings for the paint's strokejoin. More... | |
enum | Align { kLeft_Align, kCenter_Align, kRight_Align } |
enum | { kAlignCount = 3 } |
enum | TextEncoding { kUTF8_TextEncoding, kUTF16_TextEncoding, kUTF32_TextEncoding, kGlyphID_TextEncoding } |
Describes how to interpret the text parameters that are passed to paint methods like measureText() and getTextWidths(). More... | |
Public Member Functions | |
SkPaint (const SkPaint &paint) | |
SkPaint (SkPaint &&paint) | |
SkPaint & | operator= (const SkPaint &paint) |
SkPaint & | operator= (SkPaint &&paint) |
uint32_t | getHash () const |
getHash() is a shallow hash, with the same limitations as operator==. More... | |
void | flatten (SkWriteBuffer &buffer) const |
void | unflatten (SkReadBuffer &buffer) |
void | reset () |
Restores the paint to its initial settings. | |
Hinting | getHinting () const |
void | setHinting (Hinting hintingLevel) |
uint32_t | getFlags () const |
Return the paint's flags. More... | |
void | setFlags (uint32_t flags) |
Set the paint's flags. More... | |
bool | isAntiAlias () const |
Helper for getFlags(), returning true if kAntiAlias_Flag bit is set. More... | |
void | setAntiAlias (bool aa) |
Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit. More... | |
bool | isDither () const |
Helper for getFlags(), returning true if kDither_Flag bit is set. More... | |
void | setDither (bool dither) |
Helper for setFlags(), setting or clearing the kDither_Flag bit. More... | |
bool | isLinearText () const |
Helper for getFlags(), returning true if kLinearText_Flag bit is set. More... | |
void | setLinearText (bool linearText) |
Helper for setFlags(), setting or clearing the kLinearText_Flag bit. More... | |
bool | isSubpixelText () const |
Helper for getFlags(), returning true if kSubpixelText_Flag bit is set. More... | |
void | setSubpixelText (bool subpixelText) |
Helper for setFlags(), setting or clearing the kSubpixelText_Flag. More... | |
bool | isLCDRenderText () const |
void | setLCDRenderText (bool lcdText) |
Helper for setFlags(), setting or clearing the kLCDRenderText_Flag. More... | |
bool | isEmbeddedBitmapText () const |
void | setEmbeddedBitmapText (bool useEmbeddedBitmapText) |
Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit. More... | |
bool | isAutohinted () const |
void | setAutohinted (bool useAutohinter) |
Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit. More... | |
bool | isVerticalText () const |
void | setVerticalText (bool verticalText) |
Helper for setting or clearing the kVerticalText_Flag bit in setFlags(...). More... | |
bool | isFakeBoldText () const |
Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set. More... | |
void | setFakeBoldText (bool fakeBoldText) |
Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit. More... | |
bool | isDevKernText () const |
Helper for getFlags(), returns true if kDevKernText_Flag bit is set. More... | |
void | setDevKernText (bool devKernText) |
Helper for setFlags(), setting or clearing the kKernText_Flag bit. More... | |
SkFilterQuality | getFilterQuality () const |
Return the filter level. More... | |
void | setFilterQuality (SkFilterQuality quality) |
Set the filter quality. More... | |
Style | getStyle () const |
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes kFill_Style). More... | |
void | setStyle (Style style) |
Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill). More... | |
SkColor | getColor () const |
Return the paint's color. More... | |
void | setColor (SkColor color) |
Set the paint's color. More... | |
uint8_t | getAlpha () const |
Helper to getColor() that just returns the color's alpha value. More... | |
void | setAlpha (U8CPU a) |
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged. More... | |
void | setARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b) |
Helper to setColor(), that takes a,r,g,b and constructs the color value using SkColorSetARGB() More... | |
SkScalar | getStrokeWidth () const |
Return the width for stroking. More... | |
void | setStrokeWidth (SkScalar width) |
Set the width for stroking. More... | |
SkScalar | getStrokeMiter () const |
Return the paint's stroke miter value. More... | |
void | setStrokeMiter (SkScalar miter) |
Set the paint's stroke miter value. More... | |
Cap | getStrokeCap () const |
Return the paint's stroke cap type, controlling how the start and end of stroked lines and paths are treated. More... | |
void | setStrokeCap (Cap cap) |
Set the paint's stroke cap type. More... | |
Join | getStrokeJoin () const |
Return the paint's stroke join type. More... | |
void | setStrokeJoin (Join join) |
Set the paint's stroke join type. More... | |
bool | getFillPath (const SkPath &src, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1) const |
Applies any/all effects (patheffect, stroking) to src, returning the result in dst. More... | |
bool | getFillPath (const SkPath &src, SkPath *dst) const |
SkShader * | getShader () const |
Get the paint's shader object. More... | |
sk_sp< SkShader > | refShader () const |
void | setShader (sk_sp< SkShader > shader) |
Set or clear the shader object. More... | |
SkColorFilter * | getColorFilter () const |
Get the paint's colorfilter. More... | |
sk_sp< SkColorFilter > | refColorFilter () const |
void | setColorFilter (sk_sp< SkColorFilter > colorFilter) |
Set or clear the paint's colorfilter. More... | |
SkBlendMode | getBlendMode () const |
bool | isSrcOver () const |
void | setBlendMode (SkBlendMode mode) |
SkPathEffect * | getPathEffect () const |
Get the paint's patheffect object. More... | |
sk_sp< SkPathEffect > | refPathEffect () const |
void | setPathEffect (sk_sp< SkPathEffect > pathEffect) |
Set or clear the patheffect object. More... | |
SkMaskFilter * | getMaskFilter () const |
Get the paint's maskfilter object. More... | |
sk_sp< SkMaskFilter > | refMaskFilter () const |
void | setMaskFilter (sk_sp< SkMaskFilter > maskFilter) |
Set or clear the maskfilter object. More... | |
SkTypeface * | getTypeface () const |
Get the paint's typeface object. More... | |
sk_sp< SkTypeface > | refTypeface () const |
void | setTypeface (sk_sp< SkTypeface > typeface) |
Set or clear the typeface object. More... | |
SkRasterizer * | getRasterizer () const |
Get the paint's rasterizer (or NULL). More... | |
sk_sp< SkRasterizer > | refRasterizer () const |
void | setRasterizer (sk_sp< SkRasterizer > rasterizer) |
Set or clear the rasterizer object. More... | |
SkImageFilter * | getImageFilter () const |
sk_sp< SkImageFilter > | refImageFilter () const |
void | setImageFilter (sk_sp< SkImageFilter > imageFilter) |
SkDrawLooper * | getDrawLooper () const |
Return the paint's SkDrawLooper (if any). More... | |
sk_sp< SkDrawLooper > | refDrawLooper () const |
SkDrawLooper * | getLooper () const |
void | setDrawLooper (sk_sp< SkDrawLooper > drawLooper) |
Set or clear the looper object. More... | |
void | setLooper (sk_sp< SkDrawLooper > drawLooper) |
Align | getTextAlign () const |
Return the paint's Align value for drawing text. More... | |
void | setTextAlign (Align align) |
Set the paint's text alignment. More... | |
SkScalar | getTextSize () const |
Return the paint's text size. More... | |
void | setTextSize (SkScalar textSize) |
Set the paint's text size. More... | |
SkScalar | getTextScaleX () const |
Return the paint's horizontal scale factor for text. More... | |
void | setTextScaleX (SkScalar scaleX) |
Set the paint's horizontal scale factor for text. More... | |
SkScalar | getTextSkewX () const |
Return the paint's horizontal skew factor for text. More... | |
void | setTextSkewX (SkScalar skewX) |
Set the paint's horizontal skew factor for text. More... | |
TextEncoding | getTextEncoding () const |
void | setTextEncoding (TextEncoding encoding) |
SkScalar | getFontMetrics (FontMetrics *metrics, SkScalar scale=0) const |
Return the recommend spacing between lines (which will be fDescent - fAscent + fLeading). More... | |
SkScalar | getFontSpacing () const |
Return the recommend line spacing. More... | |
int | textToGlyphs (const void *text, size_t byteLength, SkGlyphID glyphs[]) const |
Convert the specified text into glyph IDs, returning the number of glyphs ID written. More... | |
bool | containsText (const void *text, size_t byteLength) const |
Return true if all of the specified text has a corresponding non-zero glyph ID. More... | |
void | glyphsToUnichars (const SkGlyphID glyphs[], int count, SkUnichar text[]) const |
Convert the glyph array into Unichars. More... | |
int | countText (const void *text, size_t byteLength) const |
Return the number of drawable units in the specified text buffer. More... | |
SkScalar | measureText (const void *text, size_t length, SkRect *bounds) const |
Return the width of the text. More... | |
SkScalar | measureText (const void *text, size_t length) const |
Return the width of the text. More... | |
size_t | breakText (const void *text, size_t length, SkScalar maxWidth, SkScalar *measuredWidth=NULL) const |
Return the number of bytes of text that were measured. More... | |
int | getTextWidths (const void *text, size_t byteLength, SkScalar widths[], SkRect bounds[]=NULL) const |
Return the advances for the text. More... | |
void | getTextPath (const void *text, size_t length, SkScalar x, SkScalar y, SkPath *path) const |
Return the path (outline) for the specified text. More... | |
void | getPosTextPath (const void *text, size_t length, const SkPoint pos[], SkPath *path) const |
Return the path (outline) for the specified text. More... | |
int | getTextIntercepts (const void *text, size_t length, SkScalar x, SkScalar y, const SkScalar bounds[2], SkScalar *intervals) const |
Return the number of intervals that intersect the intercept along the axis of the advance. More... | |
int | getPosTextIntercepts (const void *text, size_t length, const SkPoint pos[], const SkScalar bounds[2], SkScalar *intervals) const |
Return the number of intervals that intersect the intercept along the axis of the advance. More... | |
int | getPosTextHIntercepts (const void *text, size_t length, const SkScalar xpos[], SkScalar constY, const SkScalar bounds[2], SkScalar *intervals) const |
Return the number of intervals that intersect the intercept along the axis of the advance. More... | |
int | getTextBlobIntercepts (const SkTextBlob *blob, const SkScalar bounds[2], SkScalar *intervals) const |
Return the number of intervals that intersect the intercept along the axis of the advance. More... | |
SkRect | getFontBounds () const |
Return a rectangle that represents the union of the bounds of all of the glyphs, but each one positioned at (0,0). More... | |
bool | nothingToDraw () const |
bool | canComputeFastBounds () const |
Returns true if the current paint settings allow for fast computation of bounds (i.e. More... | |
const SkRect & | computeFastBounds (const SkRect &orig, SkRect *storage) const |
Only call this if canComputeFastBounds() returned true. More... | |
const SkRect & | computeFastStrokeBounds (const SkRect &orig, SkRect *storage) const |
const SkRect & | doComputeFastBounds (const SkRect &orig, SkRect *storage, Style style) const |
Static Public Attributes | |
static constexpr int | kCapCount = kLast_Cap + 1 |
static constexpr int | kJoinCount = kLast_Join + 1 |
Private Member Functions | |
SkScalar | measure_text (SkGlyphCache *, const char *text, size_t length, int *count, SkRect *bounds) const |
void | getScalerContextDescriptor (SkScalerContextEffects *, SkAutoDescriptor *, const SkSurfaceProps &surfaceProps, uint32_t scalerContextFlags, const SkMatrix *) const |
SkGlyphCache * | detachCache (const SkSurfaceProps *surfaceProps, uint32_t scalerContextFlags, const SkMatrix *) const |
void | descriptorProc (const SkSurfaceProps *surfaceProps, uint32_t scalerContextFlags, const SkMatrix *deviceMatrix, void(*proc)(SkTypeface *, const SkScalerContextEffects &, const SkDescriptor *, void *), void *context) const |
SkColor | computeLuminanceColor () const |
SkScalar | setupForAsPaths () |
Static Private Member Functions | |
static GlyphCacheProc | GetGlyphCacheProc (TextEncoding encoding, bool isDevKern, bool needFullMetrics) |
static bool | TooBigToUseCache (const SkMatrix &ctm, const SkMatrix &textM) |
static SkScalar | MaxCacheSize2 () |
Private Attributes | |
sk_sp< SkTypeface > | fTypeface |
sk_sp< SkPathEffect > | fPathEffect |
sk_sp< SkShader > | fShader |
sk_sp< SkMaskFilter > | fMaskFilter |
sk_sp< SkColorFilter > | fColorFilter |
sk_sp< SkRasterizer > | fRasterizer |
sk_sp< SkDrawLooper > | fDrawLooper |
sk_sp< SkImageFilter > | fImageFilter |
SkScalar | fTextSize |
SkScalar | fTextScaleX |
SkScalar | fTextSkewX |
SkColor | fColor |
SkScalar | fWidth |
SkScalar | fMiterLimit |
uint32_t | fBlendMode |
union { | |
struct { | |
unsigned fFlags: 16 | |
unsigned fTextAlign: 2 | |
unsigned fCapType: 2 | |
unsigned fJoinType: 2 | |
unsigned fStyle: 2 | |
unsigned fTextEncoding: 2 | |
unsigned fHinting: 2 | |
unsigned fFilterQuality: 2 | |
} fBitfields | |
uint32_t fBitfieldsUInt | |
}; | |
Friends | |
class | SkAutoGlyphCache |
class | SkAutoGlyphCacheNoGamma |
class | SkCanvas |
class | SkDraw |
class | SkPDFDevice |
class | GrAtlasTextBlob |
class | GrAtlasTextContext |
class | GrStencilAndCoverTextContext |
class | GrPathRendering |
class | GrTextUtils |
class | GrGLPathRendering |
class | SkScalerContext |
class | SkTextBaseIter |
class | SkCanonicalizePaint |
SK_API friend bool | operator== (const SkPaint &a, const SkPaint &b) |
operator== may give false negatives: two paints that draw equivalently may return false. More... | |
bool | operator!= (const SkPaint &a, const SkPaint &b) |
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
enum SkPaint::Cap |
Cap enum specifies the settings for the paint's strokecap.
This is the treatment that is applied to the beginning and end of each non-closed contour (e.g. lines).
If the cap is round or square, the caps are drawn when the contour has a zero length. Zero length contours can be created by following moveTo with a lineTo at the same point, or a moveTo followed by a close.
A dash with an on interval of zero also creates a zero length contour.
The zero length contour draws the square cap without rotation, since the no direction can be inferred.
Enumerator | |
---|---|
kButt_Cap |
begin/end contours with no extension |
kRound_Cap |
begin/end contours with a semi-circle extension |
kSquare_Cap |
begin/end contours with a half square extension |
enum SkPaint::Flags |
Specifies the bit values that are stored in the paint's flags.
Enumerator | |
---|---|
kAntiAlias_Flag |
mask to enable antialiasing |
kDither_Flag |
mask to enable dithering. see setDither() |
kFakeBoldText_Flag |
mask to enable fake-bold text |
kLinearText_Flag |
mask to enable linear-text |
kSubpixelText_Flag |
mask to enable subpixel text positioning |
kDevKernText_Flag |
mask to enable device kerning text |
kLCDRenderText_Flag |
mask to enable subpixel glyph renderering |
kEmbeddedBitmapText_Flag |
mask to enable embedded bitmap strikes |
kAutoHinting_Flag |
mask to force Freetype's autohinter |
enum SkPaint::Hinting |
Specifies the level of hinting to be performed.
These names are taken from the Gnome/Cairo names for the same. They are translated into Freetype concepts the same as in cairo-ft-font.c: kNo_Hinting -> FT_LOAD_NO_HINTING kSlight_Hinting -> FT_LOAD_TARGET_LIGHT kNormal_Hinting -> <default, no option> kFull_Hinting -> <same as kNormalHinting, unless we are rendering subpixel glyphs, in which case TARGET_LCD or TARGET_LCD_V is used>
Enumerator | |
---|---|
kNormal_Hinting |
this is the default |
enum SkPaint::Join |
Join enum specifies the settings for the paint's strokejoin.
This is the treatment that is applied to corners in paths and rectangles.
Enumerator | |
---|---|
kMiter_Join |
connect path segments with a sharp join |
kRound_Join |
connect path segments with a round join |
kBevel_Join |
connect path segments with a flat bevel join |
enum SkPaint::Style |
Styles apply to rect, oval, path, and text.
Bitmaps are always drawn in "fill", and lines are always drawn in "stroke".
Note: strokeandfill implicitly draws the result with SkPath::kWinding_FillType, so if the original path is even-odd, the results may not appear the same as if it was drawn twice, filled and then stroked.
Enumerator | |
---|---|
kFill_Style |
fill the geometry |
kStroke_Style |
stroke the geometry |
kStrokeAndFill_Style |
fill and stroke the geometry |
Describes how to interpret the text parameters that are passed to paint methods like measureText() and getTextWidths().
size_t SkPaint::breakText | ( | const void * | text, |
size_t | length, | ||
SkScalar | maxWidth, | ||
SkScalar * | measuredWidth = NULL |
||
) | const |
Return the number of bytes of text that were measured.
If isVerticalText() is true, then the vertical advances are used for the measurement.
text | The text to be measured |
length | Number of bytes of text to measure |
maxWidth | Maximum width. Only the subset of text whose accumulated widths are <= maxWidth are measured. |
measuredWidth | Optional. If non-null, this returns the actual width of the measured text. |
bool SkPaint::canComputeFastBounds | ( | ) | const |
Returns true if the current paint settings allow for fast computation of bounds (i.e.
there is nothing complex like a patheffect that would make the bounds computation expensive.
Only call this if canComputeFastBounds() returned true.
This takes a raw rectangle (the raw bounds of a shape), and adjusts it for stylistic effects in the paint (e.g. stroking). If needed, it uses the storage rect parameter. It returns the adjusted bounds that can then be used for quickReject tests.
The returned rect will either be orig or storage, thus the caller should not rely on storage being set to the result, but should always use the retured value. It is legal for orig and storage to be the same rect.
e.g. if (paint.canComputeFastBounds()) { SkRect r, storage; path.computeBounds(&r, SkPath::kFast_BoundsType); const SkRect& fastR = paint.computeFastBounds(r, &storage); if (canvas->quickReject(fastR, ...)) { don't draw the path } }
bool SkPaint::containsText | ( | const void * | text, |
size_t | byteLength | ||
) | const |
Return true if all of the specified text has a corresponding non-zero glyph ID.
If any of the code-points in the text are not supported in the typeface (i.e. the glyph ID would be zero), then return false.
If the text encoding for the paint is kGlyph_TextEncoding, then this returns true if all of the specified glyph IDs are non-zero.
|
inline |
Return the number of drawable units in the specified text buffer.
This looks at the current TextEncoding field of the paint. If you also want to have the text converted into glyph IDs, call textToGlyphs instead.
|
inline |
Helper to getColor() that just returns the color's alpha value.
|
inline |
Return the paint's color.
Note that the color is a 32bit value containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b.
|
inline |
Get the paint's colorfilter.
If there is a colorfilter, its reference count is not changed.
|
inline |
Return the paint's SkDrawLooper (if any).
Does not affect the looper's reference count.
bool SkPaint::getFillPath | ( | const SkPath & | src, |
SkPath * | dst, | ||
const SkRect * | cullRect, | ||
SkScalar | resScale = 1 |
||
) | const |
Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
The result is that drawing src with this paint will be the same as drawing dst with a default paint (at least from the geometric perspective).
src | input path |
dst | output path (may be the same as src) |
cullRect | If not null, the dst path may be culled to this rect. |
resScale | If > 1, increase precision, else if (0 < res < 1) reduce precision in favor of speed/size. |
|
inline |
Return the filter level.
This affects the quality (and performance) of drawing scaled images.
|
inline |
Return the paint's flags.
Use the Flag enum to test flag values.
SkRect SkPaint::getFontBounds | ( | ) | const |
Return a rectangle that represents the union of the bounds of all of the glyphs, but each one positioned at (0,0).
This may be conservatively large, and will not take into account any hinting, but will respect any text-scale-x or text-skew-x on this paint.
SkScalar SkPaint::getFontMetrics | ( | FontMetrics * | metrics, |
SkScalar | scale = 0 |
||
) | const |
Return the recommend spacing between lines (which will be fDescent - fAscent + fLeading).
If metrics is not null, return in it the font metrics for the typeface/pointsize/etc. currently set in the paint.
metrics | If not null, returns the font metrics for the current typeface/pointsize/etc setting in this paint. |
scale | If not 0, return width as if the canvas were scaled by this value |
return | the recommended spacing between lines |
|
inline |
Return the recommend line spacing.
This will be fDescent - fAscent + fLeading
uint32_t SkPaint::getHash | ( | ) | const |
|
inline |
Get the paint's maskfilter object.
The maskfilter reference count is not affected.
|
inline |
Get the paint's patheffect object.
The patheffect reference count is not affected.
int SkPaint::getPosTextHIntercepts | ( | const void * | text, |
size_t | length, | ||
const SkScalar | xpos[], | ||
SkScalar | constY, | ||
const SkScalar | bounds[2], | ||
SkScalar * | intervals | ||
) | const |
Return the number of intervals that intersect the intercept along the axis of the advance.
The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in string. The caller may pass nullptr for intervals to determine the size of the interval array, or may conservatively pre-allocate an array with length * 2 entries. The computed intervals are cached by glyph to improve performance for multiple calls. This permits constructing an underline that skips the descenders.
text | The text. |
length | Number of bytes of text. |
xpos | Array of x-positions, used to position each character. |
constY | The shared Y coordinate for all of the positions. |
bounds | The lower and upper line parallel to the advance. |
array | If not null, the glyph bounds contained by the advance parallel lines. |
int SkPaint::getPosTextIntercepts | ( | const void * | text, |
size_t | length, | ||
const SkPoint | pos[], | ||
const SkScalar | bounds[2], | ||
SkScalar * | intervals | ||
) | const |
Return the number of intervals that intersect the intercept along the axis of the advance.
The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in string. The caller may pass nullptr for intervals to determine the size of the interval array, or may conservatively pre-allocate an array with length * 2 entries. The computed intervals are cached by glyph to improve performance for multiple calls. This permits constructing an underline that skips the descenders.
text | the text |
length | number of bytes of text |
pos | array of positions, used to position each character |
bounds | The lower and upper line parallel to the advance. |
array | If not null, the glyph bounds contained by the advance parallel lines. |
void SkPaint::getPosTextPath | ( | const void * | text, |
size_t | length, | ||
const SkPoint | pos[], | ||
SkPath * | path | ||
) | const |
Return the path (outline) for the specified text.
Note: just like SkCanvas::drawText, this will respect the Align setting in the paint.
text | the text |
length | number of bytes of text |
pos | array of positions, used to position each character |
path | The outline of the text. |
|
inline |
Get the paint's rasterizer (or NULL).
The raster controls how paths/text are turned into alpha masks.
|
inline |
Get the paint's shader object.
The shader's reference count is not affected.
|
inline |
Return the paint's stroke cap type, controlling how the start and end of stroked lines and paths are treated.
|
inline |
Return the paint's stroke join type.
|
inline |
Return the paint's stroke miter value.
This is used to control the behavior of miter joins when the joins angle is sharp.
|
inline |
Return the width for stroking.
A value of 0 strokes in hairline mode. Hairlines always draw 1-pixel wide, regardless of the matrix.
|
inline |
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes kFill_Style).
|
inline |
Return the paint's Align value for drawing text.
int SkPaint::getTextBlobIntercepts | ( | const SkTextBlob * | blob, |
const SkScalar | bounds[2], | ||
SkScalar * | intervals | ||
) | const |
Return the number of intervals that intersect the intercept along the axis of the advance.
The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in text blob. The caller may pass nullptr for intervals to determine the size of the interval array. The computed intervals are cached by glyph to improve performance for multiple calls. This permits constructing an underline that skips the descenders.
blob | The text blob. |
bounds | The lower and upper line parallel to the advance. |
array | If not null, the glyph bounds contained by the advance parallel lines. |
int SkPaint::getTextIntercepts | ( | const void * | text, |
size_t | length, | ||
SkScalar | x, | ||
SkScalar | y, | ||
const SkScalar | bounds[2], | ||
SkScalar * | intervals | ||
) | const |
Return the number of intervals that intersect the intercept along the axis of the advance.
The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in the string. The caller may pass nullptr for intervals to determine the size of the interval array, or may conservatively pre-allocate an array with length * 2 entries. The computed intervals are cached by glyph to improve performance for multiple calls. This permits constructing an underline that skips the descenders.
text | the text |
length | number of bytes of text |
x | The x-coordinate of the origin of the text. |
y | The y-coordinate of the origin of the text. |
bounds | The lower and upper line parallel to the advance. |
array | If not null, the found intersections. |
void SkPaint::getTextPath | ( | const void * | text, |
size_t | length, | ||
SkScalar | x, | ||
SkScalar | y, | ||
SkPath * | path | ||
) | const |
Return the path (outline) for the specified text.
Note: just like SkCanvas::drawText, this will respect the Align setting in the paint.
text | the text |
length | number of bytes of text |
x | The x-coordinate of the origin of the text. |
y | The y-coordinate of the origin of the text. |
path | The outline of the text. |
|
inline |
Return the paint's horizontal scale factor for text.
The default value is 1.0.
|
inline |
Return the paint's text size.
|
inline |
Return the paint's horizontal skew factor for text.
The default value is 0.
int SkPaint::getTextWidths | ( | const void * | text, |
size_t | byteLength, | ||
SkScalar | widths[], | ||
SkRect | bounds[] = NULL |
||
) | const |
Return the advances for the text.
These will be vertical advances if isVerticalText() returns true.
text | the text |
byteLength | number of bytes to of text |
widths | If not null, returns the array of advances for the glyphs. If not NULL, must be at least a large as the number of unichars in the specified text. |
bounds | If not null, returns the bounds for each of character, relative to (0, 0) |
|
inline |
Get the paint's typeface object.
The typeface object identifies which font to use when drawing or measuring text. The typeface reference count is not affected.
Convert the glyph array into Unichars.
Unconvertable glyphs are mapped to zero. Note: this does not look at the text-encoding setting in the paint, only at the typeface.
|
inline |
Helper for getFlags(), returning true if kAntiAlias_Flag bit is set.
|
inline |
Helper for getFlags(), returns true if kDevKernText_Flag bit is set.
|
inline |
Helper for getFlags(), returning true if kDither_Flag bit is set.
|
inline |
Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set.
|
inline |
Helper for getFlags(), returning true if kLinearText_Flag bit is set.
|
inline |
Helper for getFlags(), returning true if kSubpixelText_Flag bit is set.
SkScalar SkPaint::measureText | ( | const void * | text, |
size_t | length, | ||
SkRect * | bounds | ||
) | const |
Return the width of the text.
This will return the vertical measure if isVerticalText() is true, in which case the returned value should be treated has a height instead of a width.
text | The text to be measured |
length | Number of bytes of text to measure |
bounds | If not NULL, returns the bounds of the text, relative to (0, 0). |
|
inline |
Return the width of the text.
This will return the vertical measure if isVerticalText() is true, in which case the returned value should be treated has a height instead of a width.
text | Address of the text |
length | Number of bytes of text to measure |
void SkPaint::setAlpha | ( | U8CPU | a | ) |
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.
a | set the alpha component (0..255) of the paint's color. |
void SkPaint::setAntiAlias | ( | bool | aa | ) |
Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit.
aa | true to enable antialiasing, false to disable it |
Helper to setColor(), that takes a,r,g,b and constructs the color value using SkColorSetARGB()
a | The new alpha component (0..255) of the paint's color. |
r | The new red component (0..255) of the paint's color. |
g | The new green component (0..255) of the paint's color. |
b | The new blue component (0..255) of the paint's color. |
void SkPaint::setAutohinted | ( | bool | useAutohinter | ) |
Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit.
useAutohinter | true to set the kEmbeddedBitmapText bit in the paint's flags, false to clear it. |
void SkPaint::setColor | ( | SkColor | color | ) |
Set the paint's color.
Note that the color is a 32bit value containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b.
color | The new color (including alpha) to set in the paint. |
void SkPaint::setColorFilter | ( | sk_sp< SkColorFilter > | colorFilter | ) |
Set or clear the paint's colorfilter.
If the paint already has a filter, its reference count is decremented. If filter is not NULL, its reference count is incremented.
filter | May be NULL. The filter to be installed in the paint |
void SkPaint::setDevKernText | ( | bool | devKernText | ) |
Helper for setFlags(), setting or clearing the kKernText_Flag bit.
kernText | true to set the kKernText_Flag bit in the paint's flags, false to clear it. |
void SkPaint::setDither | ( | bool | dither | ) |
Helper for setFlags(), setting or clearing the kDither_Flag bit.
dither | true to enable dithering, false to disable it |
Note: gradients ignore this setting and always dither.
void SkPaint::setDrawLooper | ( | sk_sp< SkDrawLooper > | drawLooper | ) |
Set or clear the looper object.
Pass NULL to clear any previous looper. If a previous looper exists in the paint, its reference count is decremented. If looper is not NULL, its reference count is incremented.
looper | May be NULL. The new looper to be installed in the paint. |
void SkPaint::setEmbeddedBitmapText | ( | bool | useEmbeddedBitmapText | ) |
Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit.
useEmbeddedBitmapText | true to set the kEmbeddedBitmapText bit in the paint's flags, false to clear it. |
void SkPaint::setFakeBoldText | ( | bool | fakeBoldText | ) |
Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit.
fakeBoldText | true to set the kFakeBoldText_Flag bit in the paint's flags, false to clear it. |
void SkPaint::setFilterQuality | ( | SkFilterQuality | quality | ) |
Set the filter quality.
This affects the quality (and performance) of drawing scaled images.
void SkPaint::setFlags | ( | uint32_t | flags | ) |
Set the paint's flags.
Use the Flag enum to specific flag values.
flags | The new flag bits for the paint (see Flags enum) |
void SkPaint::setLCDRenderText | ( | bool | lcdText | ) |
Helper for setFlags(), setting or clearing the kLCDRenderText_Flag.
Note: antialiasing must also be on for lcd rendering
lcdText | true to set the LCDRenderText bit in the paint's flags, false to clear it. |
void SkPaint::setLinearText | ( | bool | linearText | ) |
Helper for setFlags(), setting or clearing the kLinearText_Flag bit.
linearText | true to set the linearText bit in the paint's flags, false to clear it. |
void SkPaint::setMaskFilter | ( | sk_sp< SkMaskFilter > | maskFilter | ) |
Set or clear the maskfilter object.
Pass NULL to clear any previous maskfilter. As a convenience, the parameter passed is also returned. If a previous maskfilter exists, its reference count is decremented. If maskfilter is not NULL, its reference count is incremented.
maskfilter | May be NULL. The new maskfilter to be installed in the paint |
void SkPaint::setPathEffect | ( | sk_sp< SkPathEffect > | pathEffect | ) |
Set or clear the patheffect object.
Pass NULL to clear any previous patheffect. As a convenience, the parameter passed is also returned. If a previous patheffect exists, its reference count is decremented. If patheffect is not NULL, its reference count is incremented.
effect | May be NULL. The new patheffect to be installed in the paint |
void SkPaint::setRasterizer | ( | sk_sp< SkRasterizer > | rasterizer | ) |
Set or clear the rasterizer object.
Pass NULL to clear any previous rasterizer. As a convenience, the parameter passed is also returned. If a previous rasterizer exists in the paint, its reference count is decremented. If rasterizer is not NULL, its reference count is incremented.
rasterizer | May be NULL. The new rasterizer to be installed in the paint. |
Set or clear the shader object.
Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint's color is used. If the paint has a shader, then the shader's color(s) are use instead, but they are modulated by the paint's alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader... only the paint's alpha needs to be modified.
There is an exception to this only-respect-paint's-alpha rule: If the shader only generates alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's colortype is kAlpha_8) then the shader will use the paint's entire color to "colorize" its output (modulating the bitmap's alpha with the paint's color+alpha).
Pass NULL to clear any previous shader. As a convenience, the parameter passed is also returned. If a previous shader exists, its reference count is decremented. If shader is not NULL, its reference count is incremented.
shader | May be NULL. The shader to be installed in the paint |
void SkPaint::setStrokeCap | ( | Cap | cap | ) |
Set the paint's stroke cap type.
cap | set the paint's line cap style, used whenever the paint's style is Stroke or StrokeAndFill. |
void SkPaint::setStrokeJoin | ( | Join | join | ) |
Set the paint's stroke join type.
join | set the paint's line join style, used whenever the paint's style is Stroke or StrokeAndFill. |
void SkPaint::setStrokeMiter | ( | SkScalar | miter | ) |
Set the paint's stroke miter value.
This is used to control the behavior of miter joins when the joins angle is sharp. This value must be >= 0.
miter | set the miter limit on the paint, used whenever the paint's style is Stroke or StrokeAndFill. |
void SkPaint::setStrokeWidth | ( | SkScalar | width | ) |
Set the width for stroking.
Pass 0 to stroke in hairline mode. Hairlines always draw 1-pixel wide, regardless of the matrix.
width | set the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill. |
void SkPaint::setStyle | ( | Style | style | ) |
Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill).
style | The new style to set in the paint |
void SkPaint::setSubpixelText | ( | bool | subpixelText | ) |
Helper for setFlags(), setting or clearing the kSubpixelText_Flag.
subpixelText | true to set the subpixelText bit in the paint's flags, false to clear it. |
void SkPaint::setTextAlign | ( | Align | align | ) |
Set the paint's text alignment.
align | set the paint's Align value for drawing text. |
void SkPaint::setTextScaleX | ( | SkScalar | scaleX | ) |
Set the paint's horizontal scale factor for text.
The default value is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will stretch the text narrower.
scaleX | set the paint's scale factor in X for drawing/measuring text. |
void SkPaint::setTextSize | ( | SkScalar | textSize | ) |
Set the paint's text size.
This value must be > 0
textSize | set the paint's text size. |
void SkPaint::setTextSkewX | ( | SkScalar | skewX | ) |
Set the paint's horizontal skew factor for text.
The default value is 0. For approximating oblique text, use values around -0.25.
skewX | set the paint's skew factor in X for drawing text. |
void SkPaint::setTypeface | ( | sk_sp< SkTypeface > | typeface | ) |
Set or clear the typeface object.
Pass NULL to clear any previous typeface. As a convenience, the parameter passed is also returned. If a previous typeface exists, its reference count is decremented. If typeface is not NULL, its reference count is incremented.
typeface | May be NULL. The new typeface to be installed in the paint |
void SkPaint::setVerticalText | ( | bool | verticalText | ) |
Helper for setting or clearing the kVerticalText_Flag bit in setFlags(...).
If this bit is set, then advances are treated as Y values rather than X values, and drawText will places its glyphs vertically rather than horizontally.
int SkPaint::textToGlyphs | ( | const void * | text, |
size_t | byteLength, | ||
SkGlyphID | glyphs[] | ||
) | const |
Convert the specified text into glyph IDs, returning the number of glyphs ID written.
If glyphs is NULL, it is ignore and only the count is returned.
operator== may give false negatives: two paints that draw equivalently may return false.
It will never give false positives: two paints that are not equivalent always return false.