SkProxyCanvas Class Reference

#include <SkProxyCanvas.h>

Inherits SkCanvas.

Collaboration diagram for SkProxyCanvas:
[legend]

List of all members.

Public Member Functions

 SkProxyCanvas ()
 SkProxyCanvas (SkCanvas *proxy)
virtual ~SkProxyCanvas ()
SkCanvasgetProxy () const
void setProxy (SkCanvas *proxy)
virtual bool getViewport (SkIPoint *size) const
virtual bool setViewport (int x, int y)
virtual SkDevicesetBitmapDevice (const SkBitmap &bitmap)
virtual int save (SaveFlags flags=kMatrixClip_SaveFlag)
virtual int saveLayer (const SkRect *bounds, const SkPaint *paint, SaveFlags flags=kARGB_ClipLayer_SaveFlag)
virtual void restore ()
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)
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)
virtual void drawPaint (const SkPaint &paint)
virtual void drawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
virtual void drawRect (const SkRect &rect, 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)
virtual void drawTextOnPath (const void *text, size_t byteLength, const SkPath &path, const SkMatrix *matrix, const SkPaint &paint)
virtual void drawPicture (SkPicture &)
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)
virtual SkBoundersetBounder (SkBounder *bounder)
virtual SkDrawFiltersetDrawFilter (SkDrawFilter *filter)
virtual SkDevicecreateDevice (SkBitmap::Config, int width, int height, bool isOpaque, bool isForLayer)

Detailed Description

This class overrides all virtual methods on SkCanvas, and redirects them to a "proxy", another SkCanvas instance. It can be the basis for intercepting (and possibly modifying) calls to a canvas.

There must be a proxy installed before the proxycanvas can be used (i.e. before its virtual methods can be called).

Definition at line 13 of file SkProxyCanvas.h.


Constructor & Destructor Documentation

SkProxyCanvas::SkProxyCanvas (  )  [inline]

Definition at line 15 of file SkProxyCanvas.h.

SkProxyCanvas::SkProxyCanvas ( SkCanvas proxy  ) 
virtual SkProxyCanvas::~SkProxyCanvas (  )  [virtual]

Member Function Documentation

virtual bool SkProxyCanvas::clipPath ( const SkPath path,
SkRegion::Op  op = SkRegion::kIntersect_Op 
) [virtual]

Modify the current clip with the specified path.

Parameters:
path The path to apply to the current clip
op The region op to apply to the current clip
Returns:
true if the canvas' new clip is non-empty

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::clipRect ( const SkRect rect,
SkRegion::Op  op = SkRegion::kIntersect_Op 
) [virtual]

Modify the current clip with the specified rectangle.

Parameters:
rect The rect to intersect with the current clip
op The region op to apply to the current clip
Returns:
true if the canvas' clip is non-empty

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::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.

Parameters:
deviceRgn The region to apply to the current clip
op The region op to apply to the current clip
Returns:
true if the canvas' new clip is non-empty

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::concat ( const SkMatrix matrix  )  [virtual]

Preconcat the current matrix with the specified matrix.

Parameters:
matrix The matrix to preconcatenate with the current matrix
Returns:
true if the operation succeeded (e.g. did not overflow)

Reimplemented from SkCanvas.

virtual SkDevice* SkProxyCanvas::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.

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::drawBitmapMatrix ( const SkBitmap bitmap,
const SkMatrix m,
const SkPaint paint = NULL 
) [virtual]

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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).

Parameters:
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

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::drawPaint ( const SkPaint paint  )  [virtual]

Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.

Parameters:
paint The paint used to fill the canvas

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::drawPath ( const SkPath path,
const SkPaint paint 
) [virtual]

Draw the specified path using the specified paint. The path will be filled or framed based on the Style in the paint.

Parameters:
path The path to be drawn
paint The paint used to draw the path

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
picture The recorded drawing commands to playback into this canvas.

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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)

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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)

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::drawRect ( const SkRect rect,
const SkPaint paint 
) [virtual]

Draw the specified rectangle using the specified paint. The rectangle will be filled or stroked based on the Style in the paint.

Parameters:
rect The rect to be drawn
paint The paint used to draw the rect

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::drawShape ( SkShape  )  [virtual]

Draws the specified shape

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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)

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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.

Parameters:
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

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::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).

Parameters:
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.

Reimplemented from SkCanvas.

SkCanvas* SkProxyCanvas::getProxy (  )  const [inline]

Definition at line 19 of file SkProxyCanvas.h.

virtual bool SkProxyCanvas::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.

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::restore (  )  [virtual]

This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. It is an error to call restore() more times than save() was called.

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::rotate ( SkScalar  degrees  )  [virtual]

Preconcat the current matrix with the specified rotation.

Parameters:
degrees The amount to rotate, in degrees returns true if the operation succeeded (e.g. did not overflow)

Reimplemented from SkCanvas.

virtual int SkProxyCanvas::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.

Returns:
The value to pass to restoreToCount() to balance this save()

Reimplemented from SkCanvas.

virtual int SkProxyCanvas::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.

Parameters:
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
Returns:
The value to pass to restoreToCount() to balance this save()

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::scale ( SkScalar  sx,
SkScalar  sy 
) [virtual]

Preconcat the current matrix with the specified scale.

Parameters:
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)

Reimplemented from SkCanvas.

virtual SkDevice* SkProxyCanvas::setBitmapDevice ( const SkBitmap bitmap  )  [virtual]

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.

Reimplemented from SkCanvas.

virtual SkBounder* SkProxyCanvas::setBounder ( SkBounder bounder  )  [virtual]

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.

Parameters:
bounder the new bounder (or NULL) to be installed in the canvas
Returns:
the set bounder object

Reimplemented from SkCanvas.

virtual SkDrawFilter* SkProxyCanvas::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.

Parameters:
filter the new filter (or NULL)
Returns:
the new filter

Reimplemented from SkCanvas.

virtual void SkProxyCanvas::setMatrix ( const SkMatrix matrix  )  [virtual]

Replace the current matrix with a copy of the specified matrix.

Parameters:
matrix The matrix that will be copied into the current matrix.

Reimplemented from SkCanvas.

void SkProxyCanvas::setProxy ( SkCanvas proxy  ) 
virtual bool SkProxyCanvas::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.

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::skew ( SkScalar  sx,
SkScalar  sy 
) [virtual]

Preconcat the current matrix with the specified skew.

Parameters:
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)

Reimplemented from SkCanvas.

virtual bool SkProxyCanvas::translate ( SkScalar  dx,
SkScalar  dy 
) [virtual]

Preconcat the current matrix with the specified translation

Parameters:
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)

Reimplemented from SkCanvas.


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

Generated on Tue Oct 20 10:33:05 2009 for Skia by  doxygen 1.6.1