#include <SkCanvas.h>
Inherits SkRefCnt.
Classes | |
class | LayerIter |
Public Types | |
enum | SaveFlags { kMatrix_SaveFlag = 0x01, kClip_SaveFlag = 0x02, kHasAlphaLayer_SaveFlag = 0x04, kFullColorLayer_SaveFlag = 0x08, kClipToLayer_SaveFlag = 0x10, kMatrixClip_SaveFlag = 0x03, kARGB_NoClipLayer_SaveFlag = 0x0F, kARGB_ClipLayer_SaveFlag = 0x1F } |
enum | EdgeType { kBW_EdgeType, kAA_EdgeType } |
enum | PointMode { kPoints_PointMode, kLines_PointMode, kPolygon_PointMode } |
enum | VertexMode { kTriangles_VertexMode, kTriangleStrip_VertexMode, kTriangleFan_VertexMode } |
Public Member Functions | |
SkCanvas (const SkBitmap &bitmap) | |
SkCanvas (SkDevice *device=NULL) | |
virtual | ~SkCanvas () |
virtual bool | getViewport (SkIPoint *size) const |
virtual bool | setViewport (int x, int y) |
SkDevice * | getDevice () const |
SkDevice * | setDevice (SkDevice *device) |
virtual SkDevice * | setBitmapDevice (const SkBitmap &bitmap) |
virtual int | save (SaveFlags flags=kMatrixClip_SaveFlag) |
virtual int | saveLayer (const SkRect *bounds, const SkPaint *paint, SaveFlags flags=kARGB_ClipLayer_SaveFlag) |
int | saveLayerAlpha (const SkRect *bounds, U8CPU alpha, SaveFlags flags=kARGB_ClipLayer_SaveFlag) |
virtual void | restore () |
int | getSaveCount () const |
void | restoreToCount (int saveCount) |
virtual bool | translate (SkScalar dx, SkScalar dy) |
virtual bool | scale (SkScalar sx, SkScalar sy) |
virtual bool | rotate (SkScalar degrees) |
virtual bool | skew (SkScalar sx, SkScalar sy) |
virtual bool | concat (const SkMatrix &matrix) |
virtual void | setMatrix (const SkMatrix &matrix) |
void | resetMatrix () |
virtual bool | clipRect (const SkRect &rect, SkRegion::Op op=SkRegion::kIntersect_Op) |
virtual bool | clipPath (const SkPath &path, SkRegion::Op op=SkRegion::kIntersect_Op) |
virtual bool | clipRegion (const SkRegion &deviceRgn, SkRegion::Op op=SkRegion::kIntersect_Op) |
bool | setClipRegion (const SkRegion &deviceRgn) |
bool | quickReject (const SkRect &rect, EdgeType et) const |
bool | quickReject (const SkPath &path, EdgeType et) const |
bool | quickRejectY (SkScalar top, SkScalar bottom, EdgeType et) const |
bool | getClipBounds (SkRect *bounds, EdgeType et=kAA_EdgeType) const |
void | drawARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkXfermode::Mode mode=SkXfermode::kSrcOver_Mode) |
void | drawColor (SkColor color, SkXfermode::Mode mode=SkXfermode::kSrcOver_Mode) |
virtual void | drawPaint (const SkPaint &paint) |
virtual void | drawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) |
void | drawPoint (SkScalar x, SkScalar y, const SkPaint &paint) |
void | drawPoint (SkScalar x, SkScalar y, SkColor color) |
void | drawLine (SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint) |
virtual void | drawRect (const SkRect &rect, const SkPaint &paint) |
void | drawIRect (const SkIRect &rect, const SkPaint &paint) |
void | drawRectCoords (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint &paint) |
void | drawOval (const SkRect &oval, const SkPaint &) |
void | drawCircle (SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint) |
void | drawArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) |
void | drawRoundRect (const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint) |
virtual void | drawPath (const SkPath &path, const SkPaint &paint) |
virtual void | drawBitmap (const SkBitmap &bitmap, SkScalar left, SkScalar top, const SkPaint *paint=NULL) |
virtual void | drawBitmapRect (const SkBitmap &bitmap, const SkIRect *src, const SkRect &dst, const SkPaint *paint=NULL) |
virtual void | drawBitmapMatrix (const SkBitmap &bitmap, const SkMatrix &m, const SkPaint *paint=NULL) |
virtual void | drawSprite (const SkBitmap &bitmap, int left, int top, const SkPaint *paint=NULL) |
virtual void | drawText (const void *text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint &paint) |
virtual void | drawPosText (const void *text, size_t byteLength, const SkPoint pos[], const SkPaint &paint) |
virtual void | drawPosTextH (const void *text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint &paint) |
void | drawTextOnPathHV (const void *text, size_t byteLength, const SkPath &path, SkScalar hOffset, SkScalar vOffset, const SkPaint &paint) |
virtual void | drawTextOnPath (const void *text, size_t byteLength, const SkPath &path, const SkMatrix *matrix, const SkPaint &paint) |
virtual void | drawPicture (SkPicture &picture) |
virtual void | drawShape (SkShape *) |
virtual void | drawVertices (VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], SkXfermode *xmode, const uint16_t indices[], int indexCount, const SkPaint &paint) |
SkBounder * | getBounder () const |
virtual SkBounder * | setBounder (SkBounder *bounder) |
SkDrawFilter * | getDrawFilter () const |
virtual SkDrawFilter * | setDrawFilter (SkDrawFilter *filter) |
const SkMatrix & | getTotalMatrix () const |
const SkRegion & | getTotalClip () const |
virtual SkDevice * | createDevice (SkBitmap::Config, int width, int height, bool isOpaque, bool isForLayer) |
Protected Member Functions | |
virtual void | commonDrawBitmap (const SkBitmap &, const SkMatrix &m, const SkPaint &paint) |
Friends | |
class | SkDrawIter |
A Canvas encapsulates all of the state about drawing into a device (bitmap). This includes a reference to the device itself, and a stack of matrix/clip values. For any given draw call (e.g. drawRect), the geometry of the object being drawn is transformed by the concatenation of all the matrices in the stack. The transformed geometry is clipped by the intersection of all of the clips in the stack.
While the Canvas holds the state of the drawing device, the state (style) of the object being drawn is held by the Paint, which is provided as a parameter to each of the draw() methods. The Paint holds attributes such as color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), etc.
Definition at line 52 of file SkCanvas.h.
enum SkCanvas::EdgeType |
Enum describing how to treat edges when performing quick-reject tests of a geometry against the current clip. Treating them as antialiased (kAA_EdgeType) will take into account the extra pixels that may be drawn if the edge does not lie exactly on a device pixel boundary (after being transformed by the current matrix).
Definition at line 263 of file SkCanvas.h.
enum SkCanvas::PointMode |
kPoints_PointMode |
drawPoints draws each point separately |
kLines_PointMode |
drawPoints draws each pair of points as a line segment |
kPolygon_PointMode |
drawPoints draws the array of points as a polygon |
Definition at line 342 of file SkCanvas.h.
enum SkCanvas::SaveFlags |
kMatrix_SaveFlag |
save the matrix state, restoring it on restore() |
kClip_SaveFlag |
save the clip state, restoring it on restore() |
kHasAlphaLayer_SaveFlag |
the layer needs to support per-pixel alpha |
kFullColorLayer_SaveFlag |
the layer needs to support 8-bits per color component |
kClipToLayer_SaveFlag |
the layer should clip against the bounds argument |
kMatrixClip_SaveFlag | |
kARGB_NoClipLayer_SaveFlag | |
kARGB_ClipLayer_SaveFlag |
Definition at line 100 of file SkCanvas.h.
enum SkCanvas::VertexMode |
Definition at line 599 of file SkCanvas.h.
SkCanvas::SkCanvas | ( | const SkBitmap & | bitmap | ) | [explicit] |
Construct a canvas with the specified bitmap to draw into.
bitmap | Specifies a bitmap for the canvas to draw into. Its structure are copied to the canvas. |
SkCanvas::SkCanvas | ( | SkDevice * | device = NULL |
) | [explicit] |
Construct a canvas with the specified device to draw into.
device | Specifies a device for the canvas to draw into. The device may be null. |
virtual SkCanvas::~SkCanvas | ( | ) | [virtual] |
virtual bool SkCanvas::clipPath | ( | const SkPath & | path, | |
SkRegion::Op | op = SkRegion::kIntersect_Op | |||
) | [virtual] |
Modify the current clip with the specified path.
path | The path to apply to the current clip | |
op | The region op to apply to the current clip |
virtual bool SkCanvas::clipRect | ( | const SkRect & | rect, | |
SkRegion::Op | op = SkRegion::kIntersect_Op | |||
) | [virtual] |
Modify the current clip with the specified rectangle.
rect | The rect to intersect with the current clip | |
op | The region op to apply to the current clip |
virtual bool SkCanvas::clipRegion | ( | const SkRegion & | deviceRgn, | |
SkRegion::Op | op = SkRegion::kIntersect_Op | |||
) | [virtual] |
Modify the current clip with the specified region. Note that unlike clipRect() and clipPath() which transform their arguments by the current matrix, clipRegion() assumes its argument is already in device coordinates, and so no transformation is performed.
deviceRgn | The region to apply to the current clip | |
op | The region op to apply to the current clip |
virtual void SkCanvas::commonDrawBitmap | ( | const SkBitmap & | , | |
const SkMatrix & | m, | |||
const SkPaint & | paint | |||
) | [protected, virtual] |
virtual bool SkCanvas::concat | ( | const SkMatrix & | matrix | ) | [virtual] |
Preconcat the current matrix with the specified matrix.
matrix | The matrix to preconcatenate with the current matrix |
virtual SkDevice* SkCanvas::createDevice | ( | SkBitmap::Config | , | |
int | width, | |||
int | height, | |||
bool | isOpaque, | |||
bool | isForLayer | |||
) | [virtual] |
May be overridden by subclasses. This returns a compatible device for this canvas, with the specified config/width/height. If isOpaque is true, then the underlying bitmap is optimized to assume that every pixel will be drawn to, and thus it does not need to clear the alpha channel ahead of time (assuming the specified config supports per-pixel alpha.) If isOpaque is false, then the bitmap should clear its alpha channel.
void SkCanvas::drawArc | ( | const SkRect & | oval, | |
SkScalar | startAngle, | |||
SkScalar | sweepAngle, | |||
bool | useCenter, | |||
const SkPaint & | paint | |||
) |
Draw the specified arc, which will be scaled to fit inside the specified oval. If the sweep angle is >= 360, then the oval is drawn completely. Note that this differs slightly from SkPath::arcTo, which treats the sweep angle mod 360.
oval | The bounds of oval used to define the shape of the arc | |
startAngle | Starting angle (in degrees) where the arc begins | |
sweepAngle | Sweep angle (in degrees) measured clockwise | |
useCenter | true means include the center of the oval. For filling this will draw a wedge. False means just use the arc. | |
paint | The paint used to draw the arc |
void SkCanvas::drawARGB | ( | U8CPU | a, | |
U8CPU | r, | |||
U8CPU | g, | |||
U8CPU | b, | |||
SkXfermode::Mode | mode = SkXfermode::kSrcOver_Mode | |||
) |
Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB color, using the specified mode.
a | the alpha component (0..255) of the color to fill the canvas | |
r | the red component (0..255) of the color to fill the canvas | |
g | the green component (0..255) of the color to fill the canvas | |
b | the blue component (0..255) of the color to fill the canvas | |
mode | the mode to apply the color in (defaults to SrcOver) |
virtual void SkCanvas::drawBitmap | ( | const SkBitmap & | bitmap, | |
SkScalar | left, | |||
SkScalar | top, | |||
const SkPaint * | paint = NULL | |||
) | [virtual] |
Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix. Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height, then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
bitmap | The bitmap to be drawn | |
left | The position of the left side of the bitmap being drawn | |
top | The position of the top side of the bitmap being drawn | |
paint | The paint used to draw the bitmap, or NULL |
virtual void SkCanvas::drawBitmapMatrix | ( | const SkBitmap & | bitmap, | |
const SkMatrix & | m, | |||
const SkPaint * | paint = NULL | |||
) | [virtual] |
virtual void SkCanvas::drawBitmapRect | ( | const SkBitmap & | bitmap, | |
const SkIRect * | src, | |||
const SkRect & | dst, | |||
const SkPaint * | paint = NULL | |||
) | [virtual] |
Draw the specified bitmap, with the specified matrix applied (before the canvas' matrix is applied).
bitmap | The bitmap to be drawn | |
src | Optional: specify the subset of the bitmap to be drawn | |
dst | The destination rectangle where the scaled/translated image will be drawn | |
paint | The paint used to draw the bitmap, or NULL |
Draw the specified circle using the specified paint. If radius is <= 0, then nothing will be drawn. The circle will be filled or framed based on the Style in the paint.
cx | The x-coordinate of the center of the cirle to be drawn | |
cy | The y-coordinate of the center of the cirle to be drawn | |
radius | The radius of the cirle to be drawn | |
paint | The paint used to draw the circle |
void SkCanvas::drawColor | ( | SkColor | color, | |
SkXfermode::Mode | mode = SkXfermode::kSrcOver_Mode | |||
) |
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and mode.
color | the color to draw with | |
mode | the mode to apply the color in (defaults to SrcOver) |
Draw the specified rectangle using the specified paint. The rectangle will be filled or framed based on the Style in the paint.
rect | The rect to be drawn | |
paint | The paint used to draw the rect |
Definition at line 411 of file SkCanvas.h.
void SkCanvas::drawLine | ( | SkScalar | x0, | |
SkScalar | y0, | |||
SkScalar | x1, | |||
SkScalar | y1, | |||
const SkPaint & | paint | |||
) |
Draw a line segment with the specified start and stop x,y coordinates, using the specified paint. NOTE: since a line is always "framed", the paint's Style is ignored.
x0 | The x-coordinate of the start point of the line | |
y0 | The y-coordinate of the start point of the line | |
x1 | The x-coordinate of the end point of the line | |
y1 | The y-coordinate of the end point of the line | |
paint | The paint used to draw the line |
Draw the specified oval using the specified paint. The oval will be filled or framed based on the Style in the paint.
oval | The rectangle bounds of the oval to be drawn | |
paint | The paint used to draw the oval |
virtual void SkCanvas::drawPaint | ( | const SkPaint & | paint | ) | [virtual] |
Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.
paint | The paint used to fill the canvas |
Draw the specified path using the specified paint. The path will be filled or framed based on the Style in the paint.
path | The path to be drawn | |
paint | The paint used to draw the path |
virtual void SkCanvas::drawPicture | ( | SkPicture & | picture | ) | [virtual] |
Draw the picture into this canvas. This method effective brackets the playback of the picture's draw calls with save/restore, so the state of this canvas will be unchanged after this call. This contrasts with the more immediate method SkPicture::draw(), which does not bracket the canvas with save/restore, thus the canvas may be left in a changed state after the call.
picture | The recorded drawing commands to playback into this canvas. |
Draws a single pixel in the specified color.
x | The X coordinate of which pixel to draw | |
y | The Y coordiante of which pixel to draw | |
color | The color to draw |
Helper method for drawing a single point. See drawPoints() for a more details.
virtual void SkCanvas::drawPoints | ( | PointMode | mode, | |
size_t | count, | |||
const SkPoint | pts[], | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw a series of points, interpreted based on the PointMode mode. For all modes, the count parameter is interpreted as the total number of points. For kLine mode, count/2 line segments are drawn. For kPoint mode, each point is drawn centered at its coordinate, and its size is specified by the paint's stroke-width. It draws as a square, unless the paint's cap-type is round, in which the points are drawn as circles. For kLine mode, each pair of points is drawn as a line segment, respecting the paint's settings for cap/join/width. For kPolygon mode, the entire array is drawn as a series of connected line segments. Note that, while similar, kLine and kPolygon modes draw slightly differently than the equivalent path built with a series of moveto, lineto calls, in that the path will draw all of its contours at once, with no interactions if contours intersect each other (think XOR xfermode). drawPoints always draws each element one at a time.
mode | PointMode specifying how to draw the array of points. | |
count | The number of points in the array | |
pts | Array of points to draw | |
paint | The paint used to draw the points |
virtual void SkCanvas::drawPosText | ( | const void * | text, | |
size_t | byteLength, | |||
const SkPoint | pos[], | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw the text, with each character/glyph origin specified by the pos[] array. The origin is interpreted by the Align setting in the paint.
text | The text to be drawn | |
byteLength | The number of bytes to read from the text parameter | |
pos | Array of positions, used to position each character | |
paint | The paint used for the text (e.g. color, size, style) |
virtual void SkCanvas::drawPosTextH | ( | const void * | text, | |
size_t | byteLength, | |||
const SkScalar | xpos[], | |||
SkScalar | constY, | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw the text, with each character/glyph origin specified by the x coordinate taken from the xpos[] array, and the y from the constY param. The origin is interpreted by the Align setting in the paint.
text | The text to be drawn | |
byteLength | The number of bytes to read from the text parameter | |
xpos | Array of x-positions, used to position each character | |
constY | The shared Y coordinate for all of the positions | |
paint | The paint used for the text (e.g. color, size, style) |
Draw the specified rectangle using the specified paint. The rectangle will be filled or stroked based on the Style in the paint.
rect | The rect to be drawn | |
paint | The paint used to draw the rect |
void SkCanvas::drawRectCoords | ( | SkScalar | left, | |
SkScalar | top, | |||
SkScalar | right, | |||
SkScalar | bottom, | |||
const SkPaint & | paint | |||
) |
Draw the specified rectangle using the specified paint. The rectangle will be filled or framed based on the Style in the paint.
left | The left side of the rectangle to be drawn | |
top | The top side of the rectangle to be drawn | |
right | The right side of the rectangle to be drawn | |
bottom | The bottom side of the rectangle to be drawn | |
paint | The paint used to draw the rect |
void SkCanvas::drawRoundRect | ( | const SkRect & | rect, | |
SkScalar | rx, | |||
SkScalar | ry, | |||
const SkPaint & | paint | |||
) |
Draw the specified round-rect using the specified paint. The round-rect will be filled or framed based on the Style in the paint.
rect | The rectangular bounds of the roundRect to be drawn | |
rx | The x-radius of the oval used to round the corners | |
ry | The y-radius of the oval used to round the corners | |
paint | The paint used to draw the roundRect |
virtual void SkCanvas::drawShape | ( | SkShape * | ) | [virtual] |
Draws the specified shape
virtual void SkCanvas::drawSprite | ( | const SkBitmap & | bitmap, | |
int | left, | |||
int | top, | |||
const SkPaint * | paint = NULL | |||
) | [virtual] |
Draw the specified bitmap, with its top/left corner at (x,y), NOT transformed by the current matrix. Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height, then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
bitmap | The bitmap to be drawn | |
left | The position of the left side of the bitmap being drawn | |
top | The position of the top side of the bitmap being drawn | |
paint | The paint used to draw the bitmap, or NULL |
virtual void SkCanvas::drawText | ( | const void * | text, | |
size_t | byteLength, | |||
SkScalar | x, | |||
SkScalar | y, | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw the text, with origin at (x,y), using the specified paint. The origin is interpreted based on the Align setting in the paint.
text | The text to be drawn | |
byteLength | The number of bytes to read from the text parameter | |
x | The x-coordinate of the origin of the text being drawn | |
y | The y-coordinate of the origin of the text being drawn | |
paint | The paint used for the text (e.g. color, size, style) |
virtual void SkCanvas::drawTextOnPath | ( | const void * | text, | |
size_t | byteLength, | |||
const SkPath & | path, | |||
const SkMatrix * | matrix, | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw the text, with origin at (x,y), using the specified paint, along the specified path. The paint's Align setting determins where along the path to start the text.
text | The text to be drawn | |
byteLength | The number of bytes to read from the text parameter | |
path | The path the text should follow for its baseline | |
matrix | (may be null) Applied to the text before it is mapped onto the path | |
paint | The paint used for the text |
void SkCanvas::drawTextOnPathHV | ( | const void * | text, | |
size_t | byteLength, | |||
const SkPath & | path, | |||
SkScalar | hOffset, | |||
SkScalar | vOffset, | |||
const SkPaint & | paint | |||
) |
Draw the text, with origin at (x,y), using the specified paint, along the specified path. The paint's Align setting determins where along the path to start the text.
text | The text to be drawn | |
byteLength | The number of bytes to read from the text parameter | |
path | The path the text should follow for its baseline | |
hOffset | The distance along the path to add to the text's starting position | |
vOffset | The distance above(-) or below(+) the path to position the text | |
paint | The paint used for the text |
virtual void SkCanvas::drawVertices | ( | VertexMode | vmode, | |
int | vertexCount, | |||
const SkPoint | vertices[], | |||
const SkPoint | texs[], | |||
const SkColor | colors[], | |||
SkXfermode * | xmode, | |||
const uint16_t | indices[], | |||
int | indexCount, | |||
const SkPaint & | paint | |||
) | [virtual] |
Draw the array of vertices, interpreted as triangles (based on mode).
vmode | How to interpret the array of vertices | |
vertexCount | The number of points in the vertices array (and corresponding texs and colors arrays if non-null) | |
vertices | Array of vertices for the mesh | |
texs | May be null. If not null, specifies the coordinate in texture space for each vertex. | |
colors | May be null. If not null, specifies a color for each vertex, to be interpolated across the triangle. | |
xmode | Used if both texs and colors are present. In this case the colors are combined with the texture using mode, before being drawn using the paint. If mode is null, then kMultiply_Mode is used. | |
indices | If not null, array of indices to reference into the vertex (texs, colors) array. | |
indexCount | number of entries in the indices array (if not null) | |
paint | Specifies the shader/texture if present. |
SkBounder* SkCanvas::getBounder | ( | ) | const [inline] |
Get the current bounder object. The bounder's reference count is unchaged.
Definition at line 635 of file SkCanvas.h.
Return the bounds of the current clip (in local coordinates) in the bounds parameter, and return true if it is non-empty. This can be useful in a way similar to quickReject, in that it tells you that drawing outside of these bounds will be clipped out.
SkDevice* SkCanvas::getDevice | ( | ) | const |
Return the canvas' device object, which may be null. The device holds the bitmap of the pixels that the canvas draws into. The reference count of the returned device is not changed by this call.
SkDrawFilter* SkCanvas::getDrawFilter | ( | ) | const |
Get the current filter object. The filter's reference count is not affected. The filter is part of the state this is affected by save/restore.
int SkCanvas::getSaveCount | ( | ) | const |
const SkRegion& SkCanvas::getTotalClip | ( | ) | const |
Return the current device clip (concatenation of all clip calls). This does not account for the translate in any of the devices.
const SkMatrix& SkCanvas::getTotalMatrix | ( | ) | const |
Return the current matrix on the canvas. This does not account for the translate in any of the devices.
virtual bool SkCanvas::getViewport | ( | SkIPoint * | size | ) | const [virtual] |
If this subclass of SkCanvas supports GL viewports, return true and set size (if not null) to the size of the viewport. If it is not supported, ignore vp and return false.
Return true if the specified path, after being transformed by the current matrix, would lie completely outside of the current clip. Call this to check if an area you intend to draw into is clipped out (and therefore you can skip making the draw calls). Note, for speed it may return false even if the path itself might not intersect the clip (i.e. the bounds of the path intersects, but the path does not).
path | The path to compare with the current clip | |
et | specifies how to treat the edges (see EdgeType) |
Return true if the specified rectangle, after being transformed by the current matrix, would lie completely outside of the current clip. Call this to check if an area you intend to draw into is clipped out (and therefore you can skip making the draw calls).
rect | the rect to compare with the current clip | |
et | specifies how to treat the edges (see EdgeType) |
Return true if the horizontal band specified by top and bottom is completely clipped out. This is a conservative calculation, meaning that it is possible that if the method returns false, the band may still in fact be clipped out, but the converse is not true. If this method returns true, then the band is guaranteed to be clipped out.
top | The top of the horizontal band to compare with the clip | |
bottom | The bottom of the horizontal and to compare with the clip |
void SkCanvas::resetMatrix | ( | ) |
Helper for setMatrix(identity). Sets the current matrix to identity.
virtual void SkCanvas::restore | ( | ) | [virtual] |
void SkCanvas::restoreToCount | ( | int | saveCount | ) |
Efficient way to pop any calls to save() that happened after the save count reached saveCount. It is an error for saveCount to be less than getSaveCount()
saveCount | The number of save() levels to restore from |
virtual bool SkCanvas::rotate | ( | SkScalar | degrees | ) | [virtual] |
Preconcat the current matrix with the specified rotation.
degrees | The amount to rotate, in degrees returns true if the operation succeeded (e.g. did not overflow) |
virtual int SkCanvas::save | ( | SaveFlags | flags = kMatrixClip_SaveFlag |
) | [virtual] |
This call saves the current matrix and clip information, and pushes a copy onto a private stack. Subsequent calls to translate, scale, rotate, skew, concat or clipRect, clipPath all operate on this copy. When the balancing call to restore() is made, this copy is deleted and the previous matrix/clip state is restored.
virtual int SkCanvas::saveLayer | ( | const SkRect * | bounds, | |
const SkPaint * | paint, | |||
SaveFlags | flags = kARGB_ClipLayer_SaveFlag | |||
) | [virtual] |
This behaves the same as save(), but in addition it allocates an offscreen bitmap. All drawing calls are directed there, and only when the balancing call to restore() is made is that offscreen transfered to the canvas (or the previous layer). Subsequent calls to translate, scale, rotate, skew, concat or clipRect, clipPath all operate on this copy. When the balancing call to restore() is made, this copy is deleted and the previous matrix/clip state is restored.
bounds | (may be null) the maximum size the offscreen bitmap needs to be (in local coordinates) | |
paint | (may be null) This is copied, and is applied to the offscreen when restore() is called | |
flags | LayerFlags |
int SkCanvas::saveLayerAlpha | ( | const SkRect * | bounds, | |
U8CPU | alpha, | |||
SaveFlags | flags = kARGB_ClipLayer_SaveFlag | |||
) |
This behaves the same as save(), but in addition it allocates an offscreen bitmap. All drawing calls are directed there, and only when the balancing call to restore() is made is that offscreen transfered to the canvas (or the previous layer). Subsequent calls to translate, scale, rotate, skew, concat or clipRect, clipPath all operate on this copy. When the balancing call to restore() is made, this copy is deleted and the previous matrix/clip state is restored.
bounds | (may be null) the maximum size the offscreen bitmap needs to be (in local coordinates) | |
alpha | This is applied to the offscreen when restore() is called. | |
flags | LayerFlags |
Preconcat the current matrix with the specified scale.
sx | The amount to scale in X | |
sy | The amount to scale in Y returns true if the operation succeeded (e.g. did not overflow) |
Specify a bitmap for the canvas to draw into. This is a help method for setDevice(), and it creates a device for the bitmap by calling createDevice(). The structure of the bitmap is copied into the device.
Set a new bounder (or NULL). Pass NULL to clear any previous bounder. As a convenience, the parameter passed is also returned. If a previous bounder exists, its reference count is decremented. If bounder is not NULL, its reference count is incremented.
bounder | the new bounder (or NULL) to be installed in the canvas |
bool SkCanvas::setClipRegion | ( | const SkRegion & | deviceRgn | ) | [inline] |
Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the specified region. This does not intersect or in any other way account for the existing clip region.
deviceRgn | The region to copy into the current clip. |
Definition at line 253 of file SkCanvas.h.
Specify a device for this canvas to draw into. If it is not null, its reference count is incremented. If the canvas was already holding a device, its reference count is decremented. The new device is returned.
virtual SkDrawFilter* SkCanvas::setDrawFilter | ( | SkDrawFilter * | filter | ) | [virtual] |
Set the new filter (or NULL). Pass NULL to clear any existing filter. As a convenience, the parameter is returned. If an existing filter exists, its refcnt is decrement. If the new filter is not null, its refcnt is incremented. The filter is part of the state this is affected by save/restore.
filter | the new filter (or NULL) |
virtual void SkCanvas::setMatrix | ( | const SkMatrix & | matrix | ) | [virtual] |
Replace the current matrix with a copy of the specified matrix.
matrix | The matrix that will be copied into the current matrix. |
virtual bool SkCanvas::setViewport | ( | int | x, | |
int | y | |||
) | [virtual] |
If this subclass of SkCanvas supports GL viewports, return true and set the viewport to the specified x and y dimensions. If it is not supported, ignore x and y and return false.
Preconcat the current matrix with the specified skew.
sx | The amount to skew in X | |
sy | The amount to skew in Y returns true if the operation succeeded (e.g. did not overflow) |
Preconcat the current matrix with the specified translation
dx | The distance to translate in X | |
dy | The distance to translate in Y returns true if the operation succeeded (e.g. did not overflow) |
friend class SkDrawIter [friend] |
Definition at line 751 of file SkCanvas.h.