Flutter Engine
The Flutter Engine
|
#include <SkCanvas.h>
Classes | |
class | AutoUpdateQRBounds |
struct | ImageSetEntry |
struct | Lattice |
struct | SaveLayerRec |
Public Types | |
enum | SaveLayerFlagsSet { kPreserveLCDText_SaveLayerFlag = 1 << 1 , kInitWithPrevious_SaveLayerFlag = 1 << 2 , kF16ColorType = 1 << 4 } |
enum | PointMode { kPoints_PointMode , kLines_PointMode , kPolygon_PointMode } |
enum | SrcRectConstraint { kStrict_SrcRectConstraint , kFast_SrcRectConstraint } |
enum | QuadAAFlags : unsigned { kLeft_QuadAAFlag = 0b0001 , kTop_QuadAAFlag = 0b0010 , kRight_QuadAAFlag = 0b0100 , kBottom_QuadAAFlag = 0b1000 , kNone_QuadAAFlags = 0b0000 , kAll_QuadAAFlags = 0b1111 } |
using | SaveLayerFlags = uint32_t |
using | FilterSpan = SkSpan< sk_sp< SkImageFilter > > |
Public Member Functions | |
SkCanvas () | |
SkCanvas (int width, int height, const SkSurfaceProps *props=nullptr) | |
SkCanvas (sk_sp< SkDevice > device) | |
SkCanvas (const SkBitmap &bitmap) | |
SkCanvas (const SkBitmap &bitmap, const SkSurfaceProps &props) | |
virtual | ~SkCanvas () |
SkImageInfo | imageInfo () const |
bool | getProps (SkSurfaceProps *props) const |
SkSurfaceProps | getBaseProps () const |
SkSurfaceProps | getTopProps () const |
virtual SkISize | getBaseLayerSize () const |
sk_sp< SkSurface > | makeSurface (const SkImageInfo &info, const SkSurfaceProps *props=nullptr) |
virtual GrRecordingContext * | recordingContext () const |
virtual skgpu::graphite::Recorder * | recorder () const |
SkSurface * | getSurface () const |
void * | accessTopLayerPixels (SkImageInfo *info, size_t *rowBytes, SkIPoint *origin=nullptr) |
SkRasterHandleAllocator::Handle | accessTopRasterHandle () const |
bool | peekPixels (SkPixmap *pixmap) |
bool | readPixels (const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) |
bool | readPixels (const SkPixmap &pixmap, int srcX, int srcY) |
bool | readPixels (const SkBitmap &bitmap, int srcX, int srcY) |
bool | writePixels (const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y) |
bool | writePixels (const SkBitmap &bitmap, int x, int y) |
int | save () |
int | saveLayer (const SkRect *bounds, const SkPaint *paint) |
int | saveLayer (const SkRect &bounds, const SkPaint *paint) |
int | saveLayerAlphaf (const SkRect *bounds, float alpha) |
int | saveLayerAlpha (const SkRect *bounds, U8CPU alpha) |
int | saveLayer (const SaveLayerRec &layerRec) |
void | restore () |
int | getSaveCount () const |
void | restoreToCount (int saveCount) |
void | translate (SkScalar dx, SkScalar dy) |
void | scale (SkScalar sx, SkScalar sy) |
void | rotate (SkScalar degrees) |
void | rotate (SkScalar degrees, SkScalar px, SkScalar py) |
void | skew (SkScalar sx, SkScalar sy) |
void | concat (const SkMatrix &matrix) |
void | concat (const SkM44 &) |
void | setMatrix (const SkM44 &matrix) |
void | setMatrix (const SkMatrix &matrix) |
void | resetMatrix () |
void | clipRect (const SkRect &rect, SkClipOp op, bool doAntiAlias) |
void | clipRect (const SkRect &rect, SkClipOp op) |
void | clipRect (const SkRect &rect, bool doAntiAlias=false) |
void | clipIRect (const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect) |
void | androidFramework_setDeviceClipRestriction (const SkIRect &rect) |
void | clipRRect (const SkRRect &rrect, SkClipOp op, bool doAntiAlias) |
void | clipRRect (const SkRRect &rrect, SkClipOp op) |
void | clipRRect (const SkRRect &rrect, bool doAntiAlias=false) |
void | clipPath (const SkPath &path, SkClipOp op, bool doAntiAlias) |
void | clipPath (const SkPath &path, SkClipOp op) |
void | clipPath (const SkPath &path, bool doAntiAlias=false) |
void | clipShader (sk_sp< SkShader >, SkClipOp=SkClipOp::kIntersect) |
void | clipRegion (const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect) |
bool | quickReject (const SkRect &rect) const |
bool | quickReject (const SkPath &path) const |
SkRect | getLocalClipBounds () const |
bool | getLocalClipBounds (SkRect *bounds) const |
SkIRect | getDeviceClipBounds () const |
bool | getDeviceClipBounds (SkIRect *bounds) const |
void | drawColor (SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver) |
void | drawColor (const SkColor4f &color, SkBlendMode mode=SkBlendMode::kSrcOver) |
void | clear (SkColor color) |
void | clear (const SkColor4f &color) |
void | discard () |
void | drawPaint (const SkPaint &paint) |
void | drawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) |
void | drawPoint (SkScalar x, SkScalar y, const SkPaint &paint) |
void | drawPoint (SkPoint p, const SkPaint &paint) |
void | drawLine (SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint) |
void | drawLine (SkPoint p0, SkPoint p1, const SkPaint &paint) |
void | drawRect (const SkRect &rect, const SkPaint &paint) |
void | drawIRect (const SkIRect &rect, const SkPaint &paint) |
void | drawRegion (const SkRegion ®ion, const SkPaint &paint) |
void | drawOval (const SkRect &oval, const SkPaint &paint) |
void | drawRRect (const SkRRect &rrect, const SkPaint &paint) |
void | drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &paint) |
void | drawCircle (SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint) |
void | drawCircle (SkPoint center, SkScalar radius, const SkPaint &paint) |
void | drawArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) |
void | drawArc (const SkArc &arc, const SkPaint &paint) |
void | drawRoundRect (const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint) |
void | drawPath (const SkPath &path, const SkPaint &paint) |
void | drawImage (const SkImage *image, SkScalar left, SkScalar top) |
void | drawImage (const sk_sp< SkImage > &image, SkScalar left, SkScalar top) |
void | drawImage (const SkImage *, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *=nullptr) |
void | drawImage (const sk_sp< SkImage > &image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr) |
void | drawImageRect (const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) |
void | drawImageRect (const SkImage *, const SkRect &dst, const SkSamplingOptions &, const SkPaint *=nullptr) |
void | drawImageRect (const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SrcRectConstraint constraint) |
void | drawImageRect (const sk_sp< SkImage > &image, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr) |
void | drawImageNine (const SkImage *image, const SkIRect ¢er, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr) |
void | drawImageLattice (const SkImage *image, const Lattice &lattice, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr) |
void | drawImageLattice (const SkImage *image, const Lattice &lattice, const SkRect &dst) |
void | experimental_DrawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode) |
void | experimental_DrawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, SkColor color, SkBlendMode mode) |
void | experimental_DrawEdgeAAImageSet (const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint) |
void | drawSimpleText (const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint) |
void | drawString (const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint) |
void | drawString (const SkString &str, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint) |
void | drawGlyphs (int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint) |
void | drawGlyphs (int count, const SkGlyphID glyphs[], const SkPoint positions[], SkPoint origin, const SkFont &font, const SkPaint &paint) |
void | drawGlyphs (int count, const SkGlyphID glyphs[], const SkRSXform xforms[], SkPoint origin, const SkFont &font, const SkPaint &paint) |
void | drawTextBlob (const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) |
void | drawTextBlob (const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const SkPaint &paint) |
void | drawPicture (const SkPicture *picture) |
void | drawPicture (const sk_sp< SkPicture > &picture) |
void | drawPicture (const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint) |
void | drawPicture (const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint) |
void | drawVertices (const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint) |
void | drawVertices (const sk_sp< SkVertices > &vertices, SkBlendMode mode, const SkPaint &paint) |
void | drawMesh (const SkMesh &mesh, sk_sp< SkBlender > blender, const SkPaint &paint) |
void | drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint) |
void | drawAtlas (const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint) |
void | drawDrawable (SkDrawable *drawable, const SkMatrix *matrix=nullptr) |
void | drawDrawable (SkDrawable *drawable, SkScalar x, SkScalar y) |
void | drawAnnotation (const SkRect &rect, const char key[], SkData *value) |
void | drawAnnotation (const SkRect &rect, const char key[], const sk_sp< SkData > &value) |
virtual bool | isClipEmpty () const |
virtual bool | isClipRect () const |
SkM44 | getLocalToDevice () const |
SkMatrix | getLocalToDeviceAs3x3 () const |
SkMatrix | getTotalMatrix () const |
void | temporary_internal_getRgnClip (SkRegion *region) |
void | private_draw_shadow_rec (const SkPath &, const SkDrawShadowRec &) |
Static Public Member Functions | |
static std::unique_ptr< SkCanvas > | MakeRasterDirect (const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr) |
static std::unique_ptr< SkCanvas > | MakeRasterDirectN32 (int width, int height, SkPMColor *pixels, size_t rowBytes) |
Static Public Attributes | |
static constexpr int | kMaxFiltersPerLayer = 16 |
Protected Types | |
enum | SaveLayerStrategy { kFullLayer_SaveLayerStrategy , kNoLayer_SaveLayerStrategy } |
enum | ClipEdgeStyle { kHard_ClipEdgeStyle , kSoft_ClipEdgeStyle } |
Protected Member Functions | |
virtual sk_sp< SkSurface > | onNewSurface (const SkImageInfo &info, const SkSurfaceProps &props) |
virtual bool | onPeekPixels (SkPixmap *pixmap) |
virtual bool | onAccessTopLayerPixels (SkPixmap *pixmap) |
virtual SkImageInfo | onImageInfo () const |
virtual bool | onGetProps (SkSurfaceProps *props, bool top) const |
virtual void | willSave () |
virtual SaveLayerStrategy | getSaveLayerStrategy (const SaveLayerRec &) |
virtual bool | onDoSaveBehind (const SkRect *) |
virtual void | willRestore () |
virtual void | didRestore () |
virtual void | didConcat44 (const SkM44 &) |
virtual void | didSetM44 (const SkM44 &) |
virtual void | didTranslate (SkScalar, SkScalar) |
virtual void | didScale (SkScalar, SkScalar) |
virtual void | onDrawPaint (const SkPaint &paint) |
virtual void | onDrawBehind (const SkPaint &paint) |
virtual void | onDrawRect (const SkRect &rect, const SkPaint &paint) |
virtual void | onDrawRRect (const SkRRect &rrect, const SkPaint &paint) |
virtual void | onDrawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &paint) |
virtual void | onDrawOval (const SkRect &rect, const SkPaint &paint) |
virtual void | onDrawArc (const SkRect &rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) |
virtual void | onDrawPath (const SkPath &path, const SkPaint &paint) |
virtual void | onDrawRegion (const SkRegion ®ion, const SkPaint &paint) |
virtual void | onDrawTextBlob (const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) |
virtual void | onDrawGlyphRunList (const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) |
virtual void | onDrawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint) |
virtual void | onDrawPoints (PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) |
virtual void | onDrawImage2 (const SkImage *, SkScalar dx, SkScalar dy, const SkSamplingOptions &, const SkPaint *) |
virtual void | onDrawImageRect2 (const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) |
virtual void | onDrawImageLattice2 (const SkImage *, const Lattice &, const SkRect &dst, SkFilterMode, const SkPaint *) |
virtual void | onDrawAtlas2 (const SkImage *, const SkRSXform[], const SkRect src[], const SkColor[], int count, SkBlendMode, const SkSamplingOptions &, const SkRect *cull, const SkPaint *) |
virtual void | onDrawEdgeAAImageSet2 (const ImageSetEntry imageSet[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) |
virtual void | onDrawVerticesObject (const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint) |
virtual void | onDrawMesh (const SkMesh &, sk_sp< SkBlender >, const SkPaint &) |
virtual void | onDrawAnnotation (const SkRect &rect, const char key[], SkData *value) |
virtual void | onDrawShadowRec (const SkPath &, const SkDrawShadowRec &) |
virtual void | onDrawDrawable (SkDrawable *drawable, const SkMatrix *matrix) |
virtual void | onDrawPicture (const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint) |
virtual void | onDrawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode) |
virtual void | onClipRect (const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle) |
virtual void | onClipRRect (const SkRRect &rrect, SkClipOp op, ClipEdgeStyle edgeStyle) |
virtual void | onClipPath (const SkPath &path, SkClipOp op, ClipEdgeStyle edgeStyle) |
virtual void | onClipShader (sk_sp< SkShader >, SkClipOp) |
virtual void | onClipRegion (const SkRegion &deviceRgn, SkClipOp op) |
virtual void | onResetClip () |
virtual void | onDiscard () |
virtual sk_sp< sktext::gpu::Slug > | onConvertGlyphRunListToSlug (const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) |
virtual void | onDrawSlug (const sktext::gpu::Slug *slug, const SkPaint &paint) |
SkCanvas (const SkIRect &bounds) | |
Private Member Functions | |
virtual SkPaintFilterCanvas * | internal_private_asPaintFilterCanvas () const |
Friends | |
class | SkSurface_Base |
class | SkSurface_Ganesh |
class | SkAndroidFrameworkUtils |
class | SkCanvasPriv |
class | AutoLayerForImageFilter |
class | SkSurface_Raster |
class | SkNoDrawCanvas |
class | SkNWayCanvas |
class | SkPictureRecord |
class | SkOverdrawCanvas |
class | SkRasterHandleAllocator |
class | SkRecords::Draw |
template<typename Key > | |
class | SkTestCanvas |
class | sktext::gpu::Slug |
class | SkPicturePlayback |
class | SkCanvasStateUtils |
constexpr SkEnumBitMask< PredrawFlags > | operator| (PredrawFlags, PredrawFlags) |
constexpr SkEnumBitMask< PredrawFlags > | operator& (PredrawFlags, PredrawFlags) |
constexpr SkEnumBitMask< PredrawFlags > | operator^ (PredrawFlags, PredrawFlags) |
constexpr SkEnumBitMask< PredrawFlags > | operator~ (PredrawFlags) |
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed. SkCanvas contains a stack of SkMatrix and clip values.
SkCanvas and SkPaint together provide the state to draw into SkSurface or SkDevice. Each SkCanvas draw call transforms the geometry of the object by the concatenation of all SkMatrix values in the stack. The transformed geometry is clipped by the intersection of all of clip values in the stack. The SkCanvas draw calls use SkPaint to supply drawing state such as color, SkTypeface, text size, stroke width, SkShader and so on.
To draw to a pixel-based destination, create raster surface or GPU surface. Request SkCanvas from SkSurface to obtain the interface to draw. SkCanvas generated by raster surface draws to memory visible to the CPU. SkCanvas generated by GPU surface uses Vulkan or OpenGL to draw to the GPU.
To draw to a document, obtain SkCanvas from SVG canvas, document PDF, or SkPictureRecorder. SkDocument based SkCanvas and other SkCanvas subclasses reference SkDevice describing the destination.
SkCanvas can be constructed to draw to SkBitmap without first creating raster surface. This approach may be deprecated in the future.
Definition at line 106 of file SkCanvas.h.
using SkCanvas::FilterSpan = SkSpan<sk_sp<SkImageFilter> > |
Definition at line 678 of file SkCanvas.h.
using SkCanvas::SaveLayerFlags = uint32_t |
Definition at line 677 of file SkCanvas.h.
|
protected |
Enumerator | |
---|---|
kHard_ClipEdgeStyle | |
kSoft_ClipEdgeStyle |
Definition at line 2335 of file SkCanvas.h.
enum SkCanvas::PointMode |
Enumerator | |
---|---|
kPoints_PointMode | draw each point separately |
kLines_PointMode | draw each pair of points as a line segment |
kPolygon_PointMode | draw the array of points as a open polygon |
Definition at line 1240 of file SkCanvas.h.
enum SkCanvas::QuadAAFlags : unsigned |
Experimental. Controls anti-aliasing of each edge of images in an image-set.
Enumerator | |
---|---|
kLeft_QuadAAFlag | |
kTop_QuadAAFlag | |
kRight_QuadAAFlag | |
kBottom_QuadAAFlag | |
kNone_QuadAAFlags | |
kAll_QuadAAFlags |
Definition at line 1658 of file SkCanvas.h.
Enumerator | |
---|---|
kPreserveLCDText_SaveLayerFlag | |
kInitWithPrevious_SaveLayerFlag | initializes with previous contents |
kF16ColorType |
Definition at line 670 of file SkCanvas.h.
|
protected |
Enumerator | |
---|---|
kFullLayer_SaveLayerStrategy | |
kNoLayer_SaveLayerStrategy |
Definition at line 2263 of file SkCanvas.h.
Enumerator | |
---|---|
kStrict_SrcRectConstraint | sample only inside bounds; slower |
kFast_SrcRectConstraint | sample outside bounds; faster |
Definition at line 1541 of file SkCanvas.h.
SkCanvas::SkCanvas | ( | ) |
Creates an empty SkCanvas with no backing device or pixels, with a width and height of zero.
example: https://fiddle.skia.org/c/@Canvas_empty_constructor
Definition at line 324 of file SkCanvas.cpp.
SkCanvas::SkCanvas | ( | int | width, |
int | height, | ||
const SkSurfaceProps * | props = nullptr |
||
) |
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.
width | zero or greater |
height | zero or greater |
props | LCD striping orientation and setting for device independent fonts; may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_int_int_const_SkSurfaceProps_star
Definition at line 328 of file SkCanvas.cpp.
Private. For internal use only.
Definition at line 341 of file SkCanvas.cpp.
|
explicit |
Constructs a canvas that draws into bitmap. Sets kUnknown_SkPixelGeometry in constructed SkSurface.
SkBitmap is copied so that subsequently editing bitmap will not affect constructed SkCanvas.
May be deprecated in the future.
bitmap | width, height, SkColorType, SkAlphaType, and pixel storage of raster surface |
example: https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap
Definition at line 44 of file SkCanvas_Raster.cpp.
SkCanvas::SkCanvas | ( | const SkBitmap & | bitmap, |
const SkSurfaceProps & | props | ||
) |
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.
bitmap | width, height, SkColorType, SkAlphaType, and pixel storage of raster surface |
props | order and orientation of RGB striping; and whether to use device independent fonts |
example: https://fiddle.skia.org/c/@Canvas_const_SkBitmap_const_SkSurfaceProps
Definition at line 29 of file SkCanvas_Raster.cpp.
|
virtual |
Draws saved layers, if any. Frees up resources used by SkCanvas.
example: https://fiddle.skia.org/c/@Canvas_destructor
Definition at line 347 of file SkCanvas.cpp.
|
protected |
Definition at line 335 of file SkCanvas.cpp.
void * SkCanvas::accessTopLayerPixels | ( | SkImageInfo * | info, |
size_t * | rowBytes, | ||
SkIPoint * | origin = nullptr |
||
) |
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.
info | storage for writable pixels' SkImageInfo; may be nullptr |
rowBytes | storage for writable pixels' row bytes; may be nullptr |
origin | storage for SkCanvas top layer origin, its top-left corner; may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_accessTopLayerPixels_a example: https://fiddle.skia.org/c/@Canvas_accessTopLayerPixels_b
Definition at line 1245 of file SkCanvas.cpp.
SkRasterHandleAllocator::Handle SkCanvas::accessTopRasterHandle | ( | ) | const |
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.
example: https://fiddle.skia.org/c/@Canvas_accessTopRasterHandle
Definition at line 2841 of file SkCanvas.cpp.
void SkCanvas::androidFramework_setDeviceClipRestriction | ( | const SkIRect & | rect | ) |
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. This private API is for use by Android framework only.
DEPRECATED: Replace usage with SkAndroidFrameworkUtils::replaceClip()
rect | maximum allowed clip in device coordinates |
Definition at line 1378 of file SkCanvas.cpp.
|
inline |
Fills clip with color color using SkBlendMode::kSrc. This has the effect of replacing all pixels contained by clip with color.
color | SkColor4f representing unpremultiplied color. |
Definition at line 1208 of file SkCanvas.h.
|
inline |
Fills clip with color color using SkBlendMode::kSrc. This has the effect of replacing all pixels contained by clip with color.
color | unpremultiplied ARGB |
Definition at line 1199 of file SkCanvas.h.
|
inline |
Definition at line 991 of file SkCanvas.h.
|
inline |
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.
path | SkPath to combine with clip |
doAntiAlias | true if clip is to be anti-aliased |
Definition at line 1083 of file SkCanvas.h.
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.
path | SkPath to combine with clip |
op | SkClipOp to apply to clip |
Definition at line 1069 of file SkCanvas.h.
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.
path | SkPath to combine with clip |
op | SkClipOp to apply to clip |
doAntiAlias | true if clip is to be anti-aliased |
example: https://fiddle.skia.org/c/@Canvas_clipPath
Definition at line 1456 of file SkCanvas.cpp.
|
inline |
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.
rect | SkRect to combine with clip |
doAntiAlias | true if clip is to be anti-aliased |
Definition at line 987 of file SkCanvas.h.
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.
rect | SkRect to combine with clip |
op | SkClipOp to apply to clip |
Definition at line 975 of file SkCanvas.h.
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.
rect | SkRect to combine with clip |
op | SkClipOp to apply to clip |
doAntiAlias | true if clip is to be anti-aliased |
example: https://fiddle.skia.org/c/@Canvas_clipRect
Definition at line 1361 of file SkCanvas.cpp.
void SkCanvas::clipRegion | ( | const SkRegion & | deviceRgn, |
SkClipOp | op = SkClipOp::kIntersect |
||
) |
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.
deviceRgn | SkRegion to combine with clip |
op | SkClipOp to apply to clip |
example: https://fiddle.skia.org/c/@Canvas_clipRegion
Definition at line 1510 of file SkCanvas.cpp.
|
inline |
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.
rrect | SkRRect to combine with clip |
doAntiAlias | true if clip is to be anti-aliased |
Definition at line 1040 of file SkCanvas.h.
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.
rrect | SkRRect to combine with clip |
op | SkClipOp to apply to clip |
Definition at line 1029 of file SkCanvas.h.
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.
rrect | SkRRect to combine with clip |
op | SkClipOp to apply to clip |
doAntiAlias | true if clip is to be anti-aliased |
example: https://fiddle.skia.org/c/@Canvas_clipRRect
Definition at line 1439 of file SkCanvas.cpp.
void SkCanvas::clipShader | ( | sk_sp< SkShader > | sh, |
SkClipOp | op = SkClipOp::kIntersect |
||
) |
Definition at line 1488 of file SkCanvas.cpp.
void SkCanvas::concat | ( | const SkM44 & | m | ) |
Definition at line 1333 of file SkCanvas.cpp.
void SkCanvas::concat | ( | const SkMatrix & | matrix | ) |
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.
matrix | matrix to premultiply with existing SkMatrix |
example: https://fiddle.skia.org/c/@Canvas_concat
Definition at line 1318 of file SkCanvas.cpp.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, and DebugCanvas.
Definition at line 2279 of file SkCanvas.h.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, and DebugCanvas.
Definition at line 2282 of file SkCanvas.h.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, SkCanvasStack, and DebugCanvas.
Definition at line 2280 of file SkCanvas.h.
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, and DebugCanvas.
Definition at line 2281 of file SkCanvas.h.
|
inline |
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 SkDevice that created SkCanvas.
discard() allows optimized performance on subsequent draws by removing cached data associated with SkSurface or SkDevice. It is not necessary to call discard() once done with SkCanvas; any cached data is deleted when owning SkSurface or SkDevice is deleted.
Definition at line 1224 of file SkCanvas.h.
|
inline |
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.
rect | SkRect extent of canvas to annotate |
key | string used for lookup |
value | data holding value stored in annotation |
Definition at line 2187 of file SkCanvas.h.
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.
rect | SkRect extent of canvas to annotate |
key | string used for lookup |
value | data holding value stored in annotation |
example: https://fiddle.skia.org/c/@Canvas_drawAnnotation_2
Definition at line 1824 of file SkCanvas.cpp.
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.
arc | SkArc specifying oval, startAngle, sweepAngle, and arc-vs-wedge |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
Definition at line 1489 of file SkCanvas.h.
void SkCanvas::drawArc | ( | const SkRect & | oval, |
SkScalar | startAngle, | ||
SkScalar | sweepAngle, | ||
bool | useCenter, | ||
const SkPaint & | paint | ||
) |
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.
oval | SkRect bounds of oval containing arc to draw |
startAngle | angle in degrees where arc begins |
sweepAngle | sweep angle in degrees; positive is clockwise |
useCenter | if true, include the center of the oval |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
Definition at line 2728 of file SkCanvas.cpp.
void SkCanvas::drawAtlas | ( | const SkImage * | atlas, |
const SkRSXform | xform[], | ||
const SkRect | tex[], | ||
const SkColor | colors[], | ||
int | count, | ||
SkBlendMode | mode, | ||
const SkSamplingOptions & | sampling, | ||
const SkRect * | cullRect, | ||
const SkPaint * | paint | ||
) |
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.
SkMaskFilter and SkPathEffect on paint are ignored.
xform, tex, 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.
If atlas is nullptr, this draws nothing.
atlas | SkImage containing sprites |
xform | SkRSXform mappings for sprites in atlas |
tex | SkRect locations of sprites in atlas |
colors | one per sprite, blended with sprite using SkBlendMode; may be nullptr |
count | number of sprites to draw |
mode | SkBlendMode combining colors and sprites |
sampling | SkSamplingOptions used when sampling from the atlas image |
cullRect | bounds of transformed sprites for efficient clipping; may be nullptr |
paint | SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr |
Definition at line 1810 of file SkCanvas.cpp.
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.
center | circle center |
radius | half the diameter of circle |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
Definition at line 1445 of file SkCanvas.h.
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.
cx | circle center on the x-axis |
cy | circle center on the y-axis |
radius | half the diameter of circle |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawCircle
Definition at line 2707 of file SkCanvas.cpp.
void SkCanvas::drawColor | ( | const SkColor4f & | color, |
SkBlendMode | mode = SkBlendMode::kSrcOver |
||
) |
Fills clip with color color. mode determines how ARGB is combined with destination.
color | SkColor4f representing unpremultiplied color. |
mode | SkBlendMode used to combine source color and destination |
Definition at line 2688 of file SkCanvas.cpp.
|
inline |
Fills clip with color color. mode determines how ARGB is combined with destination.
color | unpremultiplied ARGB |
mode | SkBlendMode used to combine source color and destination |
example: https://fiddle.skia.org/c/@Canvas_drawColor
Definition at line 1182 of file SkCanvas.h.
void SkCanvas::drawDrawable | ( | SkDrawable * | drawable, |
const SkMatrix * | matrix = nullptr |
||
) |
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.
drawable | custom struct encapsulating drawing commands |
matrix | transformation applied to drawing; may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_drawDrawable
Definition at line 2574 of file SkCanvas.cpp.
void SkCanvas::drawDrawable | ( | SkDrawable * | drawable, |
SkScalar | x, | ||
SkScalar | y | ||
) |
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.
drawable | custom struct encapsulating drawing commands |
x | offset into SkCanvas writable pixels on x-axis |
y | offset into SkCanvas writable pixels on y-axis |
example: https://fiddle.skia.org/c/@Canvas_drawDrawable_2
Definition at line 2561 of file SkCanvas.cpp.
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.
outer | SkRRect outer bounds to draw |
inner | SkRRect inner bounds to draw |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawDRRect_a example: https://fiddle.skia.org/c/@Canvas_drawDRRect_b
Definition at line 1645 of file SkCanvas.cpp.
void SkCanvas::drawGlyphs | ( | int | count, |
const SkGlyphID | glyphs[], | ||
const SkPoint | positions[], | ||
const uint32_t | clusters[], | ||
int | textByteCount, | ||
const char | utf8text[], | ||
SkPoint | origin, | ||
const SkFont & | font, | ||
const SkPaint & | paint | ||
) |
Draws count glyphs, at positions relative to origin styled with font and paint with supporting utf8 and cluster information.
This function draw glyphs at the given positions relative to the given origin. It does not perform typeface fallback for glyphs not found in the SkTypeface in font.
The drawing obeys the current transform matrix and clipping.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
count | number of glyphs to draw |
glyphs | the array of glyphIDs to draw |
positions | where to draw each glyph relative to origin |
clusters | array of size count of cluster information |
textByteCount | size of the utf8text |
utf8text | utf8text supporting information for the glyphs |
origin | the origin of all the positions |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
void SkCanvas::drawGlyphs | ( | int | count, |
const SkGlyphID | glyphs[], | ||
const SkPoint | positions[], | ||
SkPoint | origin, | ||
const SkFont & | font, | ||
const SkPaint & | paint | ||
) |
Draws count glyphs, at positions relative to origin styled with font and paint.
This function draw glyphs at the given positions relative to the given origin. It does not perform typeface fallback for glyphs not found in the SkTypeface in font.
The drawing obeys the current transform matrix and clipping.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
count | number of glyphs to draw |
glyphs | the array of glyphIDs to draw |
positions | where to draw each glyph relative to origin |
origin | the origin of all the positions |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
Definition at line 2446 of file SkCanvas.cpp.
void SkCanvas::drawGlyphs | ( | int | count, |
const SkGlyphID | glyphs[], | ||
const SkRSXform | xforms[], | ||
SkPoint | origin, | ||
const SkFont & | font, | ||
const SkPaint & | paint | ||
) |
Draws count glyphs, at positions relative to origin styled with font and paint.
This function draw glyphs using the given scaling and rotations. They are positioned relative to the given origin. It does not perform typeface fallback for glyphs not found in the SkTypeface in font.
The drawing obeys the current transform matrix and clipping.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
count | number of glyphs to draw |
glyphs | the array of glyphIDs to draw |
xforms | where to draw and orient each glyph |
origin | the origin of all the positions |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
Definition at line 2464 of file SkCanvas.cpp.
Definition at line 1531 of file SkCanvas.h.
void SkCanvas::drawImage | ( | const SkImage * | image, |
SkScalar | x, | ||
SkScalar | y, | ||
const SkSamplingOptions & | sampling, | ||
const SkPaint * | paint = nullptr |
||
) |
Definition at line 2320 of file SkCanvas.cpp.
Definition at line 1528 of file SkCanvas.h.
|
inline |
Definition at line 1651 of file SkCanvas.h.
void SkCanvas::drawImageLattice | ( | const SkImage * | image, |
const Lattice & | lattice, | ||
const SkRect & | dst, | ||
SkFilterMode | filter, | ||
const SkPaint * | paint = nullptr |
||
) |
Draws SkImage image stretched proportionally to fit into SkRect dst.
SkCanvas::Lattice lattice divides image into a rectangular grid. Each intersection of an even-numbered row and column is fixed; 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, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. 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 SkShader made from SkShader::MakeBitmapShader with SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples outside of its bounds.
image | SkImage containing pixels, dimensions, and format |
lattice | division of bitmap into fixed and variable rectangles |
dst | destination SkRect of image to draw to |
filter | what technique to use when sampling the image |
paint | SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter, and so on; or nullptr |
Definition at line 1786 of file SkCanvas.cpp.
void SkCanvas::drawImageNine | ( | const SkImage * | image, |
const SkIRect & | center, | ||
const SkRect & | dst, | ||
SkFilterMode | filter, | ||
const SkPaint * | paint = nullptr |
||
) |
Draws SkImage image stretched proportionally to fit into SkRect dst. SkIRect 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, SkMatrix, and optional SkPaint paint.
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. 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 SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the image edge color when it samples outside of its bounds.
image | SkImage containing pixels, dimensions, and format |
center | SkIRect edge of image corners and sides |
dst | destination SkRect of image to draw to |
filter | what technique to use when sampling the image |
paint | SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter, and so on; or nullptr |
Definition at line 1769 of file SkCanvas.cpp.
|
inline |
Definition at line 1561 of file SkCanvas.h.
|
inline |
Definition at line 1556 of file SkCanvas.h.
void SkCanvas::drawImageRect | ( | const SkImage * | image, |
const SkRect & | dst, | ||
const SkSamplingOptions & | sampling, | ||
const SkPaint * | paint = nullptr |
||
) |
Definition at line 2343 of file SkCanvas.cpp.
void SkCanvas::drawImageRect | ( | const SkImage * | image, |
const SkRect & | src, | ||
const SkRect & | dst, | ||
const SkSamplingOptions & | sampling, | ||
const SkPaint * | paint, | ||
SrcRectConstraint | constraint | ||
) |
Definition at line 2333 of file SkCanvas.cpp.
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.
rect | rectangle to draw |
paint | stroke or fill, blend, color, and so on, used to draw |
Definition at line 1358 of file SkCanvas.h.
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.
p0 | start of line segment |
p1 | end of line segment |
paint | stroke, blend, color, and so on, used to draw |
Definition at line 1334 of file SkCanvas.h.
void SkCanvas::drawLine | ( | SkScalar | x0, |
SkScalar | y0, | ||
SkScalar | x1, | ||
SkScalar | y1, | ||
const SkPaint & | paint | ||
) |
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.
x0 | start of line segment on x-axis |
y0 | start of line segment on y-axis |
x1 | end of line segment on x-axis |
y1 | end of line segment on y-axis |
paint | stroke, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawLine
Definition at line 2700 of file SkCanvas.cpp.
Experimental, under active development, and subject to change without notice.
Draws a mesh using a user-defined specification (see SkMeshSpecification). Requires a GPU backend or SkSL to be compiled in.
SkBlender is ignored if SkMesh's specification does not output fragment shader color. Otherwise, it combines
SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
mesh | the mesh vertices and compatible specification. |
blender | combines vertices colors with SkShader if present or SkPaint opaque color if not. Ignored if the custom mesh does not output color. Defaults to SkBlendMode::kModulate if nullptr. |
paint | specifies the SkShader, used as SkVertices texture, may be nullptr |
Definition at line 1739 of file SkCanvas.cpp.
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.
oval | SkRect bounds of oval |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawOval
Definition at line 1698 of file SkCanvas.cpp.
void SkCanvas::drawPaint | ( | const SkPaint & | paint | ) |
Fills clip with SkPaint paint. SkPaint components, SkShader, SkColorFilter, SkImageFilter, and SkBlendMode affect drawing; SkMaskFilter and SkPathEffect in paint are ignored.
paint | graphics state used to fill SkCanvas |
example: https://fiddle.skia.org/c/@Canvas_drawPaint
Definition at line 1668 of file SkCanvas.cpp.
void SkCanvas::drawPatch | ( | const SkPoint | cubics[12], |
const SkColor | colors[4], | ||
const SkPoint | texCoords[4], | ||
SkBlendMode | mode, | ||
const SkPaint & | paint | ||
) |
Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
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. If texCoords is nullptr, SkShader is mapped using positions (derived from cubics).
SkBlendMode is ignored if colors is null. Otherwise, it combines
SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
cubics | SkPath cubic array, sharing common points |
colors | color array, one for each corner |
texCoords | SkPoint array of texture coordinates, mapping SkShader to corners; may be nullptr |
mode | combines patch's colors with SkShader if present or SkPaint opaque color if not. Ignored if colors is null. |
paint | SkShader, SkColorFilter, SkBlendMode, used to draw |
Definition at line 2529 of file SkCanvas.cpp.
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.
path | SkPath to draw |
paint | stroke, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawPath
Definition at line 1747 of file SkCanvas.cpp.
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.
picture | recorded drawing commands to play |
Definition at line 1973 of file SkCanvas.h.
|
inline |
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.
If paint is non-null, then the picture is always drawn into a temporary layer before actually landing on the canvas. Note that drawing into a layer can also change its appearance if there are any non-associative blendModes inside any of the pictures elements.
picture | recorded drawing commands to play |
matrix | SkMatrix to rotate, scale, translate, and so on; may be nullptr |
paint | SkPaint to apply transparency, filtering, and so on; may be nullptr |
Definition at line 2005 of file SkCanvas.h.
|
inline |
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.
picture | recorded drawing commands to play |
Definition at line 1961 of file SkCanvas.h.
void SkCanvas::drawPicture | ( | const SkPicture * | picture, |
const SkMatrix * | matrix, | ||
const SkPaint * | paint | ||
) |
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.
If paint is non-null, then the picture is always drawn into a temporary layer before actually landing on the canvas. Note that drawing into a layer can also change its appearance if there are any non-associative blendModes inside any of the pictures elements.
picture | recorded drawing commands to play |
matrix | SkMatrix to rotate, scale, translate, and so on; may be nullptr |
paint | SkPaint to apply transparency, filtering, and so on; may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_drawPicture_3
Definition at line 2747 of file SkCanvas.cpp.
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.
p | top-left edge of circle or square |
paint | stroke, blend, color, and so on, used to draw |
Definition at line 1306 of file SkCanvas.h.
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.
x | left edge of circle or square |
y | top edge of circle or square |
paint | stroke, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawPoint
Definition at line 2695 of file SkCanvas.cpp.
void SkCanvas::drawPoints | ( | PointMode | mode, |
size_t | count, | ||
const SkPoint | pts[], | ||
const SkPaint & | paint | ||
) |
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.
mode | whether pts draws points or lines |
count | number of points in the array |
pts | array of points to draw |
paint | stroke, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawPoints
Definition at line 1710 of file SkCanvas.cpp.
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.
rect | rectangle to draw |
paint | stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawRect
Definition at line 1673 of file SkCanvas.cpp.
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.
region | region to draw |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawRegion
Definition at line 1685 of file SkCanvas.cpp.
void SkCanvas::drawRoundRect | ( | const SkRect & | rect, |
SkScalar | rx, | ||
SkScalar | ry, | ||
const SkPaint & | paint | ||
) |
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.
rect | SkRect bounds of SkRRect to draw |
rx | axis length on x-axis of oval describing rounded corners |
ry | axis length on y-axis of oval describing rounded corners |
paint | stroke, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawRoundRect
Definition at line 2717 of file SkCanvas.cpp.
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.
rrect | SkRRect with up to eight corner radii to draw |
paint | SkPaint stroke or fill, blend, color, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawRRect
Definition at line 1705 of file SkCanvas.cpp.
void SkCanvas::drawSimpleText | ( | const void * | text, |
size_t | byteLength, | ||
SkTextEncoding | encoding, | ||
SkScalar | x, | ||
SkScalar | y, | ||
const SkFont & | font, | ||
const SkPaint & | paint | ||
) |
Draws text, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or SkTextEncoding::kUTF32, this function uses the default character-to-glyph mapping from the SkTypeface in font. It does not perform typeface fallback for characters not found in the SkTypeface. It does not perform kerning or other complex shaping; glyphs are positioned based on their default advances.
Text meaning depends on SkTextEncoding.
Text size is affected by SkMatrix and SkFont text size. Default text size is 12 point.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
text | character code points or glyphs drawn |
byteLength | byte length of text array |
encoding | text encoding used in the text array |
x | start of text on x-axis |
y | start of text on y-axis |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
Definition at line 2413 of file SkCanvas.cpp.
|
inline |
Draws null terminated string, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
This function uses the default character-to-glyph mapping from the SkTypeface in font. It does not perform typeface fallback for characters not found in the SkTypeface. It does not perform kerning; glyphs are positioned based on their default advances.
String str is encoded as UTF-8.
Text size is affected by SkMatrix and font text size. Default text size is 12 point.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
str | character code points drawn, ending with a char value of zero |
x | start of string on x-axis |
y | start of string on y-axis |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
Definition at line 1803 of file SkCanvas.h.
|
inline |
Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
This function uses the default character-to-glyph mapping from the SkTypeface in font. It does not perform typeface fallback for characters not found in the SkTypeface. It does not perform kerning; glyphs are positioned based on their default advances.
SkString str is encoded as UTF-8.
Text size is affected by SkMatrix and SkFont text size. Default text size is 12 point.
All elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs.
str | character code points drawn, ending with a char value of zero |
x | start of string on x-axis |
y | start of string on y-axis |
font | typeface, text size and so, used to describe the text |
paint | blend, color, and so on, used to draw |
Definition at line 1832 of file SkCanvas.h.
|
inline |
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
blob contains glyphs, their positions, and paint attributes specific to text: SkTypeface, SkPaint text size, SkPaint text scale x, SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold, SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text, and SkPaint subpixel text.
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, and SkImageFilter; apply to blob.
blob | glyphs, positions, and their paints' text size, typeface, and so on |
x | horizontal offset applied to blob |
y | vertical offset applied to blob |
paint | blend, color, stroking, and so on, used to draw |
Definition at line 1949 of file SkCanvas.h.
void SkCanvas::drawTextBlob | ( | const SkTextBlob * | blob, |
SkScalar | x, | ||
SkScalar | y, | ||
const SkPaint & | paint | ||
) |
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
blob contains glyphs, their positions, and paint attributes specific to text: SkTypeface, SkPaint text size, SkPaint text scale x, SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold, SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text, and SkPaint subpixel text.
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
Elements of paint: anti-alias, SkBlendMode, color including alpha, SkColorFilter, SkPaint dither, SkMaskFilter, SkPathEffect, SkShader, and SkPaint::Style; apply to blob. If SkPaint contains SkPaint::kStroke_Style: SkPaint miter limit, SkPaint::Cap, SkPaint::Join, and SkPaint stroke width; apply to SkPath created from blob.
blob | glyphs, positions, and their paints' text size, typeface, and so on |
x | horizontal offset applied to blob |
y | vertical offset applied to blob |
paint | blend, color, stroking, and so on, used to draw |
example: https://fiddle.skia.org/c/@Canvas_drawTextBlob
Definition at line 2484 of file SkCanvas.cpp.
void SkCanvas::drawVertices | ( | const sk_sp< SkVertices > & | vertices, |
SkBlendMode | mode, | ||
const SkPaint & | paint | ||
) |
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. If paint contains an SkShader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.
SkBlendMode is ignored if SkVertices does not have colors. Otherwise, it combines
SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
vertices | triangle mesh to draw |
mode | combines vertices' colors with SkShader if present or SkPaint opaque color if not. Ignored if the vertices do not contain color. |
paint | specifies the SkShader, used as SkVertices texture, may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_drawVertices_2
Definition at line 1715 of file SkCanvas.cpp.
void SkCanvas::drawVertices | ( | const SkVertices * | vertices, |
SkBlendMode | mode, | ||
const SkPaint & | paint | ||
) |
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. If paint contains an SkShader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.
SkBlendMode is ignored if SkVertices does not have colors. Otherwise, it combines
SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
vertices | triangle mesh to draw |
mode | combines vertices' colors with SkShader if present or SkPaint opaque color if not. Ignored if the vertices do not contain color. |
paint | specifies the SkShader, used as SkVertices texture, and SkColorFilter. |
example: https://fiddle.skia.org/c/@Canvas_drawVertices
Definition at line 1720 of file SkCanvas.cpp.
void SkCanvas::experimental_DrawEdgeAAImageSet | ( | const ImageSetEntry | imageSet[], |
int | cnt, | ||
const SkPoint | dstClips[], | ||
const SkMatrix | preViewMatrices[], | ||
const SkSamplingOptions & | sampling, | ||
const SkPaint * | paint = nullptr , |
||
SrcRectConstraint | constraint = kStrict_SrcRectConstraint |
||
) |
This is an bulk variant of experimental_DrawEdgeAAQuad() that renders 'cnt' textured quads. For each entry, 'fDstRect' is rendered with its clip (determined by entry's 'fHasClip' and the current index in 'dstClip'). The entry's fImage is applied to the destination rectangle by sampling from 'fSrcRect' sub-image. The corners of 'fSrcRect' map to the corners of 'fDstRect', just like in drawImageRect(), and they will be properly interpolated when applying a clip.
Like experimental_DrawEdgeAAQuad(), each entry can specify edge AA flags that apply to both the destination rect and its clip.
If provided, the 'dstClips' array must have length equal 4 * the number of entries with fHasClip true. If 'dstClips' is null, every entry must have 'fHasClip' set to false. The destination clip coordinates will be read consecutively with the image set entries, advancing by 4 points every time an entry with fHasClip is passed.
This entry point supports per-entry manipulations to the canvas's current matrix. If an entry provides 'fMatrixIndex' >= 0, it will be drawn as if the canvas's CTM was canvas->getTotalMatrix() * preViewMatrices[fMatrixIndex]. If 'fMatrixIndex' is less than 0, the pre-view matrix transform is implicitly the identity, so it will be drawn using just the current canvas matrix. The pre-view matrix modifies the canvas's view matrix, it does not affect the local coordinates of each entry.
An optional paint may be provided, which supports the same subset of features usable with drawImageRect (i.e. assumed to be filled and no path effects). When a paint is provided, the image set is drawn as if each image used the applied paint independently, so each is affected by the image, color, and/or mask filter.
Definition at line 1853 of file SkCanvas.cpp.
void SkCanvas::experimental_DrawEdgeAAQuad | ( | const SkRect & | rect, |
const SkPoint | clip[4], | ||
QuadAAFlags | aaFlags, | ||
const SkColor4f & | color, | ||
SkBlendMode | mode | ||
) |
This is an experimental API for the SkiaRenderer Chromium project, and its API will surely evolve if it is not removed outright.
This behaves very similarly to drawRect() combined with a clipPath() formed by clip quadrilateral. 'rect' and 'clip' are in the same coordinate space. If 'clip' is null, then it is as if the rectangle was not clipped (or, alternatively, clipped to itself). If not null, then it must provide 4 points.
In addition to combining the draw and clipping into one operation, this function adds the additional capability of controlling each of the rectangle's edges anti-aliasing independently. The edges of the clip will respect the per-edge AA flags. It is required that 'clip' be contained inside 'rect'. In terms of mapping to edge labels, the 'clip' points should be ordered top-left, top-right, bottom-right, bottom-left so that the edge between [0] and [1] is "top", [1] and [2] is "right", [2] and [3] is "bottom", and [3] and [0] is "left". This ordering matches SkRect::toQuad().
This API only draws solid color, filled rectangles so it does not accept a full SkPaint.
Definition at line 1845 of file SkCanvas.cpp.
|
inline |
Definition at line 1711 of file SkCanvas.h.
|
virtual |
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).
example: https://fiddle.skia.org/c/@Canvas_getBaseLayerSize
Reimplemented in SkPaintFilterCanvas.
Definition at line 369 of file SkCanvas.cpp.
SkSurfaceProps SkCanvas::getBaseProps | ( | ) | const |
Returns the SkSurfaceProps associated with the canvas (i.e., at the base of the layer stack).
Definition at line 1218 of file SkCanvas.cpp.
SkIRect SkCanvas::getDeviceClipBounds | ( | ) | const |
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.
example: https://fiddle.skia.org/c/@Canvas_getDeviceClipBounds
Definition at line 1607 of file SkCanvas.cpp.
|
inline |
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.
bounds | SkRect of clip in device coordinates |
Definition at line 1169 of file SkCanvas.h.
SkRect SkCanvas::getLocalClipBounds | ( | ) | const |
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.
example: https://fiddle.skia.org/c/@Canvas_getLocalClipBounds
Definition at line 1586 of file SkCanvas.cpp.
|
inline |
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.
bounds | SkRect of clip in local coordinates |
Definition at line 1145 of file SkCanvas.h.
SkM44 SkCanvas::getLocalToDevice | ( | ) | const |
Returns the current transform from local coordinates to the 'device', which for most purposes means pixels.
Definition at line 1633 of file SkCanvas.cpp.
|
inline |
Throws away the 3rd row and column in the matrix, so be warned.
Definition at line 2222 of file SkCanvas.h.
bool SkCanvas::getProps | ( | SkSurfaceProps * | props | ) | const |
Copies SkSurfaceProps, if SkCanvas is associated with raster surface or GPU surface, and returns true. Otherwise, returns false and leave props unchanged.
props | storage for writable SkSurfaceProps |
DEPRECATED: Replace usage with getBaseProps() or getTopProps()
example: https://fiddle.skia.org/c/@Canvas_getProps
Definition at line 1214 of file SkCanvas.cpp.
int SkCanvas::getSaveCount | ( | ) | const |
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.
example: https://fiddle.skia.org/c/@Canvas_getSaveCount
Definition at line 431 of file SkCanvas.cpp.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkNoDrawCanvas, and SaveCountingCanvas.
Definition at line 2270 of file SkCanvas.h.
SkSurface * SkCanvas::getSurface | ( | ) | const |
Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare pointer to that surface, else this will return nullptr.
Definition at line 365 of file SkCanvas.cpp.
SkSurfaceProps SkCanvas::getTopProps | ( | ) | const |
Returns the SkSurfaceProps associated with the canvas that are currently active (i.e., at the top of the layer stack). This can differ from getBaseProps depending on the flags passed to saveLayer (see SaveLayerFlagsSet).
Definition at line 1224 of file SkCanvas.cpp.
SkMatrix SkCanvas::getTotalMatrix | ( | ) | const |
DEPRECATED Legacy version of getLocalToDevice(), which strips away any Z information, and just returns a 3x3 version.
example: https://fiddle.skia.org/c/@Canvas_getTotalMatrix example: https://fiddle.skia.org/c/@Clip
Definition at line 1629 of file SkCanvas.cpp.
SkImageInfo SkCanvas::imageInfo | ( | ) | const |
Returns SkImageInfo for SkCanvas. If SkCanvas is not associated with raster surface or GPU surface, returned SkColorType is set to kUnknown_SkColorType.
example: https://fiddle.skia.org/c/@Canvas_imageInfo
Definition at line 1206 of file SkCanvas.cpp.
|
inlineprivatevirtual |
Definition at line 2610 of file SkCanvas.h.
|
virtual |
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.
example: https://fiddle.skia.org/c/@Canvas_isClipEmpty
Definition at line 1549 of file SkCanvas.cpp.
|
virtual |
Returns true if clip is SkRect and not empty. Returns false if the clip is empty, or if it is not SkRect.
example: https://fiddle.skia.org/c/@Canvas_isClipRect
Definition at line 1553 of file SkCanvas.cpp.
|
static |
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().
info | width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width, or height, or both, may be zero |
pixels | pointer to destination pixels buffer |
rowBytes | interval from one SkSurface row to the next, or zero |
props | LCD striping orientation and setting for device independent fonts; may be nullptr |
Definition at line 2801 of file SkCanvas.cpp.
|
inlinestatic |
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.
width | pixel column count on raster surface created; must be zero or greater |
height | pixel row count on raster surface created; must be zero or greater |
pixels | pointer to destination pixels buffer; buffer size should be height times rowBytes |
rowBytes | interval from one SkSurface row to the next, or zero |
Definition at line 163 of file SkCanvas.h.
sk_sp< SkSurface > SkCanvas::makeSurface | ( | const SkImageInfo & | info, |
const SkSurfaceProps * | props = nullptr |
||
) |
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.
info | width, height, SkColorType, SkAlphaType, and SkColorSpace |
props | SkSurfaceProps to match; may be nullptr to match SkCanvas |
example: https://fiddle.skia.org/c/@Canvas_makeSurface
Definition at line 1195 of file SkCanvas.cpp.
|
protectedvirtual |
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkCanvasStack, DebugCanvas, ClipCountingCanvas, and SkRecorder.
Definition at line 1481 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkCanvasStack, DebugCanvas, ClipCountingCanvas, and SkRecorder.
Definition at line 1370 of file SkCanvas.cpp.
Reimplemented in SkNWayCanvas, SkPictureRecord, SkCanvasStack, ClipCountingCanvas, SkRecorder, and DebugCanvas.
Definition at line 1515 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkCanvasStack, DebugCanvas, ClipCountingCanvas, and SkRecorder.
Definition at line 1449 of file SkCanvas.cpp.
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, SkCanvasStack, and DebugCanvas.
Definition at line 1505 of file SkCanvas.cpp.
|
protectedvirtual |
Definition at line 2379 of file SkCanvas.cpp.
|
protectedvirtual |
Definition at line 1888 of file SkCanvas.cpp.
|
inlineprotectedvirtual |
Reimplemented in SkNoDrawCanvas, SkNWayCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and SaveCountingCanvas.
Definition at line 2275 of file SkCanvas.h.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkPaintFilterCanvas, TestAnnotationCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2615 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2090 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 2593 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, SkCanvasVirtualEnforcer< SkNWayCanvas >, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkOverdrawCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 2031 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2585 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2132 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in MSKPPlayer::CmdRecordCanvas, SkOverdrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and SkNoDrawCanvas.
Definition at line 2638 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkOverdrawCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2623 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPaintFilterCanvas, SkOverdrawCanvas, SkRecorder, SkTestCanvas< SkSlugTestKey >, SkTestCanvas< SkSerializeSlugTestKey >, SkTestCanvas< SkRemoteSlugTestKey >, and OveridePaintFilterCanvas.
Definition at line 2356 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 2185 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 2306 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 2204 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkRecorder.
Definition at line 2521 of file SkCanvas.cpp.
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2075 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 1894 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, SkCanvasVirtualEnforcer< SkNWayCanvas >, flutter::DidDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkOverdrawCanvas, and SkNoDrawCanvas.
Definition at line 2540 of file SkCanvas.cpp.
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2144 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, DebugPaintFilterCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2762 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkOverdrawCanvas, SkNoDrawCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 1911 of file SkCanvas.cpp.
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2004 of file SkCanvas.cpp.
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2019 of file SkCanvas.cpp.
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2105 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPictureRecord, SkRecorder, DebugCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, SkCanvasVirtualEnforcer< SkNWayCanvas >, SkPaintFilterCanvas, and MSKPPlayer::CmdRecordCanvas.
Definition at line 1836 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, and SkRecorder.
Definition at line 2400 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, flutter::DidDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, DebugCanvas, MSKPPlayer::CmdRecordCanvas, OveridePaintFilterCanvas, SkCanvasVirtualEnforcer< SkCanvas >, SkCanvasVirtualEnforcer< SkNoDrawCanvas >, and SkCanvasVirtualEnforcer< SkNWayCanvas >.
Definition at line 2350 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkOverdrawCanvas, SkNoDrawCanvas, SkNWayCanvas, SkPaintFilterCanvas, SkPictureRecord, SkRecorder, and DebugCanvas.
Definition at line 2506 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkPaintFilterCanvas.
Definition at line 1230 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkPaintFilterCanvas.
Definition at line 1210 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkPaintFilterCanvas, SkPictureRecord, and SkRecorder.
Definition at line 1202 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkPictureRecord, and SkPaintFilterCanvas.
Definition at line 1241 of file SkCanvas.cpp.
|
protectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, and DebugCanvas.
Definition at line 1424 of file SkCanvas.cpp.
bool SkCanvas::peekPixels | ( | SkPixmap * | pixmap | ) |
Returns true if SkCanvas has direct access to its pixels.
Pixels are readable when SkDevice 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 DebugCanvas.
pixmap is valid only while SkCanvas is in scope and unchanged. Any SkCanvas or SkSurface call may invalidate the pixmap values.
pixmap | storage for pixel state if pixels are readable; otherwise, ignored |
example: https://fiddle.skia.org/c/@Canvas_peekPixels
Definition at line 1237 of file SkCanvas.cpp.
void SkCanvas::private_draw_shadow_rec | ( | const SkPath & | path, |
const SkDrawShadowRec & | rec | ||
) |
Definition at line 1831 of file SkCanvas.cpp.
bool SkCanvas::quickReject | ( | const SkPath & | path | ) | const |
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.
path | SkPath to compare with clip |
example: https://fiddle.skia.org/c/@Canvas_quickReject_2
Definition at line 1567 of file SkCanvas.cpp.
bool SkCanvas::quickReject | ( | const SkRect & | rect | ) | const |
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.
rect | SkRect to compare with clip |
example: https://fiddle.skia.org/c/@Canvas_quickReject
Definition at line 1557 of file SkCanvas.cpp.
Copies SkRect of pixels from SkCanvas into bitmap. SkMatrix and clip are ignored.
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination SkRect 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 SkDevice is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like DebugCanvas.
Caller must allocate pixel storage in bitmap if needed.
SkBitmap values are converted only if SkColorType and SkAlphaType do not match. Only pixels within both source and destination rectangles are copied. SkBitmap pixels outside SkRect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down bitmap.
Does not copy, and returns false if:
bitmap | storage for pixels copied from SkCanvas |
srcX | offset into readable pixels on x-axis; may be negative |
srcY | offset into readable pixels on y-axis; may be negative |
example: https://fiddle.skia.org/c/@Canvas_readPixels_3
Definition at line 386 of file SkCanvas.cpp.
bool SkCanvas::readPixels | ( | const SkImageInfo & | dstInfo, |
void * | dstPixels, | ||
size_t | dstRowBytes, | ||
int | srcX, | ||
int | srcY | ||
) |
Copies SkRect of pixels from SkCanvas into dstPixels. SkMatrix and clip are ignored.
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination SkRect 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 SkDevice is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like DebugCanvas.
The destination pixel storage must be allocated by the caller.
Pixel values are converted only if SkColorType and SkAlphaType do not match. Only pixels within both source and destination rectangles are copied. dstPixels contents outside SkRect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down destination.
Does not copy, and returns false if:
dstInfo | width, height, SkColorType, and SkAlphaType of dstPixels |
dstPixels | storage for pixels; dstInfo.height() times dstRowBytes, or larger |
dstRowBytes | size of one destination row; dstInfo.width() times pixel size, or larger |
srcX | offset into readable pixels on x-axis; may be negative |
srcY | offset into readable pixels on y-axis; may be negative |
Definition at line 382 of file SkCanvas.cpp.
Copies SkRect of pixels from SkCanvas into pixmap. SkMatrix and clip are ignored.
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination SkRect 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 SkDevice is raster, or backed by a GPU. Pixels are not readable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like DebugCanvas.
Caller must allocate pixel storage in pixmap if needed.
Pixel values are converted only if SkColorType and SkAlphaType do not match. Only pixels within both source and destination SkRect are copied. pixmap pixels contents outside SkRect intersection are unchanged.
Pass negative values for srcX or srcY to offset pixels across or down pixmap.
Does not copy, and returns false if:
pixmap | storage for pixels copied from SkCanvas |
srcX | offset into readable pixels on x-axis; may be negative |
srcY | offset into readable pixels on y-axis; may be negative |
example: https://fiddle.skia.org/c/@Canvas_readPixels_2
Definition at line 378 of file SkCanvas.cpp.
|
virtual |
Returns Recorder for the GPU surface associated with SkCanvas.
Definition at line 1641 of file SkCanvas.cpp.
|
virtual |
Returns Ganesh context of the GPU surface associated with SkCanvas.
example: https://fiddle.skia.org/c/@Canvas_recordingContext
Reimplemented in SkPaintFilterCanvas.
Definition at line 1637 of file SkCanvas.cpp.
void SkCanvas::resetMatrix | ( | ) |
Sets SkMatrix to the identity matrix. Any prior matrix state is overwritten.
example: https://fiddle.skia.org/c/@Canvas_resetMatrix
Definition at line 1355 of file SkCanvas.cpp.
void SkCanvas::restore | ( | ) |
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.
example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore
example: https://fiddle.skia.org/c/@Canvas_restore
Definition at line 461 of file SkCanvas.cpp.
void SkCanvas::restoreToCount | ( | int | saveCount | ) |
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.
saveCount | depth of state stack to restore |
example: https://fiddle.skia.org/c/@Canvas_restoreToCount
Definition at line 478 of file SkCanvas.cpp.
void SkCanvas::rotate | ( | SkScalar | degrees | ) |
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.
degrees | amount to rotate, in degrees |
example: https://fiddle.skia.org/c/@Canvas_rotate
Definition at line 1300 of file SkCanvas.cpp.
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.
degrees | amount to rotate, in degrees |
px | x-axis value of the point to rotate about |
py | y-axis value of the point to rotate about |
example: https://fiddle.skia.org/c/@Canvas_rotate_2
Definition at line 1306 of file SkCanvas.cpp.
int SkCanvas::save | ( | ) |
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.
example: https://fiddle.skia.org/c/@Canvas_save
Definition at line 447 of file SkCanvas.cpp.
int SkCanvas::saveLayer | ( | const SaveLayerRec & | layerRec | ) |
Saves SkMatrix and clip, and allocates SkSurface for subsequent drawing.
Calling restore() discards changes to SkMatrix and clip, and blends SkSurface 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.
layerRec | layer state |
example: https://fiddle.skia.org/c/@Canvas_saveLayer_3
Definition at line 500 of file SkCanvas.cpp.
Saves SkMatrix and clip, and allocates a SkSurface for subsequent drawing. Calling restore() discards changes to SkMatrix and clip, and draws the SkSurface.
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.
bounds | hint to limit the size of layer; may be nullptr |
paint | graphics state for layer; may be nullptr |
Definition at line 633 of file SkCanvas.h.
Saves SkMatrix and clip, and allocates a SkSurface for subsequent drawing. Calling restore() discards changes to SkMatrix and clip, and draws the SkSurface.
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 SkSurface 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.
bounds | hint to limit the size of the layer; may be nullptr |
paint | graphics state for layer; may be nullptr |
example: https://fiddle.skia.org/c/@Canvas_saveLayer example: https://fiddle.skia.org/c/@Canvas_saveLayer_4
Definition at line 496 of file SkCanvas.cpp.
Definition at line 661 of file SkCanvas.h.
Saves SkMatrix and clip, and allocates SkSurface 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, 1.0f is fully opaque.
Call restoreToCount() with returned value to restore this and subsequent saves.
bounds | hint to limit the size of layer; may be nullptr |
alpha | opacity of layer |
example: https://fiddle.skia.org/c/@Canvas_saveLayerAlpha
Definition at line 1077 of file SkCanvas.cpp.
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.
sx | amount to scale on x-axis |
sy | amount to scale on y-axis |
example: https://fiddle.skia.org/c/@Canvas_scale
Definition at line 1289 of file SkCanvas.cpp.
void SkCanvas::setMatrix | ( | const SkM44 & | matrix | ) |
Replaces SkMatrix with matrix. Unlike concat(), any prior matrix state is overwritten.
matrix | matrix to copy, replacing existing SkMatrix |
example: https://fiddle.skia.org/c/@Canvas_setMatrix
Definition at line 1349 of file SkCanvas.cpp.
void SkCanvas::setMatrix | ( | const SkMatrix & | matrix | ) |
Definition at line 1345 of file SkCanvas.cpp.
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.
sx | amount to skew on x-axis |
sy | amount to skew on y-axis |
example: https://fiddle.skia.org/c/@Canvas_skew
Definition at line 1312 of file SkCanvas.cpp.
void SkCanvas::temporary_internal_getRgnClip | ( | SkRegion * | region | ) |
Returns the global clip as a region. If the clip contains AA, then only the bounds of the clip may be returned.
Definition at line 1535 of file SkCanvas.cpp.
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.
dx | distance to translate on x-axis |
dy | distance to translate on y-axis |
example: https://fiddle.skia.org/c/@Canvas_translate
Definition at line 1278 of file SkCanvas.cpp.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, SaveCountingCanvas, and DebugCanvas.
Definition at line 2276 of file SkCanvas.h.
|
inlineprotectedvirtual |
Reimplemented in SkNWayCanvas, SkPictureRecord, SkRecorder, SaveCountingCanvas, and DebugCanvas.
Definition at line 2268 of file SkCanvas.h.
Copies SkRect from pixels to SkCanvas. SkMatrix and clip are ignored. Source SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Destination SkRect 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 SkDevice is raster, or backed by a GPU. Pixels are not writable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like DebugCanvas.
Pixel values are converted only if SkColorType and SkAlphaType do not match. Only pixels within both source and destination rectangles are copied. SkCanvas pixels outside SkRect intersection are unchanged.
Pass negative values for x or y to offset pixels to the left or above SkCanvas pixels.
Does not copy, and returns false if:
bitmap | contains pixels copied to SkCanvas |
x | offset into SkCanvas writable pixels on x-axis; may be negative |
y | offset into SkCanvas writable pixels on y-axis; may be negative |
example: https://fiddle.skia.org/c/@Canvas_writePixels_2 example: https://fiddle.skia.org/c/@State_Stack_a example: https://fiddle.skia.org/c/@State_Stack_b
Definition at line 391 of file SkCanvas.cpp.
bool SkCanvas::writePixels | ( | const SkImageInfo & | info, |
const void * | pixels, | ||
size_t | rowBytes, | ||
int | x, | ||
int | y | ||
) |
Copies SkRect from pixels to SkCanvas. SkMatrix and clip are ignored. Source SkRect corners are (0, 0) and (info.width(), info.height()). Destination SkRect 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 SkDevice is raster, or backed by a GPU. Pixels are not writable when SkCanvas is returned by SkDocument::beginPage, returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class like DebugCanvas.
Pixel values are converted only if SkColorType and SkAlphaType do not match. Only pixels within both source and destination rectangles are copied. SkCanvas pixels outside SkRect intersection are unchanged.
Pass negative values for x or y to offset pixels to the left or above SkCanvas pixels.
Does not copy, and returns false if:
info | width, height, SkColorType, and SkAlphaType of pixels |
pixels | pixels to copy, of size info.height() times rowBytes, or larger |
rowBytes | size of one row of pixels; info.width() times pixel size, or larger |
x | offset into SkCanvas writable pixels on x-axis; may be negative |
y | offset into SkCanvas writable pixels on y-axis; may be negative |
example: https://fiddle.skia.org/c/@Canvas_writePixels
Definition at line 399 of file SkCanvas.cpp.
|
friend |
Definition at line 2489 of file SkCanvas.h.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Definition at line 2487 of file SkCanvas.h.
|
friend |
Definition at line 2488 of file SkCanvas.h.
|
friend |
Definition at line 2544 of file SkCanvas.h.
|
friend |
Definition at line 2491 of file SkCanvas.h.
|
friend |
Definition at line 2492 of file SkCanvas.h.
|
friend |
Definition at line 2494 of file SkCanvas.h.
|
friend |
Definition at line 2513 of file SkCanvas.h.
|
friend |
Definition at line 2493 of file SkCanvas.h.
|
friend |
Definition at line 2495 of file SkCanvas.h.
|
friend |
Definition at line 2496 of file SkCanvas.h.
|
friend |
Definition at line 2477 of file SkCanvas.h.
|
friend |
Definition at line 2478 of file SkCanvas.h.
|
friend |
Definition at line 2490 of file SkCanvas.h.
|
friend |
Definition at line 2498 of file SkCanvas.h.
|
friend |
Definition at line 2512 of file SkCanvas.h.
|
staticconstexpr |
Definition at line 679 of file SkCanvas.h.