skia2/site/user/api/SkCanvas_Reference.md

5248 lines
296 KiB
Markdown
Raw Normal View History

SkCanvas Reference
===
# <a name="Canvas"></a> Canvas
<a href="SkCanvas_Reference#Canvas">Canvas</a> provides an interface for drawing, and how the drawing is clipped and transformed.
<a href="SkCanvas_Reference#Canvas">Canvas</a> contains a stack of <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> values.
<a href="SkCanvas_Reference#Canvas">Canvas</a> and <a href="SkPaint_Reference#Paint">Paint</a> together provide the state to draw into <a href="undocumented#Surface">Surface</a> or <a href="undocumented#Device">Device</a>.
Each <a href="SkCanvas_Reference#Canvas">Canvas</a> draw call transforms the geometry of the object by the concatenation of all
<a href="SkCanvas_Reference#Matrix">Matrix</a> values in the stack. The transformed geometry is clipped by the intersection
of all of <a href="SkCanvas_Reference#Clip">Clip</a> values in the stack. The <a href="SkCanvas_Reference#Canvas">Canvas</a> draw calls use <a href="SkPaint_Reference#Paint">Paint</a> to supply drawing
state such as <a href="undocumented#Color">Color</a>, <a href="undocumented#Typeface">Typeface</a>, text size, stroke width, <a href="undocumented#Shader">Shader</a> and so on.
To draw to a pixel-based destination, create <a href="undocumented#Raster_Surface">Raster Surface</a> or <a href="undocumented#GPU_Surface">GPU Surface</a>.
Request <a href="SkCanvas_Reference#Canvas">Canvas</a> from <a href="undocumented#Surface">Surface</a> to obtain the interface to draw.
<a href="SkCanvas_Reference#Canvas">Canvas</a> generated by <a href="undocumented#Raster_Surface">Raster Surface</a> draws to memory visible to the <a href="undocumented#CPU">CPU</a>.
<a href="SkCanvas_Reference#Canvas">Canvas</a> generated by <a href="undocumented#GPU_Surface">GPU Surface</a> uses <a href="undocumented#Vulkan">Vulkan</a> or <a href="undocumented#OpenGL">OpenGL</a> to draw to the <a href="undocumented#GPU">GPU</a>.
To draw to a document, obtain <a href="SkCanvas_Reference#Canvas">Canvas</a> from <a href="undocumented#Canvas">SVG Canvas</a>, <a href="undocumented#PDF">Document PDF</a>, or <a href="undocumented#Recorder">Picture Recorder</a>.
Document-based <a href="SkCanvas_Reference#Canvas">Canvas</a> and other <a href="SkCanvas_Reference#Canvas">Canvas</a> subclasses reference <a href="undocumented#Device">Device</a> describing the
destination.
<a href="SkCanvas_Reference#Canvas">Canvas</a> can be constructed to draw to <a href="undocumented#Bitmap">Bitmap</a> without first creating <a href="undocumented#Raster_Surface">Raster Surface</a>.
This approach may be deprecated in the future.
# <a name="SkCanvas"></a> Class SkCanvas
# <a name="Overview"></a> Overview
## <a name="Subtopics"></a> Subtopics
| topics | description |
| --- | --- |
## <a name="Constants"></a> Constants
| constants | description |
| --- | --- |
| <a href="SkCanvas_Reference#Lattice_Flags">Lattice::Flags</a> | Controls <a href="SkCanvas_Reference#Lattice">Lattice</a> transparency. |
| <a href="SkCanvas_Reference#PointMode">PointMode</a> | Sets <a href="SkCanvas_Reference#drawPoints">drawPoints</a> options. |
| <a href="undocumented#SaveLayerFlags">SaveLayerFlags</a> | Sets <a href="SkCanvas_Reference#SaveLayerRec">SaveLayerRec</a> options. |
| <a href="SkCanvas_Reference#SrcRectConstraint">SrcRectConstraint</a> | Sets <a href="SkCanvas_Reference#drawImageRect">drawImageRect</a> options. |
## <a name="Structs"></a> Structs
| struct | description |
| --- | --- |
| <a href="SkCanvas_Reference#Lattice">Lattice</a> | Divides <a href="undocumented#Bitmap">Bitmap</a>, <a href="undocumented#Image">Image</a> into a rectangular grid. |
| <a href="SkCanvas_Reference#SaveLayerRec">SaveLayerRec</a> | Contains state to create the layer offscreen. |
## <a name="Constructors"></a> Constructors
Create the desired type of <a href="undocumented#Surface">Surface</a> to obtain its <a href="SkCanvas_Reference#Canvas">Canvas</a> when possible. <a href="SkCanvas_Reference#Overview_Constructors">Constructors</a> are useful
when no <a href="undocumented#Surface">Surface</a> is required, and some helpers implicitly create <a href="undocumented#Raster_Surface">Raster Surface</a>.
| | description |
| --- | --- |
| <a href="SkCanvas_Reference#empty_constructor">SkCanvas()</a> | No <a href="undocumented#Surface">Surface</a>, no dimensions. |
| <a href="SkCanvas_Reference#int_int_const_SkSurfaceProps_star">SkCanvas(int width, int height, const SkSurfaceProps* props = NULL)</a> | No <a href="undocumented#Surface">Surface</a>, set dimensions, <a href="undocumented#Properties">Surface Properties</a>. |
| <a href="SkCanvas_Reference#copy_constructor">SkCanvas(SkBaseDevice* device)</a> | Existing <a href="undocumented#Device">Device</a>. (<a href="undocumented#SkBaseDevice">SkBaseDevice</a> is private.) |
| <a href="SkCanvas_Reference#copy_constructor">SkCanvas(const SkBitmap& bitmap)</a> | Uses existing <a href="undocumented#Bitmap">Bitmap</a>. |
| <a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)</a> | Uses existing <a href="undocumented#Bitmap">Bitmap</a> and <a href="undocumented#Properties">Surface Properties</a>. |
| <a href="SkCanvas_Reference#MakeRasterDirect">MakeRasterDirect</a> | Creates from <a href="undocumented#SkImageInfo">SkImageInfo</a> and <a href="undocumented#Storage">Pixel Storage</a>. |
| <a href="SkCanvas_Reference#MakeRasterDirectN32">MakeRasterDirectN32</a> | Creates from image data and <a href="undocumented#Storage">Pixel Storage</a>. |
## <a name="Member_Functions"></a> Member Functions
| function | description |
| --- | --- |
| <a href="SkCanvas_Reference#accessTopLayerPixels">accessTopLayerPixels</a> | Returns writable pixel access if available. |
| <a href="SkCanvas_Reference#accessTopRasterHandle">accessTopRasterHandle</a> | Returns context that tracks <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#clear">clear</a> | Fills <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Color">Color</a>. |
| <a href="SkCanvas_Reference#clipPath">clipPath</a> | Combines <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="SkPath_Reference#Path">Path</a>. |
| <a href="SkCanvas_Reference#clipRRect">clipRRect</a> | Combines <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Round_Rect">Round Rect</a>. |
| <a href="SkCanvas_Reference#clipRect">clipRect</a> | Combines <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Rect">Rect</a>. |
| <a href="SkCanvas_Reference#clipRegion">clipRegion</a> | Combines <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Region">Region</a>. |
| <a href="SkCanvas_Reference#concat">concat</a> | Multiplies <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#discard">discard</a> | Makes <a href="SkCanvas_Reference#Canvas">Canvas</a> contents undefined. |
| <a href="SkCanvas_Reference#drawAnnotation">drawAnnotation</a> | Associates a <a href="undocumented#Rect">Rect</a> with a key-value pair. |
| <a href="SkCanvas_Reference#drawArc">drawArc</a> | Draws <a href="undocumented#Arc">Arc</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawAtlas">drawAtlas</a> | Draws sprites using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> | Draws <a href="undocumented#Bitmap">Bitmap</a> at (x, y) position. |
| <a href="SkCanvas_Reference#drawBitmapLattice">drawBitmapLattice</a> | Draws differentially stretched <a href="undocumented#Bitmap">Bitmap</a>. |
| <a href="SkCanvas_Reference#drawBitmapNine">drawBitmapNine</a> | Draws <a href="undocumented#Nine_Patch">Nine Patch</a> <a href="undocumented#Bitmap">Bitmap</a>. |
| <a href="SkCanvas_Reference#drawBitmapRect">drawBitmapRect</a> | Draws <a href="undocumented#Bitmap">Bitmap</a>, source <a href="undocumented#Rect">Rect</a> to destination <a href="undocumented#Rect">Rect</a>. |
| <a href="SkCanvas_Reference#drawCircle">drawCircle</a> | Draws <a href="undocumented#Circle">Circle</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawColor">drawColor</a> | Fills <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Color">Color</a> and <a href="undocumented#Blend_Mode">Blend Mode</a>. |
| <a href="SkCanvas_Reference#drawDRRect">drawDRRect</a> | Draws double <a href="undocumented#Round_Rect">Round Rect</a> stroked or filled. |
| <a href="SkCanvas_Reference#drawDrawable">drawDrawable</a> | Draws <a href="undocumented#Drawable">Drawable</a>, encapsulated drawing commands. |
| <a href="SkCanvas_Reference#drawIRect">drawIRect</a> | Draws <a href="undocumented#IRect">IRect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawImage">drawImage</a> | Draws <a href="undocumented#Image">Image</a> at (x, y) position. |
| <a href="SkCanvas_Reference#drawImageLattice">drawImageLattice</a> | Draws differentially stretched <a href="undocumented#Image">Image</a>. |
| <a href="SkCanvas_Reference#drawImageNine">drawImageNine</a> | Draws <a href="undocumented#Nine_Patch">Nine Patch</a> <a href="undocumented#Image">Image</a>. |
| <a href="SkCanvas_Reference#drawImageRect">drawImageRect</a> | Draws <a href="undocumented#Image">Image</a>, source <a href="undocumented#Rect">Rect</a> to destination <a href="undocumented#Rect">Rect</a>. |
| <a href="SkCanvas_Reference#drawLine">drawLine</a> | Draws line segment between two points. |
| <a href="SkCanvas_Reference#drawOval">drawOval</a> | Draws <a href="undocumented#Oval">Oval</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawPaint">drawPaint</a> | Fills <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawPatch">drawPatch</a> | Draws cubic <a href="undocumented#Coons">Coons</a> patch. |
| <a href="SkCanvas_Reference#drawPath">drawPath</a> | Draws <a href="SkPath_Reference#Path">Path</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawPicture">drawPicture</a> | Draws <a href="undocumented#Picture">Picture</a> using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#drawPoint">drawPoint</a> | Draws point at (x, y) position. |
| <a href="SkCanvas_Reference#drawPoints">drawPoints</a> | Draws array as points, lines, polygon. |
| <a href="SkCanvas_Reference#drawPosText">drawPosText</a> | Draws text at array of (x, y) positions. |
| <a href="SkCanvas_Reference#drawPosTextH">drawPosTextH</a> | Draws text at x positions with common baseline. |
| <a href="SkCanvas_Reference#drawRRect">drawRRect</a> | Draws <a href="undocumented#Round_Rect">Round Rect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawRect">drawRect</a> | Draws <a href="undocumented#Rect">Rect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawRegion">drawRegion</a> | Draws <a href="undocumented#Region">Region</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawRoundRect">drawRoundRect</a> | Draws <a href="undocumented#Round_Rect">Round Rect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawText">drawText</a> | Draws text at (x, y), using font advance. |
| <a href="SkCanvas_Reference#drawTextBlob">drawTextBlob</a> | Draws text with arrays of positions and <a href="SkPaint_Reference#Paint">Paint</a>. |
| <a href="SkCanvas_Reference#drawTextOnPath">drawTextOnPath</a> | Draws text following <a href="SkPath_Reference#Path">Path</a> contour. |
| <a href="SkCanvas_Reference#drawTextOnPathHV">drawTextOnPathHV</a> | Draws text following <a href="SkPath_Reference#Path">Path</a> with offsets. |
| <a href="SkCanvas_Reference#drawTextRSXform">drawTextRSXform</a> | Draws text with array of <a href="undocumented#RSXform">RSXform</a>. |
| <a href="SkCanvas_Reference#drawString">drawString</a> | Draws null terminated string at (x, y) using font advance. |
| <a href="SkCanvas_Reference#drawVertices">drawVertices</a> | Draws <a href="undocumented#Vertices">Vertices</a>, a triangle mesh. |
| <a href="SkCanvas_Reference#flush">flush</a> | Triggers execution of all pending draw operations. |
| <a href="SkCanvas_Reference#getBaseLayerSize">getBaseLayerSize</a> | Gets size of base layer in global coordinates. |
| <a href="SkCanvas_Reference#getDeviceClipBounds">getDeviceClipBounds</a> | Returns <a href="undocumented#IRect">IRect</a> bounds of <a href="SkCanvas_Reference#Clip">Clip</a>. |
| <a href="SkCanvas_Reference#getDrawFilter">getDrawFilter</a> | Legacy; to be deprecated. |
| <a href="SkCanvas_Reference#getGrContext">getGrContext</a> | Returns <a href="undocumented#GPU_Context">GPU Context</a> of the <a href="undocumented#GPU_Surface">GPU Surface</a>. |
| <a href="SkCanvas_Reference#getLocalClipBounds">getLocalClipBounds</a> | Returns <a href="SkCanvas_Reference#Clip">Clip</a> bounds in source coordinates. |
| <a href="SkCanvas_Reference#getMetaData">getMetaData</a> | Associates additional data with the canvas. |
| <a href="SkCanvas_Reference#getProps">getProps</a> | Copies <a href="undocumented#Properties">Surface Properties</a> if available. |
| <a href="SkCanvas_Reference#getSaveCount">getSaveCount</a> | Returns depth of stack containing <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#getTotalMatrix">getTotalMatrix</a> | Returns <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#imageInfo">imageInfo</a> | Returns <a href="undocumented#Info">Image Info</a> for <a href="SkCanvas_Reference#Canvas">Canvas</a>. |
| <a href="SkCanvas_Reference#isClipEmpty">isClipEmpty</a> | Returns if <a href="SkCanvas_Reference#Clip">Clip</a> is empty. |
| <a href="SkCanvas_Reference#isClipRect">isClipRect</a> | Returns if <a href="SkCanvas_Reference#Clip">Clip</a> is <a href="undocumented#Rect">Rect</a> and not empty. |
| <a href="SkCanvas_Reference#MakeRasterDirect">MakeRasterDirect</a> | Creates <a href="SkCanvas_Reference#Canvas">Canvas</a> from <a href="undocumented#SkImageInfo">SkImageInfo</a> and pixel data. |
| <a href="SkCanvas_Reference#MakeRasterDirectN32">MakeRasterDirectN32</a> | Creates <a href="SkCanvas_Reference#Canvas">Canvas</a> from image specifications and pixel data. |
| <a href="SkCanvas_Reference#makeSurface">makeSurface</a> | Creates <a href="undocumented#Surface">Surface</a> matching <a href="undocumented#SkImageInfo">SkImageInfo</a> and <a href="undocumented#SkSurfaceProps">SkSurfaceProps</a>. |
| <a href="SkCanvas_Reference#peekPixels">peekPixels</a> | Returns if <a href="SkCanvas_Reference#Canvas">Canvas</a> has direct access to its pixels. |
| <a href="SkCanvas_Reference#quickReject">quickReject</a> | Returns if <a href="undocumented#Rect">Rect</a> is outside <a href="SkCanvas_Reference#Clip">Clip</a>. |
| <a href="SkCanvas_Reference#readPixels">readPixels</a> | Copies and converts rectangle of pixels from <a href="SkCanvas_Reference#Canvas">Canvas</a>. |
| <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a> | Resets <a href="SkCanvas_Reference#Matrix">Matrix</a> to identity. |
| <a href="SkCanvas_Reference#restore">restore</a> | Restores changes to <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>, pops save stack. |
| <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> | Restores changes to <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> to given depth. |
| <a href="SkCanvas_Reference#rotate">rotate</a> | Rotates <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#save">save</a> | Saves <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> on stack. |
| <a href="SkCanvas_Reference#saveLayer">saveLayer</a> | Saves <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> on stack; creates offscreen. |
| <a href="SkCanvas_Reference#saveLayerAlpha">saveLayerAlpha</a> | Saves <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> on stack; creates offscreen; sets opacity. |
| <a href="SkCanvas_Reference#saveLayerPreserveLCDTextRequests">saveLayerPreserveLCDTextRequests</a> | Saves <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> on stack; creates offscreen for <a href="undocumented#LCD">LCD</a> text. |
| <a href="SkCanvas_Reference#scale">scale</a> | Scales <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#setAllowSimplifyClip">setAllowSimplifyClip</a> | Experimental. |
| <a href="SkCanvas_Reference#setDrawFilter">setDrawFilter</a> | Legacy; to be deprecated. |
| <a href="SkCanvas_Reference#setMatrix">setMatrix</a> | Sets <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#skew">skew</a> | Skews <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#translate">translate</a> | Translates <a href="SkCanvas_Reference#Matrix">Matrix</a>. |
| <a href="SkCanvas_Reference#writePixels">writePixels</a> | Copies and converts rectangle of pixels to <a href="SkCanvas_Reference#Canvas">Canvas</a>. |
<a name="MakeRasterDirect"></a>
## MakeRasterDirect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
static std::unique_ptr<SkCanvas> MakeRasterDirect(const SkImageInfo& info,
void* pixels, size_t rowBytes)
</pre>
Allocates raster <a href="SkCanvas_Reference#Canvas">Canvas</a> that will draw directly into <a href="SkCanvas_Reference#MakeRasterDirect">pixels</a>.
To access <a href="SkCanvas_Reference#MakeRasterDirect">pixels</a> after drawing, call <a href="SkCanvas_Reference#flush">flush</a> or <a href="SkCanvas_Reference#peekPixels">peekPixels</a>.
<a href="SkCanvas_Reference#Canvas">Canvas</a> is returned if all parameters are valid.
Valid parameters include:
<a href="SkCanvas_Reference#MakeRasterDirect">info</a> dimensions are zero or positive;
<a href="SkCanvas_Reference#MakeRasterDirect">info</a> contains <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a> supported by <a href="undocumented#Raster_Surface">Raster Surface</a>;
<a href="SkCanvas_Reference#MakeRasterDirect">pixels</a> is not nullptr;
<a href="SkCanvas_Reference#MakeRasterDirect">rowBytes</a> is zero or large enough to contain <a href="SkCanvas_Reference#MakeRasterDirect">info</a> width <a href="SkCanvas_Reference#MakeRasterDirect">pixels</a> of <a href="undocumented#Color_Type">Image Color Type</a>.
Pass zero for <a href="SkCanvas_Reference#MakeRasterDirect">rowBytes</a> to compute <a href="SkCanvas_Reference#MakeRasterDirect">rowBytes</a> from <a href="SkCanvas_Reference#MakeRasterDirect">info</a> width and size of pixel.
If <a href="SkCanvas_Reference#MakeRasterDirect">rowBytes</a> is greater than zero, it must be equal to or greater than
<a href="SkCanvas_Reference#MakeRasterDirect">info</a> width times bytes required for <a href="undocumented#Color_Type">Image Color Type</a>.
<a href="undocumented#Pixel">Pixel</a> buffer size should be <a href="SkCanvas_Reference#MakeRasterDirect">info</a> height times computed <a href="SkCanvas_Reference#MakeRasterDirect">rowBytes</a>.
### Parameters
<table> <tr> <td><code><strong>info </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, <a href="undocumented#Alpha_Type">Image Alpha Type</a>, <a href="undocumented#Color_Space">Color Space</a>, of <a href="undocumented#Raster_Surface">Raster Surface</a>;
width, or height, or both, may be zero</td>
</tr> <tr> <td><code><strong>pixels </strong></code></td> <td>
pointer to destination <a href="SkCanvas_Reference#MakeRasterDirect">pixels</a> buffer</td>
</tr> <tr> <td><code><strong>rowBytes </strong></code></td> <td>
interval from one <a href="undocumented#Surface">Surface</a> row to the next, or zero</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> if all parameters are valid; otherwise, nullptr
### Example
<div><fiddle-embed name="30839f66c2d267e021d0cabb81ef1123"><div>Allocates a three by three bitmap, clears it to white, and draws a black pixel
in the center.</div>
#### Example Output
~~~~
---
-x-
---
~~~~
</fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#MakeRasterDirectN32">MakeRasterDirectN32</a> <a href="undocumented#MakeRasterDirect">SkSurface::MakeRasterDirect</a>
---
<a name="MakeRasterDirectN32"></a>
## MakeRasterDirectN32
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
static std::unique_ptr<SkCanvas> MakeRasterDirectN32(int width, int height,
SkPMColor* pixels,
size_t rowBytes)
</pre>
Allocates raster <a href="SkCanvas_Reference#Canvas">Canvas</a> specified by inline image specification. Subsequent <a href="SkCanvas_Reference#Canvas">Canvas</a>
calls draw into <a href="SkCanvas_Reference#MakeRasterDirectN32">pixels</a>.
<a href="undocumented#Color_Type">Image Color Type</a> is set to <a href="undocumented#SkColorType">kN32 SkColorType</a>.
<a href="undocumented#Alpha_Type">Image Alpha Type</a> is set to <a href="undocumented#SkAlphaType">kPremul SkAlphaType</a>.
To access <a href="SkCanvas_Reference#MakeRasterDirectN32">pixels</a> after drawing, call <a href="SkCanvas_Reference#flush">flush</a> or <a href="SkCanvas_Reference#peekPixels">peekPixels</a>.
<a href="SkCanvas_Reference#Canvas">Canvas</a> is returned if all parameters are valid.
Valid parameters include:
<a href="SkCanvas_Reference#width">width</a> and <a href="SkCanvas_Reference#height">height</a> are zero or positive;
<a href="SkCanvas_Reference#MakeRasterDirectN32">pixels</a> is not nullptr;
<a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a> is zero or large enough to contain <a href="SkCanvas_Reference#width">width</a> <a href="SkCanvas_Reference#MakeRasterDirectN32">pixels</a> of <a href="undocumented#SkColorType">kN32 SkColorType</a>.
Pass zero for <a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a> to compute <a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a> from fo <a href="SkCanvas_Reference#width">width</a> and size of pixel.
If <a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a> is greater than zero, it must be equal to or greater than
<a href="SkCanvas_Reference#width">width</a> times bytes required for <a href="undocumented#Color_Type">Image Color Type</a>.
<a href="undocumented#Pixel">Pixel</a> buffer size should be <a href="SkCanvas_Reference#height">height</a> times <a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a>.
### Parameters
<table> <tr> <td><code><strong>width </strong></code></td> <td>
pixel column count on <a href="undocumented#Raster_Surface">Raster Surface</a> created; must be zero or greater</td>
</tr> <tr> <td><code><strong>height </strong></code></td> <td>
pixel row count on <a href="undocumented#Raster_Surface">Raster Surface</a> created.; must be zero or greater</td>
</tr> <tr> <td><code><strong>pixels </strong></code></td> <td>
pointer to destination <a href="SkCanvas_Reference#MakeRasterDirectN32">pixels</a> buffer; buffer size should be <a href="SkCanvas_Reference#height">height</a>
times <a href="SkCanvas_Reference#MakeRasterDirectN32">rowBytes</a></td>
</tr> <tr> <td><code><strong>rowBytes </strong></code></td> <td>
interval from one <a href="undocumented#Surface">Surface</a> row to the next, or zero</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> if all parameters are valid; otherwise, nullptr
### Example
<div><fiddle-embed name="bc8d576bf09358cf0e972b72efba936c"><div>Allocates a three by three bitmap, clears it to white, and draws a black pixel
in the center.</div>
#### Example Output
~~~~
---
-x-
---
~~~~
</fiddle-embed></div>
---
<a name="empty_constructor"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkCanvas()
</pre>
Creates an empty canvas with no backing device or pixels, with
a width and height of zero.
### Return Value
empty canvas
### Example
<div><fiddle-embed name="903451d6c93bf69e2833747a3e8cc8f7"><div>Passes a placeholder to a function that requires one.</div>
#### Example Output
~~~~
paint draws text left to right
paint draws text top to bottom
paint draws text top to bottom
~~~~
</fiddle-embed></div>
---
<a name="int_int_const_SkSurfaceProps_star"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkCanvas(int width, int height, const SkSurfaceProps* props = NULL)
</pre>
Creates <a href="SkCanvas_Reference#Canvas">Canvas</a> of the specified dimensions without a <a href="undocumented#Surface">Surface</a>.
Used by subclasses with custom implementations for draw methods.
If <a href="SkCanvas_Reference#int_int_const_SkSurfaceProps_star">props</a> equals nullptr, <a href="undocumented#Properties">Surface Properties</a> are created with <a href="undocumented#Properties_Legacy_Font_Host">Surface Properties Legacy Font Host</a> settings,
which choose the pixel striping direction and order. Since a platform may dynamically
change its direction when the device is rotated, and since a platform may have
multiple monitors with different characteristics, it's best not to rely on this
legacy behavior.
### Parameters
<table> <tr> <td><code><strong>width </strong></code></td> <td>
zero or greater</td>
</tr> <tr> <td><code><strong>height </strong></code></td> <td>
zero or greater</td>
</tr> <tr> <td><code><strong>props </strong></code></td> <td>
<a href="undocumented#LCD">LCD</a> striping orientation and setting for device independent fonts;
may be nullptr</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> placeholder with dimensions
### Example
<div><fiddle-embed name="ce6a5ef2df447970b4453489d9d67930">
#### Example Output
~~~~
canvas is empty
~~~~
</fiddle-embed></div>
### See Also
<a href="undocumented#SkSurfaceProps">SkSurfaceProps</a> <a href="undocumented#SkPixelGeometry">SkPixelGeometry</a>
---
<a name="copy_constructor"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
explicit SkCanvas(SkBaseDevice* device)
</pre>
Construct a canvas that draws into <a href="SkCanvas_Reference#device">device</a>.
Used by child classes of <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a>.
### Parameters
<table> <tr> <td><code><strong>device </strong></code></td> <td>
specifies a <a href="SkCanvas_Reference#device">device</a> for the canvas to draw into</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> that can be used to draw into <a href="SkCanvas_Reference#device">device</a>
### Example
<div><fiddle-embed name="cc6d6fd6d9aa98b12984e11ef52172ec"></fiddle-embed></div>
---
<a name="copy_constructor"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
explicit SkCanvas(const SkBitmap& bitmap)
</pre>
Construct a canvas that draws into <a href="SkCanvas_Reference#copy_constructor">bitmap</a>.
Sets <a href="undocumented#kLegacyFontHost_InitType">SkSurfaceProps::kLegacyFontHost InitType</a> in constructed <a href="undocumented#Surface">Surface</a>.
<a href="undocumented#Bitmap">Bitmap</a> is copied so that subsequently editing <a href="SkCanvas_Reference#copy_constructor">bitmap</a> will not affect
constructed <a href="SkCanvas_Reference#Canvas">Canvas</a>.
May be deprecated in the future.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, <a href="undocumented#Alpha_Type">Image Alpha Type</a>, and pixel
storage of <a href="undocumented#Raster_Surface">Raster Surface</a></td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> that can be used to draw into <a href="SkCanvas_Reference#copy_constructor">bitmap</a>
### Example
<div><fiddle-embed name=""><div>The actual output depends on the installed fonts.</div>
#### Example Output
~~~~
-----
--x--
--x--
--x--
--x--
--x--
--x--
-----
--x--
--x--
-----
~~~~
</fiddle-embed></div>
---
## <a name="SkCanvas::ColorBehavior"></a> Enum SkCanvas::ColorBehavior
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
enum class <a href="SkCanvas_Reference#ColorBehavior">ColorBehavior</a> {
<a href="SkCanvas_Reference#ColorBehavior_kLegacy">kLegacy</a>,
};</pre>
### Constants
<table>
<tr>
<td><a name="SkCanvas::ColorBehavior::kLegacy"></a> <code><strong>SkCanvas::ColorBehavior::kLegacy </strong></code></td><td>0</td><td>Is a placeholder to allow specialized constructor; has no meaning.</td>
</tr>
</table>
<a name="const_SkBitmap"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkCanvas(const SkBitmap& bitmap, ColorBehavior behavior)
</pre>
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
specifies a <a href="SkCanvas_Reference#bitmap">bitmap</a> for the canvas to draw into</td>
</tr> <tr> <td><code><strong>behavior </strong></code></td> <td>
specializes this constructor; value is unused</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> that can be used to draw into <a href="SkCanvas_Reference#bitmap">bitmap</a>
---
<a name="const_SkBitmap_const_SkSurfaceProps"></a>
## SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
</pre>
Construct a canvas that draws into <a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">bitmap</a>.
Use <a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">props</a> to match the device characteristics, like <a href="undocumented#LCD">LCD</a> striping.
<a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">bitmap</a> is copied so that subsequently editing <a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">bitmap</a> will not affect
constructed <a href="SkCanvas_Reference#Canvas">Canvas</a>.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, <a href="undocumented#Alpha_Type">Image Alpha Type</a>,
and pixel storage of <a href="undocumented#Raster_Surface">Raster Surface</a></td>
</tr> <tr> <td><code><strong>props </strong></code></td> <td>
order and orientation of <a href="undocumented#RGB">RGB</a> striping; and whether to use
device independent fonts</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#Canvas">Canvas</a> that can be used to draw into <a href="SkCanvas_Reference#const_SkBitmap_const_SkSurfaceProps">bitmap</a>
### Example
<div><fiddle-embed name="5ddec03684bb09f94b016dc205cb173b"><div>The actual output depends on the installed fonts.</div>
#### Example Output
~~~~
-----
---x-
---x-
---x-
---x-
---x-
---x-
-----
---x-
---x-
-----
~~~~
</fiddle-embed></div>
---
<a name="destructor"></a>
## ~SkCanvas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual ~SkCanvas()
</pre>
Draw saved layers, if any.
Free up resources used by <a href="SkCanvas_Reference#Canvas">Canvas</a>.
### Example
<div><fiddle-embed name="b7bc91ff16c9b9351b2a127f35394b82"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> offscreen draws into bitmap. <a href="SkCanvas_Reference#saveLayerAlpha">saveLayerAlpha</a> sets up an additional
drawing surface that blends with the bitmap. When offscreen goes out of
scope, offscreen destructor is called. The saved layer is restored, drawing
transparent letters.</div></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#State_Stack">State Stack</a>
---
<a name="getMetaData"></a>
## getMetaData
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkMetaData& getMetaData()
</pre>
Returns storage to associate additional data with the canvas.
The storage is freed when <a href="SkCanvas_Reference#Canvas">Canvas</a> is deleted.
### Return Value
storage that can be read from and written to
### Example
<div><fiddle-embed name="1598396056045e8d0c583b748293d652">
#### Example Output
~~~~
before: (null)
during: Hello!
after: (null)
~~~~
</fiddle-embed></div>
---
<a name="imageInfo"></a>
## imageInfo
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkImageInfo imageInfo() const
</pre>
Returns <a href="undocumented#Info">Image Info</a> for <a href="SkCanvas_Reference#Canvas">Canvas</a>. If <a href="SkCanvas_Reference#Canvas">Canvas</a> is not associated with <a href="undocumented#Raster_Surface">Raster Surface</a> or
<a href="undocumented#GPU_Surface">GPU Surface</a>, returned <a href="undocumented#Color_Type">Image Color Type</a> is set to <a href="undocumented#SkColorType">kUnknown SkColorType</a>.
### Return Value
dimensions and <a href="undocumented#Color_Type">Image Color Type</a> of <a href="SkCanvas_Reference#Canvas">Canvas</a>
### Example
<div><fiddle-embed name="d93389d971f8084c4ccc7a66e4e157ee">
#### Example Output
~~~~
emptyInfo == canvasInfo
~~~~
</fiddle-embed></div>
---
<a name="getProps"></a>
## getProps
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool getProps(SkSurfaceProps* props) const
</pre>
If <a href="SkCanvas_Reference#Canvas">Canvas</a> is associated with <a href="undocumented#Raster_Surface">Raster Surface</a> or
<a href="undocumented#GPU_Surface">GPU Surface</a>, copies <a href="undocumented#Properties">Surface Properties</a> and returns true. Otherwise,
return false and leave <a href="SkCanvas_Reference#props">props</a> unchanged.
### Parameters
<table> <tr> <td><code><strong>props </strong></code></td> <td>
storage for writable <a href="undocumented#SkSurfaceProps">SkSurfaceProps</a></td>
</tr>
</table>
### Return Value
true if <a href="undocumented#Properties">Surface Properties</a> was copied
### Example
<div><fiddle-embed name="0fbf2dedc2619bbfbf173c9e3bc1a508">
#### Example Output
~~~~
isRGB:0
isRGB:1
~~~~
</fiddle-embed></div>
---
<a name="flush"></a>
## flush
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void flush()
</pre>
Triggers the immediate execution of all pending draw operations.
If <a href="SkCanvas_Reference#Canvas">Canvas</a> is associated with <a href="undocumented#GPU_Surface">GPU Surface</a>, resolves all pending <a href="undocumented#GPU">GPU</a> operations.
### Example
<div><fiddle-embed name=""></fiddle-embed></div>
---
<a name="getBaseLayerSize"></a>
## getBaseLayerSize
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual SkISize getBaseLayerSize() const
</pre>
Gets the size of the base or root layer in global canvas coordinates. The
origin of the base layer is always (0,0). The current drawable area may be
smaller (due to clipping or <a href="SkCanvas_Reference#saveLayer">saveLayer</a>).
### Return Value
integral width and height of base layer
### Example
<div><fiddle-embed name="374e245d91cd729eca48fd20e631fdf3">
#### Example Output
~~~~
clip=10,30
size=20,30
~~~~
</fiddle-embed></div>
---
<a name="makeSurface"></a>
## makeSurface
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
sk_sp<SkSurface> makeSurface(const SkImageInfo& info,
const SkSurfaceProps* props = nullptr)
</pre>
Creates <a href="undocumented#Surface">Surface</a> matching <a href="SkCanvas_Reference#info">info</a> and <a href="SkCanvas_Reference#props">props</a>, and associates it with <a href="SkCanvas_Reference#Canvas">Canvas</a>.
Returns nullptr if no match found.
If <a href="SkCanvas_Reference#props">props</a> is nullptr, matches <a href="undocumented#Properties">Surface Properties</a> in <a href="SkCanvas_Reference#Canvas">Canvas</a>. If <a href="SkCanvas_Reference#props">props</a> is nullptr and <a href="SkCanvas_Reference#Canvas">Canvas</a>
does not have <a href="undocumented#Properties">Surface Properties</a>, creates <a href="undocumented#Surface">Surface</a> with default <a href="undocumented#Properties">Surface Properties</a>.
### Parameters
<table> <tr> <td><code><strong>info </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, <a href="undocumented#Alpha_Type">Image Alpha Type</a>, and <a href="undocumented#Color_Space">Color Space</a></td>
</tr> <tr> <td><code><strong>props </strong></code></td> <td>
<a href="undocumented#Properties">Surface Properties</a> to match; may be nullptr to match <a href="SkCanvas_Reference#Canvas">Canvas</a></td>
</tr>
</table>
### Return Value
<a href="undocumented#Surface">Surface</a> matching <a href="SkCanvas_Reference#info">info</a> and <a href="SkCanvas_Reference#props">props</a>, or nullptr if no match is available
### Example
<div><fiddle-embed name="1ce28351444b41ab2b8e3128a4b9b9c2">
#### Example Output
~~~~
compatible != nullptr
size = 3, 4
~~~~
</fiddle-embed></div>
---
<a name="getGrContext"></a>
## getGrContext
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual GrContext* getGrContext()
</pre>
Returns <a href="undocumented#GPU_Context">GPU Context</a> of the <a href="undocumented#GPU_Surface">GPU Surface</a> associated with <a href="SkCanvas_Reference#Canvas">Canvas</a>.
### Return Value
<a href="undocumented#GPU_Context">GPU Context</a>, if available; nullptr otherwise
### Example
<div><fiddle-embed name="c4ea949e5fa5a0630dcb6b0204bd498f"></fiddle-embed></div>
---
<a name="accessTopLayerPixels"></a>
## accessTopLayerPixels
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes,
SkIPoint* origin = NULL)
</pre>
Returns the pixel base address, <a href="undocumented#Info">Image Info</a>, <a href="SkCanvas_Reference#rowBytes">rowBytes</a>, and <a href="SkCanvas_Reference#accessTopLayerPixels">origin</a> if the pixels
can be read directly. The returned address is only valid
while <a href="SkCanvas_Reference#Canvas">Canvas</a> is in scope and unchanged. Any <a href="SkCanvas_Reference#Canvas">Canvas</a> call or <a href="undocumented#Surface">Surface</a> call
may invalidate the returned address and other returned values.
If pixels are inaccessible, <a href="SkCanvas_Reference#info">info</a>, <a href="SkCanvas_Reference#rowBytes">rowBytes</a>, and <a href="SkCanvas_Reference#accessTopLayerPixels">origin</a> are unchanged.
### Parameters
<table> <tr> <td><code><strong>info </strong></code></td> <td>
storage for writable pixels' <a href="undocumented#Info">Image Info</a>; may be nullptr</td>
</tr> <tr> <td><code><strong>rowBytes </strong></code></td> <td>
storage for writable pixels' row bytes; may be nullptr</td>
</tr> <tr> <td><code><strong>origin </strong></code></td> <td>
storage for <a href="SkCanvas_Reference#Canvas">Canvas</a> top layer <a href="SkCanvas_Reference#accessTopLayerPixels">origin</a>, its top left corner;
may be nullptr</td>
</tr>
</table>
### Return Value
Address of pixels, or nullptr if inaccessible
### Example
<div><fiddle-embed name="38d0d6ca9bea146d31bcbec197856359"></fiddle-embed></div>
### Example
<div><fiddle-embed name="a7ac9c21bbabcdeeca00f72a61cd0f3e"><div>Draws "" on the device. Then draws "" in an offscreen layer, and reads the
offscreen to add a large dotted "". Finally blends the offscreen with the
device.
The offscreen and blended result appear on the <a href="undocumented#CPU">CPU</a> and <a href="undocumented#GPU">GPU</a> but the large dotted
"" appear only on the <a href="undocumented#CPU">CPU</a>.</div></fiddle-embed></div>
---
<a name="accessTopRasterHandle"></a>
## accessTopRasterHandle
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkRasterHandleAllocator::Handle accessTopRasterHandle() const
</pre>
Returns custom context that tracks the <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a>.
Use <a href="undocumented#Raster_Handle_Allocator">Raster Handle Allocator</a> to blend <a href="undocumented#Skia">Skia</a> drawing with custom drawing, typically performed
by the host platform's user interface. This accessor returns the custom context generated by
<a href="undocumented#MakeCanvas">SkRasterHandleAllocator::MakeCanvas</a>, which creates a custom canvas with raster storage for
the drawing destination.
### Return Value
context of custom allocator
### Example
<div><fiddle-embed name="4486d0c0b22ad2931db130f42da4c80c"><div></div>
#### Example Output
~~~~
context = skia
~~~~
</fiddle-embed></div>
### See Also
<a href="undocumented#SkRasterHandleAllocator">SkRasterHandleAllocator</a>
---
<a name="peekPixels"></a>
## peekPixels
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool peekPixels(SkPixmap* pixmap)
</pre>
Returns true if <a href="SkCanvas_Reference#Canvas">Canvas</a> has direct access to its pixels.
Pixels are readable when <a href="undocumented#Device">Device</a> is raster. Pixels are not readable when <a href="SkCanvas_Reference#Canvas">Canvas</a>
is returned from <a href="undocumented#GPU_Surface">GPU Surface</a>, returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>, returned by
<a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility class
like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
<a href="SkCanvas_Reference#peekPixels">pixmap</a> is valid only while <a href="SkCanvas_Reference#Canvas">Canvas</a> is in scope and unchanged. Any
<a href="SkCanvas_Reference#Canvas">Canvas</a> or <a href="undocumented#Surface">Surface</a> call may invalidate the <a href="SkCanvas_Reference#peekPixels">pixmap</a> values.
### Parameters
<table> <tr> <td><code><strong>pixmap </strong></code></td> <td>
storage for <a href="SkCanvas_Reference#Canvas">Canvas</a> pixel state if <a href="SkCanvas_Reference#Canvas">Canvas</a> pixels are readable;
otherwise, ignored</td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#Canvas">Canvas</a> has direct access to pixels
### Example
<div><fiddle-embed name="e9411d676d1fa13b46331abe9e14ad3e">
#### Example Output
~~~~
width=256 height=256
~~~~
</fiddle-embed></div>
---
<a name="readPixels"></a>
## readPixels
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY)
</pre>
Copies rectangle of pixels from <a href="SkCanvas_Reference#Canvas">Canvas</a> into <a href="SkCanvas_Reference#dstPixels">dstPixels</a>. <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> are
ignored. Source rectangle corners are (<a href="SkCanvas_Reference#srcX">srcX</a>, <a href="SkCanvas_Reference#srcY">srcY</a>) and
(this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.width(), this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.height()).
Destination rectangle corners are (0, 0) and (<a href="SkCanvas_Reference#dstInfo">dstInfo</a>.width(), <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.colorType() and <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.alphaType() if required.
Pixels are readable when <a href="undocumented#Device">Device</a> is raster, or backed by a <a href="undocumented#GPU">GPU</a>.
Pixels are not readable when <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> is returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>,
returned by <a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility
class like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
The destination pixel storage must be allocated by the caller.
<a href="undocumented#Pixel">Pixel</a> values are converted only if <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a>
do not match. Only pixels within both source and destination rectangles
are copied. <a href="SkCanvas_Reference#dstPixels">dstPixels</a> contents outside the rectangle intersection are unchanged.
Pass negative values for <a href="SkCanvas_Reference#srcX">srcX</a> or <a href="SkCanvas_Reference#srcY">srcY</a> to offset pixels across or down destination.
Does not copy, and returns false if:
<table> <tr>
<td>Source and destination rectangles do not intersect.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels could not be converted to <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.colorType() or <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.alphaType().</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels are not readable; for instance, <a href="SkCanvas_Reference#Canvas">Canvas</a> is document-based.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#dstRowBytes">dstRowBytes</a> is too small to contain one row of pixels.</td> </tr>
</table>
### Parameters
<table> <tr> <td><code><strong>dstInfo </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, and <a href="undocumented#Alpha_Type">Image Alpha Type</a> of <a href="SkCanvas_Reference#dstPixels">dstPixels</a></td>
</tr> <tr> <td><code><strong>dstPixels </strong></code></td> <td>
storage for pixels; <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.height() times <a href="SkCanvas_Reference#dstRowBytes">dstRowBytes</a>, or larger</td>
</tr> <tr> <td><code><strong>dstRowBytes </strong></code></td> <td>
size of one destination row; <a href="SkCanvas_Reference#dstInfo">dstInfo</a>.width() times pixel size, or larger</td>
</tr> <tr> <td><code><strong>srcX </strong></code></td> <td>
offset into readable pixels in x; may be negative</td>
</tr> <tr> <td><code><strong>srcY </strong></code></td> <td>
offset into readable pixels in y; may be negative</td>
</tr>
</table>
### Return Value
true if pixels were copied
### Example
<div><fiddle-embed name="2964297993747769b0760874c19e0168"><div>A black circle drawn on a blue background provides an image to copy.
<a href="SkCanvas_Reference#readPixels">readPixels</a> copies one quarter of the canvas into each of the four corners.
The offscreen draws over the image.</div></fiddle-embed></div>
### Example
<div><fiddle-embed name="481e990e923a0ed34654f4361b94f096"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> returned by <a href="undocumented#Raster_Surface">Raster Surface</a> has premultiplied pixel values.
<a href="SkCanvas_Reference#clear">clear</a> takes unpremultiplied input with <a href="undocumented#Alpha">Color Alpha</a> equal 0x80
and <a href="undocumented#RGB">Color RGB</a> equal 0x55, 0xAA, 0xFF. <a href="undocumented#RGB">Color RGB</a> is multipled by <a href="undocumented#Alpha">Color Alpha</a>
to generate premultipled value 0x802B5580. <a href="SkCanvas_Reference#readPixels">readPixels</a> converts pixel back
to unpremultipled value 0x8056A9FF, introducing error.</div>
#### Example Output
~~~~
pixel = 802b5580
pixel = 8056a9ff
~~~~
</fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#peekPixels">peekPixels</a> <a href="SkCanvas_Reference#writePixels">writePixels</a> <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> <a href="SkCanvas_Reference#drawImage">drawImage</a>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool readPixels(const SkPixmap& pixmap, int srcX, int srcY)
</pre>
Copies rectangle of pixels from <a href="SkCanvas_Reference#Canvas">Canvas</a> into <a href="SkCanvas_Reference#pixmap">pixmap</a>. <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> are
ignored. Source rectangle corners are (<a href="SkCanvas_Reference#srcX">srcX</a>, <a href="SkCanvas_Reference#srcY">srcY</a>) and
(this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.width(), this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.height()).
Destination rectangle are (0, 0) and (<a href="SkCanvas_Reference#pixmap">pixmap</a>.width(), <a href="SkCanvas_Reference#pixmap">pixmap</a>.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to <a href="SkCanvas_Reference#pixmap">pixmap</a>.colorType() and <a href="SkCanvas_Reference#pixmap">pixmap</a>.alphaType() if required.
Pixels are readable when <a href="undocumented#Device">Device</a> is raster, or backed by a <a href="undocumented#GPU">GPU</a>.
Pixels are not readable when <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> is returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>,
returned by <a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility
class like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
Allocates pixel storage in <a href="SkCanvas_Reference#pixmap">pixmap</a> if needed.
<a href="undocumented#Pixel">Pixel</a> values are converted only if <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a>
do not match. Only pixels within both source and destination rectangles
are copied. <a href="SkCanvas_Reference#pixmap">pixmap</a> pixels contents outside the rectangle intersection are unchanged.
Pass negative values for <a href="SkCanvas_Reference#srcX">srcX</a> or <a href="SkCanvas_Reference#srcY">srcY</a> to offset pixels across or down <a href="SkCanvas_Reference#pixmap">pixmap</a>.
Does not copy, and returns false if:
<table> <tr>
<td>Source and destination rectangles do not intersect.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels could not be converted to <a href="SkCanvas_Reference#pixmap">pixmap</a>.colorType() or <a href="SkCanvas_Reference#pixmap">pixmap</a>.alphaType().</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels are not readable; for instance, <a href="SkCanvas_Reference#Canvas">Canvas</a> is document-based.</td> </tr> <tr>
<td><a href="undocumented#Pixmap">Pixmap</a> pixels could not be allocated.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#pixmap">pixmap</a>.rowBytes() is too small to contain one row of pixels.</td> </tr>
</table>
### Parameters
<table> <tr> <td><code><strong>pixmap </strong></code></td> <td>
storage for pixels copied from <a href="SkCanvas_Reference#Canvas">Canvas</a></td>
</tr> <tr> <td><code><strong>srcX </strong></code></td> <td>
offset into readable pixels in x; may be negative</td>
</tr> <tr> <td><code><strong>srcY </strong></code></td> <td>
offset into readable pixels in y; may be negative</td>
</tr>
</table>
### Return Value
true if pixels were copied
### Example
<div><fiddle-embed name="85f199032943b6483722c34a91c4e20f"><div><a href="SkCanvas_Reference#clear">clear</a> takes unpremultiplied input with <a href="undocumented#Alpha">Color Alpha</a> equal 0x80
and <a href="undocumented#RGB">Color RGB</a> equal 0x55, 0xAA, 0xFF. <a href="undocumented#RGB">Color RGB</a> is multipled by <a href="undocumented#Alpha">Color Alpha</a>
to generate premultipled value 0x802B5580.</div>
#### Example Output
~~~~
pixel = 802b5580
~~~~
</fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#peekPixels">peekPixels</a> <a href="SkCanvas_Reference#writePixels">writePixels</a> <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> <a href="SkCanvas_Reference#drawImage">drawImage</a>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool readPixels(const SkBitmap& bitmap, int srcX, int srcY)
</pre>
Copies rectangle of pixels from <a href="SkCanvas_Reference#Canvas">Canvas</a> into <a href="SkCanvas_Reference#bitmap">bitmap</a>. <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> are
ignored. Source rectangle corners are (<a href="SkCanvas_Reference#srcX">srcX</a>, <a href="SkCanvas_Reference#srcY">srcY</a>) and
(this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.width(), this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.height()).
Destination rectangle corners are (0, 0) and (<a href="SkCanvas_Reference#bitmap">bitmap</a>.width(), <a href="SkCanvas_Reference#bitmap">bitmap</a>.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to <a href="SkCanvas_Reference#bitmap">bitmap</a>.colorType() and <a href="SkCanvas_Reference#bitmap">bitmap</a>.alphaType() if required.
Pixels are readable when <a href="undocumented#Device">Device</a> is raster, or backed by a <a href="undocumented#GPU">GPU</a>.
Pixels are not readable when <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> is returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>,
returned by <a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility
class like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
Allocates pixel storage in <a href="SkCanvas_Reference#bitmap">bitmap</a> if needed.
<a href="undocumented#Bitmap">Bitmap</a> values are converted only if <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a>
do not match. Only pixels within both source and destination rectangles
are copied. <a href="undocumented#Bitmap">Bitmap</a> pixels outside the rectangle intersection are unchanged.
Pass negative values for <a href="SkCanvas_Reference#srcX">srcX</a> or <a href="SkCanvas_Reference#srcY">srcY</a> to offset pixels across or down <a href="SkCanvas_Reference#bitmap">bitmap</a>.
Does not copy, and returns false if:
<table> <tr>
<td>Source and destination rectangles do not intersect.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels could not be converted to <a href="SkCanvas_Reference#bitmap">bitmap</a>.colorType() or <a href="SkCanvas_Reference#bitmap">bitmap</a>.alphaType().</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels are not readable; for instance, <a href="SkCanvas_Reference#Canvas">Canvas</a> is document-based.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#bitmap">bitmap</a> pixels could not be allocated.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#bitmap">bitmap</a>.rowBytes() is too small to contain one row of pixels.</td> </tr>
</table>
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
storage for pixels copied from <a href="SkCanvas_Reference#Canvas">Canvas</a></td>
</tr> <tr> <td><code><strong>srcX </strong></code></td> <td>
offset into readable pixels in x; may be negative</td>
</tr> <tr> <td><code><strong>srcY </strong></code></td> <td>
offset into readable pixels in y; may be negative</td>
</tr>
</table>
### Return Value
true if pixels were copied
### Example
<div><fiddle-embed name="af6dec8ef974aa67bf102f29915bcd6a"><div><a href="SkCanvas_Reference#clear">clear</a> takes unpremultiplied input with <a href="undocumented#Alpha">Color Alpha</a> equal 0x80
and <a href="undocumented#RGB">Color RGB</a> equal 0x55, 0xAA, 0xFF. <a href="undocumented#RGB">Color RGB</a> is multipled by <a href="undocumented#Alpha">Color Alpha</a>
to generate premultipled value 0x802B5580.</div>
#### Example Output
~~~~
pixel = 802b5580
~~~~
</fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#peekPixels">peekPixels</a> <a href="SkCanvas_Reference#writePixels">writePixels</a> <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> <a href="SkCanvas_Reference#drawImage">drawImage</a>
---
<a name="writePixels"></a>
## writePixels
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
int x, int y)
</pre>
Copies rectangle from <a href="SkCanvas_Reference#pixels">pixels</a> to <a href="SkCanvas_Reference#Canvas">Canvas</a>. <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> are ignored.
Source rectangle corners are (0, 0) and (<a href="SkCanvas_Reference#info">info</a>.width(), <a href="SkCanvas_Reference#info">info</a>.height()).
Destination rectangle corners are (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>) and
(this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.width(), this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.height()). Copies each readable pixel
intersecting both rectangles, without scaling, converting to
this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.colorType() and this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.alphaType() if required.
Pixels are writable when <a href="undocumented#Device">Device</a> is raster, or backed by a <a href="undocumented#GPU">GPU</a>.
Pixels are not writable when <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> is returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>,
returned by <a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility
class like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
<a href="undocumented#Pixel">Pixel</a> values are converted only if <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a>
do not match. Only <a href="SkCanvas_Reference#pixels">pixels</a> within both source and destination rectangles
are copied. <a href="SkCanvas_Reference#Canvas">Canvas</a> <a href="SkCanvas_Reference#pixels">pixels</a> outside the rectangle intersection are unchanged.
Pass negative values for <a href="SkCanvas_Reference#x">x</a> or <a href="SkCanvas_Reference#y">y</a> to offset <a href="SkCanvas_Reference#pixels">pixels</a> to the left or
above <a href="SkCanvas_Reference#Canvas">Canvas</a> <a href="SkCanvas_Reference#pixels">pixels</a>.
Does not copy, and returns false if:
<table> <tr>
<td>Source and destination rectangles do not intersect.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#pixels">pixels</a> could not be converted to this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.colorType() or this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.alphaType().</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> <a href="SkCanvas_Reference#pixels">pixels</a> are not writable; for instance, <a href="SkCanvas_Reference#Canvas">Canvas</a> is document-based.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#rowBytes">rowBytes</a> is too small to contain one row of <a href="SkCanvas_Reference#pixels">pixels</a>.</td> </tr>
</table>
### Parameters
<table> <tr> <td><code><strong>info </strong></code></td> <td>
width, height, <a href="undocumented#Color_Type">Image Color Type</a>, and <a href="undocumented#Alpha_Type">Image Alpha Type</a> of <a href="SkCanvas_Reference#pixels">pixels</a></td>
</tr> <tr> <td><code><strong>pixels </strong></code></td> <td>
<a href="SkCanvas_Reference#pixels">pixels</a> to copy, of size <a href="SkCanvas_Reference#info">info</a>.height() times <a href="SkCanvas_Reference#rowBytes">rowBytes</a>, or larger</td>
</tr> <tr> <td><code><strong>rowBytes </strong></code></td> <td>
size of one <a href="SkCanvas_Reference#pixels">pixels</a> row; <a href="SkCanvas_Reference#info">info</a>.width() times pixel size, or larger</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable <a href="SkCanvas_Reference#pixels">pixels</a> in <a href="SkCanvas_Reference#x">x</a>; may be negative</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable <a href="SkCanvas_Reference#pixels">pixels</a> in <a href="SkCanvas_Reference#y">y</a>; may be negative</td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#pixels">pixels</a> were written to <a href="SkCanvas_Reference#Canvas">Canvas</a>
### Example
<div><fiddle-embed name="29b98ebf58aa9fd1edfaabf9f4490b3a"></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#readPixels">readPixels</a> <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> <a href="SkCanvas_Reference#drawImage">drawImage</a>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool writePixels(const SkBitmap& bitmap, int x, int y)
</pre>
Copies rectangle from pixels to <a href="SkCanvas_Reference#Canvas">Canvas</a>. <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkCanvas_Reference#Clip">Clip</a> are ignored.
Source rectangle corners are (0, 0) and (<a href="SkCanvas_Reference#bitmap">bitmap</a>.width(), <a href="SkCanvas_Reference#bitmap">bitmap</a>.height()).
Destination rectangle corners are (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>) and
(this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.width(), this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.height()). Copies each readable pixel
intersecting both rectangles, without scaling, converting to
this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.colorType() and this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.alphaType() if required.
Pixels are writable when <a href="undocumented#Device">Device</a> is raster, or backed by a <a href="undocumented#GPU">GPU</a>.
Pixels are not writable when <a href="SkCanvas_Reference#SkCanvas">SkCanvas</a> is returned by <a href="undocumented#beginPage">SkDocument::beginPage</a>,
returned by <a href="undocumented#beginRecording">SkPictureRecorder::beginRecording</a>, or <a href="SkCanvas_Reference#Canvas">Canvas</a> is the base of a utility
class like <a href="undocumented#SkDumpCanvas">SkDumpCanvas</a>.
<a href="undocumented#Pixel">Pixel</a> values are converted only if <a href="undocumented#Color_Type">Image Color Type</a> and <a href="undocumented#Alpha_Type">Image Alpha Type</a>
do not match. Only pixels within both source and destination rectangles
are copied. <a href="SkCanvas_Reference#Canvas">Canvas</a> pixels outside the rectangle intersection are unchanged.
Pass negative values for <a href="SkCanvas_Reference#x">x</a> or <a href="SkCanvas_Reference#y">y</a> to offset pixels to the left or
above <a href="SkCanvas_Reference#Canvas">Canvas</a> pixels.
Does not copy, and returns false if:
<table> <tr>
<td>Source and destination rectangles do not intersect.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#bitmap">bitmap</a> does not have allocated pixels.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#bitmap">bitmap</a> pixels could not be converted to this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.colorType() or this-><a href="SkCanvas_Reference#imageInfo">imageInfo</a>.alphaType().</td> </tr> <tr>
<td><a href="SkCanvas_Reference#Canvas">Canvas</a> pixels are not writable; for instance, <a href="SkCanvas_Reference#Canvas">Canvas</a> is document-based.</td> </tr> <tr>
<td><a href="SkCanvas_Reference#bitmap">bitmap</a> pixels are inaccessible; for instance, <a href="SkCanvas_Reference#bitmap">bitmap</a> wraps a texture.</td> </tr>
</table>
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
contains pixels copied to <a href="SkCanvas_Reference#Canvas">Canvas</a></td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable pixels in <a href="SkCanvas_Reference#x">x</a>; may be negative</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable pixels in <a href="SkCanvas_Reference#y">y</a>; may be negative</td>
</tr>
</table>
### Return Value
true if pixels were written to <a href="SkCanvas_Reference#Canvas">Canvas</a>
### Example
<div><fiddle-embed name="8b128e067881f9251357653692fa28da"></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#readPixels">readPixels</a> <a href="SkCanvas_Reference#drawBitmap">drawBitmap</a> <a href="SkCanvas_Reference#drawImage">drawImage</a>
---
# <a name="State_Stack"></a> State Stack
<a href="SkCanvas_Reference#Canvas">Canvas</a> maintains a stack of state that allows hierarchical drawing, commonly used
to implement windows and views. The initial state has an identity matrix and and
an infinite clip. Even with a wide-open clip, drawing is constrained by the
bounds of the <a href="SkCanvas_Reference#Canvas">Canvas</a> <a href="undocumented#Surface">Surface</a> or <a href="undocumented#Device">Device</a>.
<a href="SkCanvas_Reference#Canvas">Canvas</a> savable state consists of <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>.
<a href="SkCanvas_Reference#Clip">Clip</a> describes the area that may be drawn to.
<a href="SkCanvas_Reference#Matrix">Matrix</a> transforms the geometry.
<a href="undocumented#Draw_Filter">Draw Filter</a> (deprecated on most platforms) modifies the paint before drawing.
<a href="SkCanvas_Reference#save">save</a>, <a href="SkCanvas_Reference#saveLayer">saveLayer</a>, <a href="SkCanvas_Reference#saveLayerPreserveLCDTextRequests">saveLayerPreserveLCDTextRequests</a>, and <a href="SkCanvas_Reference#saveLayerAlpha">saveLayerAlpha</a>
save state and return the depth of the stack.
<a href="SkCanvas_Reference#restore">restore</a>, <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a>, and
### Example
<div><fiddle-embed name="a4548baa133302e933b4d3442c06f5b3"><div>Draw to ever smaller clips; then restore drawing to full canvas.
Note that the second <a href="SkCanvas_Reference#clipRect">clipRect</a> is not permitted to enlarge <a href="SkCanvas_Reference#Clip">Clip</a>.</div></fiddle-embed></div>
Each <a href="SkCanvas_Reference#Clip">Clip</a> uses the current <a href="SkCanvas_Reference#Matrix">Matrix</a> for its coordinates.
### Example
<div><fiddle-embed name="9f563a2d60aa31d4b26742e5aa17aa4e"><div>While <a href="SkCanvas_Reference#clipRect">clipRect</a> is given the same rectangle twice, <a href="SkCanvas_Reference#Matrix">Matrix</a> makes the second
<a href="SkCanvas_Reference#clipRect">clipRect</a> draw at half the size of the first.</div></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#save">save</a> <a href="SkCanvas_Reference#saveLayer">saveLayer</a> <a href="SkCanvas_Reference#saveLayerPreserveLCDTextRequests">saveLayerPreserveLCDTextRequests</a> <a href="SkCanvas_Reference#saveLayerAlpha">saveLayerAlpha</a> <a href="SkCanvas_Reference#restore">restore</a> <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a>
<a name="save"></a>
## save
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int save()
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms).
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
restoring the <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> to their state when <a href="SkCanvas_Reference#save">save</a> was called.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>, <a href="SkCanvas_Reference#setMatrix">setMatrix</a>,
and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>, <a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
Saved <a href="SkCanvas_Reference#Canvas">Canvas</a> state is put on a stack; multiple calls to <a href="SkCanvas_Reference#save">save</a> should be balance
by an equal number of calls to <a href="SkCanvas_Reference#restore">restore</a>.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with result to restore this and subsequent saves.
### Return Value
depth of saved stack
### Example
<div><fiddle-embed name="e477dce358a9ba3b0aa1bf33b8a376de"><div>The black square is translated 50 pixels down and to the right.
Restoring <a href="SkCanvas_Reference#Canvas">Canvas</a> state removes <a href="SkCanvas_Reference#translate">translate</a> from <a href="SkCanvas_Reference#Canvas">Canvas</a> stack;
the red square is not translated, and is drawn at the origin.</div></fiddle-embed></div>
---
## <a name="Layer"></a> Layer
<a href="SkCanvas_Reference#State_Stack_Layer">Layer</a> allocates a temporary offscreen <a href="undocumented#Bitmap">Bitmap</a> to draw into. When the drawing is
complete, the <a href="undocumented#Bitmap">Bitmap</a> is drawn into the <a href="SkCanvas_Reference#Canvas">Canvas</a>.
<a href="SkCanvas_Reference#State_Stack_Layer">Layer</a> is saved in a stack along with other saved state. When state with a <a href="SkCanvas_Reference#State_Stack_Layer">Layer</a>
is restored, the offscreen <a href="undocumented#Bitmap">Bitmap</a> is drawn into the previous layer.
<a href="SkCanvas_Reference#State_Stack_Layer">Layer</a> may be initialized with the contents of the previous layer. When <a href="SkCanvas_Reference#State_Stack_Layer">Layer</a> is
restored, its <a href="undocumented#Bitmap">Bitmap</a> can be modified by <a href="SkPaint_Reference#Paint">Paint</a> passed to <a href="SkCanvas_Reference#State_Stack_Layer">Layer</a> to apply
<a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>.
<a name="saveLayer"></a>
## saveLayer
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int saveLayer(const SkRect* bounds, const SkPaint* paint)
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms),
and allocates an offscreen <a href="undocumented#Bitmap">Bitmap</a> for subsequent drawing.
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
and draws the offscreen bitmap.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>,
<a href="SkCanvas_Reference#setMatrix">setMatrix</a>, and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>,
<a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
<a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#bounds">bounds</a> suggests but does not define the offscreen size. To clip drawing to
a specific rectangle, use <a href="SkCanvas_Reference#clipRect">clipRect</a>.
Optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a> applies <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and
<a href="undocumented#Blend_Mode">Blend Mode</a> when <a href="SkCanvas_Reference#restore">restore</a> is called.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with returned value to restore this and subsequent saves.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
hint to limit the size of the offscreen; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
graphics state for offscreen; may be nullptr</td>
</tr>
</table>
### Return Value
depth of saved stack
### Example
<div><fiddle-embed name="05f9b6fa6b5007aea89dfe66c306855d"><div>Rectangles are blurred by <a href="undocumented#Image_Filter">Image Filter</a> when <a href="SkCanvas_Reference#restore">restore</a> draws offscreen to main
<a href="SkCanvas_Reference#Canvas">Canvas</a>.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int saveLayer(const SkRect& bounds, const SkPaint* paint)
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms),
and allocates an offscreen <a href="undocumented#Bitmap">Bitmap</a> for subsequent drawing.
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
and draws the offscreen <a href="undocumented#Bitmap">Bitmap</a>.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>,
<a href="SkCanvas_Reference#setMatrix">setMatrix</a>, and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>,
<a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
<a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#bounds">bounds</a> suggests but does not define the offscreen size. To clip drawing to
a specific rectangle, use <a href="SkCanvas_Reference#clipRect">clipRect</a>.
Optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a> applies <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and
<a href="undocumented#Blend_Mode">Blend Mode</a> when <a href="SkCanvas_Reference#restore">restore</a> is called.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with returned value to restore this and subsequent saves.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
hint to limit the size of the offscreen; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
graphics state for offscreen; may be nullptr</td>
</tr>
</table>
### Return Value
depth of saved stack
### Example
<div><fiddle-embed name="812f3c8f8b93e8c7e55528c7a22887bf"><div>Rectangles are blurred by <a href="undocumented#Image_Filter">Image Filter</a> when <a href="SkCanvas_Reference#restore">restore</a> draws offscreen to main <a href="SkCanvas_Reference#Canvas">Canvas</a>.
The red rectangle is clipped; it does not fully fit on the offscreen <a href="SkCanvas_Reference#Canvas">Canvas</a>.
<a href="undocumented#Image_Filter">Image Filter</a> blurs past edge of offscreen so red rectangle is blurred on all sides.</div></fiddle-embed></div>
---
<a name="saveLayerPreserveLCDTextRequests"></a>
## saveLayerPreserveLCDTextRequests
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPaint* paint)
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms),
and allocates an offscreen bitmap for subsequent drawing.
<a href="SkPaint_Reference#LCD_Text">LCD Text</a> is preserved when the offscreen is drawn to the prior layer.
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
and draws the offscreen bitmap.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>,
<a href="SkCanvas_Reference#setMatrix">setMatrix</a>, and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>,
<a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
<a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#bounds">bounds</a> suggests but does not define the offscreen size. To clip drawing to
a specific rectangle, use <a href="SkCanvas_Reference#clipRect">clipRect</a>.
Optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a> applies <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and
<a href="undocumented#Blend_Mode">Blend Mode</a> when <a href="SkCanvas_Reference#restore">restore</a> is called.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with returned value to restore this and subsequent saves.
Draw text on an opaque background so that <a href="SkPaint_Reference#LCD_Text">LCD Text</a> blends correctly with the
prior layer. <a href="SkPaint_Reference#LCD_Text">LCD Text</a> drawn on a background with transparency may result in
incorrect banding.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
hint to limit the size of the offscreen; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
graphics state for offscreen; may be nullptr</td>
</tr>
</table>
### Return Value
depth of saved stack
### Example
<div><fiddle-embed name="8460bf8b013f46c67e0bd96e13451aff"></fiddle-embed></div>
---
<a name="saveLayerAlpha"></a>
## saveLayerAlpha
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int saveLayerAlpha(const SkRect* bounds, U8CPU alpha)
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms),
and allocates an offscreen bitmap for subsequent drawing.
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
and blends the offscreen bitmap with <a href="SkCanvas_Reference#alpha">alpha</a> opacity onto the prior layer.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>,
<a href="SkCanvas_Reference#setMatrix">setMatrix</a>, and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>,
<a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
<a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#bounds">bounds</a> suggests but does not define the offscreen size. To clip drawing to
a specific rectangle, use <a href="SkCanvas_Reference#clipRect">clipRect</a>.
<a href="SkCanvas_Reference#alpha">alpha</a> of zero is fully transparent, 255 is fully opaque.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with returned value to restore this and subsequent saves.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
hint to limit the size of the offscreen; may be nullptr</td>
</tr> <tr> <td><code><strong>alpha </strong></code></td> <td>
opacity of the offscreen</td>
</tr>
</table>
### Return Value
depth of saved stack
### Example
<div><fiddle-embed name="8ab88d86fb438856cc48d6e2f08a6e24"></fiddle-embed></div>
---
## <a name="SkCanvas::_anonymous"></a> Enum SkCanvas::_anonymous
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
enum {
<a href="SkCanvas_Reference#kIsOpaque_SaveLayerFlag">kIsOpaque SaveLayerFlag</a> = 1 << 0,
<a href="SkCanvas_Reference#kPreserveLCDText_SaveLayerFlag">kPreserveLCDText SaveLayerFlag</a> = 1 << 1,
<a href="SkCanvas_Reference#kInitWithPrevious_SaveLayerFlag">kInitWithPrevious SaveLayerFlag</a> = 1 << 2,
<a href="SkCanvas_Reference#kDontClipToLayer_Legacy_SaveLayerFlag">kDontClipToLayer Legacy SaveLayerFlag</a> = kDontClipToLayer_PrivateSaveLayerFlag,
};
typedef uint32_t <a href="undocumented#SaveLayerFlags">SaveLayerFlags</a>;</pre>
<a href="undocumented#SaveLayerFlags">SaveLayerFlags</a> provides options that may be used in any combination in <a href="SkCanvas_Reference#SaveLayerRec">SaveLayerRec</a>,
defining how the offscreen allocated by <a href="SkCanvas_Reference#saveLayer">saveLayer</a> operates.
### Constants
<table>
<tr>
<td><a name="SkCanvas::kIsOpaque_SaveLayerFlag"></a> <code><strong>SkCanvas::kIsOpaque_SaveLayerFlag </strong></code></td><td>1</td><td>Creates offscreen without transparency. Flag is ignored if layer <a href="SkPaint_Reference#Paint">Paint</a> contains
<a href="undocumented#Image_Filter">Image Filter</a> or <a href="undocumented#Color_Filter">Color Filter</a>.</td>
</tr>
<tr>
<td><a name="SkCanvas::kPreserveLCDText_SaveLayerFlag"></a> <code><strong>SkCanvas::kPreserveLCDText_SaveLayerFlag </strong></code></td><td>2</td><td>Creates offscreen for <a href="undocumented#LCD">LCD</a> text. Flag is ignored if layer <a href="SkPaint_Reference#Paint">Paint</a> contains
<a href="undocumented#Image_Filter">Image Filter</a> or <a href="undocumented#Color_Filter">Color Filter</a>.</td>
</tr>
<tr>
<td><a name="SkCanvas::kInitWithPrevious_SaveLayerFlag"></a> <code><strong>SkCanvas::kInitWithPrevious_SaveLayerFlag </strong></code></td><td>4</td><td>Initializes offscreen with the contents of the previous layer.</td>
</tr>
<tr>
<td><a name="SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag"></a> <code><strong>SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag </strong></code></td><td>0x80000000</td><td>Only present on <a href="undocumented#Android">Android</a>.
Skips setting a clip to the layer bounds.</td>
</tr>
</table>
### Example
<div><fiddle-embed name="d314c688925d2c549d4762f5cc6e6a1a"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> layer captures red and blue circles scaled up by four.
scalePaint blends offscreen back with transparency.</div></fiddle-embed></div>
# <a name="SkCanvas::SaveLayerRec"></a> Struct SkCanvas::SaveLayerRec
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
struct <a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> {
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a>*(...
const <a href="undocumented#SkRect">SkRect</a>* <a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a>;
const <a href="SkPaint_Reference#SkPaint">SkPaint</a>* <a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a>;
const <a href="undocumented#SkImageFilter">SkImageFilter</a>* <a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a>;
<a href="undocumented#SaveLayerFlags">SaveLayerFlags</a> <a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>;
};</pre>
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> contains the state used to create the layer offscreen.
<code><strong>const SkRect* fBounds</strong></code>
<a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a> is used as a hint to limit the size of the offscreen; may be nullptr.
<a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a> suggests but does not define the offscreen size. To clip drawing to
a specific rectangle, use <a href="SkCanvas_Reference#clipRect">clipRect</a>.
<code><strong>const SkPaint* fPaint</strong></code>
<a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a> modifies how the offscreen overlays the prior layer; may be nullptr.
<a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and
<a href="undocumented#Mask_Filter">Mask Filter</a> affect the offscreen draw.
<code><strong>const SkImageFilter* fBackdrop</strong></code>
<a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a> applies <a href="undocumented#Image_Filter">Image Filter</a> to the prior layer when copying to the layer
offscreen; may be nullptr. Use <a href="SkCanvas_Reference#kInitWithPrevious_SaveLayerFlag">kInitWithPrevious SaveLayerFlag</a> to copy the
prior layer without an <a href="undocumented#Image_Filter">Image Filter</a>.
<code><strong>const SkImage* fClipMask</strong></code>
<a href="SkCanvas_Reference#restore">restore</a> clips the layer offscreen by the alpha channel of <a href="SkCanvas_Reference#SaveLayerRec_fClipMask">fClipMask</a> when
the offscreen is copied to <a href="undocumented#Device">Device</a>. <a href="SkCanvas_Reference#SaveLayerRec_fClipMask">fClipMask</a> may be nullptr. .
<code><strong>const SkMatrix* fClipMatrix</strong></code>
<a href="SkCanvas_Reference#SaveLayerRec_fClipMatrix">fClipMatrix</a> transforms <a href="SkCanvas_Reference#SaveLayerRec_fClipMask">fClipMask</a> before it clips the layer offscreen. If
<a href="SkCanvas_Reference#SaveLayerRec_fClipMask">fClipMask</a> describes a translucent gradient, it may be scaled and rotated
without introducing artifacts. <a href="SkCanvas_Reference#SaveLayerRec_fClipMatrix">fClipMatrix</a> may be nullptr.
<code><strong>SaveLayerFlags fSaveLayerFlags</strong></code>
<a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a> are used to create layer offscreen without transparency,
create layer offscreen for <a href="undocumented#LCD">LCD</a> text, and to create layer offscreen with the
contents of the previous layer.
### Example
<div><fiddle-embed name="7b18146582fc2440656b839a173ed500"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> layer captures a red anti-aliased circle and a blue aliased circle scaled
up by four. After drawing another unscaled red circle on top, the offscreen is
transferred to the main canvas.</div></fiddle-embed></div>
<a name="SaveLayerRec"></a>
## SaveLayerRec
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SaveLayerRec()
</pre>
Sets <a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a>, <a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a>, and <a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a> to nullptr. Clears <a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>.
### Return Value
empty <a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a>
### Example
<div><fiddle-embed name="ac7c834dce2eac6ef49c15e820e94003">
#### Example Output
~~~~
rec1 == rec2
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SaveLayerRec(const SkRect* bounds, const SkPaint* paint,
SaveLayerFlags saveLayerFlags = 0)
</pre>
Sets <a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a>, <a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a>, and <a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>; sets <a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a> to nullptr.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
offscreen dimensions; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
applied to offscreen when overlaying prior layer; may be nullptr</td>
</tr> <tr> <td><code><strong>saveLayerFlags </strong></code></td> <td>
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> options to modify offscreen</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> with empty backdrop
### Example
<div><fiddle-embed name="027f920259888fc19591ea9a90d92873">
#### Example Output
~~~~
rec1 == rec2
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SaveLayerRec(const SkRect* bounds, const SkPaint* paint,
const SkImageFilter* backdrop, SaveLayerFlags saveLayerFlags)
</pre>
Sets <a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a>, <a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a>, <a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a>, and <a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
offscreen dimensions; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
applied to offscreen when overlaying prior layer;
may be nullptr</td>
</tr> <tr> <td><code><strong>backdrop </strong></code></td> <td>
prior layer copied to offscreen with <a href="undocumented#Image_Filter">Image Filter</a>;
may be nullptr</td>
</tr> <tr> <td><code><strong>saveLayerFlags </strong></code></td> <td>
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> options to modify offscreen</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> fully specified
### Example
<div><fiddle-embed name="9b7fa2fe855642ffff6538829db15328">
#### Example Output
~~~~
rec1 == rec2
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SaveLayerRec(const SkRect* bounds, const SkPaint* paint,
const SkImageFilter* backdrop, const SkImage* clipMask,
const SkMatrix* clipMatrix, SaveLayerFlags saveLayerFlags)
</pre>
Not ready for general use.Sets <a href="SkCanvas_Reference#SaveLayerRec_fBounds">fBounds</a>, <a href="SkCanvas_Reference#SaveLayerRec_fPaint">fPaint</a>, <a href="SkCanvas_Reference#SaveLayerRec_fBackdrop">fBackdrop</a>, <a href="SkCanvas_Reference#SaveLayerRec_fClipMask">fClipMask</a>, <a href="SkCanvas_Reference#SaveLayerRec_fClipMatrix">fClipMatrix</a>, and <a href="SkCanvas_Reference#SaveLayerRec_fSaveLayerFlags">fSaveLayerFlags</a>.
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec_4">clipMatrix</a> uses alpha channel of image, transformed by <a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec_4">clipMatrix</a>, to clip layer
when drawn to <a href="SkCanvas_Reference#Canvas">Canvas</a>.
Implementation is incomplete; has no effect if <a href="undocumented#Device">Device</a> is <a href="undocumented#GPU_backed">GPU-backed</a>.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
offscreen dimensions; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
graphics state applied to offscreen when overlaying prior
layer; may be nullptr</td>
</tr> <tr> <td><code><strong>backdrop </strong></code></td> <td>
prior layer copied to offscreen with <a href="undocumented#Image_Filter">Image Filter</a>;
may be nullptr</td>
</tr> <tr> <td><code><strong>clipMask </strong></code></td> <td>
clip applied to layer; may be nullptr</td>
</tr> <tr> <td><code><strong>clipMatrix </strong></code></td> <td>
matrix applied to <a href="SkCanvas_Reference#clipMask">clipMask</a>; may be nullptr to use
identity matrix</td>
</tr> <tr> <td><code><strong>saveLayerFlags </strong></code></td> <td>
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> options to modify offscreen</td>
</tr>
</table>
### Return Value
<a href="SkCanvas_Reference#SaveLayerRec_SaveLayerRec">SaveLayerRec</a> fully specified
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int saveLayer(const SaveLayerRec& layerRec)
</pre>
Saves <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> (<a href="undocumented#Draw_Filter">Draw Filter</a> deprecated on most platforms),
and allocates an offscreen bitmap for subsequent drawing.
Calling <a href="SkCanvas_Reference#restore">restore</a> discards changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>,
and blends the offscreen bitmap with alpha opacity onto the prior layer.
<a href="SkCanvas_Reference#Matrix">Matrix</a> may be changed by <a href="SkCanvas_Reference#translate">translate</a>, <a href="SkCanvas_Reference#scale">scale</a>, <a href="SkCanvas_Reference#rotate">rotate</a>, <a href="SkCanvas_Reference#skew">skew</a>, <a href="SkCanvas_Reference#concat">concat</a>,
<a href="SkCanvas_Reference#setMatrix">setMatrix</a>, and <a href="SkCanvas_Reference#resetMatrix">resetMatrix</a>. <a href="SkCanvas_Reference#Clip">Clip</a> may be changed by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a>,
<a href="SkCanvas_Reference#clipPath">clipPath</a>, <a href="SkCanvas_Reference#clipRegion">clipRegion</a>.
<a href="SkCanvas_Reference#SaveLayerRec">SaveLayerRec</a> contains the state used to create the layer offscreen.
Call <a href="SkCanvas_Reference#restoreToCount">restoreToCount</a> with returned value to restore this and subsequent saves.
### Parameters
<table> <tr> <td><code><strong>layerRec </strong></code></td> <td>
offscreen state</td>
</tr>
</table>
### Return Value
depth of save state stack
### Example
<div><fiddle-embed name="0da8c199f1d9ec4d1b9c5d1114d6cbd6"><div>The example draws an image, and saves it into a layer with <a href="SkCanvas_Reference#kInitWithPrevious_SaveLayerFlag">kInitWithPrevious SaveLayerFlag</a>.
Next it punches a hole in the layer and restore with <a href="undocumented#kPlus">SkBlendMode::kPlus</a>.
Where the layer was cleared, the original image will draw unchanged.
Outside of the circle the mandrill is brightened.</div></fiddle-embed></div>
---
<a name="restore"></a>
## restore
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void restore()
</pre>
Removes changes to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> since <a href="SkCanvas_Reference#Canvas">Canvas</a> state was
last saved. The state is removed from the stack.
Does nothing if the stack is empty.
### Example
<div><fiddle-embed name="e78471212a67f2f4fd39496e17a30d17"></fiddle-embed></div>
---
<a name="getSaveCount"></a>
## getSaveCount
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
int getSaveCount() const
</pre>
Returns the number of saved states, each containing: <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a>.
Equals the number of <a href="SkCanvas_Reference#save">save</a> calls less the number of <a href="SkCanvas_Reference#restore">restore</a> calls plus one.
The save count of a new canvas is one.
### Return Value
depth of save state stack
### Example
<div><fiddle-embed name="005f2b207e078baac596681924fe591e">
#### Example Output
~~~~
depth = 1
depth = 2
depth = 1
~~~~
</fiddle-embed></div>
---
<a name="restoreToCount"></a>
## restoreToCount
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void restoreToCount(int saveCount)
</pre>
Restores state to <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkCanvas_Reference#Clip">Clip</a>, and <a href="undocumented#Draw_Filter">Draw Filter</a> values when <a href="SkCanvas_Reference#save">save</a>, <a href="SkCanvas_Reference#saveLayer">saveLayer</a>,
<a href="SkCanvas_Reference#saveLayerPreserveLCDTextRequests">saveLayerPreserveLCDTextRequests</a>, or <a href="SkCanvas_Reference#saveLayerAlpha">saveLayerAlpha</a> returned <a href="SkCanvas_Reference#saveCount">saveCount</a>.
Does nothing if <a href="SkCanvas_Reference#saveCount">saveCount</a> is greater than state stack count.
Restores state to initial values if <a href="SkCanvas_Reference#saveCount">saveCount</a> is less than or equal to one.
### Parameters
<table> <tr> <td><code><strong>saveCount </strong></code></td> <td>
depth of state stack to restore</td>
</tr>
</table>
### Example
<div><fiddle-embed name="9ed0d56436e114c7097fd49eed1aea47">
#### Example Output
~~~~
depth = 1
depth = 3
depth = 1
~~~~
</fiddle-embed></div>
---
# <a name="Matrix"></a> Matrix
<a name="translate"></a>
## translate
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void translate(SkScalar dx, SkScalar dy)
</pre>
Translate <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#dx">dx</a> along the x-axis and <a href="SkCanvas_Reference#dy">dy</a> along the y-axis.
Mathematically, replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with a translation matrix
pre-multiplied with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of moving the drawing by (<a href="SkCanvas_Reference#dx">dx</a>, <a href="SkCanvas_Reference#dy">dy</a>) before transforming
the result with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>dx </strong></code></td> <td>
distance to translate in x</td>
</tr> <tr> <td><code><strong>dy </strong></code></td> <td>
distance to translate in y</td>
</tr>
</table>
### Example
<div><fiddle-embed name="eb93d5fa66a5f7a10f4f9210494d7222"><div><a href="SkCanvas_Reference#scale">scale</a> followed by <a href="SkCanvas_Reference#translate">translate</a> produces different results from <a href="SkCanvas_Reference#translate">translate</a> followed
by <a href="SkCanvas_Reference#scale">scale</a>.
The blue stroke follows translate of (50, 50); a black
fill follows scale of (2, 1/2.f). After restoring the clip, which resets
<a href="SkCanvas_Reference#Matrix">Matrix</a>, a red frame follows the same scale of (2, 1/2.f); a gray fill
follows translate of (50, 50).</div></fiddle-embed></div>
---
<a name="scale"></a>
## scale
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void scale(SkScalar sx, SkScalar sy)
</pre>
Scale <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#sx">sx</a> on the x-axis and <a href="SkCanvas_Reference#sy">sy</a> on the y-axis.
Mathematically, replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with a scale matrix
pre-multiplied with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of scaling the drawing by (<a href="SkCanvas_Reference#sx">sx</a>, <a href="SkCanvas_Reference#sy">sy</a>) before transforming
the result with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>sx </strong></code></td> <td>
amount to scale in x</td>
</tr> <tr> <td><code><strong>sy </strong></code></td> <td>
amount to scale in y</td>
</tr>
</table>
### Example
<div><fiddle-embed name="7d0d801ef13c6c6da51e840c22ac15b0"></fiddle-embed></div>
---
<a name="rotate"></a>
## rotate
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void rotate(SkScalar degrees)
</pre>
Rotate <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#degrees">degrees</a>. Positive <a href="SkCanvas_Reference#degrees">degrees</a> rotates clockwise.
Mathematically, replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with a rotation matrix
pre-multiplied with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of rotating the drawing by <a href="SkCanvas_Reference#degrees">degrees</a> before transforming
the result with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>degrees </strong></code></td> <td>
amount to rotate, in <a href="SkCanvas_Reference#degrees">degrees</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="caafb205771b714948e00dcd58ccaf1f"><div>Draw clock hands at time 5:10. The hour hand and minute hand point up and
are rotated clockwise.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void rotate(SkScalar degrees, SkScalar px, SkScalar py)
</pre>
Rotate <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#degrees">degrees</a> about a point at (<a href="SkCanvas_Reference#px">px</a>, <a href="SkCanvas_Reference#py">py</a>). Positive <a href="SkCanvas_Reference#degrees">degrees</a> rotates
clockwise.
Mathematically, construct a rotation matrix. Pre-multiply the rotation matrix by
a translation matrix, then replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with the resulting matrix
pre-multiplied with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of rotating the drawing about a given point before
transforming the result with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>degrees </strong></code></td> <td>
amount to rotate, in <a href="SkCanvas_Reference#degrees">degrees</a></td>
</tr> <tr> <td><code><strong>px </strong></code></td> <td>
x-coordinate of the point to rotate about</td>
</tr> <tr> <td><code><strong>py </strong></code></td> <td>
y-coordinate of the point to rotate about</td>
</tr>
</table>
### Example
<div><fiddle-embed name="bcf5baea1c66a957d5ffd7b54bbbfeff"></fiddle-embed></div>
---
<a name="skew"></a>
## skew
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void skew(SkScalar sx, SkScalar sy)
</pre>
Skew <a href="SkCanvas_Reference#Matrix">Matrix</a> by <a href="SkCanvas_Reference#sx">sx</a> on the x-axis and <a href="SkCanvas_Reference#sy">sy</a> on the y-axis. A positive value of <a href="SkCanvas_Reference#sx">sx</a>
skews the drawing right as y increases; a positive value of <a href="SkCanvas_Reference#sy">sy</a> skews the drawing
down as x increases.
Mathematically, replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with a skew matrix pre-multiplied with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of skewing the drawing by (<a href="SkCanvas_Reference#sx">sx</a>, <a href="SkCanvas_Reference#sy">sy</a>) before transforming
the result with <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>sx </strong></code></td> <td>
amount to skew in x</td>
</tr> <tr> <td><code><strong>sy </strong></code></td> <td>
amount to skew in y</td>
</tr>
</table>
### Example
<div><fiddle-embed name="2e2acc21d7774df7e0940a30ad2ca99e"><div>Black text mimics an oblique text style by using a negative skew in x that
shifts the geometry to the right as the y values decrease.
Red text uses a positive skew in y to shift the geometry down as the x values
increase.
Blue text combines x and y skew to rotate and scale.</div></fiddle-embed></div>
---
<a name="concat"></a>
## concat
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void concat(const SkMatrix& matrix)
</pre>
Replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with <a href="SkCanvas_Reference#matrix">matrix</a> pre-multiplied with existing <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This has the effect of transforming the drawn geometry by <a href="SkCanvas_Reference#matrix">matrix</a>, before
transforming the result with existing <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>matrix </strong></code></td> <td>
<a href="SkCanvas_Reference#matrix">matrix</a> to pre-multiply with existing <a href="SkCanvas_Reference#Matrix">Matrix</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="8f6818b25a92a88638ad99b2dd293f61"></fiddle-embed></div>
---
<a name="setMatrix"></a>
## setMatrix
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void setMatrix(const SkMatrix& matrix)
</pre>
Replace <a href="SkCanvas_Reference#Matrix">Matrix</a> with <a href="SkCanvas_Reference#matrix">matrix</a>.
Unlike <a href="SkCanvas_Reference#concat">concat</a>, any prior <a href="SkCanvas_Reference#matrix">matrix</a> state is overwritten.
### Parameters
<table> <tr> <td><code><strong>matrix </strong></code></td> <td>
<a href="SkCanvas_Reference#matrix">matrix</a> to copy, replacing existing <a href="SkCanvas_Reference#Matrix">Matrix</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="24b9cf7e6f9a08394e1e07413bd8733a"></fiddle-embed></div>
---
<a name="resetMatrix"></a>
## resetMatrix
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void resetMatrix()
</pre>
Sets <a href="SkCanvas_Reference#Matrix">Matrix</a> to the identity matrix.
Any prior matrix state is overwritten.
### Example
<div><fiddle-embed name="412afffdf4682baa503a4e2e99201967"></fiddle-embed></div>
---
<a name="getTotalMatrix"></a>
## getTotalMatrix
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
const SkMatrix& getTotalMatrix() const
</pre>
Returns <a href="SkCanvas_Reference#Matrix">Matrix</a>.
This does not account for translation by <a href="undocumented#Device">Device</a> or <a href="undocumented#Surface">Surface</a>.
### Return Value
<a href="SkCanvas_Reference#Matrix">Matrix</a> in <a href="SkCanvas_Reference#Canvas">Canvas</a>
### Example
<div><fiddle-embed name="c0d5fa544759704768f47cac91ae3832">
#### Example Output
~~~~
isIdentity true
~~~~
</fiddle-embed></div>
---
# <a name="Clip"></a> Clip
<a href="SkCanvas_Reference#Clip">Clip</a> is built from a stack of clipping paths. Each <a href="SkPath_Reference#Path">Path</a> in the
stack can be constructed from one or more <a href="SkPath_Reference#Contour">Path Contour</a> elements. The
<a href="SkPath_Reference#Contour">Path Contour</a> may be composed of any number of <a href="SkPath_Reference#Verb">Path Verb</a> segments. Each
<a href="SkPath_Reference#Contour">Path Contour</a> forms a closed area; <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> defines the area enclosed
by <a href="SkPath_Reference#Contour">Path Contour</a>.
<a href="SkCanvas_Reference#Clip">Clip</a> stack of <a href="SkPath_Reference#Path">Path</a> elements successfully restrict the <a href="SkPath_Reference#Path">Path</a> area. Each
<a href="SkPath_Reference#Path">Path</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>, then intersected with or subtracted from the
prior <a href="SkCanvas_Reference#Clip">Clip</a> to form the replacement <a href="SkCanvas_Reference#Clip">Clip</a>. Use <a href="undocumented#kDifference">SkClipOp::kDifference</a>
to subtract <a href="SkPath_Reference#Path">Path</a> from <a href="SkCanvas_Reference#Clip">Clip</a>; use <a href="undocumented#kIntersect">SkClipOp::kIntersect</a> to intersect <a href="SkPath_Reference#Path">Path</a>
with <a href="SkCanvas_Reference#Clip">Clip</a>.
A clipping <a href="SkPath_Reference#Path">Path</a> may be anti-aliased; if <a href="SkPath_Reference#Path">Path</a>, after transformation, is
composed of horizontal and vertical lines, clearing <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> allows whole pixels
to either be inside or outside the clip. The fastest drawing has a aliased,
rectanglar clip.
If clipping <a href="SkPath_Reference#Path">Path</a> has <a href="SkPaint_Reference#Anti_alias">Anti-alias</a> set, clip may partially clip a pixel, requiring
that drawing blend partially with the destination along the edge. A rotated
rectangular anti-aliased clip looks smoother but draws slower.
<a href="SkCanvas_Reference#Clip">Clip</a> can combine with <a href="undocumented#Rect">Rect</a> and <a href="undocumented#Round_Rect">Round Rect</a> primitives; like
<a href="SkPath_Reference#Path">Path</a>, these are transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before they are combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
<a href="SkCanvas_Reference#Clip">Clip</a> can combine with <a href="undocumented#Region">Region</a>. <a href="undocumented#Region">Region</a> is assumed to be in <a href="undocumented#Device">Device</a> coordinates
and is unaffected by <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Example
<div><fiddle-embed name="d2e60e5171f26ff9ddefae48387f889b"><div>Draw a red circle with an aliased clip and an anti-aliased clip.
Use an image filter to zoom into the pixels drawn.
The edge of the aliased clip fully draws pixels in the red circle.
The edge of the anti-aliased clip partially draws pixels in the red circle.</div></fiddle-embed></div>
<a name="clipRect"></a>
## clipRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRect(const SkRect& rect, SkClipOp op, bool doAntiAlias)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rect">rect</a>,
with an aliased or anti-aliased clip edge. <a href="SkCanvas_Reference#rect">rect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>
before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
Rectangle to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be anti-aliased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="6a614faa0fbcf19958b5559c19b02d0f"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRect(const SkRect& rect, SkClipOp op)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rect">rect</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkCanvas_Reference#rect">rect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
Rectangle to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="13bbc5fa5597a6cd4d704b419dbc66d9"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRect(const SkRect& rect, bool doAntiAlias = false)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rect">rect</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkCanvas_Reference#rect">rect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>
before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
Rectangle to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be anti-aliased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="1d4e0632c97e42692775d834fe10aa99"><div>A circle drawn in pieces looks uniform when drawn aliased.
The same circle pieces blend with pixels more than once when anti-aliased,
visible as a thin pair of lines through the right circle.</div></fiddle-embed></div>
---
<a name="androidFramework_setDeviceClipRestriction"></a>
## androidFramework_setDeviceClipRestriction
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void androidFramework_setDeviceClipRestriction(const SkIRect& rect)
</pre>
Sets the max clip rectangle, which can be set by <a href="SkCanvas_Reference#clipRect">clipRect</a>, <a href="SkCanvas_Reference#clipRRect">clipRRect</a> and
<a href="SkCanvas_Reference#clipPath">clipPath</a> and intersect the current clip with the specified <a href="SkCanvas_Reference#androidFramework_setDeviceClipRestriction">rect</a>.
The max clip affects only future ops (it is not retroactive).
The clip restriction is not recorded in pictures.
Pass an empty <a href="SkCanvas_Reference#androidFramework_setDeviceClipRestriction">rect</a> to disable max clip.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
maximum allowed clip in device coordinates</td>
</tr>
#
---
</table>
<a name="clipRRect"></a>
## clipRRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rrect">rrect</a>,
with an aliased or anti-aliased clip edge.
<a href="SkCanvas_Reference#rrect">rrect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>
before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rrect </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be antialiased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="182ef48ab5e04ba3578496fda8d9fa36"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRRect(const SkRRect& rrect, SkClipOp op)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rrect">rrect</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkCanvas_Reference#rrect">rrect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rrect </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="ef6ae2eaae6761130ce38065d0364abd"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRRect(const SkRRect& rrect, bool doAntiAlias = false)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#rrect">rrect</a>,
with an aliased or anti-aliased clip edge.
<a href="SkCanvas_Reference#rrect">rrect</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>rrect </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be antialiased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="f583114580b2176fe3e75b0994476a84"></fiddle-embed></div>
---
<a name="clipPath"></a>
## clipPath
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#path">path</a>,
with an aliased or anti-aliased clip edge. <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> determines if <a href="SkCanvas_Reference#path">path</a>
describes the area inside or outside its contours; and if <a href="SkPath_Reference#Contour">Path Contour</a> overlaps
itself or another <a href="SkPath_Reference#Contour">Path Contour</a>, whether the overlaps form part of the area.
<a href="SkCanvas_Reference#path">path</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be antialiased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="ee47ae6b813bfaa55e1a7b7c053ed60d"><div>Top figure uses <a href="SkPath_Reference#kInverseWinding_FillType">SkPath::kInverseWinding FillType</a> and <a href="undocumented#kDifference">SkClipOp::kDifference</a>;
area outside clip is subtracted from circle.
Bottom figure uses <a href="SkPath_Reference#kWinding_FillType">SkPath::kWinding FillType</a> and <a href="undocumented#kIntersect">SkClipOp::kIntersect</a>;
area inside clip is intersected with circle.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipPath(const SkPath& path, SkClipOp op)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#path">path</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkPath_Reference#Fill_Type">Path Fill Type</a> determines if <a href="SkCanvas_Reference#path">path</a>
describes the area inside or outside its contours; and if <a href="SkPath_Reference#Contour">Path Contour</a> overlaps
itself or another <a href="SkPath_Reference#Contour">Path Contour</a>, whether the overlaps form part of the area.
<a href="SkCanvas_Reference#path">path</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>
before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="7856755c1bf8431c286c734b353345ad"><div>Overlapping <a href="undocumented#Rect">Rects</a> form a clip. When clip's <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> is set to
<a href="SkPath_Reference#kWinding_FillType">SkPath::kWinding FillType</a>, the overlap is included. Set to
<a href="SkPath_Reference#kEvenOdd_FillType">SkPath::kEvenOdd FillType</a>, the overlap is excluded and forms a hole.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipPath(const SkPath& path, bool doAntiAlias = false)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#path">path</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkPath_Reference#Fill_Type">Path Fill Type</a> determines if <a href="SkCanvas_Reference#path">path</a>
describes the area inside or outside its contours; and if <a href="SkPath_Reference#Contour">Path Contour</a> overlaps
itself or another <a href="SkPath_Reference#Contour">Path Contour</a>, whether the overlaps form part of the area.
<a href="SkCanvas_Reference#path">path</a> is transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a> before it is combined with <a href="SkCanvas_Reference#Clip">Clip</a>.
### Parameters
<table> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>doAntiAlias </strong></code></td> <td>
true if <a href="SkCanvas_Reference#Clip">Clip</a> is to be antialiased</td>
</tr>
</table>
### Example
<div><fiddle-embed name="187a7ae77a8176e417181411988534b6"><div><a href="SkCanvas_Reference#Clip">Clip</a> loops over itself covering its center twice. When clip's <a href="SkPath_Reference#Fill_Type">Path Fill Type</a>
is set to <a href="SkPath_Reference#kWinding_FillType">SkPath::kWinding FillType</a>, the overlap is included. Set to
<a href="SkPath_Reference#kEvenOdd_FillType">SkPath::kEvenOdd FillType</a>, the overlap is excluded and forms a hole.</div></fiddle-embed></div>
---
<a name="setAllowSimplifyClip"></a>
## setAllowSimplifyClip
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void setAllowSimplifyClip(bool allow)
</pre>
Only used for testing.Set to simplify clip stack using path ops.
---
<a name="clipRegion"></a>
## clipRegion
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkClipOp::kIntersect)
</pre>
Replace <a href="SkCanvas_Reference#Clip">Clip</a> with the intersection or difference of <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="undocumented#Region">Region</a> <a href="SkCanvas_Reference#deviceRgn">deviceRgn</a>.
Resulting <a href="SkCanvas_Reference#Clip">Clip</a> is aliased; pixels are fully contained by the clip.
<a href="SkCanvas_Reference#deviceRgn">deviceRgn</a> is unaffected by <a href="SkCanvas_Reference#Matrix">Matrix</a>.
### Parameters
<table> <tr> <td><code><strong>deviceRgn </strong></code></td> <td>
<a href="undocumented#Region">Region</a> to combine with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr> <tr> <td><code><strong>op </strong></code></td> <td>
<a href="undocumented#Op">Clip Op</a> to apply to <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="7bb57c0e456c5fda2c2cca4abb68b19e"><div>region is unaffected by canvas rotation; rect is affected by canvas rotation.
Both clips are aliased; this is unnoticable on <a href="undocumented#Region">Region</a> clip because it
aligns to pixel boundaries.</div></fiddle-embed></div>
---
<a name="quickReject"></a>
## quickReject
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool quickReject(const SkRect& rect) const
</pre>
Return true if <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#rect">rect</a>, transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>, can be quickly determined to be
outside of <a href="SkCanvas_Reference#Clip">Clip</a>. May return false even though <a href="SkCanvas_Reference#rect">rect</a> is outside of <a href="SkCanvas_Reference#Clip">Clip</a>.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> to compare with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#rect">rect</a>, transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>, does not intersect <a href="SkCanvas_Reference#Clip">Clip</a>
### Example
<div><fiddle-embed name="c15e39862d5f07b0fed44c71e86f7cc9">
#### Example Output
~~~~
quickReject true
quickReject false
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool quickReject(const SkPath& path) const
</pre>
Return true if <a href="SkCanvas_Reference#path">path</a>, transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>, can be quickly determined to be
outside of <a href="SkCanvas_Reference#Clip">Clip</a>. May return false even though <a href="SkCanvas_Reference#path">path</a> is outside of <a href="SkCanvas_Reference#Clip">Clip</a>.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
### Parameters
<table> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> to compare with <a href="SkCanvas_Reference#Clip">Clip</a></td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#path">path</a>, transformed by <a href="SkCanvas_Reference#Matrix">Matrix</a>, does not intersect <a href="SkCanvas_Reference#Clip">Clip</a>
### Example
<div><fiddle-embed name="64723a541c40073157abf2ca67907e15">
#### Example Output
~~~~
quickReject true
quickReject false
~~~~
</fiddle-embed></div>
---
<a name="getLocalClipBounds"></a>
## getLocalClipBounds
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkRect getLocalClipBounds() const
</pre>
Return bounds of <a href="SkCanvas_Reference#Clip">Clip</a>, transformed by inverse of <a href="SkCanvas_Reference#Matrix">Matrix</a>. If <a href="SkCanvas_Reference#Clip">Clip</a> is empty,
return <a href="undocumented#MakeEmpty">SkRect::MakeEmpty</a>, where all <a href="undocumented#Rect">Rect</a> sides equal zero.
<a href="undocumented#Rect">Rect</a> returned is outset by one to account for partial pixel coverage if <a href="SkCanvas_Reference#Clip">Clip</a>
is anti-aliased.
### Return Value
bounds of <a href="SkCanvas_Reference#Clip">Clip</a> in local coordinates
### Example
<div><fiddle-embed name="0b36ff64daf88c046b4ae6ed4ee64db9"><div>Initial bounds is device bounds outset by 1 on all sides.
Clipped bounds is <a href="SkCanvas_Reference#clipPath">clipPath</a> bounds outset by 1 on all sides.
Scaling the canvas by two in x and y scales the local bounds by 1/2 in x and y.</div>
#### Example Output
~~~~
left:-1 top:-1 right:257 bottom:257
left:29 top:129 right:121 bottom:231
left:14.5 top:64.5 right:60.5 bottom:115.5
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool getLocalClipBounds(SkRect* bounds) const
</pre>
Return <a href="SkCanvas_Reference#bounds">bounds</a> of <a href="SkCanvas_Reference#Clip">Clip</a>, transformed by inverse of <a href="SkCanvas_Reference#Matrix">Matrix</a>. If <a href="SkCanvas_Reference#Clip">Clip</a> is empty,
return false, and set <a href="SkCanvas_Reference#bounds">bounds</a> to <a href="undocumented#MakeEmpty">SkRect::MakeEmpty</a>, where all <a href="undocumented#Rect">Rect</a> sides equal zero.
<a href="SkCanvas_Reference#bounds">bounds</a> is outset by one to account for partial pixel coverage if <a href="SkCanvas_Reference#Clip">Clip</a>
is anti-aliased.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#Clip">Clip</a> in local coordinates</td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#Clip">Clip</a> <a href="SkCanvas_Reference#bounds">bounds</a> is not empty
### Example
<div><fiddle-embed name="85496614e90c66b020f8a70db8d06f4a">
#### Example Output
~~~~
local bounds empty = false
local bounds empty = true
~~~~
</fiddle-embed></div>
---
<a name="getDeviceClipBounds"></a>
## getDeviceClipBounds
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkIRect getDeviceClipBounds() const
</pre>
Return <a href="undocumented#IRect">IRect</a> bounds of <a href="SkCanvas_Reference#Clip">Clip</a>, unaffected by <a href="SkCanvas_Reference#Matrix">Matrix</a>. If <a href="SkCanvas_Reference#Clip">Clip</a> is empty,
return <a href="undocumented#MakeEmpty">SkRect::MakeEmpty</a>, where all <a href="undocumented#Rect">Rect</a> sides equal zero.
Unlike <a href="SkCanvas_Reference#getLocalClipBounds">getLocalClipBounds</a>, returned <a href="undocumented#IRect">IRect</a> is not outset.
### Return Value
bounds of <a href="SkCanvas_Reference#Clip">Clip</a> in <a href="undocumented#Device">Device</a> coordinates
### Example
<div><fiddle-embed name="5f4c910afa4a5a61702e5119eab2cac9"><div>Initial bounds is device bounds, not outset.
Clipped bounds is <a href="SkCanvas_Reference#clipPath">clipPath</a> bounds, not outset.
Scaling the canvas by 1/2 in x and y scales the device bounds by 1/2 in x and y.</div>
#### Example Output
~~~~
left:0 top:0 right:256 bottom:256
left:30 top:130 right:120 bottom:230
left:15 top:65 right:60 bottom:115
~~~~
</fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
bool getDeviceClipBounds(SkIRect* bounds) const
</pre>
Return <a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#bounds">bounds</a> of <a href="SkCanvas_Reference#Clip">Clip</a>, unaffected by <a href="SkCanvas_Reference#Matrix">Matrix</a>. If <a href="SkCanvas_Reference#Clip">Clip</a> is empty,
return false, and set <a href="SkCanvas_Reference#bounds">bounds</a> to <a href="undocumented#MakeEmpty">SkRect::MakeEmpty</a>, where all <a href="undocumented#Rect">Rect</a> sides equal zero.
Unlike <a href="SkCanvas_Reference#getLocalClipBounds">getLocalClipBounds</a>, <a href="SkCanvas_Reference#bounds">bounds</a> is not outset.
### Parameters
<table> <tr> <td><code><strong>bounds </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#Clip">Clip</a> in device coordinates</td>
</tr>
</table>
### Return Value
true if <a href="SkCanvas_Reference#Clip">Clip</a> <a href="SkCanvas_Reference#bounds">bounds</a> is not empty
### Example
<div><fiddle-embed name="6abb99f849a1f0e33e1dedc00d1c4f7a">
#### Example Output
~~~~
device bounds empty = false
device bounds empty = true
~~~~
</fiddle-embed></div>
---
<a name="drawColor"></a>
## drawColor
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver)
</pre>
Fill <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Color">Color</a> <a href="SkCanvas_Reference#color">color</a>.
<a href="SkCanvas_Reference#mode">mode</a> determines how <a href="undocumented#ARGB">Color ARGB</a> is combined with destination.
### Parameters
<table> <tr> <td><code><strong>color </strong></code></td> <td>
<a href="undocumented#Unpremultiplied">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a></td>
</tr> <tr> <td><code><strong>mode </strong></code></td> <td>
<a href="undocumented#SkBlendMode">SkBlendMode</a> used to combine source <a href="SkCanvas_Reference#color">color</a> and destination</td>
</tr>
</table>
### Example
<div><fiddle-embed name="9cf94fead1e6b17d836c704b4eac269a"></fiddle-embed></div>
---
<a name="clear"></a>
## clear
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void clear(SkColor color)
</pre>
Fill <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="undocumented#Color">Color</a> <a href="SkCanvas_Reference#color">color</a> using <a href="undocumented#kSrc">SkBlendMode::kSrc</a>.
This has the effect of replacing all pixels contained by <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="SkCanvas_Reference#color">color</a>.
### Parameters
<table> <tr> <td><code><strong>color </strong></code></td> <td>
<a href="undocumented#Unpremultiplied">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="d97750e04989d42dc879406127b22c0b"></fiddle-embed></div>
---
<a name="discard"></a>
## discard
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void discard()
</pre>
Make <a href="SkCanvas_Reference#Canvas">Canvas</a> contents undefined. Subsequent calls that read <a href="SkCanvas_Reference#Canvas">Canvas</a> pixels,
such as drawing with <a href="undocumented#SkBlendMode">SkBlendMode</a>, return undefined results. <a href="SkCanvas_Reference#discard">discard</a> does
not change <a href="SkCanvas_Reference#Clip">Clip</a> or <a href="SkCanvas_Reference#Matrix">Matrix</a>.
<a href="SkCanvas_Reference#discard">discard</a> may do nothing, depending on the implementation of <a href="undocumented#Surface">Surface</a> or <a href="undocumented#Device">Device</a>
that created <a href="SkCanvas_Reference#Canvas">Canvas</a>.
<a href="SkCanvas_Reference#discard">discard</a> allows optimized performance on subsequent draws by removing
cached data associated with <a href="undocumented#Surface">Surface</a> or <a href="undocumented#Device">Device</a>.
It is not necessary to call <a href="SkCanvas_Reference#discard">discard</a> once done with <a href="SkCanvas_Reference#Canvas">Canvas</a>;
any cached data is deleted when owning <a href="undocumented#Surface">Surface</a> or <a href="undocumented#Device">Device</a> is deleted.
---
<a name="drawPaint"></a>
## drawPaint
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPaint(const SkPaint& paint)
</pre>
Fill <a href="SkCanvas_Reference#Clip">Clip</a> with <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>. <a href="SkPaint_Reference#Paint">Paint</a> components <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a> affect drawing;
<a href="undocumented#Path_Effect">Path Effect</a> in <a href="SkCanvas_Reference#paint">paint</a> is ignored.
### Parameters
<table> <tr> <td><code><strong>paint </strong></code></td> <td>
graphics state used to fill <a href="SkCanvas_Reference#Canvas">Canvas</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="1cd076b9b1a7c976cdca72b93c4f42dd"></fiddle-embed></div>
---
## <a name="SkCanvas::PointMode"></a> Enum SkCanvas::PointMode
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
enum <a href="SkCanvas_Reference#PointMode">PointMode</a> {
<a href="SkCanvas_Reference#kPoints_PointMode">kPoints PointMode</a>,
<a href="SkCanvas_Reference#kLines_PointMode">kLines PointMode</a>,
<a href="SkCanvas_Reference#kPolygon_PointMode">kPolygon PointMode</a>
};</pre>
Selects if an array of points are drawn as discrete points, as lines, or as
an open polygon.
### Constants
<table>
<tr>
<td><a name="SkCanvas::kPoints_PointMode"></a> <code><strong>SkCanvas::kPoints_PointMode </strong></code></td><td>0</td><td>Draw each point separately.</td>
</tr>
<tr>
<td><a name="SkCanvas::kLines_PointMode"></a> <code><strong>SkCanvas::kLines_PointMode </strong></code></td><td>1</td><td>Draw each pair of points as a line segment.</td>
</tr>
<tr>
<td><a name="SkCanvas::kPolygon_PointMode"></a> <code><strong>SkCanvas::kPolygon_PointMode </strong></code></td><td>2</td><td>Draw the array of points as a open polygon.</td>
</tr>
</table>
### Example
<div><fiddle-embed name="292b4b2008961b6f612434d3121fc4ce"><div>The upper left corner shows three squares when drawn as points.
The upper right corner shows one line; when drawn as lines, two points are required per line.
The lower right corner shows two lines; when draw as polygon, no miter is drawn at the corner.
The lower left corner shows two lines with a miter when path contains polygon.</div></fiddle-embed></div>
<a name="drawPoints"></a>
## drawPoints
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint)
</pre>
Draw <a href="SkCanvas_Reference#pts">pts</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#count">count</a> is the number of points; if <a href="SkCanvas_Reference#count">count</a> is less than one, has no effect.
<a href="SkCanvas_Reference#mode">mode</a> may be one of: <a href="SkCanvas_Reference#kPoints_PointMode">kPoints PointMode</a>, <a href="SkCanvas_Reference#kLines_PointMode">kLines PointMode</a>, or <a href="SkCanvas_Reference#kPolygon_PointMode">kPolygon PointMode</a>.
If <a href="SkCanvas_Reference#mode">mode</a> is <a href="SkCanvas_Reference#kPoints_PointMode">kPoints PointMode</a>, the shape of point drawn depends on <a href="SkCanvas_Reference#paint">paint</a>
<a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a>. If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kRound_Cap">SkPaint::kRound Cap</a>, each point draws a
circle of diameter <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>. If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kSquare_Cap">SkPaint::kSquare Cap</a>
or <a href="SkPaint_Reference#kButt_Cap">SkPaint::kButt Cap</a>, each point draws a square of width and height
<a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>.
If <a href="SkCanvas_Reference#mode">mode</a> is <a href="SkCanvas_Reference#kLines_PointMode">kLines PointMode</a>, each pair of points draws a line segment.
One line is drawn for every two points; each point is used once. If <a href="SkCanvas_Reference#count">count</a> is odd,
the final point is ignored.
If <a href="SkCanvas_Reference#mode">mode</a> is <a href="SkCanvas_Reference#kPolygon_PointMode">kPolygon PointMode</a>, each adjacent pair of points draws a line segment.
<a href="SkCanvas_Reference#count">count</a> minus one lines are drawn; the first and last point are used once.
Each line segment respects <a href="SkCanvas_Reference#paint">paint</a> <a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a> and <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>.
<a href="SkPaint_Reference#Style">Paint Style</a> is ignored, as if were set to <a href="SkPaint_Reference#kStroke_Style">SkPaint::kStroke Style</a>.
Always draws each element one at a time; is not affected by
<a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a>, and unlike <a href="SkCanvas_Reference#drawPath">drawPath</a>, does not create a mask from all points
and lines before drawing.
### Parameters
<table> <tr> <td><code><strong>mode </strong></code></td> <td>
Whether <a href="SkCanvas_Reference#pts">pts</a> draws points or lines</td>
</tr> <tr> <td><code><strong>count </strong></code></td> <td>
The number of points in the array</td>
</tr> <tr> <td><code><strong>pts </strong></code></td> <td>
Array of points to draw</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
Stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="f1dfbb0d5a17c8beab19af29f2aaba8c"><div>
<table> <tr>
<td>The first column draws points.</td> </tr> <tr>
<td>The second column draws points as lines.</td> </tr> <tr>
<td>The third column draws points as a polygon.</td> </tr> <tr>
<td>The fourth column draws points as a polygonal path.</td> </tr> <tr>
<td>The first row uses a round cap and round join.</td> </tr> <tr>
<td>The second row uses a square cap and a miter join.</td> </tr> <tr>
<td>The third row uses a butt cap and a bevel join.</td> </tr>
</table>
The transparent color makes multiple line draws visible;
the path is drawn all at once.</div></fiddle-embed></div>
---
<a name="drawPoint"></a>
## drawPoint
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint)
</pre>
Draw point at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>) using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
The shape of point drawn depends on <a href="SkCanvas_Reference#paint">paint</a> <a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a>.
If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kRound_Cap">SkPaint::kRound Cap</a>, draw a circle of diameter
<a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>. If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kSquare_Cap">SkPaint::kSquare Cap</a> or <a href="SkPaint_Reference#kButt_Cap">SkPaint::kButt Cap</a>,
draw a square of width and height <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>.
<a href="SkPaint_Reference#Style">Paint Style</a> is ignored, as if were set to <a href="SkPaint_Reference#kStroke_Style">SkPaint::kStroke Style</a>.
### Parameters
<table> <tr> <td><code><strong>x </strong></code></td> <td>
left edge of circle or square</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
top edge of circle or square</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="3476b553e7b547b604a3f6969f02d933"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPoint(SkPoint p, const SkPaint& paint)
</pre>
Draw point <a href="SkCanvas_Reference#p">p</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
The shape of point drawn depends on <a href="SkCanvas_Reference#paint">paint</a> <a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a>.
If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kRound_Cap">SkPaint::kRound Cap</a>, draw a circle of diameter
<a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>. If <a href="SkCanvas_Reference#paint">paint</a> is set to <a href="SkPaint_Reference#kSquare_Cap">SkPaint::kSquare Cap</a> or <a href="SkPaint_Reference#kButt_Cap">SkPaint::kButt Cap</a>,
draw a square of width and height <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a>.
<a href="SkPaint_Reference#Style">Paint Style</a> is ignored, as if were set to <a href="SkPaint_Reference#kStroke_Style">SkPaint::kStroke Style</a>.
### Parameters
<table> <tr> <td><code><strong>p </strong></code></td> <td>
top-left edge of circle or square</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="1a0a839061c69d870acca2bcfbdf1a41"></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#drawPoints">drawPoints</a> <a href="SkCanvas_Reference#drawCircle">drawCircle</a> <a href="SkCanvas_Reference#drawRect">drawRect</a>
---
<a name="drawLine"></a>
## drawLine
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1,
const SkPaint& paint)
</pre>
Draws line segment from (<a href="SkCanvas_Reference#x0">x0</a>, <a href="SkCanvas_Reference#y0">y0</a>) to (<a href="SkCanvas_Reference#x1">x1</a>, <a href="SkCanvas_Reference#y1">y1</a>) using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness;
<a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a> draws the end rounded or square;
<a href="SkPaint_Reference#Style">Paint Style</a> is ignored, as if were set to <a href="SkPaint_Reference#kStroke_Style">SkPaint::kStroke Style</a>.
### Parameters
<table> <tr> <td><code><strong>x0 </strong></code></td> <td>
start of line segment on x-axis</td>
</tr> <tr> <td><code><strong>y0 </strong></code></td> <td>
start of line segment on y-axis</td>
</tr> <tr> <td><code><strong>x1 </strong></code></td> <td>
end of line segment on x-axis</td>
</tr> <tr> <td><code><strong>y1 </strong></code></td> <td>
end of line segment on y-axis</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="d10ee4a265f278d02afe11ad889b293b"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint)
</pre>
Draws line segment from <a href="SkCanvas_Reference#p0">p0</a> to <a href="SkCanvas_Reference#p1">p1</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness;
<a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a> draws the end rounded or square;
<a href="SkPaint_Reference#Style">Paint Style</a> is ignored, as if were set to <a href="SkPaint_Reference#kStroke_Style">SkPaint::kStroke Style</a>.
### Parameters
<table> <tr> <td><code><strong>p0 </strong></code></td> <td>
start of line segment</td>
</tr> <tr> <td><code><strong>p1 </strong></code></td> <td>
end of line segment</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="f8525816cb596dde1a3855446792c8e0"></fiddle-embed></div>
---
<a name="drawRect"></a>
## drawRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawRect(const SkRect& rect, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#rect">rect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if rectangle is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness, and
<a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a> draws the corners rounded or square.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
rectangle to be drawn</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="871b0da9b4a23de11ae7a772ce14aed3"></fiddle-embed></div>
---
<a name="drawIRect"></a>
## drawIRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawIRect(const SkIRect& rect, const SkPaint& paint)
</pre>
Draw <a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#rect">rect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if rectangle is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness, and
<a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a> draws the corners rounded or square.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
rectangle to be drawn</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="d3d8ca584134560750b1efa4a4c6e138"></fiddle-embed></div>
---
<a name="drawRegion"></a>
## drawRegion
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawRegion(const SkRegion& region, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Region">Region</a> <a href="SkCanvas_Reference#region">region</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if rectangle is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness, and
<a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a> draws the corners rounded or square.
### Parameters
<table> <tr> <td><code><strong>region </strong></code></td> <td>
<a href="SkCanvas_Reference#region">region</a> to be drawn</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="80309e0deca0f8add616cec7bec634ca"></fiddle-embed></div>
---
<a name="drawOval"></a>
## drawOval
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawOval(const SkRect& oval, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Oval">Oval</a> <a href="SkCanvas_Reference#oval">oval</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="undocumented#Oval">Oval</a> is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
### Parameters
<table> <tr> <td><code><strong>oval </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of <a href="undocumented#Oval">Oval</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="8b6b86f8a022811cd29a9c6ab771df12"></fiddle-embed></div>
---
<a name="drawRRect"></a>
## drawRRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawRRect(const SkRRect& rrect, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Round_Rect">Round Rect</a> <a href="SkCanvas_Reference#rrect">rrect</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="SkCanvas_Reference#rrect">rrect</a> is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
<a href="SkCanvas_Reference#rrect">rrect</a> may represent a rectangle, circle, oval, uniformly rounded rectangle, or
may have any combination of positive non-square radii for the four corners.
### Parameters
<table> <tr> <td><code><strong>rrect </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> with up to eight corner radii to draw</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="369cdbfb2a200d5bb8ae40f7cc1025c3"></fiddle-embed></div>
---
<a name="drawDRRect"></a>
## drawDRRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Round_Rect">Round Rect</a> <a href="SkCanvas_Reference#outer">outer</a> and <a href="SkCanvas_Reference#inner">inner</a>
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#outer">outer</a> must contain <a href="SkCanvas_Reference#inner">inner</a> or the drawing is undefined.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if rrect is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
If stroked and <a href="undocumented#Round_Rect">Round Rect</a> corner has zero length radii, <a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a> can
draw corners rounded or square.
<a href="undocumented#GPU_backed">GPU-backed</a> platforms optimize drawing when both <a href="SkCanvas_Reference#outer">outer</a> and <a href="SkCanvas_Reference#inner">inner</a> are
concave and <a href="SkCanvas_Reference#outer">outer</a> contains <a href="SkCanvas_Reference#inner">inner</a>. These platforms may not be able to draw
<a href="SkPath_Reference#Path">Path</a> built with identical data as fast.
### Parameters
<table> <tr> <td><code><strong>outer </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> <a href="SkCanvas_Reference#outer">outer</a> bounds to draw</td>
</tr> <tr> <td><code><strong>inner </strong></code></td> <td>
<a href="undocumented#Round_Rect">Round Rect</a> <a href="SkCanvas_Reference#inner">inner</a> bounds to draw</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="02e33141f13da2f19aef7feb7117b541"></fiddle-embed></div>
### Example
<div><fiddle-embed name="30823cb4edf884d330285ea161664931"><div>Outer <a href="undocumented#Rect">Rect</a> has no corner radii, but stroke join is rounded.
Inner <a href="undocumented#Round_Rect">Round Rect</a> has corner radii; outset stroke increases radii of corners.
Stroke join does not affect <a href="SkCanvas_Reference#inner">inner</a> <a href="undocumented#Round_Rect">Round Rect</a> since it has no sharp corners.</div></fiddle-embed></div>
---
<a name="drawCircle"></a>
## drawCircle
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Circle">Circle</a> at (<a href="SkCanvas_Reference#cx">cx</a>, <a href="SkCanvas_Reference#cy">cy</a>) with <a href="SkCanvas_Reference#radius">radius</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
If <a href="SkCanvas_Reference#radius">radius</a> is zero or less, nothing is drawn.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="undocumented#Circle">Circle</a> is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
### Parameters
<table> <tr> <td><code><strong>cx </strong></code></td> <td>
<a href="undocumented#Circle">Circle</a> center on the x-axis</td>
</tr> <tr> <td><code><strong>cy </strong></code></td> <td>
<a href="undocumented#Circle">Circle</a> center on the y-axis</td>
</tr> <tr> <td><code><strong>radius </strong></code></td> <td>
half the diameter of <a href="undocumented#Circle">Circle</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="841229e25ca9dfb68bd0dc4dfff356eb"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Circle">Circle</a> at (cx, cy) with <a href="SkCanvas_Reference#radius">radius</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
If <a href="SkCanvas_Reference#radius">radius</a> is zero or less, nothing is drawn.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="undocumented#Circle">Circle</a> is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
### Parameters
<table> <tr> <td><code><strong>center </strong></code></td> <td>
<a href="undocumented#Circle">Circle</a> <a href="SkCanvas_Reference#center">center</a></td>
</tr> <tr> <td><code><strong>radius </strong></code></td> <td>
half the diameter of <a href="undocumented#Circle">Circle</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="9303ffae45ddd0b0a1f93d816a1762f4"></fiddle-embed></div>
---
<a name="drawArc"></a>
## drawArc
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
bool useCenter, const SkPaint& paint)
</pre>
Draw <a href="undocumented#Arc">Arc</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="undocumented#Arc">Arc</a> is part of <a href="undocumented#Oval">Oval</a> bounded by <a href="SkCanvas_Reference#oval">oval</a>, sweeping from <a href="SkCanvas_Reference#startAngle">startAngle</a> to <a href="SkCanvas_Reference#startAngle">startAngle</a> plus
<a href="SkCanvas_Reference#sweepAngle">sweepAngle</a>. <a href="SkCanvas_Reference#startAngle">startAngle</a> and <a href="SkCanvas_Reference#sweepAngle">sweepAngle</a> are in degrees.
<a href="SkCanvas_Reference#startAngle">startAngle</a> of zero places start point at the right middle edge of <a href="SkCanvas_Reference#oval">oval</a>.
A positive <a href="SkCanvas_Reference#sweepAngle">sweepAngle</a> places <a href="undocumented#Arc">Arc</a> end point clockwise from start point;
a negative <a href="SkCanvas_Reference#sweepAngle">sweepAngle</a> places <a href="undocumented#Arc">Arc</a> end point counterclockwise from start point.
<a href="SkCanvas_Reference#sweepAngle">sweepAngle</a> may exceed 360 degrees, a full circle.
If <a href="SkCanvas_Reference#useCenter">useCenter</a> is true, draw a wedge that includes lines from <a href="SkCanvas_Reference#oval">oval</a>
center to <a href="undocumented#Arc">Arc</a> end points. If <a href="SkCanvas_Reference#useCenter">useCenter</a> is false, draw <a href="undocumented#Arc">Arc</a> between end points.
If <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#oval">oval</a> is empty or <a href="SkCanvas_Reference#sweepAngle">sweepAngle</a> is zero, nothing is drawn.
### Parameters
<table> <tr> <td><code><strong>oval </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of <a href="undocumented#Oval">Oval</a> containing <a href="undocumented#Arc">Arc</a> to draw</td>
</tr> <tr> <td><code><strong>startAngle </strong></code></td> <td>
angle in degrees where <a href="undocumented#Arc">Arc</a> begins</td>
</tr> <tr> <td><code><strong>sweepAngle </strong></code></td> <td>
sweep angle in degrees; positive is clockwise</td>
</tr> <tr> <td><code><strong>useCenter </strong></code></td> <td>
if true, include the center of the <a href="SkCanvas_Reference#oval">oval</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> stroke or fill, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="11f0fbe7b30d776913c2e7c92c02ff57"></fiddle-embed></div>
### Example
<div><fiddle-embed name="e91dbe45974489b8962c815017b7914f"></fiddle-embed></div>
---
<a name="drawRoundRect"></a>
## drawRoundRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
const SkPaint& paint)
</pre>
Draw <a href="undocumented#Round_Rect">Round Rect</a> bounded by <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#rect">rect</a>, with corner radii (<a href="SkCanvas_Reference#rx">rx</a>, <a href="SkCanvas_Reference#ry">ry</a>) using <a href="SkCanvas_Reference#Clip">Clip</a>,
<a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="undocumented#Round_Rect">Round Rect</a> is stroked or filled;
if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness.
If <a href="SkCanvas_Reference#rx">rx</a> or <a href="SkCanvas_Reference#ry">ry</a> are less than zero, they are treated as if they are zero.
If <a href="SkCanvas_Reference#rx">rx</a> plus <a href="SkCanvas_Reference#ry">ry</a> exceeds <a href="SkCanvas_Reference#rect">rect</a> width or <a href="SkCanvas_Reference#rect">rect</a> height, radii are scaled down to fit.
If <a href="SkCanvas_Reference#rx">rx</a> and <a href="SkCanvas_Reference#ry">ry</a> are zero, <a href="undocumented#Round_Rect">Round Rect</a> is drawn as <a href="undocumented#Rect">Rect</a> and if stroked is affected by
<a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a>.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of <a href="undocumented#Round_Rect">Round Rect</a> to draw</td>
</tr> <tr> <td><code><strong>rx </strong></code></td> <td>
semiaxis length in x of oval describing rounded corners</td>
</tr> <tr> <td><code><strong>ry </strong></code></td> <td>
semiaxis length in y of oval describing rounded corners</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="199fe818c09026c114e165bff166a39f"><div>Top row has a zero radius a generates a rectangle.
Second row radii sum to less than sides.
Third row radii sum equals sides.
Fourth row radii sum exceeds sides; radii are scaled to fit.</div></fiddle-embed></div>
---
<a name="drawPath"></a>
## drawPath
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPath(const SkPath& path, const SkPaint& paint)
</pre>
Draw <a href="SkPath_Reference#Path">Path</a> <a href="SkCanvas_Reference#path">path</a> using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkPath_Reference#Path">Path</a> contains an array of <a href="SkPath_Reference#Contour">Path Contour</a>, each of which may be open or closed.
In <a href="SkCanvas_Reference#paint">paint</a>: <a href="SkPaint_Reference#Style">Paint Style</a> determines if <a href="undocumented#Round_Rect">Round Rect</a> is stroked or filled:
if filled, <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> determines whether <a href="SkPath_Reference#Contour">Path Contour</a> describes inside or
outside of fill; if stroked, <a href="SkPaint_Reference#Stroke_Width">Paint Stroke Width</a> describes the line thickness,
<a href="SkPaint_Reference#Stroke_Cap">Paint Stroke Cap</a> describes line ends, and <a href="SkPaint_Reference#Stroke_Join">Paint Stroke Join</a> describes how
corners are drawn.
### Parameters
<table> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> to draw</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
stroke, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="d489555a878cb2ab08eea5faf516f54e"><div>Top rows draw stroked <a href="SkCanvas_Reference#path">path</a> with combinations of joins and caps. The open contour
is affected by caps; the closed contour is affected by joins.
Bottom row draws fill the same for open and closed contour.
First bottom column shows winding fills overlap.
Second bottom column shows even odd fills exclude overlap.
Third bottom column shows inverse winding fills area outside both contours.</div></fiddle-embed></div>
---
# <a name="Draw_Image"></a> Draw Image
<a href="SkCanvas_Reference#drawImage">drawImage</a>, <a href="SkCanvas_Reference#drawImageRect">drawImageRect</a>, and <a href="SkCanvas_Reference#drawImageNine">drawImageNine</a> can be called with a bare pointer or
a smart pointer as a convenience. The pairs of calls are otherwise identical.
<a name="drawImage"></a>
## drawImage
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint = NULL)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, with its top-left corner at (<a href="SkCanvas_Reference#left">left</a>, <a href="SkCanvas_Reference#top">top</a>),
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImage">paint</a>.
If <a href="SkCanvas_Reference#drawImage">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>,
and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImage">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds. If generated
mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just as <a href="undocumented#Shader">Shader</a>
made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the
<a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
uncompressed rectangular map of pixels</td>
</tr> <tr> <td><code><strong>left </strong></code></td> <td>
<a href="SkCanvas_Reference#left">left</a> side of <a href="SkCanvas_Reference#image">image</a></td>
</tr> <tr> <td><code><strong>top </strong></code></td> <td>
<a href="SkCanvas_Reference#top">top</a> side of <a href="SkCanvas_Reference#image">image</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="185746dc0faa6f1df30c4afe098646ff"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
const SkPaint* paint = NULL)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, with its top-left corner at (<a href="SkCanvas_Reference#left">left</a>, <a href="SkCanvas_Reference#top">top</a>),
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImage_2">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImage_2">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImage_2">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds. If generated
mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just as <a href="undocumented#Shader">Shader</a>
made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the
<a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
uncompressed rectangular map of pixels</td>
</tr> <tr> <td><code><strong>left </strong></code></td> <td>
<a href="SkCanvas_Reference#left">left</a> side of <a href="SkCanvas_Reference#image">image</a></td>
</tr> <tr> <td><code><strong>top </strong></code></td> <td>
pop side of <a href="SkCanvas_Reference#image">image</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="a4e877e891b1be5faa2b7fd07f673a10"></fiddle-embed></div>
---
## <a name="SkCanvas::SrcRectConstraint"></a> Enum SkCanvas::SrcRectConstraint
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
enum <a href="SkCanvas_Reference#SrcRectConstraint">SrcRectConstraint</a> {
<a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a>,
<a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a>,
};</pre>
<a href="SkCanvas_Reference#SrcRectConstraint">SrcRectConstraint</a> controls the behavior at the edge of the <a href="undocumented#Rect">Rect</a> src, provided to
<a href="SkCanvas_Reference#drawImageRect">drawImageRect</a>, trading off speed for precision.
<a href="undocumented#Image_Filter">Image Filter</a> in <a href="SkPaint_Reference#Paint">Paint</a> may sample multiple pixels in the image. <a href="undocumented#Rect">Rect</a> src
restricts the bounds of pixels that may be read. <a href="undocumented#Image_Filter">Image Filter</a> may slow down if
it cannot read outside the bounds, when sampling near the edge of <a href="undocumented#Rect">Rect</a> src.
<a href="SkCanvas_Reference#SrcRectConstraint">SrcRectConstraint</a> specifies whether an <a href="undocumented#Image_Filter">Image Filter</a> is allowed to read pixels
outside <a href="undocumented#Rect">Rect</a> src.
### Constants
<table>
<tr>
<td><a name="SkCanvas::kStrict_SrcRectConstraint"></a> <code><strong>SkCanvas::kStrict_SrcRectConstraint </strong></code></td><td>Requires Image_Filter to respect Rect src,</td><td>sampling only inside of its bounds, possibly with a performance penalty.</td>
</tr>
<tr>
<td><a name="SkCanvas::kFast_SrcRectConstraint"></a> <code><strong>SkCanvas::kFast_SrcRectConstraint </strong></code></td><td>Permits Image_Filter to sample outside of Rect src</td><td>by half the width of <a href="undocumented#Image_Filter">Image Filter</a>, permitting it to run faster but with
error at the image edges.</td>
</tr>
</table>
### Example
<div><fiddle-embed name="5df49d1f4da37275a1f10ef7f1a749f0"><div>redBorder contains a black and white checkerboard bordered by red.
redBorder is drawn scaled by 16 on the left.
The middle and right bitmaps are filtered checkboards.
Drawing the checkerboard with <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> shows only a blur of black and white.
Drawing the checkerboard with <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows red to bleed in the corners.</div></fiddle-embed></div>
<a name="drawImageRect"></a>
## drawImageRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#src">src</a> of <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within <a href="SkCanvas_Reference#src">src</a>; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>src </strong></code></td> <td>
source <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within <a href="SkCanvas_Reference#src">src</a> or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="2b01c707ef8b5ce3023b7a1d55fce059"><div>The left bitmap draws with <a href="SkPaint_Reference#Paint">Paint</a> default <a href="undocumented#SkFilterQuality">kNone SkFilterQuality</a>, and stays within
its bounds; there's no bleeding with <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a>.
the middle and right bitmaps draw with <a href="undocumented#SkFilterQuality">kLow SkFilterQuality</a>; with
<a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a>, the filter remains within the checkerboard, and
with <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> red bleeds on the edges.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#isrc">isrc</a> of <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
Note that <a href="SkCanvas_Reference#isrc">isrc</a> is on integer pixel boundaries; <a href="SkCanvas_Reference#dst">dst</a> may include fractional
boundaries. Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a>
<a href="SkCanvas_Reference#drawImageRect_2">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_2">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect_2">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>isrc </strong></code></td> <td>
source <a href="undocumented#IRect">IRect</a> of <a href="SkCanvas_Reference#image">image</a> to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="b63b8f9f587b8d918973dc065ce4a593"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>,
and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_3">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_3">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect_3">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="3cf8fb639fef99993cafc064d550c739"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src,
const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#src">src</a> of <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_4">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_4">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect_4">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within <a href="SkCanvas_Reference#src">src</a>; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>src </strong></code></td> <td>
source <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within <a href="SkCanvas_Reference#src">src</a> or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="589999454db90c573f7facfb007253a7"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> scales and translates; transformation from <a href="SkCanvas_Reference#src">src</a> to <a href="SkCanvas_Reference#dst">dst</a> also scales.
The two matrices are concatenated to create the final transformation.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc,
const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#isrc">isrc</a> of <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="SkCanvas_Reference#isrc">isrc</a> is on integer pixel boundaries; <a href="SkCanvas_Reference#dst">dst</a> may include fractional boundaries.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_5">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_5">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect_5">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>isrc </strong></code></td> <td>
source <a href="undocumented#IRect">IRect</a> of <a href="SkCanvas_Reference#image">image</a> to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="249fadde5d0d0fc515e9f53f188af48b"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>,
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_6">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageRect_6">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageRect_6">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="37a85bd2247487c7af584e42c1cabe4a"></fiddle-embed></div>
---
<a name="drawImageNine"></a>
## drawImageNine
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, const SkPaint* paint = nullptr)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a> stretched differentially to fit into <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#center">center</a> divides the <a href="SkCanvas_Reference#image">image</a> into nine sections: four sides, four corners, and
the <a href="SkCanvas_Reference#center">center</a>. Corners are unscaled or scaled down proportionately if their sides
are larger than <a href="SkCanvas_Reference#dst">dst</a>; <a href="SkCanvas_Reference#center">center</a> and four sides are scaled to fit remaining space, if any.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageNine">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageNine">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageNine">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>center </strong></code></td> <td>
<a href="undocumented#IRect">IRect</a> edge of <a href="SkCanvas_Reference#image">image</a> corners and sides</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="47f78f3f70ccd9e6c40ee3203a5c71dd"><div>The leftmost <a href="SkCanvas_Reference#image">image</a> is smaller than <a href="SkCanvas_Reference#center">center</a>; only corners are drawn, all scaled to fit.
The second <a href="SkCanvas_Reference#image">image</a> equals the size of <a href="SkCanvas_Reference#center">center</a>; only corners are drawn, unscaled.
The remaining images are larger than <a href="SkCanvas_Reference#center">center</a>. All corners draw unscaled. The sides
and <a href="SkCanvas_Reference#center">center</a> are scaled if needed to take up the remaining space.</div></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center,
const SkRect& dst, const SkPaint* paint = nullptr)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a> stretched differentially to fit into <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#center">center</a> divides the <a href="SkCanvas_Reference#image">image</a> into nine sections: four sides, four corners, and
the <a href="SkCanvas_Reference#center">center</a>. Corners are unscaled or scaled down proportionately if their sides
are larger than <a href="SkCanvas_Reference#dst">dst</a>; <a href="SkCanvas_Reference#center">center</a> and four sides are scaled to fit remaining space, if any.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageNine_2">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageNine_2">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#image">image</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageNine_2">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#image">image</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#image">image</a> bounds, replicate <a href="SkCanvas_Reference#image">image</a> edge colors, just
as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#makeShader">SkImage::makeShader</a> with <a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set
replicates the <a href="SkCanvas_Reference#image">image</a>'s edge color when it samples outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>center </strong></code></td> <td>
<a href="undocumented#IRect">IRect</a> edge of <a href="SkCanvas_Reference#image">image</a> corners and sides</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="e941e553970569d1ffb03a42f7fcd6d9"><div>The two leftmost images has four corners and sides to the left and right of <a href="SkCanvas_Reference#center">center</a>.
The leftmost <a href="SkCanvas_Reference#image">image</a> scales the width of corners proportionately to fit.
The third and fourth <a href="SkCanvas_Reference#image">image</a> corners are unscaled; the sides and <a href="SkCanvas_Reference#center">center</a> are scaled to
fill the remaining space.
The rightmost <a href="SkCanvas_Reference#image">image</a> has four corners scaled vertically to fit, and uses sides above
and below <a href="SkCanvas_Reference#center">center</a> to fill the remaining space.</div></fiddle-embed></div>
---
<a name="drawBitmap"></a>
## drawBitmap
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint = NULL)
</pre>
Draw <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a>, with its top-left corner at (<a href="SkCanvas_Reference#left">left</a>, <a href="SkCanvas_Reference#top">top</a>),
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmap">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmap">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmap">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>left </strong></code></td> <td>
<a href="SkCanvas_Reference#left">left</a> side of <a href="SkCanvas_Reference#bitmap">bitmap</a></td>
</tr> <tr> <td><code><strong>top </strong></code></td> <td>
<a href="SkCanvas_Reference#top">top</a> side of <a href="SkCanvas_Reference#bitmap">bitmap</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="70d7fbf7de82264dd66a526d98d31def"></fiddle-embed></div>
---
<a name="drawBitmapRect"></a>
## drawBitmapRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#src">src</a> of <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmapRect">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within <a href="SkCanvas_Reference#src">src</a>; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>src </strong></code></td> <td>
source <a href="undocumented#Rect">Rect</a> of image to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of image to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within <a href="SkCanvas_Reference#src">src</a> or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="de449106e78ec558d9921b9f076de164"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc,
const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#isrc">isrc</a> of <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="SkCanvas_Reference#isrc">isrc</a> is on integer pixel boundaries; <a href="SkCanvas_Reference#dst">dst</a> may include fractional boundaries.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect_2">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect_2">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmapRect_2">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>isrc </strong></code></td> <td>
source <a href="undocumented#IRect">IRect</a> of image to draw from</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of image to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
Filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="69b028ef1f95c355672fbdcbf47550f2"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
</pre>
Draw <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a>, scaled and translated to fill <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
isrc is on integer pixel boundaries; <a href="SkCanvas_Reference#dst">dst</a> may include fractional boundaries.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect_3">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapRect_3">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmapRect_3">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
<a href="SkCanvas_Reference#constraint">constraint</a> set to <a href="SkCanvas_Reference#kStrict_SrcRectConstraint">kStrict SrcRectConstraint</a> limits <a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Filter_Quality">Filter Quality</a> to
sample within src; set to <a href="SkCanvas_Reference#kFast_SrcRectConstraint">kFast SrcRectConstraint</a> allows sampling outside to
improve performance.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of image to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr> <tr> <td><code><strong>constraint </strong></code></td> <td>
filter strictly within src or draw faster</td>
</tr>
</table>
### Example
<div><fiddle-embed name="76b74b826e43b4a595d18115564e88c7"></fiddle-embed></div>
---
<a name="drawBitmapNine"></a>
## drawBitmapNine
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint = NULL)
</pre>
Draw <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a> stretched differentially to fit into <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="undocumented#IRect">IRect</a> <a href="SkCanvas_Reference#center">center</a> divides the <a href="SkCanvas_Reference#bitmap">bitmap</a> into nine sections: four sides, four corners,
and the <a href="SkCanvas_Reference#center">center</a>. Corners are unscaled or scaled down proportionately if their
sides are larger than <a href="SkCanvas_Reference#dst">dst</a>; <a href="SkCanvas_Reference#center">center</a> and four sides are scaled to fit remaining
space, if any.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapNine">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapNine">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmapNine">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>center </strong></code></td> <td>
<a href="undocumented#IRect">IRect</a> edge of image corners and sides</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of image to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="a4a30aa10e566a85fe6f6cad2ff9935b"><div>The two leftmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draws has four corners and sides to the left and right of <a href="SkCanvas_Reference#center">center</a>.
The leftmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draw scales the width of corners proportionately to fit.
The third and fourth draw corners are unscaled; the sides and <a href="SkCanvas_Reference#center">center</a> are scaled to
fill the remaining space.
The rightmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draw has four corners scaled vertically to fit, and uses sides above
and below <a href="SkCanvas_Reference#center">center</a> to fill the remaining space.</div></fiddle-embed></div>
---
# <a name="SkCanvas::Lattice"></a> Struct SkCanvas::Lattice
<a href="SkCanvas_Reference#Lattice">Lattice</a> divides <a href="undocumented#Bitmap">Bitmap</a> or <a href="undocumented#Image">Image</a> into a rectangular grid.
Grid entries on even columns and even rows are fixed; these entries are
always drawn at their original size if the destination is large enough.
If the destination side is too small to hold the fixed entries, all fixed
entries are proportionately scaled down to fit.
The grid entries not on even columns and rows are scaled to fit the
remaining space, if any.
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
struct <a href="SkCanvas_Reference#Lattice">Lattice</a> {
enum <a href="SkCanvas_Reference#Lattice_Flags">Flags</a> {...
const int* <a href="SkCanvas_Reference#Lattice_fXDivs">fXDivs</a>;
const int* <a href="SkCanvas_Reference#Lattice_fYDivs">fYDivs</a>;
const <a href="SkCanvas_Reference#Lattice_Flags">Flags</a>* <a href="SkCanvas_Reference#Lattice_fFlags">fFlags</a>;
int <a href="SkCanvas_Reference#Lattice_fXCount">fXCount</a>;
int <a href="SkCanvas_Reference#Lattice_fYCount">fYCount</a>;
const <a href="undocumented#SkIRect">SkIRect</a>* <a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a>;
};</pre>
## <a name="SkCanvas::Lattice::Flags"></a> Enum SkCanvas::Lattice::Flags
<pre style="padding: 1em 1em 1em 1em;width: 44em; background-color: #f0f0f0">
enum <a href="SkCanvas_Reference#Lattice_Flags">Flags</a> : uint8_t {
<a href="SkCanvas_Reference#Lattice_kTransparent_Flags">kTransparent Flags</a> = 1 << 0,
};</pre>
Optional setting per rectangular grid entry to make it transparent.
### Constants
<table>
<tr>
<td><a name="SkCanvas::Lattice::kTransparent_Flags"></a> <code><strong>SkCanvas::Lattice::kTransparent_Flags </strong></code></td><td>1</td><td>Set to skip lattice rectangle by making it transparent.</td>
</tr>
</table>
<code><strong>const int* fXDivs</strong></code>
Array of x-coordinates that divide the bitmap vertically.
Array entries must be unique, increasing, greater than or equal to
<a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> left edge, and less than <a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> right edge.
Set the first element to <a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> left to collapse the left column of
fixed grid entries.
<code><strong>const int* fYDivs</strong></code>
Array of y-coordinates that divide the bitmap horizontally.
Array entries must be unique, increasing, greater than or equal to
<a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> top edge, and less than <a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> bottom edge.
Set the first element to <a href="SkCanvas_Reference#Lattice_fBounds">fBounds</a> top to collapse the top row of fixed
grid entries.
<code><strong>const Flags* fFlags</strong></code>
Optional array of <a href="SkCanvas_Reference#Lattice_Flags">Flags</a>, one per rectangular grid entry:
array length must be( <a href="SkCanvas_Reference#Lattice_fXCount">fXCount</a> + 1) * (<a href="SkCanvas_Reference#Lattice_fYCount">fYCount</a> + 1).
Array entries correspond to the rectangular grid entries, ascending
left to right and then top to bottom.
<code><strong>int fXCount</strong></code>
Number of entries in <a href="SkCanvas_Reference#Lattice_fXDivs">fXDivs</a> array; one less than the number of
horizontal divisions.
<code><strong>int fYCount</strong></code>
Number of entries in <a href="SkCanvas_Reference#Lattice_fYDivs">fYDivs</a> array; one less than the number of vertical
divisions.
<code><strong>const SkIRect* fBounds</strong></code>
Optional subset <a href="undocumented#IRect">IRect</a> source to draw from.
If nullptr, source bounds is dimensions of <a href="undocumented#Bitmap">Bitmap</a> or <a href="undocumented#Image">Image</a>.
<a name="drawBitmapLattice"></a>
## drawBitmapLattice
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice,
const SkRect& dst, const SkPaint* paint = nullptr)
</pre>
Draw <a href="undocumented#Bitmap">Bitmap</a> <a href="SkCanvas_Reference#bitmap">bitmap</a> stretched differentially to fit into <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="SkCanvas_Reference#Lattice">Lattice</a> <a href="SkCanvas_Reference#lattice">lattice</a> divides <a href="SkCanvas_Reference#bitmap">bitmap</a> into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of <a href="SkCanvas_Reference#drawBitmapNine">drawBitmapNine</a>, fixed <a href="SkCanvas_Reference#lattice">lattice</a> elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s
dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapLattice">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawBitmapLattice">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If <a href="SkCanvas_Reference#bitmap">bitmap</a> is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawBitmapLattice">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds.
If generated mask extends beyond <a href="SkCanvas_Reference#bitmap">bitmap</a> bounds, replicate <a href="SkCanvas_Reference#bitmap">bitmap</a> edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the <a href="SkCanvas_Reference#bitmap">bitmap</a>'s edge color when it samples
outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>bitmap </strong></code></td> <td>
<a href="undocumented#Bitmap">Bitmap</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>lattice </strong></code></td> <td>
division of <a href="SkCanvas_Reference#bitmap">bitmap</a> into fixed and variable rectangles</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of image to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="773134f4fe127f9c9caa110c24c988dc"><div>The two leftmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draws has four corners and sides to the left and right of center.
The leftmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draw scales the width of corners proportionately to fit.
The third and fourth draw corners are unscaled; the sides are scaled to
fill the remaining space; the center is transparent.
The rightmost <a href="SkCanvas_Reference#bitmap">bitmap</a> draw has four corners scaled vertically to fit, and uses sides above
and below center to fill the remaining space.</div></fiddle-embed></div>
---
<a name="drawImageLattice"></a>
## drawImageLattice
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawImageLattice(const SkImage* image, const Lattice& lattice,
const SkRect& dst, const SkPaint* paint = nullptr)
</pre>
Draw <a href="undocumented#Image">Image</a> <a href="SkCanvas_Reference#image">image</a> stretched differentially to fit into <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#dst">dst</a>.
<a href="SkCanvas_Reference#Lattice">Lattice</a> <a href="SkCanvas_Reference#lattice">lattice</a> divides <a href="SkCanvas_Reference#image">image</a> into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of <a href="SkCanvas_Reference#drawBitmapNine">drawBitmapNine</a>, fixed <a href="SkCanvas_Reference#lattice">lattice</a> elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the bitmap's
dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageLattice">paint</a>.
If <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#drawImageLattice">paint</a> is supplied, apply <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
<a href="undocumented#Blend_Mode">Blend Mode</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>. If bitmap is <a href="undocumented#SkColorType">kAlpha 8 SkColorType</a>, apply <a href="undocumented#Shader">Shader</a>.
If <a href="SkCanvas_Reference#drawImageLattice">paint</a> contains <a href="undocumented#Mask_Filter">Mask Filter</a>, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as <a href="undocumented#Shader">Shader</a> made from <a href="undocumented#MakeBitmapShader">SkShader::MakeBitmapShader</a> with
<a href="undocumented#kClamp_TileMode">SkShader::kClamp TileMode</a> set replicates the bitmap's edge color when it samples
outside of its bounds.
### Parameters
<table> <tr> <td><code><strong>image </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing pixels, dimensions, and format</td>
</tr> <tr> <td><code><strong>lattice </strong></code></td> <td>
division of bitmap into fixed and variable rectangles</td>
</tr> <tr> <td><code><strong>dst </strong></code></td> <td>
destination <a href="undocumented#Rect">Rect</a> of <a href="SkCanvas_Reference#image">image</a> to draw to</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> containing <a href="undocumented#Blend_Mode">Blend Mode</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>,
and so on; or nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="c52ee1d4c69363c6b109539c1da3ce83"><div>The leftmost <a href="SkCanvas_Reference#image">image</a> is smaller than center; only corners are drawn, all scaled to fit.
The second <a href="SkCanvas_Reference#image">image</a> equals the size of center; only corners are drawn, unscaled.
The remaining images are larger than center. All corners draw unscaled. The sides
are scaled if needed to take up the remaining space; the center is transparent.</div></fiddle-embed></div>
---
<a name="drawText"></a>
## drawText
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint)
</pre>
Draw <a href="SkCanvas_Reference#text">text</a>, with origin at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>), using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#text">text</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#text">text</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>.
<a href="SkCanvas_Reference#x">x</a> and <a href="SkCanvas_Reference#y">y</a> meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>; by default
<a href="SkCanvas_Reference#text">text</a> draws left to right, positioning the first glyph's left side bearing at <a href="SkCanvas_Reference#x">x</a>
and its baseline at <a href="SkCanvas_Reference#y">y</a>. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
start of <a href="SkCanvas_Reference#text">text</a> on x-axis</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
start of <a href="SkCanvas_Reference#text">text</a> on y-axis</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="a3365bd3044b13e8e0318ee8aefbdf91"><div>The same <a href="SkCanvas_Reference#text">text</a> is drawn varying <a href="SkPaint_Reference#Text_Size">Paint Text Size</a> and varying
<a href="SkCanvas_Reference#Matrix">Matrix</a>.</div></fiddle-embed></div>
---
<a name="drawString"></a>
## drawString
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint)
</pre>
Draw null terminated <a href="SkCanvas_Reference#drawString">string</a>, with origin at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>), using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and
<a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#drawString">string</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#drawString">string</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. Other values of <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a> are unlikely to produce the desired
results, since zero bytes may be embedded in the <a href="SkCanvas_Reference#drawString">string</a>.
<a href="SkCanvas_Reference#x">x</a> and <a href="SkCanvas_Reference#y">y</a> meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>; by default
<a href="SkCanvas_Reference#drawString">string</a> draws left to right, positioning the first glyph's left side bearing at <a href="SkCanvas_Reference#x">x</a>
and its baseline at <a href="SkCanvas_Reference#y">y</a>. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to text. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>string </strong></code></td> <td>
character code points or glyphs drawn,
ending with a char value of zero</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
start of <a href="SkCanvas_Reference#drawString">string</a> on x-axis</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
start of <a href="SkCanvas_Reference#drawString">string</a> on y-axis</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
text size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="65cc4b15cd1a8d067eb1dbfd7e2c17dd"></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#drawText">drawText</a>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawString(const SkString& string, SkScalar x, SkScalar y,
const SkPaint& paint)
</pre>
Draw null terminated <a href="SkCanvas_Reference#drawString_2">string</a>, with origin at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>), using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and
<a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#drawString_2">string</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#drawString_2">string</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. Other values of <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a> are unlikely to produce the desired
results, since zero bytes may be embedded in the <a href="SkCanvas_Reference#drawString_2">string</a>.
<a href="SkCanvas_Reference#x">x</a> and <a href="SkCanvas_Reference#y">y</a> meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>; by default
<a href="SkCanvas_Reference#drawString_2">string</a> draws left to right, positioning the first glyph's left side bearing at <a href="SkCanvas_Reference#x">x</a>
and its baseline at <a href="SkCanvas_Reference#y">y</a>. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to text. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>string </strong></code></td> <td>
character code points or glyphs drawn,
ending with a char value of zero</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
start of <a href="SkCanvas_Reference#drawString_2">string</a> on x-axis</td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
start of <a href="SkCanvas_Reference#drawString_2">string</a> on y-axis</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
text size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="435178c09feb3bfec5e35d983609a013"></fiddle-embed></div>
### See Also
<a href="SkCanvas_Reference#drawText">drawText</a>
---
<a name="drawPosText"></a>
## drawPosText
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint& paint)
</pre>
Draw each glyph in <a href="SkCanvas_Reference#text">text</a> with the origin in <a href="SkCanvas_Reference#pos">pos</a> array, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and
<a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>. The number of entries in <a href="SkCanvas_Reference#pos">pos</a> array must match the number of glyphs
described by <a href="SkCanvas_Reference#byteLength">byteLength</a> of <a href="SkCanvas_Reference#text">text</a>.
<a href="SkCanvas_Reference#text">text</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#text">text</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. <a href="SkCanvas_Reference#pos">pos</a> elements' meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>;
by default each glyph's left side bearing is positioned at x and its
baseline is positioned at y. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and
<a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
Layout engines such as <a href="undocumented#Harfbuzz">Harfbuzz</a> typically position each glyph
rather than using the font's advance widths.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>pos </strong></code></td> <td>
array of glyph origins</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="bf0b2402533a23b6392e0676b7a8414c"></fiddle-embed></div>
---
<a name="drawPosTextH"></a>
## drawPosTextH
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint)
</pre>
Draw each glyph in <a href="SkCanvas_Reference#text">text</a> with its (x, y) origin composed from <a href="SkCanvas_Reference#xpos">xpos</a> array and
<a href="SkCanvas_Reference#constY">constY</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>. The number of entries in <a href="SkCanvas_Reference#xpos">xpos</a> array
must match the number of glyphs described by <a href="SkCanvas_Reference#byteLength">byteLength</a> of <a href="SkCanvas_Reference#text">text</a>.
<a href="SkCanvas_Reference#text">text</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#text">text</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. pos elements' meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>;
by default each glyph's left side bearing is positioned at an <a href="SkCanvas_Reference#xpos">xpos</a> element and
its baseline is positioned at <a href="SkCanvas_Reference#constY">constY</a>. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and
<a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
Layout engines such as <a href="undocumented#Harfbuzz">Harfbuzz</a> typically position each glyph
rather than using the font's advance widths if all glyphs share the same
baseline.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>xpos </strong></code></td> <td>
array of x positions, used to position each glyph</td>
</tr> <tr> <td><code><strong>constY </strong></code></td> <td>
shared y coordinate for all of x positions</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="95c6a7ef82993a8d2add676080e9438a"></fiddle-embed></div>
---
<a name="drawTextOnPathHV"></a>
## drawTextOnPathHV
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path,
SkScalar hOffset, SkScalar vOffset, const SkPaint& paint)
</pre>
Draw <a href="SkCanvas_Reference#text">text</a> on <a href="SkPath_Reference#Path">Path</a> <a href="SkCanvas_Reference#path">path</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
Origin of <a href="SkCanvas_Reference#text">text</a> is at distance <a href="SkCanvas_Reference#hOffset">hOffset</a> along the <a href="SkCanvas_Reference#path">path</a>, offset by a perpendicular
vector of length <a href="SkCanvas_Reference#vOffset">vOffset</a>. If the <a href="SkCanvas_Reference#path">path</a> section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the <a href="SkCanvas_Reference#path">path</a>. If the <a href="SkCanvas_Reference#text">text</a>'s advance is larger
than the <a href="SkCanvas_Reference#path">path</a> length, the excess <a href="SkCanvas_Reference#text">text</a> is clipped.
<a href="SkCanvas_Reference#text">text</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#text">text</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. Origin meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>; by
default <a href="SkCanvas_Reference#text">text</a> positions the first glyph's left side bearing at origin x and its
baseline at origin y. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> providing <a href="SkCanvas_Reference#text">text</a> baseline</td>
</tr> <tr> <td><code><strong>hOffset </strong></code></td> <td>
distance along <a href="SkCanvas_Reference#path">path</a> to offset origin</td>
</tr> <tr> <td><code><strong>vOffset </strong></code></td> <td>
offset of <a href="SkCanvas_Reference#text">text</a> above (if negative) or below (if positive) the <a href="SkCanvas_Reference#path">path</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="25cc5452156d7f06e85f514913d46b5c"></fiddle-embed></div>
---
<a name="drawTextOnPath"></a>
## drawTextOnPath
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
const SkMatrix* matrix, const SkPaint& paint)
</pre>
Draw <a href="SkCanvas_Reference#text">text</a> on <a href="SkPath_Reference#Path">Path</a> <a href="SkCanvas_Reference#path">path</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
Origin of <a href="SkCanvas_Reference#text">text</a> is at beginning of <a href="SkCanvas_Reference#path">path</a> offset by <a href="SkCanvas_Reference#drawTextOnPath">matrix</a>, if provided, before it
is mapped to <a href="SkCanvas_Reference#path">path</a>. If the <a href="SkCanvas_Reference#path">path</a> section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the <a href="SkCanvas_Reference#path">path</a>. If the <a href="SkCanvas_Reference#text">text</a>'s advance is larger
than the <a href="SkCanvas_Reference#path">path</a> length, the excess <a href="SkCanvas_Reference#text">text</a> is clipped.
<a href="SkCanvas_Reference#text">text</a>'s meaning depends on <a href="SkPaint_Reference#Text_Encoding">Paint Text Encoding</a>; by default, <a href="SkCanvas_Reference#text">text</a> encoding is
<a href="undocumented#UTF_8">UTF-8</a>. Origin meaning depends on <a href="SkPaint_Reference#Text_Align">Paint Text Align</a> and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>; by
default <a href="SkCanvas_Reference#text">text</a> positions the first glyph's left side bearing at origin x and its
baseline at origin y. <a href="undocumented#Text">Text</a> size is affected by <a href="SkCanvas_Reference#Matrix">Matrix</a> and <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>path </strong></code></td> <td>
<a href="SkPath_Reference#Path">Path</a> providing <a href="SkCanvas_Reference#text">text</a> baseline</td>
</tr> <tr> <td><code><strong>matrix </strong></code></td> <td>
transform of glyphs before mapping to <a href="SkCanvas_Reference#path">path</a>; may be nullptr
to use identity <a href="SkCanvas_Reference#Matrix">Matrix</a>.</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="0f60797fbdce3d3c71c46b800e6bd6f8"></fiddle-embed></div>
---
<a name="drawTextRSXform"></a>
## drawTextRSXform
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawTextRSXform(const void* text, size_t byteLength,
const SkRSXform xform[], const SkRect* cullRect,
const SkPaint& paint)
</pre>
Draw <a href="SkCanvas_Reference#text">text</a>, transforming each glyph by the corresponding <a href="undocumented#SkRSXform">SkRSXform</a>,
using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="undocumented#RSXform">RSXform</a> array specifies a separate square scale, rotation, and translation for
each glyph.
Optional <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#cullRect">cullRect</a> is a conservative bounds of <a href="SkCanvas_Reference#text">text</a>, taking into account
<a href="undocumented#RSXform">RSXform</a> and <a href="SkCanvas_Reference#paint">paint</a>. If cullrect is outside of <a href="SkCanvas_Reference#Clip">Clip</a>, canvas can skip drawing.
All elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>,
<a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#text">text</a>. By default, draws
filled 12 point black glyphs.
### Parameters
<table> <tr> <td><code><strong>text </strong></code></td> <td>
character code points or glyphs drawn</td>
</tr> <tr> <td><code><strong>byteLength </strong></code></td> <td>
byte length of <a href="SkCanvas_Reference#text">text</a> array</td>
</tr> <tr> <td><code><strong>xform </strong></code></td> <td>
<a href="undocumented#RSXform">RSXform</a> rotates, scales, and translates each glyph individually</td>
</tr> <tr> <td><code><strong>cullRect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of <a href="SkCanvas_Reference#text">text</a> for efficient clipping; or nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkCanvas_Reference#text">text</a> size, blend, color, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="55c84c39890c7516f7c835c46b1b8fc9"></fiddle-embed></div>
---
<a name="drawTextBlob"></a>
## drawTextBlob
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint)
</pre>
Draw <a href="undocumented#Text_Blob">Text Blob</a> <a href="SkCanvas_Reference#blob">blob</a> at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>), using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#blob">blob</a> contains glyphs, their positions, and <a href="SkCanvas_Reference#paint">paint</a> attributes specific to text:
<a href="undocumented#Typeface">Typeface</a>, <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>, <a href="SkPaint_Reference#Text_Scale_X">Paint Text Scale X</a>, <a href="SkPaint_Reference#Text_Skew_X">Paint Text Skew X</a>,
<a href="SkPaint_Reference#Text_Align">Paint Text Align</a>, <a href="SkPaint_Reference#Hinting">Paint Hinting</a>, <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="SkPaint_Reference#Fake_Bold">Paint Fake Bold</a>,
<a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a>, <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a>, <a href="SkPaint_Reference#LCD_Text">LCD Text</a>, <a href="SkPaint_Reference#Linear_Text">Linear Text</a>,
<a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>, and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>.
Elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#blob">blob</a>.
### Parameters
<table> <tr> <td><code><strong>blob </strong></code></td> <td>
glyphs, positions, and their paints' text size, typeface, and so on</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
horizontal offset applied to <a href="SkCanvas_Reference#blob">blob</a></td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
vertical offset applied to <a href="SkCanvas_Reference#blob">blob</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
blend, color, stroking, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="b8c0a748ed5c328f38e00f5f3d12e5e6"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y,
const SkPaint& paint)
</pre>
Draw <a href="undocumented#Text_Blob">Text Blob</a> <a href="SkCanvas_Reference#blob">blob</a> at (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>), using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#blob">blob</a> contains glyphs, their positions, and <a href="SkCanvas_Reference#paint">paint</a> attributes specific to text:
<a href="undocumented#Typeface">Typeface</a>, <a href="SkPaint_Reference#Text_Size">Paint Text Size</a>, <a href="SkPaint_Reference#Text_Scale_X">Paint Text Scale X</a>, <a href="SkPaint_Reference#Text_Skew_X">Paint Text Skew X</a>,
<a href="SkPaint_Reference#Text_Align">Paint Text Align</a>, <a href="SkPaint_Reference#Hinting">Paint Hinting</a>, <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="SkPaint_Reference#Fake_Bold">Paint Fake Bold</a>,
<a href="SkPaint_Reference#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a>, <a href="SkPaint_Reference#Full_Hinting_Spacing">Full Hinting Spacing</a>, <a href="SkPaint_Reference#LCD_Text">LCD Text</a>, <a href="SkPaint_Reference#Linear_Text">Linear Text</a>,
<a href="SkPaint_Reference#Subpixel_Text">Subpixel Text</a>, and <a href="SkPaint_Reference#Vertical_Text">Paint Vertical Text</a>.
Elements of <a href="SkCanvas_Reference#paint">paint</a>: <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Rasterizer">Rasterizer</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Draw_Looper">Draw Looper</a>; apply to <a href="SkCanvas_Reference#blob">blob</a>.
### Parameters
<table> <tr> <td><code><strong>blob </strong></code></td> <td>
glyphs, positions, and their paints' text size, typeface, and so on</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
horizontal offset applied to <a href="SkCanvas_Reference#blob">blob</a></td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
vertical offset applied to <a href="SkCanvas_Reference#blob">blob</a></td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
blend, color, stroking, and so on, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="d313ad4726518f5d44f6433887bb7ce9"><div><a href="SkPaint_Reference#Paint">Paint</a> attributes unrelated to text, like color, have no effect on <a href="SkCanvas_Reference#paint">paint</a> in allocated <a href="undocumented#Text_Blob">Text Blob</a>.
<a href="SkPaint_Reference#Paint">Paint</a> attributes related to text, like text size, have no effect on <a href="SkCanvas_Reference#paint">paint</a> passed to <a href="SkCanvas_Reference#drawTextBlob">drawTextBlob</a>.</div></fiddle-embed></div>
---
<a name="drawPicture"></a>
## drawPicture
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPicture(const SkPicture* picture)
</pre>
Draw <a href="undocumented#Picture">Picture</a> <a href="SkCanvas_Reference#picture">picture</a>, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>.
<a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> are unchanged by <a href="SkCanvas_Reference#picture">picture</a> contents, as if
<a href="SkCanvas_Reference#save">save</a> was called before and <a href="SkCanvas_Reference#restore">restore</a> was called after <a href="SkCanvas_Reference#drawPicture">drawPicture</a>.
<a href="undocumented#Picture">Picture</a> records a series of draw commands for later playback.
### Parameters
<table> <tr> <td><code><strong>picture </strong></code></td> <td>
recorded drawing commands to play</td>
</tr>
</table>
### Example
<div><fiddle-embed name="fde216281ff93d612768a49f2cf309ae"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPicture(const sk_sp<SkPicture>& picture)
</pre>
Draw <a href="undocumented#Picture">Picture</a> <a href="SkCanvas_Reference#picture">picture</a>, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>.
<a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a> are unchanged by <a href="SkCanvas_Reference#picture">picture</a> contents, as if
<a href="SkCanvas_Reference#save">save</a> was called before and <a href="SkCanvas_Reference#restore">restore</a> was called after <a href="SkCanvas_Reference#drawPicture">drawPicture</a>.
<a href="undocumented#Picture">Picture</a> records a series of draw commands for later playback.
### Parameters
<table> <tr> <td><code><strong>picture </strong></code></td> <td>
recorded drawing commands to play</td>
</tr>
</table>
### Example
<div><fiddle-embed name="a7373b01354dda73dafe8718f4fd0cfc"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPicture(const SkPicture* picture, const SkMatrix* matrix,
const SkPaint* paint)
</pre>
Draw <a href="undocumented#Picture">Picture</a> <a href="SkCanvas_Reference#picture">picture</a>, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>; transforming <a href="SkCanvas_Reference#picture">picture</a> with
<a href="SkCanvas_Reference#Matrix">Matrix</a> <a href="SkCanvas_Reference#matrix">matrix</a>, if provided; and use <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a> <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>, if provided.
<a href="SkCanvas_Reference#matrix">matrix</a> transformation is equivalent to: <a href="SkCanvas_Reference#save">save</a>, <a href="SkCanvas_Reference#concat">concat</a>, <a href="SkCanvas_Reference#drawPicture">drawPicture</a>, <a href="SkCanvas_Reference#restore">restore</a>.
<a href="SkCanvas_Reference#paint">paint</a> use is equivalent to: <a href="SkCanvas_Reference#saveLayer">saveLayer</a>, <a href="SkCanvas_Reference#drawPicture">drawPicture</a>, <a href="SkCanvas_Reference#restore">restore</a>.
### Parameters
<table> <tr> <td><code><strong>picture </strong></code></td> <td>
recorded drawing commands to play</td>
</tr> <tr> <td><code><strong>matrix </strong></code></td> <td>
<a href="SkCanvas_Reference#Matrix">Matrix</a> to rotate, scale, translate, and so on; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> to apply transparency, filtering, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="4ec028d8ffa0a6ae1a99ff8d094b02bc"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix,
const SkPaint* paint)
</pre>
Draw <a href="undocumented#Picture">Picture</a> <a href="SkCanvas_Reference#picture">picture</a>, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>; transforming <a href="SkCanvas_Reference#picture">picture</a> with
<a href="SkCanvas_Reference#Matrix">Matrix</a> <a href="SkCanvas_Reference#matrix">matrix</a>, if provided; and use <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a> <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>, if provided.
<a href="SkCanvas_Reference#matrix">matrix</a> transformation is equivalent to: <a href="SkCanvas_Reference#save">save</a>, <a href="SkCanvas_Reference#concat">concat</a>, <a href="SkCanvas_Reference#drawPicture">drawPicture</a>, <a href="SkCanvas_Reference#restore">restore</a>.
<a href="SkCanvas_Reference#paint">paint</a> use is equivalent to: <a href="SkCanvas_Reference#saveLayer">saveLayer</a>, <a href="SkCanvas_Reference#drawPicture">drawPicture</a>, <a href="SkCanvas_Reference#restore">restore</a>.
### Parameters
<table> <tr> <td><code><strong>picture </strong></code></td> <td>
recorded drawing commands to play</td>
</tr> <tr> <td><code><strong>matrix </strong></code></td> <td>
<a href="SkCanvas_Reference#Matrix">Matrix</a> to rotate, scale, translate, and so on; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> to apply transparency, filtering, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="7295eb14091e98565cec0353661a6a7d"></fiddle-embed></div>
---
<a name="drawVertices"></a>
## drawVertices
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawVertices(const SkVertices* vertices, SkBlendMode mode,
const SkPaint& paint)
</pre>
Draw <a href="undocumented#Vertices">Vertices</a> <a href="SkCanvas_Reference#vertices">vertices</a>, a triangle mesh, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>.
If <a href="undocumented#Texs">Vertices Texs</a> and <a href="undocumented#Colors">Vertices Colors</a> are defined in <a href="SkCanvas_Reference#vertices">vertices</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>
contains <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Blend_Mode">Blend Mode</a> <a href="SkCanvas_Reference#mode">mode</a> combines <a href="undocumented#Colors">Vertices Colors</a> with <a href="undocumented#Shader">Shader</a>.
### Parameters
<table> <tr> <td><code><strong>vertices </strong></code></td> <td>
triangle mesh to draw</td>
</tr> <tr> <td><code><strong>mode </strong></code></td> <td>
combines <a href="undocumented#Colors">Vertices Colors</a> with <a href="undocumented#Shader">Shader</a>, if both are present</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
specifies the <a href="undocumented#Shader">Shader</a>, used as <a href="undocumented#Vertices">Vertices</a> texture; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="f48b22eaad1bb7adcc3faaa321754af6"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode,
const SkPaint& paint)
</pre>
Draw <a href="undocumented#Vertices">Vertices</a> <a href="SkCanvas_Reference#vertices">vertices</a>, a triangle mesh, using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>.
If <a href="undocumented#Texs">Vertices Texs</a> and <a href="undocumented#Colors">Vertices Colors</a> are defined in <a href="SkCanvas_Reference#vertices">vertices</a>, and <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>
contains <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Blend_Mode">Blend Mode</a> <a href="SkCanvas_Reference#mode">mode</a> combines <a href="undocumented#Colors">Vertices Colors</a> with <a href="undocumented#Shader">Shader</a>.
### Parameters
<table> <tr> <td><code><strong>vertices </strong></code></td> <td>
triangle mesh to draw</td>
</tr> <tr> <td><code><strong>mode </strong></code></td> <td>
combines <a href="undocumented#Colors">Vertices Colors</a> with <a href="undocumented#Shader">Shader</a>, if both are present</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
specifies the <a href="undocumented#Shader">Shader</a>, used as <a href="undocumented#Vertices">Vertices</a> texture, may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="94e32538646d5f1299c427e473f9ec87"></fiddle-embed></div>
---
<a name="drawPatch"></a>
## drawPatch
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode mode,
const SkPaint& paint)
</pre>
Draw a cubic <a href="undocumented#Coons">Coons</a> patch: the interpolation of four <a href="SkCanvas_Reference#cubics">cubics</a> with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
The <a href="undocumented#Coons">Coons</a> patch uses <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>'s <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>. If <a href="undocumented#Shader">Shader</a> is provided it is treated
as the <a href="undocumented#Coons">Coons</a> patch texture; <a href="undocumented#Blend_Mode">Blend Mode</a> <a href="SkCanvas_Reference#mode">mode</a> combines <a href="undocumented#Color">Color</a> <a href="SkCanvas_Reference#colors">colors</a> and <a href="undocumented#Shader">Shader</a> if
both are provided.
<a href="undocumented#Point">Point</a> array <a href="SkCanvas_Reference#cubics">cubics</a> specifies four <a href="SkCanvas_Reference#cubics">cubics</a> starting at the top left corner,
in clockwise order, sharing every fourth point. The last cubic ends at the
first point.
<a href="undocumented#Color">Color</a> array color associates <a href="SkCanvas_Reference#colors">colors</a> with corners in top left, top right,
bottom right, bottom left order.
If <a href="SkCanvas_Reference#paint">paint</a> contains <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Point">Point</a> array <a href="SkCanvas_Reference#drawPatch">texCoords</a> maps <a href="undocumented#Shader">Shader</a> as texture to
corners in top left, top right, bottom right, bottom left order.
### Parameters
<table> <tr> <td><code><strong>cubics </strong></code></td> <td>
Cubic array, sharing common points</td>
</tr> <tr> <td><code><strong>colors </strong></code></td> <td>
<a href="undocumented#Color">Color</a> array, one for each corner</td>
</tr> <tr> <td><code><strong>texCoords </strong></code></td> <td>
<a href="undocumented#Point">Point</a> array of texure coordinates, mapping <a href="undocumented#Shader">Shader</a> to corners;
may be nullptr</td>
</tr>
# <tr> <td><code><strong>mode </strong></code></td> <td>
<a href="undocumented#Blend_Mode">Blend Mode</a> for <a href="SkCanvas_Reference#colors">colors</a>, and for <a href="undocumented#Shader">Shader</a> if <a href="SkCanvas_Reference#paint">paint</a> has one</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="accb545d67984ced168f5be6ab824795"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], const SkPaint& paint)
</pre>
Draw a cubic <a href="undocumented#Coons">Coons</a> patch: the interpolation of four <a href="SkCanvas_Reference#cubics">cubics</a> with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
The <a href="undocumented#Coons">Coons</a> patch uses <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>, <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>'s <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>,
<a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>. If <a href="undocumented#Shader">Shader</a> is provided it is treated
as the <a href="undocumented#Coons">Coons</a> patch texture; <a href="undocumented#Blend_Mode">Blend Mode</a> mode combines <a href="undocumented#Color">Color</a> <a href="SkCanvas_Reference#colors">colors</a> and <a href="undocumented#Shader">Shader</a> if
both are provided.
<a href="undocumented#Point">Point</a> array <a href="SkCanvas_Reference#cubics">cubics</a> specifies four <a href="SkCanvas_Reference#cubics">cubics</a> starting at the top left corner,
in clockwise order, sharing every fourth point. The last cubic ends at the
first point.
<a href="undocumented#Color">Color</a> array color associates <a href="SkCanvas_Reference#colors">colors</a> with corners in top left, top right,
bottom right, bottom left order.
If <a href="SkCanvas_Reference#paint">paint</a> contains <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Point">Point</a> array <a href="SkCanvas_Reference#drawPatch_2">texCoords</a> maps <a href="undocumented#Shader">Shader</a> as texture to
corners in top left, top right, bottom right, bottom left order.
### Parameters
<table> <tr> <td><code><strong>cubics </strong></code></td> <td>
Cubic array, sharing common points</td>
</tr> <tr> <td><code><strong>colors </strong></code></td> <td>
<a href="undocumented#Color">Color</a> array, one for each corner</td>
</tr> <tr> <td><code><strong>texCoords </strong></code></td> <td>
<a href="undocumented#Point">Point</a> array of texure coordinates, mapping <a href="undocumented#Shader">Shader</a> to corners;
may be nullptr</td>
</tr>
# <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="undocumented#Shader">Shader</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, used to draw</td>
</tr>
</table>
### Example
<div><fiddle-embed name="4cf70f8d194867d053d7e177e5088445"></fiddle-embed></div>
### Example
<div><fiddle-embed name="3412c2a16cb529af0e04878d264451f2"></fiddle-embed></div>
---
<a name="drawAtlas"></a>
## drawAtlas
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode,
const SkRect* cullRect, const SkPaint* paint)
</pre>
Draw a set of sprites from <a href="SkCanvas_Reference#atlas">atlas</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#paint">paint</a> uses <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>
to draw, if present. For each entry in the array, <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#tex">tex</a> locates sprite in
<a href="SkCanvas_Reference#atlas">atlas</a>, and <a href="undocumented#RSXform">RSXform</a> <a href="SkCanvas_Reference#xform">xform</a> transforms it into destination space.
<a href="SkCanvas_Reference#xform">xform</a>, text, and <a href="SkCanvas_Reference#colors">colors</a> if present, must contain <a href="SkCanvas_Reference#count">count</a> entries.
Optional <a href="SkCanvas_Reference#colors">colors</a> are applied for each sprite using <a href="undocumented#Blend_Mode">Blend Mode</a>.
Optional <a href="SkCanvas_Reference#cullRect">cullRect</a> is a conservative bounds of all transformed sprites.
If cullrect is outside of <a href="SkCanvas_Reference#Clip">Clip</a>, canvas can skip drawing.
### Parameters
<table> <tr> <td><code><strong>atlas </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing sprites</td>
</tr> <tr> <td><code><strong>xform </strong></code></td> <td>
<a href="undocumented#RSXform">RSXform</a> mappings for sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>tex </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> locations of sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>colors </strong></code></td> <td>
<a href="undocumented#Color">Color</a>, one per sprite, blended with sprite using <a href="undocumented#Blend_Mode">Blend Mode</a>; may be nullptr</td>
</tr> <tr> <td><code><strong>count </strong></code></td> <td>
number of sprites to draw</td>
</tr> <tr> <td><code><strong>mode </strong></code></td> <td>
<a href="undocumented#Blend_Mode">Blend Mode</a> combining <a href="SkCanvas_Reference#colors">colors</a> and sprites</td>
</tr> <tr> <td><code><strong>cullRect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of transformed sprites for efficient clipping; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="1df575f9b8132306ce0552a2554ed132"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkBlendMode mode, const SkRect* cullRect, const SkPaint* paint)
</pre>
Draw a set of sprites from <a href="SkCanvas_Reference#atlas">atlas</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#paint">paint</a> uses <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>
to draw, if present. For each entry in the array, <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#tex">tex</a> locates sprite in
<a href="SkCanvas_Reference#atlas">atlas</a>, and <a href="undocumented#RSXform">RSXform</a> <a href="SkCanvas_Reference#xform">xform</a> transforms it into destination space.
<a href="SkCanvas_Reference#xform">xform</a>, text, and <a href="SkCanvas_Reference#colors">colors</a> if present, must contain <a href="SkCanvas_Reference#count">count</a> entries.
Optional <a href="SkCanvas_Reference#colors">colors</a> is applied for each sprite using <a href="undocumented#Blend_Mode">Blend Mode</a>.
Optional <a href="SkCanvas_Reference#cullRect">cullRect</a> is a conservative bounds of all transformed sprites.
If cullrect is outside of <a href="SkCanvas_Reference#Clip">Clip</a>, canvas can skip drawing.
### Parameters
<table> <tr> <td><code><strong>atlas </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing sprites</td>
</tr> <tr> <td><code><strong>xform </strong></code></td> <td>
<a href="undocumented#RSXform">RSXform</a> mappings for sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>tex </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> locations of sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>colors </strong></code></td> <td>
<a href="undocumented#Color">Color</a>, one per sprite, blended with sprite using <a href="undocumented#Blend_Mode">Blend Mode</a>; may be nullptr</td>
</tr> <tr> <td><code><strong>count </strong></code></td> <td>
number of sprites to draw</td>
</tr> <tr> <td><code><strong>mode </strong></code></td> <td>
<a href="undocumented#Blend_Mode">Blend Mode</a> combining <a href="SkCanvas_Reference#colors">colors</a> and sprites</td>
</tr> <tr> <td><code><strong>cullRect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of transformed sprites for efficient clipping; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="0e66a8f230a8d531bcef9f5ebdc5aac1"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
int count, const SkRect* cullRect, const SkPaint* paint)
</pre>
Draw a set of sprites from <a href="SkCanvas_Reference#atlas">atlas</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#paint">paint</a> uses <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>
to draw, if present. For each entry in the array, <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#tex">tex</a> locates sprite in
<a href="SkCanvas_Reference#atlas">atlas</a>, and <a href="undocumented#RSXform">RSXform</a> <a href="SkCanvas_Reference#xform">xform</a> transforms it into destination space.
<a href="SkCanvas_Reference#xform">xform</a> and text must contain <a href="SkCanvas_Reference#count">count</a> entries.
Optional <a href="SkCanvas_Reference#cullRect">cullRect</a> is a conservative bounds of all transformed sprites.
If cullrect is outside of <a href="SkCanvas_Reference#Clip">Clip</a>, canvas can skip drawing.
### Parameters
<table> <tr> <td><code><strong>atlas </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing sprites</td>
</tr> <tr> <td><code><strong>xform </strong></code></td> <td>
<a href="undocumented#RSXform">RSXform</a> mappings for sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>tex </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> locations of sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>count </strong></code></td> <td>
number of sprites to draw</td>
</tr> <tr> <td><code><strong>cullRect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of transformed sprites for efficient clipping; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="8dc0d0fdeab20bbc21cac6874ddbefcd"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[],
const SkRect tex[], int count, const SkRect* cullRect,
const SkPaint* paint)
</pre>
Draw a set of sprites from <a href="SkCanvas_Reference#atlas">atlas</a>, using <a href="SkCanvas_Reference#Clip">Clip</a>, <a href="SkCanvas_Reference#Matrix">Matrix</a>, and optional <a href="SkPaint_Reference#Paint">Paint</a> <a href="SkCanvas_Reference#paint">paint</a>.
<a href="SkCanvas_Reference#paint">paint</a> uses <a href="SkPaint_Reference#Anti_alias">Anti-alias</a>, <a href="undocumented#Alpha">Color Alpha</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, and <a href="undocumented#Blend_Mode">Blend Mode</a>
to draw, if present. For each entry in the array, <a href="undocumented#Rect">Rect</a> <a href="SkCanvas_Reference#tex">tex</a> locates sprite in
<a href="SkCanvas_Reference#atlas">atlas</a>, and <a href="undocumented#RSXform">RSXform</a> <a href="SkCanvas_Reference#xform">xform</a> transforms it into destination space.
<a href="SkCanvas_Reference#xform">xform</a> and text must contain <a href="SkCanvas_Reference#count">count</a> entries.
Optional <a href="SkCanvas_Reference#cullRect">cullRect</a> is a conservative bounds of all transformed sprites.
If cullrect is outside of <a href="SkCanvas_Reference#Clip">Clip</a>, canvas can skip drawing.
### Parameters
<table> <tr> <td><code><strong>atlas </strong></code></td> <td>
<a href="undocumented#Image">Image</a> containing sprites</td>
</tr> <tr> <td><code><strong>xform </strong></code></td> <td>
<a href="undocumented#RSXform">RSXform</a> mappings for sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>tex </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> locations of sprites in <a href="SkCanvas_Reference#atlas">atlas</a></td>
</tr> <tr> <td><code><strong>count </strong></code></td> <td>
number of sprites to draw</td>
</tr> <tr> <td><code><strong>cullRect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> bounds of transformed sprites for efficient clipping; may be nullptr</td>
</tr> <tr> <td><code><strong>paint </strong></code></td> <td>
<a href="SkPaint_Reference#Paint">Paint</a> <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Image_Filter">Image Filter</a>, <a href="undocumented#Blend_Mode">Blend Mode</a>, and so on; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="c093c2b14bd3e6171ede7cd4049d9b57"></fiddle-embed></div>
---
<a name="drawDrawable"></a>
## drawDrawable
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = NULL)
</pre>
Draw <a href="undocumented#Drawable">Drawable</a> <a href="SkCanvas_Reference#drawable">drawable</a> using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>, concatenated with
optional <a href="SkCanvas_Reference#matrix">matrix</a>.
If <a href="SkCanvas_Reference#Canvas">Canvas</a> has an asynchronous implementation, as is the case
when it is recording into <a href="undocumented#Picture">Picture</a>, then <a href="SkCanvas_Reference#drawable">drawable</a> will be referenced,
so that <a href="undocumented#draw">SkDrawable::draw()</a> can be called when the operation is finalized. To force
immediate drawing, call <a href="undocumented#draw">SkDrawable::draw()</a> instead.
### Parameters
<table> <tr> <td><code><strong>drawable </strong></code></td> <td>
custom struct encapsulating drawing commands</td>
</tr> <tr> <td><code><strong>matrix </strong></code></td> <td>
transformation applied to drawing; may be nullptr</td>
</tr>
</table>
### Example
<div><fiddle-embed name="3a4dfcd08838866b5cfc0d82489195ba"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y)
</pre>
Draw <a href="undocumented#Drawable">Drawable</a> <a href="SkCanvas_Reference#drawable">drawable</a> using <a href="SkCanvas_Reference#Clip">Clip</a> and <a href="SkCanvas_Reference#Matrix">Matrix</a>, offset by (<a href="SkCanvas_Reference#x">x</a>, <a href="SkCanvas_Reference#y">y</a>).
If <a href="SkCanvas_Reference#Canvas">Canvas</a> has an asynchronous implementation, as is the case
when it is recording into <a href="undocumented#Picture">Picture</a>, then <a href="SkCanvas_Reference#drawable">drawable</a> will be referenced,
so that <a href="undocumented#draw">SkDrawable::draw()</a> can be called when the operation is finalized. To force
immediate drawing, call <a href="undocumented#draw">SkDrawable::draw()</a> instead.
### Parameters
<table> <tr> <td><code><strong>drawable </strong></code></td> <td>
custom struct encapsulating drawing commands</td>
</tr> <tr> <td><code><strong>x </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable pixels in <a href="SkCanvas_Reference#x">x</a></td>
</tr> <tr> <td><code><strong>y </strong></code></td> <td>
offset into <a href="SkCanvas_Reference#Canvas">Canvas</a> writable pixels in <a href="SkCanvas_Reference#y">y</a></td>
</tr>
</table>
### Example
<div><fiddle-embed name="1bdc07ad3b154c89b771722c2fcaee3f"></fiddle-embed></div>
---
<a name="drawAnnotation"></a>
## drawAnnotation
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAnnotation(const SkRect& rect, const char key[], SkData* value)
</pre>
Associate <a href="undocumented#Rect">Rect</a> on <a href="SkCanvas_Reference#Canvas">Canvas</a> when an annotation; a key-value pair, where the <a href="SkCanvas_Reference#key">key</a> is
a null-terminated utf8 string, and optional <a href="SkCanvas_Reference#value">value</a> is stored as <a href="undocumented#Data">Data</a>.
Only some canvas implementations, such as recording to <a href="undocumented#Picture">Picture</a>, or drawing to
<a href="undocumented#PDF">Document PDF</a>, use annotations.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> extent of canvas to annotate</td>
</tr> <tr> <td><code><strong>key </strong></code></td> <td>
string used for lookup</td>
</tr> <tr> <td><code><strong>value </strong></code></td> <td>
data holding <a href="SkCanvas_Reference#value">value</a> stored in annotation</td>
</tr>
</table>
### Example
<div><fiddle-embed name="00b430bd80d740e19c6d020a940f56d5"></fiddle-embed></div>
---
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
void drawAnnotation(const SkRect& rect, const char key[],
const sk_sp<SkData>& value)
</pre>
Associate <a href="undocumented#Rect">Rect</a> on <a href="SkCanvas_Reference#Canvas">Canvas</a> when an annotation; a key-value pair, where the <a href="SkCanvas_Reference#key">key</a> is
a null-terminated utf8 string, and optional <a href="SkCanvas_Reference#value">value</a> is stored as <a href="undocumented#Data">Data</a>.
Only some canvas implementations, such as recording to <a href="undocumented#Picture">Picture</a>, or drawing to
<a href="undocumented#PDF">Document PDF</a>, use annotations.
### Parameters
<table> <tr> <td><code><strong>rect </strong></code></td> <td>
<a href="undocumented#Rect">Rect</a> extent of canvas to annotate</td>
</tr> <tr> <td><code><strong>key </strong></code></td> <td>
string used for lookup</td>
</tr> <tr> <td><code><strong>value </strong></code></td> <td>
data holding <a href="SkCanvas_Reference#value">value</a> stored in annotation</td>
</tr>
</table>
### Example
<div><fiddle-embed name="00b430bd80d740e19c6d020a940f56d5"></fiddle-embed></div>
---
<a name="getDrawFilter"></a>
## getDrawFilter
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
SkDrawFilter* getDrawFilter() const
</pre>
Legacy call to be deprecated.
---
<a name="setDrawFilter"></a>
## setDrawFilter
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter)
</pre>
Legacy call to be deprecated.
---
<a name="isClipEmpty"></a>
## isClipEmpty
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual bool isClipEmpty() const
</pre>
Returns true if <a href="SkCanvas_Reference#Clip">Clip</a> is empty; that is, nothing will draw.
May do work when called; it should not be called
more often than needed. However, once called, subsequent calls perform no
work until <a href="SkCanvas_Reference#Clip">Clip</a> changes.
### Return Value
true if <a href="SkCanvas_Reference#Clip">Clip</a> is empty
### Example
<div><fiddle-embed name="f106f146a58c8604308d4d8d7086d2f5">
#### Example Output
~~~~
clip is not empty
clip is empty
~~~~
</fiddle-embed></div>
---
<a name="isClipRect"></a>
## isClipRect
<pre style="padding: 1em 1em 1em 1em;width: 50em; background-color: #f0f0f0">
virtual bool isClipRect() const
</pre>
Returns true if <a href="SkCanvas_Reference#Clip">Clip</a> is <a href="undocumented#Rect">Rect</a> and not empty.
Returns false if the clip is empty, or if it is not <a href="undocumented#Rect">Rect</a>.
### Return Value
true if <a href="SkCanvas_Reference#Clip">Clip</a> is <a href="undocumented#Rect">Rect</a> and not empty
### Example
<div><fiddle-embed name="9894bfb476c78a8f6c8f49fbbca3d50d">
#### Example Output
~~~~
clip is rect
clip is not rect
~~~~
</fiddle-embed></div>
---