English | Site Directory

Android - An Open Handset Alliance Project

android.graphics
public class

android.graphics.Canvas

java.lang.Object
android.graphics.Canvas

The Canvas class holds the "draw" calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).

Nested Classes

Summary

Constants

      Value  
int  CLIP_SAVE_FLAG  restore the current clip when restore() is called   0x00000002 
int  CLIP_TO_LAYER_SAVE_FLAG  clip against the layer's bounds   16  0x00000010 
int  FULL_COLOR_LAYER_SAVE_FLAG  the layer needs to 8-bits per color component   0x00000008 
int  HAS_ALPHA_LAYER_SAVE_FLAG  the layer needs to per-pixel alpha   0x00000004 
int  MATRIX_SAVE_FLAG  restore the current matrix when restore() is called   0x00000001 

Public Constructors

          Canvas()
Construct an empty canvas.
          Canvas(Bitmap bitmap)
Construct a canvas with the specified bitmap to draw into.

Public Methods

        boolean  clipPath(Path path)
Intersect the current clip with the specified path.
        boolean  clipPath(Path path, Op op)
Modify the current clip with the specified path.
        boolean  clipRect(float left, float top, float right, float bottom)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRect(Rect rect)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRect(float left, float top, float right, float bottom, Op op)
Modify the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRect(Rect rect, Op op)
Modify the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRect(RectF rect)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRect(RectF rect, Op op)
Modify the current clip with the specified rectangle.
        boolean  clipRect(int left, int top, int right, int bottom)
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
        boolean  clipRegion(Region region, Op op)
Modify the current clip with the specified region.
        boolean  clipRegion(Region region)
Intersect the current clip with the specified region.
        void  concat(Matrix matrix)
Preconcat the current matrix with the specified matrix.
        void  drawARGB(int a, int r, int g, int b)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB color, using srcover porterduff mode.
        void  drawArc(RectF oval, float startAngle, float sweepAngle, Paint paint)
Draw the specified arc, which will be scaled to fit inside the specified oval.
        void  drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
        void  drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.
        void  drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
        void  drawCircle(float cx, float cy, float radius, Paint paint)
Draw the specified circle using the specified paint.
        void  drawColor(int color)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode.
        void  drawColor(int color, Mode mode)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and porter-duff xfermode.
        void  drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.
        void  drawOval(RectF oval, Paint paint)
Draw the specified oval using the specified paint.
        void  drawPaint(Paint paint)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.
        void  drawPath(Path path, Paint paint)
Draw the specified path using the specified paint.
        void  drawPicture(Picture picture)
Save the canvas state, draw the picture, and restore the canvas state.
        void  drawPoint(float x, float y, Paint paint)
Helper for drawPoints() for drawing a single point.
        void  drawPoints(float[] pts, int offset, int length, Paint paint)
Draw a series of points.
        void  drawPoints(float[] pts, Paint paint)
Helper for drawPoints() that assumes you want to draw the entire array
        void  drawPosText(char[] text, int index, int count, float[] pos, Paint paint)
Draw the text in the array, with each character's origin specified by the pos array.
        void  drawPosText(String text, float[] pos, Paint paint)
Draw the text in the array, with each character's origin specified by the pos array.
        void  drawRGB(int r, int g, int b)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified RGB color, using srcover porterduff mode.
        void  drawRect(RectF rect, Paint paint)
Draw the specified Rect using the specified paint.
        void  drawRect(float left, float top, float right, float bottom, Paint paint)
Draw the specified Rect using the specified paint.
        void  drawRect(Rect r, Paint paint)
Draw the specified Rect using the specified Paint.
        void  drawRoundRect(RectF rect, float rx, float ry, Paint paint)
Draw the specified round-rect using the specified paint.
        void  drawText(String text, int start, int end, float x, float y, Paint paint)
Draw the text, with origin at (x,y), using the specified paint.
        void  drawText(char[] text, int index, int count, float x, float y, Paint paint)
Draw the text, with origin at (x,y), using the specified paint.
        void  drawText(String text, float x, float y, Paint paint)
Draw the text, with origin at (x,y), using the specified paint.
        void  drawText(CharSequence text, int start, int end, float x, float y, Paint paint)
Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint.
        void  drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
        void  drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
        int  getBitmapHeight()
Returns the height of the current drawing layer
        int  getBitmapWidth()
Returns the width of the current drawing layer
    final    Matrix  getCTM()
Return a new matrix with a copy of the canvas' current transformation matrix.
        void  getCTM(Matrix ctm)
Return, in ctm, the current transformation matrix.
        boolean  getClipBounds(Rect bounds)
Retrieve the clip bounds, returning true if they are non-empty.
    final    Rect  getClipBounds()
Retrieve the clip bounds.
        DrawFilter  getDrawFilter()
        int  getSaveCount()
Returns the number of matrix/clip states on the Canvas' private stack.
        boolean  isBitmapOpaque()
Return true if the bitmap that the current layer draws into is opaque (i.e.
        boolean  quickReject(Path path, EdgeType type)
Return true if the specified path, after being transformed by the current matrix, would lie completely outside of the current clip.
        boolean  quickReject(float left, float top, float right, float bottom, EdgeType type)
Return true if the specified rectangle, after being transformed by the current matrix, would lie completely outside of the current clip.
        boolean  quickReject(RectF rect, EdgeType type)
Return true if the specified rectangle, after being transformed by the current matrix, would lie completely outside of the current clip.
        void  restore()
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.
        void  restoreToCount(int saveCount)
Efficient way to pop any calls to save() that happened after the save count reached saveCount.
    final    void  rotate(float degrees, float px, float py)
Preconcat the current matrix with the specified rotation.
        void  rotate(float degrees)
Preconcat the current matrix with the specified rotation.
        int  save()
Saves the current matrix and clip onto a private stack.
        int  save(int saveFlags)
Based on saveFlags, can save the current matrix and clip onto a private stack.
        int  saveLayer(float left, float top, float right, float bottom, Paint paint, int saveFlags)
Helper version of saveLayer() that takes 4 values rather than a RectF.
        int  saveLayer(RectF bounds, Paint paint, int saveFlags)
This behaves the same as save(), but in addition it allocates an offscreen bitmap.
        int  saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags)
Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
        int  saveLayerAlpha(RectF bounds, int alpha, int saveFlags)
This behaves the same as save(), but in addition it allocates an offscreen bitmap.
    final    void  scale(float sx, float sy, float px, float py)
Preconcat the current matrix with the specified scale.
        void  scale(float sx, float sy)
Preconcat the current matrix with the specified scale.
        void  setDevice(Bitmap bitmap)
Specify a bitmap for the canvas to draw into.
        void  setDrawFilter(DrawFilter filter)
        void  skew(float sx, float sy)
Preconcat the current matrix with the specified skew.
        void  translate(float dx, float dy)
Preconcat the current matrix with the specified translation

Protected Methods

        void  finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
Methods inherited from class java.lang.Object

Details

Constants

public static final int CLIP_SAVE_FLAG

restore the current clip when restore() is called
Constant Value: 2 (0x00000002)

public static final int CLIP_TO_LAYER_SAVE_FLAG

clip against the layer's bounds
Constant Value: 16 (0x00000010)

public static final int FULL_COLOR_LAYER_SAVE_FLAG

the layer needs to 8-bits per color component
Constant Value: 8 (0x00000008)

public static final int HAS_ALPHA_LAYER_SAVE_FLAG

the layer needs to per-pixel alpha
Constant Value: 4 (0x00000004)

public static final int MATRIX_SAVE_FLAG

restore the current matrix when restore() is called
Constant Value: 1 (0x00000001)

Public Constructors

public Canvas()

Construct an empty canvas. Use setDevice() to specify a bitmap to draw into.

public Canvas(Bitmap bitmap)

Construct a canvas with the specified bitmap to draw into. The bitmap must be mutable, or an exception will be thrown.

Parameters

bitmap Specifies a mutable bitmap for the canvas to draw into.

Public Methods

public boolean clipPath(Path path)

Intersect the current clip with the specified path.

Parameters

path The path to intersect with the current clip

Returns

  • true if the resulting is non-empty

public boolean clipPath(Path path, Op op)

Modify the current clip with the specified path.

Parameters

path The path to operate on the current clip
op How the clip is modified

Returns

  • true if the resulting is non-empty

public boolean clipRect(float left, float top, float right, float bottom)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

left The left side of the rectangle to intersect with the current clip
top The top of the rectangle to intersect with the current clip
right The right side of the rectangle to intersect with the current clip
bottom The bottom of the rectangle to intersect with the current clip

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(Rect rect)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

rect The rectangle to intersect with the current clip.

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(float left, float top, float right, float bottom, Op op)

Modify the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

left The left side of the rectangle to intersect with the current clip
top The top of the rectangle to intersect with the current clip
right The right side of the rectangle to intersect with the current clip
bottom The bottom of the rectangle to intersect with the current clip
op How the clip is modified

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(Rect rect, Op op)

Modify the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

rect The rectangle to intersect with the current clip.
op How the clip is modified

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(RectF rect)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

rect The rectangle to intersect with the current clip.

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(RectF rect, Op op)

Modify the current clip with the specified rectangle.

Parameters

rect The rect to intersect with the current clip
op How the clip is modified

Returns

  • true if the resulting clip is non-empty

public boolean clipRect(int left, int top, int right, int bottom)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

Parameters

left The left side of the rectangle to intersect with the current clip
top The top of the rectangle to intersect with the current clip
right The right side of the rectangle to intersect with the current clip
bottom The bottom of the rectangle to intersect with the current clip

Returns

  • true if the resulting clip is non-empty

public boolean clipRegion(Region region, Op op)

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 the coordinate system of the current layer's bitmap, and so not transformation is performed.

Parameters

region The region to operate on the current clip, based on op
op How the clip is modified

Returns

  • true if the resulting is non-empty

public boolean clipRegion(Region region)

Intersect 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 the coordinate system of the current layer's bitmap, and so not transformation is performed.

Parameters

region The region to operate on the current clip, based on op

Returns

  • true if the resulting is non-empty

public void concat(Matrix matrix)

Preconcat the current matrix with the specified matrix.

Parameters

matrix The matrix to preconcatenate with the current matrix

public void drawARGB(int a, int r, int g, int b)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB color, using srcover porterduff mode.

Parameters

a alpha component (0..255) of the color to draw onto the canvas
r red component (0..255) of the color to draw onto the canvas
g green component (0..255) of the color to draw onto the canvas
b blue component (0..255) of the color to draw onto the canvas

public void drawArc(RectF oval, float startAngle, float sweepAngle, Paint paint)

Draw the specified arc, which will be scaled to fit inside the specified oval.

Parameters

oval The bounds of oval used to define the shape and size of the arc
startAngle Starting angle (in degrees) where the arc begins
sweepAngle Sweep angle (in degrees) measured clockwise
paint The paint used to draw the arc

public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw. Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), 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
src May be null. The subset of the bitmap to be drawn
dst The rectangle that the bitmap will be scaled/translated to fit into
paint May be null. The paint used to draw the bitmap

public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint)

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 (e.g. BlurMaskFilter), 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 (may be null)

public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw. Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), 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
src May be null. The subset of the bitmap to be drawn
dst The rectangle that the bitmap will be scaled/translated to fit into
paint May be null. The paint used to draw the bitmap

public void drawCircle(float cx, float cy, float radius, Paint paint)

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.

Parameters

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

public void drawColor(int color)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode.

Parameters

color the color to draw onto the canvas

public void drawColor(int color, Mode mode)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and porter-duff xfermode.

Parameters

color the color to draw with
mode the porter-duff mode to apply to the color

public void drawLine(float startX, float startY, float stopX, float stopY, Paint 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 Style is ignored in the paint.

Parameters

startX The x-coordinate of the start point of the line
startY The y-coordinate of the start point of the line
paint The paint used to draw the line

public void drawOval(RectF oval, Paint paint)

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

Parameters

oval The rectangle bounds of the oval to be drawn

public void drawPaint(Paint paint)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint. This is equivalent (but faster) to drawing an infinitely large rectangle with the specified paint.

Parameters

paint The paint used to draw onto the canvas

public void drawPath(Path path, Paint paint)

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

public void drawPicture(Picture picture)

Save the canvas state, draw the picture, and restore the canvas state.

Parameters

picture The picture to be drawn

public void drawPoint(float x, float y, Paint paint)

Helper for drawPoints() for drawing a single point.

public void drawPoints(float[] pts, int offset, int length, Paint paint)

Draw a series of points. Each point is centered at the coordinate specified by pts[], and its diameter is specified by the paint's stroke width (as transformed by the canvas' CTM), with special treatment for a stroke width of 0, which always draws exactly 1 pixel (or at most 4 if antialiasing is enabled). The shape of the point is controlled by the paint's Cap type. The shape is a square, unless the cap type is Round, in which case the shape is a circle.

Parameters

pts Array of points to draw [x0 y0 x1 y1 x2 y2 ...]
offset Logical index of the first point to draw (internally this becomes offset*2 to find the first [x ...] value)
length The logical number of points to draw (internally this becomes length*2 to know how many floats to process)
paint The paint used to draw the points

public void drawPoints(float[] pts, Paint paint)

Helper for drawPoints() that assumes you want to draw the entire array

public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint)

Draw the text in the array, with each character's origin specified by the pos array.

Parameters

text The text to be drawn
index The index of the first character to draw
count The number of characters to draw, starting from index.
pos Array of [x,y] positions, used to position each character
paint The paint used for the text (e.g. color, size, style)

public void drawPosText(String text, float[] pos, Paint paint)

Draw the text in the array, with each character's origin specified by the pos array.

Parameters

text The text to be drawn
pos Array of [x,y] positions, used to position each character
paint The paint used for the text (e.g. color, size, style)

public void drawRGB(int r, int g, int b)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified RGB color, using srcover porterduff mode.

Parameters

r red component (0..255) of the color to draw onto the canvas
g green component (0..255) of the color to draw onto the canvas
b blue component (0..255) of the color to draw onto the canvas

public void drawRect(RectF rect, Paint paint)

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

Parameters

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

public void drawRect(float left, float top, float right, float bottom, Paint paint)

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

Parameters

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

public void drawRect(Rect r, Paint paint)

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

Parameters

r The rectangle to be drawn.
paint The paint used to draw the rectangle

public void drawRoundRect(RectF rect, float rx, float ry, Paint paint)

Draw the specified round-rect using the specified paint. The roundrect will be filled or framed based on the Style in the paint.

Parameters

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

public void drawText(String text, int start, int end, float x, float y, Paint paint)

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
start The index of the first character in text to draw
end (end - 1) is the index of the last character in text to draw
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)

public void drawText(char[] text, int index, int count, float x, float y, Paint paint)

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

public void drawText(String text, float x, float y, Paint paint)

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

public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint)

Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint. The origin is interpreted based on the Align setting in the Paint.

Parameters

text The text to be drawn
start The index of the first character in text to draw
end (end - 1) is the index of the last character in text to draw
x The x-coordinate of origin for where to draw the text
y The y-coordinate of origin for where to draw the text
paint The paint used for the text (e.g. color, size, style)

public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint 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.

Parameters

text The text to be drawn
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 (e.g. color, size, style)

public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint 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.

Parameters

text The text to be drawn
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 (e.g. color, size, style)

public int getBitmapHeight()

Returns the height of the current drawing layer

Returns

  • the height of the current drawing layer

public int getBitmapWidth()

Returns the width of the current drawing layer

Returns

  • the width of the current drawing layer

public final Matrix getCTM()

Return a new matrix with a copy of the canvas' current transformation matrix.

public void getCTM(Matrix ctm)

Return, in ctm, the current transformation matrix. This does not alter the matrix in the canvas, but just returns a copy of it.

public boolean getClipBounds(Rect bounds)

Retrieve the clip bounds, returning true if they are non-empty.

Parameters

bounds Return the clip bounds here. If it is null, ignore it but still return true if the current clip is non-empty.

Returns

  • true if the current clip is non-empty.

public final Rect getClipBounds()

Retrieve the clip bounds.

Returns

  • the clip bounds, or [0, 0, 0, 0] if the clip is empty.

public DrawFilter getDrawFilter()

public int getSaveCount()

Returns the number of matrix/clip states on the Canvas' private stack. This will equal # save() calls - # restore() calls.

public boolean isBitmapOpaque()

Return true if the bitmap that the current layer draws into is opaque (i.e. does not support per-pixel alpha).

Returns

  • true if the bitmap that the current layer draws into is opaque

public boolean quickReject(Path path, EdgeType type)

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).

Parameters

path The path to compare with the current clip
type true if the path should be considered antialiased, since that means it may affect a larger area (more pixels) than non-antialiased.

Returns

  • true if the path (transformed by the canvas' matrix) does not intersect with the canvas' clip

public boolean quickReject(float left, float top, float right, float bottom, EdgeType type)

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).

Parameters

left The left side of the rectangle to compare with the current clip
top The top of the rectangle to compare with the current clip
right The right side of the rectangle to compare with the current clip
bottom The bottom of the rectangle to compare with the current clip
type true if the rect should be considered antialiased, since that means it may affect a larger area (more pixels) than non-antialiased.

Returns

  • true if the rect (transformed by the canvas' matrix) does not intersect with the canvas' clip

public boolean quickReject(RectF rect, EdgeType type)

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).

Parameters

rect the rect to compare with the current clip
type specifies how to treat the edges (BW or antialiased)

Returns

  • true if the rect (transformed by the canvas' matrix) does not intersect with the canvas' clip

public void restore()

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.

public void 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()