Canvas provides an interface for drawing, and how the drawing is clipped and transformed. Canvas contains a stack of Matrix and Clip values.
Canvas and Paint together provide the state to draw into Surface or Device. Each Canvas draw call transforms the geometry of the object by the concatenation of all Matrix values in the stack. The transformed geometry is clipped by the intersection of all of Clip values in the stack. The Canvas draw calls use Paint to supply drawing state such as Color, Typeface, text size, stroke width, Shader and so on.
To draw to a pixel-based destination, create Raster_Surface or GPU_Surface. Request Canvas from Surface to obtain the interface to draw. Canvas generated by Raster_Surface draws to memory visible to the CPU. Canvas generated by GPU_Surface uses Vulkan or OpenGL to draw to the GPU.
To draw to a document, obtain Canvas from SVG_Canvas, Document_PDF, or Picture_Recorder. Document based Canvas and other Canvas subclasses reference Device describing the destination.
Canvas can be constructed to draw to Bitmap without first creating Raster_Surface. This approach may be deprecated in the future.
Canvas may be created directly when no Surface is required; some Canvas methods implicitly create Raster_Surface.
Allocates raster SkCanvas that will draw directly into pixels.
SkCanvas is returned if all parameters are valid. Valid parameters include: info dimensions are zero or positive; info contains SkColorType and SkAlphaType supported by raster surface; pixels is not nullptr; rowBytes is zero or large enough to contain info width pixels of SkColorType.
Pass zero for rowBytes to compute rowBytes from info width and size of pixel. If rowBytes is greater than zero, it must be equal to or greater than info width times bytes required for SkColorType.
Pixel buffer size should be info height times computed rowBytes. Pixels are not initialized. To access pixels after drawing, call flush() or peekPixels().
width, or height, or both, may be zero
may be nullptr
SkCanvas if all parameters are valid; otherwise, nullptr
--- -x- ---
MakeRasterDirectN32 SkSurface::MakeRasterDirect
Allocates raster SkCanvas specified by inline image specification. Subsequent SkCanvas calls draw into pixels. SkColorType is set to kN32_SkColorType. SkAlphaType is set to kPremul_SkAlphaType. To access pixels after drawing, call flush() or peekPixels().
SkCanvas is returned if all parameters are valid. Valid parameters include: width and height are zero or positive; pixels is not nullptr; rowBytes is zero or large enough to contain width pixels of kN32_SkColorType.
Pass zero for rowBytes to compute rowBytes from width and size of pixel. If rowBytes is greater than zero, it must be equal to or greater than width times bytes required for SkColorType.
Pixel buffer size should be height times rowBytes.
times rowBytes
SkCanvas if all parameters are valid; otherwise, nullptr
--- -x- ---
MakeRasterDirect SkSurface::MakeRasterDirect SkImageInfo::MakeN32Premul
Creates an empty SkCanvas with no backing device or pixels, with a width and height of zero.
empty SkCanvas
rect stays rect is true rect stays rect is false rect stays rect is true
MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas
Creates SkCanvas of the specified dimensions without a SkSurface. Used by subclasses with custom implementations for draw member functions.
If props equals nullptr, SkSurfaceProps are created with SkSurfaceProps::InitType 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 is best not to rely on this legacy behavior.
may be nullptr
SkCanvas placeholder with dimensions
canvas is empty
MakeRasterDirect SkSurfaceProps SkPixelGeometry SkCreateColorSpaceXformCanvas
To be deprecated soon.
Constructs a canvas that draws into bitmap. Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed SkSurface.
SkBitmap is copied so that subsequently editing bitmap will not affect constructed SkCanvas.
May be deprecated in the future.
storage of raster surface
SkCanvas that can be used to draw into bitmap
----- ---x- ---x- ---x- ---x- ---x- ---x- ----- ---x- ---x- -----
MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas
Private: Android framework only.
For use by Android framework only.
SkCanvas that can be used to draw into bitmap
Constructs a canvas that draws into bitmap. Use props to match the device characteristics, like LCD striping.
bitmap is copied so that subsequently editing bitmap will not affect constructed SkCanvas.
and pixel storage of raster surface
device independent fonts
SkCanvas that can be used to draw into bitmap
----- ---x- ---x- ---x- ---x- ---x- ---x- ----- ---x- ---x- -----
MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas
Draws saved layers, if any. Frees up resources used by SkCanvas.
State_Stack
Returns storage to associate additional data with the canvas. The storage is freed when SkCanvas is deleted.
storage that can be read from and written to
before: (null) during: Hello! after: (null)
SkMetaData
Returns SkImageInfo for SkCanvas. If SkCanvas is not associated with raster surface or GPU surface, returned SkColorType is set to kUnknown_SkColorType.
dimensions and SkColorType of SkCanvas
emptyInfo == canvasInfo
SkImageInfo MakeRasterDirect makeSurface
Copies SkSurfaceProps, if SkCanvas is associated with raster surface or GPU surface, and returns true. Otherwise, returns false and leave props unchanged.
true if SkSurfaceProps was copied
isRGB:0 isRGB:1
SkSurfaceProps makeSurface
Triggers the immediate execution of all pending draw operations. If SkCanvas is associated with GPU surface, resolves all pending GPU operations. If SkCanvas is associated with raster surface, has no effect; raster draw operations are never deferred.
peekPixels SkSurface::flush GrContext::flush SkSurface::prepareForExternalIO GrContext::abandonContext
Gets the size of the base or root layer in global canvas coordinates. The origin of the base layer is always (0,0). The area available for drawing may be smaller (due to clipping or saveLayer).
integral width and height of base layer
clip=10,30 size=20,30
getDeviceClipBounds
Creates SkSurface matching info and props, and associates it with SkCanvas. Returns nullptr if no match found.
If props is nullptr, matches SkSurfaceProps in SkCanvas. If props is nullptr and SkCanvas does not have SkSurfaceProps, creates SkSurface with default SkSurfaceProps.
SkSurface matching info and props, or nullptr if no match is available
compatible != nullptr size = 3, 4
SkSurface SkSurface::makeSurface SkImageInfo SkSurfaceProps
Returns GPU context of the GPU surface associated with SkCanvas.
GPU context, if available; nullptr otherwise
GrContext
Returns the pixel base address, SkImageInfo, rowBytes, and origin if the pixels can be read directly. The returned address is only valid while SkCanvas is in scope and unchanged. Any SkCanvas call or SkSurface call may invalidate the returned address and other returned values.
If pixels are inaccessible, info, rowBytes, and origin are unchanged.
may be nullptr
address of pixels, or nullptr if inaccessible
The Layer and blended result appear on the CPU and GPU but the large dotted "DEF" appear only on the CPU.
SkImageInfo SkPixmap
Returns custom context that tracks the SkMatrix and clip.
Use SkRasterHandleAllocator to blend Skia drawing with custom drawing, typically performed by the host platform user interface. The custom context returned is generated by SkRasterHandleAllocator::MakeCanvas, which creates a custom canvas with raster storage for the drawing destination.
context of custom allocation
context = skia
SkRasterHandleAllocator
Returns true if SkCanvas has direct access to its pixels.
Pixels are readable when SkBaseDevice is raster. Pixels are not readable when SkCanvas is returned from GPU surface, returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like SkDebugCanvas.
pixmap is valid only while SkCanvas is in scope and unchanged. Any SkCanvas or SkSurface call may invalidate the pixmap values.
true if SkCanvas has direct access to pixels
width=256 height=256
readPixels SkBitmap::peekPixels SkImage::peekPixels SkSurface::peekPixels
Copies Rect of pixels from Canvas into dstPixels. Matrix and Clip are ignored.
Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination Rect corners are (0, 0) and (dstInfo.width(), dstInfo.height()). Copies each readable pixel intersecting both rectangles, without scaling, converting to dstInfo.colorType() and dstInfo.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility class like SkDebugCanvas.
The destination pixel storage must be allocated by the caller.
Pixel values are converted only if Color_Type and Alpha_Type do not match. Only pixels within both source and destination rectangles are copied. dstPixels contents outside Rect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down destination.
Does not copy, and returns false if:
true if pixels were copied
pixel = 802b5580 pixel = 8056a9ff
peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels
Copies Rect of pixels from Canvas into pixmap. Matrix and Clip are ignored.
Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination Rect corners are (0, 0) and (pixmap.width(), pixmap.height()). Copies each readable pixel intersecting both rectangles, without scaling, converting to pixmap.colorType() and pixmap.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility class like SkDebugCanvas.
Caller must allocate pixel storage in pixmap if needed.
Pixel values are converted only if Color_Type and Alpha_Type do not match. Only pixels within both source and destination Rects are copied. pixmap pixels contents outside Rect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down pixmap.
Does not copy, and returns false if:
true if pixels were copied
pixel = 802b5580
peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels
Copies Rect of pixels from Canvas into bitmap. Matrix and Clip are ignored.
Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination Rect corners are (0, 0) and (bitmap.width(), bitmap.height()). Copies each readable pixel intersecting both rectangles, without scaling, converting to bitmap.colorType() and bitmap.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility class like SkDebugCanvas.
Caller must allocate pixel storage in bitmap if needed.
Bitmap values are converted only if Color_Type and Alpha_Type do not match. Only pixels within both source and destination rectangles are copied. Bitmap pixels outside Rect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down bitmap.
Does not copy, and returns false if:
true if pixels were copied
pixel = 802b5580
peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels
Copies Rect from pixels to Canvas. Matrix and Clip are ignored. Source Rect corners are (0, 0) and (info.width(), info.height()). Destination Rect corners are (x, y) and (imageInfo().width(), imageInfo().height()).
Copies each readable pixel intersecting both rectangles, without scaling, converting to imageInfo().colorType() and imageInfo().alphaType() if required.
Pixels are writable when Device is raster, or backed by a GPU. Pixels are not writable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility class like SkDebugCanvas.
Pixel values are converted only if Color_Type and Alpha_Type do not match. Only pixels within both source and destination rectangles are copied. Canvas pixels outside Rect intersection are unchanged.
Pass negative values for x or y to offset pixels to the left or above Canvas pixels.
Does not copy, and returns false if:
true if pixels were written to Canvas
readPixels drawBitmap drawImage SkBitmap::writePixels
Copies Rect from pixels to Canvas. Matrix and Clip are ignored. Source Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Destination Rect corners are (x, y) and (imageInfo().width(), imageInfo().height()).
Copies each readable pixel intersecting both rectangles, without scaling, converting to imageInfo().colorType() and imageInfo().alphaType() if required.
Pixels are writable when Device is raster, or backed by a GPU. Pixels are not writable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility class like SkDebugCanvas.
Pixel values are converted only if Color_Type and Alpha_Type do not match. Only pixels within both source and destination rectangles are copied. Canvas pixels outside Rect intersection are unchanged.
Pass negative values for x or y to offset pixels to the left or above Canvas pixels.
Does not copy, and returns false if:
true if pixels were written to Canvas
readPixels drawBitmap drawImage SkBitmap::writePixels
Canvas 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 Canvas Surface or Device.
Canvas savable state consists of Clip and Matrix. Clip describes the area that may be drawn to. Matrix transforms the geometry.
save(), saveLayer, saveLayerPreserveLCDTextRequests, and saveLayerAlpha save state and return the depth of the stack.
restore(), restoreToCount, and ~SkCanvas() revert state to its value when saved.
Each state on the stack intersects Clip with the previous Clip, and concatenates Matrix with the previous Matrix. The intersected Clip makes the drawing area the same or smaller; the concatenated Matrix may move the origin and potentially scale or rotate the coordinate space.
Canvas does not require balancing the state stack but it is a good idea to do so. Calling save() without restore() will eventually cause Skia to fail; mismatched save() and restore() create hard to find bugs.
It is not possible to use state to draw outside of the clip defined by the previous state.
Each Clip uses the current Matrix for its coordinates.
save saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restore() restoreToCount
Saves SkMatrix and clip. Calling restore() discards changes to SkMatrix and clip, restoring the SkMatrix and clip to their state when save() was called.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
Saved SkCanvas state is put on a stack; multiple calls to save() should be balance by an equal number of calls to restore().
Call restoreToCount() with result to restore this and subsequent saves.
depth of saved stack
saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restore restoreToCount
Removes changes to SkMatrix and clip since SkCanvas state was last saved. The state is removed from the stack.
Does nothing if the stack is empty.
save saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restoreToCount
Returns the number of saved states, each containing: SkMatrix and clip. Equals the number of save() calls less the number of restore() calls plus one. The save count of a new canvas is one.
depth of save state stack
depth = 1 depth = 2 depth = 1
save restore restoreToCount
Restores state to SkMatrix and clip values when save(), saveLayer(), saveLayerPreserveLCDTextRequests(), or saveLayerAlpha() returned saveCount.
Does nothing if saveCount is greater than state stack count. Restores state to initial values if saveCount is less than or equal to one.
depth = 1 depth = 3 depth = 1
restore getSaveCount save
Layer allocates a temporary Bitmap to draw into. When the drawing is complete, the Bitmap is drawn into the Canvas.
Layer is saved in a stack along with other saved state. When state with a Layer is restored, the Bitmap is drawn into the previous Layer.
Layer may be initialized with the contents of the previous Layer. When Layer is restored, its Bitmap can be modified by Paint passed to Layer to apply Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode.
Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing. Calling restore() discards changes to SkMatrix and clip, and draws the SkBitmap.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
SkRect bounds suggests but does not define the SkBitmap size. To clip drawing to a specific rectangle, use clipRect().
Optional SkPaint paint applies alpha, SkColorFilter, SkImageFilter, and SkBlendMode when restore() is called.
Call restoreToCount() with returned value to restore this and subsequent saves.
depth of saved stack
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec
Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing. Calling restore() discards changes to SkMatrix and clip, and draws the SkBitmap.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
SkRect bounds suggests but does not define the layer size. To clip drawing to a specific rectangle, use clipRect().
Optional SkPaint paint applies alpha, SkColorFilter, SkImageFilter, and SkBlendMode when restore() is called.
Call restoreToCount() with returned value to restore this and subsequent saves.
depth of saved stack
save restore saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec
Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing. LCD text is preserved when the layer is drawn to the prior layer.
Calling restore() discards changes to SkMatrix and clip, and draws layer.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
SkRect bounds suggests but does not define the layer size. To clip drawing to a specific rectangle, use clipRect().
Optional SkPaint paint applies alpha, SkColorFilter, SkImageFilter, and SkBlendMode when restore() is called.
Call restoreToCount() with returned value to restore this and subsequent saves.
Draw text on an opaque background so that LCD text blends correctly with the prior layer. LCD text drawn on a background with transparency may result in incorrect blending.
depth of saved stack
save restore saveLayer saveLayerAlpha SaveLayerRec
Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
Calling restore() discards changes to SkMatrix and clip, and blends layer with alpha opacity onto prior layer.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
SkRect bounds suggests but does not define layer size. To clip drawing to a specific rectangle, use clipRect().
alpha of zero is fully transparent, 255 is fully opaque.
Call restoreToCount() with returned value to restore this and subsequent saves.
depth of saved stack
save restore saveLayer saveLayerPreserveLCDTextRequests SaveLayerRec
SaveLayerFlags provides options that may be used in any combination in SaveLayerRec, defining how Layer allocated by saveLayer operates. It may be set to zero, kPreserveLCDText_SaveLayerFlag, kInitWithPrevious_SaveLayerFlag, or both flags.
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec
SaveLayerRec contains the state used to create the Layer.
Sets fBounds, fPaint, and fBackdrop to nullptr. Clears fSaveLayerFlags.
empty SaveLayerRec
rec1 == rec2
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha
Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.
SaveLayerRec with empty fBackdrop
rec1 == rec2
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha
Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.
may be nullptr
SaveLayerRec fully specified
rec1 == rec2
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha
Experimental. Not ready for general use.
Sets fBounds, fPaint, fBackdrop, fClipMask, fClipMatrix, and fSaveLayerFlags. clipMatrix uses Color_Alpha channel of image, transformed by clipMatrix, to clip Layer when drawn to Canvas.
Implementation is not complete; has no effect if Device is GPU-backed.
SaveLayerRec fully specified
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha
Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
Calling restore() discards changes to SkMatrix and clip, and blends SkBitmap with alpha opacity onto the prior layer.
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
SaveLayerRec contains the state used to create the layer.
Call restoreToCount() with returned value to restore this and subsequent saves.
depth of save state stack
save restore saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha
Translates SkMatrix by dx along the x-axis and dy along the y-axis.
Mathematically, replaces SkMatrix with a translation matrix premultiplied with SkMatrix.
This has the effect of moving the drawing by (dx, dy) before transforming the result with SkMatrix.
The blue stroke follows translate of (50, 50); a black fill follows scale of (2, 1/2.f). After restoring the clip, which resets Matrix, a red frame follows the same scale of (2, 1/2.f); a gray fill follows translate of (50, 50).
concat() scale() skew() rotate() setMatrix
Scales SkMatrix by sx on the x-axis and sy on the y-axis.
Mathematically, replaces SkMatrix with a scale matrix premultiplied with SkMatrix.
This has the effect of scaling the drawing by (sx, sy) before transforming the result with SkMatrix.
concat() translate() skew() rotate() setMatrix
Rotates SkMatrix by degrees. Positive degrees rotates clockwise.
Mathematically, replaces SkMatrix with a rotation matrix premultiplied with SkMatrix.
This has the effect of rotating the drawing by degrees before transforming the result with SkMatrix.
concat() translate() skew() scale() setMatrix
Rotates SkMatrix by degrees about a point at (px, py). Positive degrees rotates clockwise.
Mathematically, constructs a rotation matrix; premultiplies the rotation matrix by a translation matrix; then replaces SkMatrix with the resulting matrix premultiplied with SkMatrix.
This has the effect of rotating the drawing about a given point before transforming the result with SkMatrix.
concat() translate() skew() scale() setMatrix
Skews SkMatrix by sx on the x-axis and sy on the y-axis. A positive value of sx skews the drawing right as y-axis values increase; a positive value of sy skews the drawing down as x-axis values increase.
Mathematically, replaces SkMatrix with a skew matrix premultiplied with SkMatrix.
This has the effect of skewing the drawing by (sx, sy) before transforming the result with SkMatrix.
concat() translate() rotate() scale() setMatrix
Replaces SkMatrix with matrix premultiplied with existing SkMatrix.
This has the effect of transforming the drawn geometry by matrix, before transforming the result with existing SkMatrix.
translate() rotate() scale() skew() setMatrix
Replaces SkMatrix with matrix. Unlike concat(), any prior matrix state is overwritten.
resetMatrix concat() translate() rotate() scale() skew()
Sets SkMatrix to the identity matrix. Any prior matrix state is overwritten.
setMatrix concat() translate() rotate() scale() skew()
Returns SkMatrix. This does not account for translation by SkBaseDevice or SkSurface.
SkMatrix in SkCanvas
isIdentity true
setMatrix resetMatrix concat()
Clip is built from a stack of clipping paths. Each Path in the stack can be constructed from one or more Path_Contour elements. The Path_Contour may be composed of any number of Path_Verb segments. Each Path_Contour forms a closed area; Path_Fill_Type defines the area enclosed by Path_Contour.
Clip stack of Path elements successfully restrict the Path area. Each Path is transformed by Matrix, then intersected with or subtracted from the prior Clip to form the replacement Clip. Use SkClipOp::kDifference to subtract Path from Clip; use SkClipOp::kIntersect to intersect Path with Clip.
A clipping Path may be Anti_Aliased; if Path, after transformation, is composed of horizontal and vertical lines, clearing Anti_Alias allows whole pixels to either be inside or outside the clip. The fastest drawing has a Aliased, rectangular clip.
If clipping Path has Anti_Alias 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.
Clip can combine with Rect and Round_Rect primitives; like Path, these are transformed by Matrix before they are combined with Clip.
Clip can combine with Region. Region is assumed to be in Device coordinates and is unaffected by Matrix.
Replaces clip with the intersection or difference of clip and rect, with an aliased or anti-aliased clip edge. rect is transformed by SkMatrix before it is combined with clip.
clipRRect clipPath clipRegion
Replaces clip with the intersection or difference of clip and rect. Resulting clip is aliased; pixels are fully contained by the clip. rect is transformed by SkMatrix before it is combined with clip.
clipRRect clipPath clipRegion
Replaces clip with the intersection of clip and rect. Resulting clip is aliased; pixels are fully contained by the clip. rect is transformed by SkMatrix before it is combined with clip.
clipRRect clipPath clipRegion
Sets the maximum clip rectangle, which can be set by clipRect, clipRRect and clipPath and intersect the current clip with the specified rect. The maximum clip affects only future clipping operations; it is not retroactive. The clip restriction is not recorded in pictures.
Pass an empty rect to disable maximum clip.
Private: This private API is for use by Android framework only.
Replaces clip with the intersection or difference of clip and rrect, with an aliased or anti-aliased clip edge. rrect is transformed by SkMatrix before it is combined with clip.
clipRect clipPath clipRegion
Replaces clip with the intersection or difference of clip and rrect. Resulting clip is aliased; pixels are fully contained by the clip. rrect is transformed by SkMatrix before it is combined with clip.
clipRect clipPath clipRegion
Replaces clip with the intersection of clip and rrect, with an aliased or anti-aliased clip edge. rrect is transformed by SkMatrix before it is combined with clip.
clipRect clipPath clipRegion
Replaces clip with the intersection or difference of clip and path, with an aliased or anti-aliased clip edge. SkPath::FillType determines if path describes the area inside or outside its contours; and if path contour overlaps itself or another path contour, whether the overlaps form part of the area. path is transformed by SkMatrix before it is combined with clip.
Bottom figure uses SkPath::kWinding_FillType and SkClipOp::kIntersect; area inside clip is intersected with circle.
clipRect clipRRect clipRegion
Replaces clip with the intersection or difference of clip and path. Resulting clip is aliased; pixels are fully contained by the clip. SkPath::FillType determines if path describes the area inside or outside its contours; and if path contour overlaps itself or another path contour, whether the overlaps form part of the area. path is transformed by SkMatrix before it is combined with clip.
clipRect clipRRect clipRegion
Replaces clip with the intersection of clip and path. Resulting clip is aliased; pixels are fully contained by the clip. SkPath::FillType determines if path describes the area inside or outside its contours; and if path contour overlaps itself or another path contour, whether the overlaps form part of the area. path is transformed by SkMatrix before it is combined with clip.
clipRect clipRRect clipRegion
Experimental. For testing only.
Set to simplify clip stack using PathOps.
Replaces clip with the intersection or difference of clip and SkRegion deviceRgn. Resulting clip is aliased; pixels are fully contained by the clip. deviceRgn is unaffected by SkMatrix.
clipRect clipRRect clipPath
Returns true if SkRect rect, transformed by SkMatrix, can be quickly determined to be outside of clip. May return false even though rect is outside of clip.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
true if rect, transformed by SkMatrix, does not intersect clip
quickReject true quickReject false
getLocalClipBounds getTotalMatrix SkBitmap::drawsNothing
Returns true if path, transformed by SkMatrix, can be quickly determined to be outside of clip. May return false even though path is outside of clip.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
true if path, transformed by SkMatrix, does not intersect clip
quickReject true quickReject false
getLocalClipBounds getTotalMatrix SkBitmap::drawsNothing
Returns bounds of clip, transformed by inverse of SkMatrix. If clip is empty, return SkRect::MakeEmpty, where all SkRect sides equal zero.
SkRect returned is outset by one to account for partial pixel coverage if clip is anti-aliased.
bounds of clip in local coordinates
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
getDeviceClipBounds getBaseLayerSize quickReject
Returns bounds of clip, transformed by inverse of SkMatrix. If clip is empty, return false, and set bounds to SkRect::MakeEmpty, where all SkRect sides equal zero.
bounds is outset by one to account for partial pixel coverage if clip is anti-aliased.
true if clip bounds is not empty
local bounds empty = false local bounds empty = true
getDeviceClipBounds getBaseLayerSize quickReject
Returns SkIRect bounds of clip, unaffected by SkMatrix. If clip is empty, return SkRect::MakeEmpty, where all SkRect sides equal zero.
Unlike getLocalClipBounds(), returned SkIRect is not outset.
bounds of clip in SkBaseDevice coordinates
left:0 top:0 right:256 bottom:256 left:30 top:130 right:120 bottom:230 left:15 top:65 right:60 bottom:115
getLocalClipBounds getBaseLayerSize quickReject
Returns SkIRect bounds of clip, unaffected by SkMatrix. If clip is empty, return false, and set bounds to SkRect::MakeEmpty, where all SkRect sides equal zero.
Unlike getLocalClipBounds(), bounds is not outset.
true if clip bounds is not empty
device bounds empty = false device bounds empty = true
getLocalClipBounds getBaseLayerSize quickReject
Fills clip with color color. mode determines how ARGB is combined with destination.
clear SkBitmap::erase drawPaint
Fills clip with color color using SkBlendMode::kSrc. This has the effect of replacing all pixels contained by clip with color.
drawColor SkBitmap::erase drawPaint
Makes SkCanvas contents undefined. Subsequent calls that read SkCanvas pixels, such as drawing with SkBlendMode, return undefined results. discard() does not change clip or SkMatrix.
discard() may do nothing, depending on the implementation of SkSurface or SkBaseDevice that created SkCanvas.
discard() allows optimized performance on subsequent draws by removing cached data associated with SkSurface or SkBaseDevice. It is not necessary to call discard() once done with SkCanvas; any cached data is deleted when owning SkSurface or SkBaseDevice is deleted.
flush() SkSurface::prepareForExternalIO GrContext::abandonContext
Fills clip with SkPaint paint. SkPaint components SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkBlendMode affect drawing; SkPathEffect in paint is ignored.
clear drawColor SkBitmap::erase
Selects if an array of points are drawn as discrete points, as lines, or as an open polygon.
drawLine drawPoint drawPath
Draws pts using clip, SkMatrix and SkPaint paint. count is the number of points; if count is less than one, has no effect. mode may be one of: kPoints_PointMode, kLines_PointMode, or kPolygon_PointMode.
If mode is kPoints_PointMode, the shape of point drawn depends on paint SkPaint::Cap. If paint is set to SkPaint::kRound_Cap, each point draws a circle of diameter SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap, each point draws a square of width and height SkPaint stroke width.
If mode is kLines_PointMode, each pair of points draws a line segment. One line is drawn for every two points; each point is used once. If count is odd, the final point is ignored.
If mode is kPolygon_PointMode, each adjacent pair of points draws a line segment. count minus one lines are drawn; the first and last point are used once.
Each line segment respects paint SkPaint::Cap and SkPaint stroke width. SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
Always draws each element one at a time; is not affected by SkPaint::Join, and unlike drawPath(), does not create a mask from all points and lines before drawing.
The transparent color makes multiple line draws visible; the path is drawn all at once.
drawLine drawPoint drawPath
Draws point at (x, y) using clip, SkMatrix and SkPaint paint.
The shape of point drawn depends on paint SkPaint::Cap. If paint is set to SkPaint::kRound_Cap, draw a circle of diameter SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap, draw a square of width and height SkPaint stroke width. SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
drawPoints drawCircle drawRect drawLine drawPath
Draws point p using clip, SkMatrix and SkPaint paint.
The shape of point drawn depends on paint SkPaint::Cap. If paint is set to SkPaint::kRound_Cap, draw a circle of diameter SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap, draw a square of width and height SkPaint stroke width. SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
drawPoints drawCircle drawRect drawLine drawPath
Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint. In paint: SkPaint stroke width describes the line thickness; SkPaint::Cap draws the end rounded or square; SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
drawPoint drawCircle drawRect drawPath
Draws line segment from p0 to p1 using clip, SkMatrix, and SkPaint paint. In paint: SkPaint stroke width describes the line thickness; SkPaint::Cap draws the end rounded or square; SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
drawPoint drawCircle drawRect drawPath
Draws SkRect rect using clip, SkMatrix, and SkPaint paint. In paint: SkPaint::Style determines if rectangle is stroked or filled; if stroked, SkPaint stroke width describes the line thickness, and SkPaint::Join draws the corners rounded or square.
drawIRect drawRRect drawRoundRect drawRegion drawPath drawLine
Draws SkIRect rect using clip, SkMatrix, and SkPaint paint. In paint: SkPaint::Style determines if rectangle is stroked or filled; if stroked, SkPaint stroke width describes the line thickness, and SkPaint::Join draws the corners rounded or square.
drawRect drawRRect drawRoundRect drawRegion drawPath drawLine
Draws SkRegion region using clip, SkMatrix, and SkPaint paint. In paint: SkPaint::Style determines if rectangle is stroked or filled; if stroked, SkPaint stroke width describes the line thickness, and SkPaint::Join draws the corners rounded or square.
drawRect drawIRect drawPath
Draws oval oval using clip, SkMatrix, and SkPaint. In paint: SkPaint::Style determines if oval is stroked or filled; if stroked, SkPaint stroke width describes the line thickness.
drawCircle drawPoint drawPath drawRRect drawRoundRect
Draws SkRRect rrect using clip, SkMatrix, and SkPaint paint. In paint: SkPaint::Style determines if rrect is stroked or filled; if stroked, SkPaint stroke width describes the line thickness.
rrect may represent a rectangle, circle, oval, uniformly rounded rectangle, or may have any combination of positive non-square radii for the four corners.
drawRect drawRoundRect drawDRRect drawCircle drawOval drawPath
Draws SkRRect outer and inner using clip, SkMatrix, and SkPaint paint. outer must contain inner or the drawing is undefined. In paint: SkPaint::Style determines if SkRRect is stroked or filled; if stroked, SkPaint stroke width describes the line thickness. If stroked and SkRRect corner has zero length radii, SkPaint::Join can draw corners rounded or square.
GPU-backed platforms optimize drawing when both outer and inner are concave and outer contains inner. These platforms may not be able to draw SkPath built with identical data as fast.
drawRect drawRoundRect drawRRect drawCircle drawOval drawPath
Draws circle at (cx, cy) with radius using clip, SkMatrix, and SkPaint paint. If radius is zero or less, nothing is drawn. In paint: SkPaint::Style determines if circle is stroked or filled; if stroked, SkPaint stroke width describes the line thickness.
drawOval drawRRect drawRoundRect drawPath drawArc drawPoint drawLine
Draws circle at center with radius using clip, SkMatrix, and SkPaint paint. If radius is zero or less, nothing is drawn. In paint: SkPaint::Style determines if circle is stroked or filled; if stroked, SkPaint stroke width describes the line thickness.
drawOval drawRRect drawRoundRect drawPath drawArc drawPoint drawLine
Draws arc using clip, SkMatrix, and SkPaint paint.
Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus sweepAngle. startAngle and sweepAngle are in degrees.
startAngle of zero places start point at the right middle edge of oval. A positive sweepAngle places arc end point clockwise from start point; a negative sweepAngle places arc end point counterclockwise from start point. sweepAngle may exceed 360 degrees, a full circle. If useCenter is true, draw a wedge that includes lines from oval center to arc end points. If useCenter is false, draw arc between end points.
If SkRect oval is empty or sweepAngle is zero, nothing is drawn.
SkPath::arcTo drawCircle drawOval drawPath
Draws SkRRect bounded by SkRect rect, with corner radii (rx, ry) using clip, SkMatrix, and SkPaint paint.
In paint: SkPaint::Style determines if SkRRect is stroked or filled; if stroked, SkPaint stroke width describes the line thickness. If rx or ry are less than zero, they are treated as if they are zero. If rx plus ry exceeds rect width or rect height, radii are scaled down to fit. If rx and ry are zero, SkRRect is drawn as SkRect and if stroked is affected by SkPaint::Join.
drawRRect drawRect drawDRRect drawPath drawCircle drawOval drawPoint
Draws SkPath path using clip, SkMatrix, and SkPaint paint. SkPath contains an array of path contour, each of which may be open or closed.
In paint: SkPaint::Style determines if SkRRect is stroked or filled: if filled, SkPath::FillType determines whether path contour describes inside or outside of fill; if stroked, SkPaint stroke width describes the line thickness, SkPaint::Cap describes line ends, and SkPaint::Join describes how corners are drawn.
SkPath drawLine drawArc drawRect drawPoints
drawImage, drawImageRect, and drawImageNine can be called with a bare pointer or a smart pointer as a convenience. The pairs of calls are otherwise identical.
Draws SkImage image, with its top-left corner at (left, top), using clip, SkMatrix, and optional SkPaint paint.
If paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
and so on; or nullptr
drawBitmap drawImageLattice drawImageNine drawImageRect SkPaint::setImageFilter
Draws SkImage image, with its top-left corner at (left, top), using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
and so on; or nullptr
drawBitmap drawImageLattice drawImageNine drawImageRect SkPaint::setImageFilter
SrcRectConstraint controls the behavior at the edge of source Rect, provided to drawImageRect, trading off speed for precision.
Image_Filter in Paint may sample multiple pixels in the image. Source Rect restricts the bounds of pixels that may be read. Image_Filter may slow down if it cannot read outside the bounds, when sampling near the edge of source Rect. SrcRectConstraint specifies whether an Image_Filter is allowed to read pixels outside source Rect.
drawImageRect drawImage SkPaint::setImageFilter
Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within src; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst. Note that isrc is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst. isrc is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within image; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within image; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
SrcRectConstraint drawImage drawImageLattice drawImageNine
Draws Image image stretched proportionally to fit into Rect dst. IRect center divides the image into nine sections: four sides, four corners, and the center. Corners are unmodified or scaled down proportionately if their sides are larger than dst; center and four sides are scaled to fit remaining space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint. If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader. If paint contains Mask_Filter, generate mask from image bounds. If paint Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. Any SkMaskFilter on paint is ignored as is paint Anti_Aliasing state. If generated mask extends beyond image bounds, replicate image edge colors, just as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
drawImage drawBitmapNine drawImageLattice drawImageRect
Draws Image image stretched proportionally to fit into Rect dst. IRect center divides the image into nine sections: four sides, four corners, and the center. Corners are not scaled, or scaled down proportionately if their sides are larger than dst; center and four sides are scaled to fit remaining space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint. If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader. If paint contains Mask_Filter, generate mask from image bounds. If paint Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. Any SkMaskFilter on paint is ignored as is paint Anti_Aliasing state. If generated mask extends beyond image bounds, replicate image edge colors, just as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
drawImage drawBitmapNine drawImageLattice drawImageRect
Draws SkBitmap bitmap, with its top-left corner at (left, top), using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as SkShader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
and so on; or nullptr
drawImage drawBitmapLattice drawBitmapNine drawBitmapRect SkBitmap::readPixels SkBitmap::writePixels
Draws SkRect src of SkBitmap bitmap, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as SkShader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within src; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
drawImageRect drawBitmap drawBitmapLattice drawBitmapNine
Draws SkIRect isrc of SkBitmap bitmap, scaled and translated to fill SkRect dst. isrc is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as SkShader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
drawImageRect drawBitmap drawBitmapLattice drawBitmapNine
Draws SkBitmap bitmap, scaled and translated to fill SkRect dst. bitmap bounds is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as SkShader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to sample within bitmap; set to kFast_SrcRectConstraint allows sampling outside to improve performance.
and so on; or nullptr
drawImageRect drawBitmap drawBitmapLattice drawBitmapNine
Draws Bitmap bitmap stretched proportionally to fit into Rect dst. IRect center divides the bitmap into nine sections: four sides, four corners, and the center. Corners are not scaled, or scaled down proportionately if their sides are larger than dst; center and four sides are scaled to fit remaining space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint. If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader. If paint contains Mask_Filter, generate mask from bitmap bounds. If paint Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. Any SkMaskFilter on paint is ignored as is paint Anti_Aliasing state. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as Shader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
drawImageNine drawBitmap drawBitmapLattice drawBitmapRect
Lattice divides Bitmap or Image 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.
Optional setting per rectangular grid entry to make it transparent, or to fill the grid entry with a color.
Each RectType is one of: kDefault, kTransparent, kFixedColor.
Array entries correspond to the rectangular grid entries, ascending left to right and then top to bottom.
Array entries correspond to the rectangular grid entries, ascending left to right, then top to bottom.
Draws Bitmap bitmap stretched proportionally to fit into Rect dst.
Lattice lattice divides bitmap into a rectangular grid. Each intersection of an even-numbered row and column is fixed; like the corners of drawBitmapNine, fixed lattice elements never scale larger than their initial size and shrink proportionately when all fixed elements exceed the bitmap dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint. If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader. If paint contains Mask_Filter, generate mask from bitmap bounds. If paint Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. Any SkMaskFilter on paint is ignored as is paint Anti_Aliasing state. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as Shader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
drawImageLattice drawBitmap drawBitmapNine Lattice
Draws Image image stretched proportionally to fit into Rect dst.
Lattice lattice divides image into a rectangular grid. Each intersection of an even-numbered row and column is fixed; like the corners of drawBitmapNine, fixed lattice elements never scale larger than their initial size and shrink proportionately when all fixed elements exceed the bitmap dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint. If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader. If paint contains Mask_Filter, generate mask from image bounds. If paint Filter_Quality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint Filter_Quality, use kLow_SkFilterQuality to filter pixels. Any SkMaskFilter on paint is ignored as is paint Anti_Aliasing state. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, just as Shader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
drawBitmapLattice drawImage drawImageNine Lattice
Private: Do not use.
Private: Do not use.
Private: Do not use.
Draws a set of images. Do not use this method.
Draws text, with origin at (x, y), using clip, SkMatrix, and SkPaint paint.
text meaning depends on SkPaint::TextEncoding; by default, text is encoded as UTF-8.
x and y meaning depends on SkPaint::Align and SkPaint vertical text; by default text draws left to right, positioning the first glyph left side bearing at x and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
drawString drawPosText drawPosTextH drawTextBlob drawTextRSXform
Draws null terminated string, with origin at (x, y), using clip, SkMatrix, and SkPaint paint.
string meaning depends on SkPaint::TextEncoding; by default, strings are encoded as UTF-8. Other values of SkPaint::TextEncoding are unlikely to produce the desired results, since zero bytes may be embedded in the string.
x and y meaning depends on SkPaint::Align and SkPaint vertical text; by default string draws left to right, positioning the first glyph left side bearing at x and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
ending with a char value of zero
drawText drawPosText drawPosTextH drawTextBlob drawTextRSXform
Draws null terminated string, with origin at (x, y), using clip, SkMatrix, and SkPaint paint.
string meaning depends on SkPaint::TextEncoding; by default, strings are encoded as UTF-8. Other values of SkPaint::TextEncoding are unlikely to produce the desired results, since zero bytes may be embedded in the string.
x and y meaning depends on SkPaint::Align and SkPaint vertical text; by default string draws left to right, positioning the first glyph left side bearing at x and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
ending with a char value of zero
drawText drawPosText drawPosTextH drawTextBlob drawTextRSXform
Draws each glyph in text with the origin in pos array, using clip, SkMatrix, and SkPaint paint. The number of entries in pos array must match the number of glyphs described by byteLength of text.
text meaning depends on SkPaint::TextEncoding; by default, text is encoded as UTF-8. pos elements meaning depends on SkPaint vertical text; by default glyph left side bearing and baseline are relative to SkPoint in pos array. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
Layout engines such as Harfbuzz typically position each glyph rather than using the font advance widths.
drawText drawPosTextH drawTextBlob drawTextRSXform
Draws each glyph in text with its origin composed from xpos array and constY, using clip, SkMatrix, and SkPaint paint. The number of entries in xpos array must match the number of glyphs described by byteLength of text.
text meaning depends on SkPaint::TextEncoding; by default, text is encoded as UTF-8. xpos elements meaning depends on SkPaint vertical text; by default each glyph left side bearing is positioned at an xpos element and its baseline is positioned at constY. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
Layout engines such as Harfbuzz typically position each glyph rather than using the font advance widths if all glyphs share the same baseline.
drawText drawPosText drawTextBlob drawTextRSXform
Draws text, transforming each glyph by the corresponding SkRSXform, using clip, SkMatrix, and SkPaint paint.
SkRSXform xform array specifies a separate square scale, rotation, and translation for each glyph. xform does not affect paint SkShader.
Optional SkRect cullRect is a conservative bounds of text, taking into account SkRSXform and paint. If cullRect is outside of clip, canvas can skip drawing.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws filled 12 point black glyphs.
drawText drawPosText drawTextBlob
Draws Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint.
blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, and Subpixel_Text .
Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: Anti_Alias, Blend_Mode, Color including Color_Alpha, Color_Filter, Paint_Dither, Draw_Looper, Mask_Filter, Path_Effect, Shader, and Paint_Style; apply to blob. If Paint contains SkPaint::kStroke_Style: Paint_Miter_Limit, Paint_Stroke_Cap, Paint_Stroke_Join, and Paint_Stroke_Width; apply to Path created from blob.
drawText drawPosText drawPosTextH
Draws Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint.
blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, and Subpixel_Text .
Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob.
drawText drawPosText drawPosTextH
Draws SkPicture picture, using clip and SkMatrix. Clip and SkMatrix are unchanged by picture contents, as if save() was called before and restore() was called after drawPicture().
SkPicture records a series of draw commands for later playback.
drawDrawable SkPicture SkPicture::playback
Draws SkPicture picture, using clip and SkMatrix. Clip and SkMatrix are unchanged by picture contents, as if save() was called before and restore() was called after drawPicture().
SkPicture records a series of draw commands for later playback.
drawDrawable SkPicture SkPicture::playback
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter, SkImageFilter, and SkBlendMode, if provided.
matrix transformation is equivalent to: save(), concat(), drawPicture(), restore(). paint use is equivalent to: saveLayer(), drawPicture(), restore().
drawDrawable SkPicture SkPicture::playback
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter, SkImageFilter, and SkBlendMode, if provided.
matrix transformation is equivalent to: save(), concat(), drawPicture(), restore(). paint use is equivalent to: saveLayer(), drawPicture(), restore().
drawDrawable SkPicture SkPicture::playback
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. If vertices texs and vertices colors are defined in vertices, and SkPaint paint contains SkShader, SkBlendMode mode combines vertices colors with SkShader.
drawPatch drawPicture
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. If vertices texs and vertices colors are defined in vertices, and SkPaint paint contains SkShader, SkBlendMode mode combines vertices colors with SkShader.
drawPatch drawPicture
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. Bone data is used to deform vertices with bone weights. If vertices texs and vertices colors are defined in vertices, and SkPaint paint contains SkShader, SkBlendMode mode combines vertices colors with SkShader. The first element of bones should be an object to world space transformation matrix that will be applied before performing mesh deformations. If no such transformation is needed, it should be the identity matrix. boneCount must be at most 80, and thus the size of bones should be at most 80.
drawPatch drawPicture
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. Bone data is used to deform vertices with bone weights. If vertices texs and vertices colors are defined in vertices, and SkPaint paint contains SkShader, SkBlendMode mode combines vertices colors with SkShader. The first element of bones should be an object to world space transformation matrix that will be applied before performing mesh deformations. If no such transformation is needed, it should be the identity matrix. boneCount must be at most 80, and thus the size of bones should be at most 80.
drawPatch drawPicture
Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter, alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated as Coons patch texture; SkBlendMode mode combines color colors and SkShader if both are provided.
SkPoint array cubics specifies four SkPath cubic starting at the top-left corner, in clockwise order, sharing every fourth point. The last SkPath cubic ends at the first point.
Color array color associates colors with corners in top-left, top-right, bottom-right, bottom-left order.
If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to corners in top-left, top-right, bottom-right, bottom-left order.
may be nullptr
drawVertices drawPicture
Draws SkPath cubic Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter, alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated as Coons patch texture; SkBlendMode mode combines color colors and SkShader if both are provided.
SkPoint array cubics specifies four SkPath cubic starting at the top-left corner, in clockwise order, sharing every fourth point. The last SkPath cubic ends at the first point.
Color array color associates colors with corners in top-left, top-right, bottom-right, bottom-left order.
If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to corners in top-left, top-right, bottom-right, bottom-left order.
may be nullptr
drawVertices drawPicture
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint. paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode to draw, if present. For each entry in the array, SkRect tex locates sprite in atlas, and SkRSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries. Optional colors are applied for each sprite using SkBlendMode mode, treating sprite as source and colors as destination. Optional cullRect is a conservative bounds of all transformed sprites. If cullRect is outside of clip, canvas can skip drawing.
drawBitmap drawImage
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint. paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode to draw, if present. For each entry in the array, SkRect tex locates sprite in atlas, and SkRSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries. Optional colors is applied for each sprite using SkBlendMode. Optional cullRect is a conservative bounds of all transformed sprites. If cullRect is outside of clip, canvas can skip drawing.
drawBitmap drawImage
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint. paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode to draw, if present. For each entry in the array, SkRect tex locates sprite in atlas, and SkRSXform xform transforms it into destination space.
xform and text must contain count entries. Optional cullRect is a conservative bounds of all transformed sprites. If cullRect is outside of clip, canvas can skip drawing.
drawBitmap drawImage
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint. paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode to draw, if present. For each entry in the array, SkRect tex locates sprite in atlas, and SkRSXform xform transforms it into destination space.
xform and text must contain count entries. Optional cullRect is a conservative bounds of all transformed sprites. If cullRect is outside of clip, canvas can skip drawing.
drawBitmap drawImage
Draws SkDrawable drawable using clip and SkMatrix, concatenated with optional matrix.
If SkCanvas has an asynchronous implementation, as is the case when it is recording into SkPicture, then drawable will be referenced, so that SkDrawable::draw() can be called when the operation is finalized. To force immediate drawing, call SkDrawable::draw() instead.
SkDrawable drawPicture
Draws SkDrawable drawable using clip and SkMatrix, offset by (x, y).
If SkCanvas has an asynchronous implementation, as is the case when it is recording into SkPicture, then drawable will be referenced, so that SkDrawable::draw() can be called when the operation is finalized. To force immediate drawing, call SkDrawable::draw() instead.
SkDrawable drawPicture
Associates SkRect on SkCanvas with an annotation; a key-value pair, where the key is a null-terminated UTF-8 string, and optional value is stored as SkData.
Only some canvas implementations, such as recording to SkPicture, or drawing to document PDF, use annotations.
SkPicture SkDocument
Associates SkRect on SkCanvas when an annotation; a key-value pair, where the key is a null-terminated UTF-8 string, and optional value is stored as SkData.
Only some canvas implementations, such as recording to SkPicture, or drawing to document PDF, use annotations.
SkPicture SkDocument
Returns true if clip 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 clip changes.
true if clip is empty
clip is not empty clip is empty
isClipRect getLocalClipBounds getDeviceClipBounds
Returns true if clip is SkRect and not empty. Returns false if the clip is empty, or if it is not SkRect.
true if clip is SkRect and not empty
clip is rect clip is not rect
isClipEmpty getLocalClipBounds getDeviceClipBounds