#include <SkPaint.h>
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition at line 51 of file SkPaint.h.
enum SkPaint::Align |
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).
enum SkPaint::Flags |
Specifies the bit values that are stored in the paint's flags.
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>
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.
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.
Specify the direction the text buffer should be processed in breakText()
kForward_TextBufferDirection |
When measuring text for breakText(), begin at the start of the text buffer and proceed forward through the data. This is the default. |
kBackward_TextBufferDirection |
When measuring text for breakText(), begin at the end of the text buffer and proceed backwards through the data. |
Describes how to interpret the text parameters that are passed to paint methods like measureText() and getTextWidths().
SkPaint::SkPaint | ( | ) |
SkPaint::SkPaint | ( | const SkPaint & | paint | ) |
SkPaint::~SkPaint | ( | ) |
size_t SkPaint::breakText | ( | const void * | text, | |
size_t | length, | |||
SkScalar | maxWidth, | |||
SkScalar * | measuredWidth = NULL , |
|||
TextBufferDirection | tbd = kForward_TextBufferDirection | |||
) | const |
Return the width of the text.
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. | |
tbd | Optional. The direction the text buffer should be traversed during measuring. |
bool SkPaint::canComputeFastBounds | ( | ) | const [inline] |
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 } }
int SkPaint::countText | ( | const void * | text, | |
size_t | byteLength | |||
) | const [inline] |
void SkPaint::flatten | ( | SkFlattenableWriteBuffer & | ) | const |
uint8_t SkPaint::getAlpha | ( | ) | const [inline] |
Helper to getColor() that just returns the color's alpha value.
SkColor SkPaint::getColor | ( | ) | const [inline] |
SkColorFilter* SkPaint::getColorFilter | ( | ) | const [inline] |
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) |
uint32_t SkPaint::getFlags | ( | ) | const [inline] |
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 |
SkScalar SkPaint::getFontSpacing | ( | ) | const [inline] |
SkDrawLooper* SkPaint::getLooper | ( | ) | const [inline] |
SkMaskFilter* SkPaint::getMaskFilter | ( | ) | const [inline] |
SkPathEffect* SkPaint::getPathEffect | ( | ) | const [inline] |
SkRasterizer* SkPaint::getRasterizer | ( | ) | const [inline] |
SkShader* SkPaint::getShader | ( | ) | const [inline] |
Cap SkPaint::getStrokeCap | ( | ) | const [inline] |
Join SkPaint::getStrokeJoin | ( | ) | const [inline] |
SkScalar SkPaint::getStrokeMiter | ( | ) | const [inline] |
SkScalar SkPaint::getStrokeWidth | ( | ) | const [inline] |
Style SkPaint::getStyle | ( | ) | const [inline] |
Align SkPaint::getTextAlign | ( | ) | const [inline] |
TextEncoding SkPaint::getTextEncoding | ( | ) | const [inline] |
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.
SkScalar SkPaint::getTextScaleX | ( | ) | const [inline] |
SkScalar SkPaint::getTextSize | ( | ) | const [inline] |
SkScalar SkPaint::getTextSkewX | ( | ) | const [inline] |
int SkPaint::getTextWidths | ( | const void * | text, | |
size_t | byteLength, | |||
SkScalar | widths[], | |||
SkRect | bounds[] = NULL | |||
) | const |
Return the advance widths for the characters in the string.
text | the text | |
byteLength | number of bytes to of text | |
widths | If not null, returns the array of advance widths of 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) |
SkTypeface* SkPaint::getTypeface | ( | ) | const [inline] |
SkXfermode* SkPaint::getXfermode | ( | ) | const [inline] |
bool SkPaint::isAntiAlias | ( | ) | const [inline] |
Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
bool SkPaint::isDevKernText | ( | ) | const [inline] |
Helper for getFlags(), returns true if kDevKernText_Flag bit is set
bool SkPaint::isDither | ( | ) | const [inline] |
Helper for getFlags(), returning true if kDither_Flag bit is set
bool SkPaint::isFakeBoldText | ( | ) | const [inline] |
Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set
bool SkPaint::isLinearText | ( | ) | const [inline] |
Helper for getFlags(), returning true if kLinearText_Flag bit is set
bool SkPaint::isStrikeThruText | ( | ) | const [inline] |
Helper for getFlags(), returns true if kStrikeThruText_Flag bit is set
bool SkPaint::isSubpixelText | ( | ) | const [inline] |
Helper for getFlags(), returning true if kSubpixelText_Flag bit is set
bool SkPaint::isUnderlineText | ( | ) | const [inline] |
Helper for getFlags(), returning true if kUnderlineText_Flag bit is set
SkScalar SkPaint::measureText | ( | const void * | text, | |
size_t | length | |||
) | const [inline] |
SkScalar SkPaint::measureText | ( | const void * | text, | |
size_t | length, | |||
SkRect * | bounds, | |||
SkScalar | scale = 0 | |||
) | const |
Return the width of the text.
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). | |
scale | If not 0, return width as if the canvas were scaled by this value |
void SkPaint::reset | ( | ) |
Restores the paint to its initial settings.
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::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. |
SkColorFilter* SkPaint::setColorFilter | ( | SkColorFilter * | filter | ) |
Set or clear the paint's colorfilter, returning the parameter.
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 |
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::setFilterBitmap | ( | bool | filterBitmap | ) |
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 | subpixelRender | ) |
Helper for setFlags(), setting or clearing the kLCDRenderText_Flag bit
subpixelRender | true to set the subpixelRenderText 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. |
SkDrawLooper* SkPaint::setLooper | ( | SkDrawLooper * | ) |
SkMaskFilter* SkPaint::setMaskFilter | ( | 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 |
SkPathEffect* SkPaint::setPathEffect | ( | SkPathEffect * | effect | ) |
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 |
SkRasterizer* SkPaint::setRasterizer | ( | 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.
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::setStrikeThruText | ( | bool | strikeThruText | ) |
Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit
strikeThruText | true to set the strikeThruText bit in the paint's flags, false to clear it. |
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 bit
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::setTextEncoding | ( | TextEncoding | encoding | ) |
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. |
SkTypeface* SkPaint::setTypeface | ( | 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::setUnderlineText | ( | bool | underlineText | ) |
Helper for setFlags(), setting or clearing the kUnderlineText_Flag bit
underlineText | true to set the underlineText bit in the paint's flags, false to clear it. |
SkXfermode* SkPaint::setXfermode | ( | SkXfermode * | xfermode | ) |
Set or clear the xfermode object.
Pass NULL to clear any previous xfermode. As a convenience, the parameter passed is also returned. If a previous xfermode exists, its reference count is decremented. If xfermode is not NULL, its reference count is incremented.
xfermode | May be NULL. The new xfermode to be installed in the paint |
SkXfermode* SkPaint::setXfermodeMode | ( | SkXfermode::Mode | ) |
Create an xfermode based on the specified Mode, and assign it into the paint, returning the mode that was set. If the Mode is SrcOver, then the paint's xfermode is set to null.
int SkPaint::textToGlyphs | ( | const void * | text, | |
size_t | byteLength, | |||
uint16_t | 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.
void SkPaint::unflatten | ( | SkFlattenableReadBuffer & | ) |
friend class SkTextToPathIter [friend] |