8 #ifndef SkCanvas_DEFINED
9 #define SkCanvas_DEFINED
30 #include "include/private/base/SkCPUTypes.h"
31 #include "include/private/base/SkDeque.h"
38 #ifndef SK_SUPPORT_LEGACY_GETTOTALMATRIX
39 #define SK_SUPPORT_LEGACY_GETTOTALMATRIX
43 class GlyphRunBuilder;
47 class AutoLayerForImageFilter;
58 class SkPaintFilterCanvas;
70 struct SkDrawShadowRec;
209 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
212 enum class ColorBehavior {
321 virtual skgpu::graphite::Recorder*
recorder()
const;
627 return this->saveLayer(&bounds, paint);
655 return this->saveLayerAlphaf(bounds, alpha * (1.0f / 255));
664 kPreserveLCDText_SaveLayerFlag = 1 << 1,
665 kInitWithPrevious_SaveLayerFlag = 1 << 2,
667 kF16ColorType = 1 << 4,
690 :
SaveLayerRec(bounds, paint, nullptr, 1.f, saveLayerFlags) {}
706 :
SaveLayerRec(bounds, paint, backdrop, 1.f, saveLayerFlags) {}
727 friend class SkCanvasPriv;
733 , fBackdrop(backdrop)
734 , fSaveLayerFlags(saveLayerFlags)
735 , fExperimentalBackdropScale(backdropScale) {}
739 SkScalar fExperimentalBackdropScale = 1.f;
924 this->clipRect(rect, op,
false);
978 this->clipRRect(rrect, op,
false);
1018 this->clipPath(path, op,
false);
1094 *bounds = this->getLocalClipBounds();
1118 *bounds = this->getDeviceClipBounds();
1131 this->drawColor(SkColor4f::FromColor(color), mode);
1148 this->clear(SkColor4f::FromColor(color));
1255 this->drawPoint(p.x(), p.y(), paint);
1283 this->drawLine(p0.x(), p0.y(), p1.x(), p1.y(), paint);
1309 this->drawRect(r, paint);
1394 this->drawCircle(center.x(), center.y(), radius, paint);
1418 bool useCenter,
const SkPaint& paint);
1477 this->drawImage(image.
get(), x, y, sampling, paint);
1486 this->drawImageRect(image.
get(), src, dst, sampling, paint, constraint);
1490 this->drawImageRect(image.
get(), dst, sampling, paint);
1586 kLeft_QuadAAFlag = 0b0001,
1587 kTop_QuadAAFlag = 0b0010,
1588 kRight_QuadAAFlag = 0b0100,
1589 kBottom_QuadAAFlag = 0b1000,
1591 kNone_QuadAAFlags = 0b0000,
1592 kAll_QuadAAFlags = 0b1111,
1598 int matrixIndex,
float alpha,
unsigned aaFlags,
bool hasClip);
1601 float alpha,
unsigned aaFlags);
1611 int fMatrixIndex = -1;
1613 unsigned fAAFlags = kNone_QuadAAFlags;
1614 bool fHasClip =
false;
1640 this->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, SkColor4f::FromColor(color), mode);
1672 const SkPoint dstClips[],
const SkMatrix preViewMatrices[],
1787 const uint32_t clusters[],
int textByteCount,
const char utf8text[],
1877 this->drawTextBlob(blob.
get(), x, y, paint);
1889 this->drawPicture(picture,
nullptr,
nullptr);
1901 this->drawPicture(picture.
get());
1934 this->drawPicture(picture.
get(), matrix, paint);
2115 this->drawAnnotation(rect, key, value.
get());
2150 return this->getLocalToDevice().asM33();
2153 #ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
2198 return kFullLayer_SaveLayerStrategy;
2221 bool useCenter,
const SkPaint& paint);
2245 const SkPoint dstClips[],
const SkMatrix preViewMatrices[],
2279 const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint);
2287 enum ShaderOverrideOpacity {
2288 kNone_ShaderOverrideOpacity,
2289 kOpaque_ShaderOverrideOpacity,
2290 kNotOpaque_ShaderOverrideOpacity,
2296 [[nodiscard]]
bool predrawNotify(
bool willOverwritesEntireSurface =
false);
2297 [[nodiscard]]
bool predrawNotify(
const SkRect*,
const SkPaint*, ShaderOverrideOpacity);
2299 enum class CheckForOverwrite : bool {
2304 std::optional<AutoLayerForImageFilter> aboutToDraw(
2307 const SkRect* rawBounds =
nullptr,
2308 CheckForOverwrite = CheckForOverwrite::kNo,
2309 ShaderOverrideOpacity = kNone_ShaderOverrideOpacity);
2313 SkDevice* rootDevice()
const {
2314 SkASSERT(fRootDevice);
2315 return fRootDevice.get();
2320 SkDevice* topDevice()
const;
2342 BackImage(
const BackImage&);
2343 BackImage(BackImage&&);
2344 BackImage& operator=(
const BackImage&);
2356 std::unique_ptr<Layer> fLayer;
2362 std::unique_ptr<BackImage> fBackImage;
2364 int fDeferredSaveCount = 0;
2366 MCRec(SkDevice* device);
2367 MCRec(
const MCRec* prev);
2373 bool layerIsCoverage);
2375 void reset(SkDevice* device);
2379 static constexpr
int kMCRecSize = 96;
2380 static constexpr
int kMCRecCount = 32;
2382 intptr_t fMCRecStorage[kMCRecSize * kMCRecCount /
sizeof(intptr_t)];
2394 std::unique_ptr<SkRasterHandleAllocator> fAllocator;
2396 SkSurface_Base* fSurfaceBase;
2397 SkSurface_Base* getSurfaceBase()
const {
return fSurfaceBase; }
2398 void setSurfaceBase(SkSurface_Base* sb) {
2401 friend class SkSurface_Base;
2402 friend class SkSurface_Ganesh;
2405 int fClipRestrictionSaveCount = -1;
2408 void checkForDeferredSave();
2409 void internalSetMatrix(
const SkM44&);
2411 friend class SkAndroidFrameworkUtils;
2412 friend class SkCanvasPriv;
2413 friend class AutoLayerForImageFilter;
2414 friend class SkSurface_Raster;
2415 friend class SkNoDrawCanvas;
2416 friend class SkNWayCanvas;
2417 friend class SkPictureRecord;
2420 friend class SkRecords::Draw;
2421 template <
typename Key>
2422 friend class SkTestCanvas;
2436 friend class sktext::gpu::Slug;
2437 friend class SkPicturePlayback;
2447 void drawSlug(
const sktext::gpu::Slug* slug);
2457 int only_axis_aligned_saveBehind(
const SkRect* subset);
2463 void drawClippedToSaveBehind(
const SkPaint&);
2465 void resetForNextPicture(
const SkIRect& bounds);
2468 friend class SkCanvasStateUtils;
2474 bool internalQuickReject(
const SkRect& bounds,
const SkPaint& paint,
2477 void internalDrawPaint(
const SkPaint& paint);
2479 void internalSaveBehind(
const SkRect*);
2481 void internalConcat44(
const SkM44&);
2484 void internalSave();
2485 void internalRestore();
2487 enum class DeviceCompatibleWithFilter : bool {
2506 void internalDrawDeviceWithFilter(SkDevice* src, SkDevice* dst,
2508 DeviceCompatibleWithFilter compat,
2510 bool srcIsCoverageLayer =
false);
2517 bool wouldOverwriteEntireSurface(
const SkRect*,
const SkPaint*, ShaderOverrideOpacity)
const;
2529 bool androidFramework_isClipAA()
const;
2536 void internal_private_resetClip();
2538 virtual SkPaintFilterCanvas* internal_private_asPaintFilterCanvas()
const {
return nullptr; }
2542 SkRect fQuickRejectBounds;
2546 SkRect computeDeviceClipBounds(
bool outsetForAA=
true)
const;
2548 class AutoUpdateQRBounds;
2549 void validateClip()
const;
2551 std::unique_ptr<sktext::GlyphRunBuilder> fScratchGlyphRunBuilder;
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
SkClipOp
Definition: SkClipOp.h:13
Types, consts, functions, and macros for colors.
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:37
uint32_t SkPMColor
32-bit ARGB color value, premultiplied.
Definition: SkColor.h:205
SkTextEncoding
Definition: SkFontTypes.h:11
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
SkFilterMode
Definition: SkSamplingOptions.h:16
float SkScalar
Definition: SkScalar.h:14
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:171
Definition: GrRecordingContext.h:42
Stack helper class calls SkCanvas::restoreToCount when SkAutoCanvasRestore goes out of scope.
Definition: SkCanvas.h:2559
void restore()
Restores SkCanvas to saved state immediately.
Definition: SkCanvas.h:2589
SkAutoCanvasRestore(SkCanvas *canvas, bool doSave)
Preserves SkCanvas::save() count.
Definition: SkCanvas.h:2568
~SkAutoCanvasRestore()
Restores SkCanvas to saved state.
Definition: SkCanvas.h:2580
SkBitmap describes a two-dimensional raster pixel array.
Definition: SkBitmap.h:59
SkBlender represents a custom blend function in the Skia pipeline.
Definition: SkBlender.h:19
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:99
static std::unique_ptr< SkCanvas > MakeRasterDirectN32(int width, int height, SkPMColor *pixels, size_t rowBytes)
Allocates raster SkCanvas specified by inline image specification.
Definition: SkCanvas.h:156
virtual void onDrawPath(const SkPath &path, const SkPaint &paint)
virtual void onDrawVerticesObject(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Saves SkMatrix and clip, and allocates a SkSurface for subsequent drawing.
virtual ~SkCanvas()
Draws saved layers, if any.
virtual void onDrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
bool getProps(SkSurfaceProps *props) const
Copies SkSurfaceProps, if SkCanvas is associated with raster surface or GPU surface,...
SkRasterHandleAllocator::Handle accessTopRasterHandle() const
Returns custom context that tracks the SkMatrix and clip.
void clipPath(const SkPath &path, bool doAntiAlias=false)
Replaces clip with the intersection of clip and path.
Definition: SkCanvas.h:1031
void drawRect(const SkRect &rect, const SkPaint &paint)
Draws SkRect rect using clip, SkMatrix, and SkPaint paint.
void drawOval(const SkRect &oval, const SkPaint &paint)
Draws oval oval using clip, SkMatrix, and SkPaint.
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and rect, with an aliased or anti-aliased c...
virtual void onClipRRect(const SkRRect &rrect, SkClipOp op, ClipEdgeStyle edgeStyle)
virtual void onDrawMesh(const SkMesh &, sk_sp< SkBlender >, const SkPaint &)
bool peekPixels(SkPixmap *pixmap)
Returns true if SkCanvas has direct access to its pixels.
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Draws pts using clip, SkMatrix and SkPaint paint.
void concat(const SkM44 &)
virtual void onResetClip()
SkSurfaceProps getTopProps() const
Returns the SkSurfaceProps associated with the canvas that are currently active (i....
virtual void onDrawSlug(const sktext::gpu::Slug *slug)
void 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,...
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
Definition: SkCanvas.h:1488
void restore()
Removes changes to SkMatrix and clip since SkCanvas state was last saved.
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
Draws point at (x, y) using clip, SkMatrix and SkPaint paint.
void 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.
void rotate(SkScalar degrees, SkScalar px, SkScalar py)
Rotates SkMatrix by degrees about a point at (px, py).
virtual void onDrawRRect(const SkRRect &rrect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
Translates SkMatrix by dx along the x-axis and dy along the y-axis.
virtual skgpu::graphite::Recorder * recorder() const
Returns Recorder for the GPU surface associated with SkCanvas.
void drawPoint(SkPoint p, const SkPaint &paint)
Draws point p using clip, SkMatrix and SkPaint paint.
Definition: SkCanvas.h:1254
void 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.
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:939
sk_sp< SkSurface > makeSurface(const SkImageInfo &info, const SkSurfaceProps *props=nullptr)
Creates SkSurface matching info and props, and associates it with SkCanvas.
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
Allocates raster SkCanvas that will draw directly into pixels.
virtual bool isClipRect() const
Returns true if clip is SkRect and not empty.
void drawImageNine(const SkImage *image, const SkIRect ¢er, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Draws SkImage image stretched proportionally to fit into SkRect dst.
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Fills clip with color color.
Definition: SkCanvas.h:1130
virtual void onDrawRect(const SkRect &rect, const SkPaint &paint)
void drawPicture(const sk_sp< SkPicture > &picture)
Draws SkPicture picture, using clip and SkMatrix.
Definition: SkCanvas.h:1900
void drawDrawable(SkDrawable *drawable, SkScalar x, SkScalar y)
Draws SkDrawable drawable using clip and SkMatrix, offset by (x, y).
void androidFramework_setDeviceClipRestriction(const SkIRect &rect)
Sets the maximum clip rectangle, which can be set by clipRect(), clipRRect() and clipPath() and inter...
void clipRect(const SkRect &rect, SkClipOp op)
Replaces clip with the intersection or difference of clip and rect.
Definition: SkCanvas.h:923
int saveLayer(const SaveLayerRec &layerRec)
Saves SkMatrix and clip, and allocates SkSurface for subsequent drawing.
virtual bool isClipEmpty() const
Returns true if clip is empty; that is, nothing will draw.
void drawImage(const SkImage *, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *=nullptr)
void 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.
void clear(const SkColor4f &color)
Fills clip with color color using SkBlendMode::kSrc.
Definition: SkCanvas.h:1156
SkMatrix getLocalToDeviceAs3x3() const
Throws away the 3rd row and column in the matrix, so be warned.
Definition: SkCanvas.h:2149
bool writePixels(const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y)
Copies SkRect from pixels to SkCanvas.
void discard()
Makes SkCanvas contents undefined.
Definition: SkCanvas.h:1172
virtual void onDrawEdgeAAImageSet2(const ImageSetEntry imageSet[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
SkRect getLocalClipBounds() const
Returns bounds of clip, transformed by inverse of SkMatrix.
virtual GrRecordingContext * recordingContext() const
Returns Ganesh context of the GPU surface associated with SkCanvas.
virtual sk_sp< sktext::gpu::Slug > onConvertGlyphRunListToSlug(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
virtual void onClipPath(const SkPath &path, SkClipOp op, ClipEdgeStyle edgeStyle)
void drawString(const SkString &str, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
Definition: SkCanvas.h:1759
virtual void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
virtual void didScale(SkScalar, SkScalar)
Definition: SkCanvas.h:2209
virtual void didSetM44(const SkM44 &)
Definition: SkCanvas.h:2207
virtual void onDrawArc(const SkRect &rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
virtual bool onGetProps(SkSurfaceProps *props, bool top) const
bool getLocalClipBounds(SkRect *bounds) const
Returns bounds of clip, transformed by inverse of SkMatrix.
Definition: SkCanvas.h:1093
virtual void didRestore()
Definition: SkCanvas.h:2204
void drawPaint(const SkPaint &paint)
Fills clip with SkPaint paint.
void 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.
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Draws SkDrawable drawable using clip and SkMatrix, concatenated with optional matrix.
void * 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.
void drawAnnotation(const SkRect &rect, const char key[], SkData *value)
Associates SkRect on SkCanvas with an annotation; a key-value pair, where the key is a null-terminate...
bool writePixels(const SkBitmap &bitmap, int x, int y)
Copies SkRect from pixels to SkCanvas.
virtual void onDrawDrawable(SkDrawable *drawable, const SkMatrix *matrix)
virtual bool onAccessTopLayerPixels(SkPixmap *pixmap)
void clipRRect(const SkRRect &rrect, SkClipOp op)
Replaces clip with the intersection or difference of clip and rrect.
Definition: SkCanvas.h:977
virtual void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
bool quickReject(const SkPath &path) const
Returns true if path, transformed by SkMatrix, can be quickly determined to be outside of clip.
virtual bool onPeekPixels(SkPixmap *pixmap)
bool readPixels(const SkPixmap &pixmap, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into pixmap.
virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &)
Definition: SkCanvas.h:2197
SkCanvas(const SkBitmap &bitmap, const SkSurfaceProps &props)
Constructs a canvas that draws into bitmap.
void clipPath(const SkPath &path, SkClipOp op)
Replaces clip with the intersection or difference of clip and path.
Definition: SkCanvas.h:1017
void drawColor(const SkColor4f &color, SkBlendMode mode=SkBlendMode::kSrcOver)
Fills clip with color color.
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
Definition: SkCanvas.h:654
void clipRect(const SkRect &rect, bool doAntiAlias=false)
Replaces clip with the intersection of clip and rect.
Definition: SkCanvas.h:935
SrcRectConstraint
Definition: SkCanvas.h:1468
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1469
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1470
int saveLayer(const SkRect &bounds, const SkPaint *paint)
Saves SkMatrix and clip, and allocates a SkSurface for subsequent drawing.
Definition: SkCanvas.h:626
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)
Draws count glyphs, at positions relative to origin styled with font and paint with supporting utf8 a...
SkM44 getLocalToDevice() const
Returns the current transform from local coordinates to the 'device', which for most purposes means p...
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
Replaces clip with the intersection or difference of clip and SkRegion deviceRgn.
void 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 ...
SaveLayerStrategy
Definition: SkCanvas.h:2190
@ kFullLayer_SaveLayerStrategy
Definition: SkCanvas.h:2191
@ kNoLayer_SaveLayerStrategy
Definition: SkCanvas.h:2192
virtual void onClipRect(const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle)
virtual SkImageInfo onImageInfo() const
void drawMesh(const SkMesh &mesh, sk_sp< SkBlender > blender, const SkPaint &paint)
Experimental, under active development, and subject to change without notice.
virtual void onDrawOval(const SkRect &rect, const SkPaint &paint)
void drawIRect(const SkIRect &rect, const SkPaint &paint)
Draws SkIRect rect using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1306
virtual void onDrawImageLattice2(const SkImage *, const Lattice &, const SkRect &dst, SkFilterMode, const SkPaint *)
void clear(SkColor color)
Fills clip with color color using SkBlendMode::kSrc.
Definition: SkCanvas.h:1147
virtual void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
virtual void onDrawBehind(const SkPaint &paint)
virtual void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &)
uint32_t SaveLayerFlags
Definition: SkCanvas.h:670
virtual void onDrawAtlas2(const SkImage *, const SkRSXform[], const SkRect src[], const SkColor[], int count, SkBlendMode, const SkSamplingOptions &, const SkRect *cull, const SkPaint *)
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SrcRectConstraint constraint)
Definition: SkCanvas.h:1483
bool getDeviceClipBounds(SkIRect *bounds) const
Returns SkIRect bounds of clip, unaffected by SkMatrix.
Definition: SkCanvas.h:1117
SkSurface * getSurface() const
Sometimes a canvas is owned by a surface.
virtual void willRestore()
Definition: SkCanvas.h:2203
int getSaveCount() const
Returns the number of saved states, each containing: SkMatrix and clip.
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
This is an bulk variant of experimental_DrawEdgeAAQuad() that renders 'cnt' textured quads.
void rotate(SkScalar degrees)
Rotates SkMatrix by degrees.
void restoreToCount(int saveCount)
Restores state to SkMatrix and clip values when save(), saveLayer(), saveLayerPreserveLCDTextRequests...
virtual sk_sp< SkSurface > onNewSurface(const SkImageInfo &info, const SkSurfaceProps &props)
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, SkColor color, SkBlendMode mode)
Definition: SkCanvas.h:1638
virtual void didTranslate(SkScalar, SkScalar)
Definition: SkCanvas.h:2208
void drawImage(const sk_sp< SkImage > &image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1458
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Draws SkRRect rrect using clip, SkMatrix, and SkPaint paint.
SkMatrix getTotalMatrix() const
DEPRECATED Legacy version of getLocalToDevice(), which strips away any Z information,...
void 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,...
virtual void onDrawAnnotation(const SkRect &rect, const char key[], SkData *value)
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Draws arc using clip, SkMatrix, and SkPaint paint.
void 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.
void drawPicture(const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint)
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix,...
Definition: SkCanvas.h:1932
void clipRRect(const SkRRect &rrect, bool doAntiAlias=false)
Replaces clip with the intersection of clip and rrect, with an aliased or anti-aliased clip edge.
Definition: SkCanvas.h:988
void resetMatrix()
Sets SkMatrix to the identity matrix.
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and path, with an aliased or anti-aliased c...
void setMatrix(const SkMatrix &matrix)
SkIRect getDeviceClipBounds() const
Returns SkIRect bounds of clip, unaffected by SkMatrix.
SaveLayerFlagsSet
Definition: SkCanvas.h:663
virtual void onDrawRegion(const SkRegion ®ion, const SkPaint &paint)
virtual void onDrawImageRect2(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void drawRegion(const SkRegion ®ion, const SkPaint &paint)
Draws SkRegion region using clip, SkMatrix, and SkPaint paint.
virtual void onClipRegion(const SkRegion &deviceRgn, SkClipOp op)
virtual void didConcat44(const SkM44 &)
Definition: SkCanvas.h:2206
void drawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix,...
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
int save()
Saves SkMatrix and clip.
void drawPath(const SkPath &path, const SkPaint &paint)
Draws SkPath path using clip, SkMatrix, and 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)
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
void setMatrix(const SkM44 &matrix)
Replaces SkMatrix with matrix.
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst)
Definition: SkCanvas.h:1578
void temporary_internal_getRgnClip(SkRegion *region)
Returns the global clip as a region.
virtual void onDrawImage2(const SkImage *, SkScalar dx, SkScalar dy, const SkSamplingOptions &, const SkPaint *)
SkCanvas(const SkIRect &bounds)
void drawCircle(SkPoint center, SkScalar radius, const SkPaint &paint)
Draws circle at center with radius using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1393
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Draws SkRRect outer and inner using clip, SkMatrix, and SkPaint paint.
SkCanvas(sk_sp< SkDevice > device)
Private.
virtual void onDrawPaint(const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
Scales SkMatrix by sx on the x-axis and sy on the y-axis.
void concat(const SkMatrix &matrix)
Replaces SkMatrix with matrix premultiplied with existing SkMatrix.
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
void drawImage(const sk_sp< SkImage > &image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
Definition: SkCanvas.h:1475
ClipEdgeStyle
Definition: SkCanvas.h:2262
@ kHard_ClipEdgeStyle
Definition: SkCanvas.h:2263
virtual void onDrawGlyphRunList(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
virtual bool onDoSaveBehind(const SkRect *)
Definition: SkCanvas.h:2202
SkCanvas(int width, int height, const SkSurfaceProps *props=nullptr)
Creates SkCanvas of the specified dimensions without a SkSurface.
SkSurfaceProps getBaseProps() const
Returns the SkSurfaceProps associated with the canvas (i.e., at the base of the layer stack).
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void drawVertices(const sk_sp< SkVertices > &vertices, SkBlendMode mode, const SkPaint &paint)
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
virtual SkISize getBaseLayerSize() const
Gets the size of the base or root layer in global canvas coordinates.
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Draws null terminated string, with origin at (x, y), using clip, SkMatrix, SkFont font,...
Definition: SkCanvas.h:1730
void drawPicture(const SkPicture *picture)
Draws SkPicture picture, using clip and SkMatrix.
Definition: SkCanvas.h:1888
bool readPixels(const SkBitmap &bitmap, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into bitmap.
void clipShader(sk_sp< SkShader >, SkClipOp=SkClipOp::kIntersect)
virtual void willSave()
Definition: SkCanvas.h:2195
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
virtual void onClipShader(sk_sp< SkShader >, SkClipOp)
void drawLine(SkPoint p0, SkPoint p1, const SkPaint &paint)
Draws line segment from p0 to p1 using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1282
SkImageInfo imageInfo() const
Returns SkImageInfo for SkCanvas.
void drawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const SkPaint &paint)
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1876
PointMode
Definition: SkCanvas.h:1188
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1190
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1191
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1189
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into dstPixels.
void skew(SkScalar sx, SkScalar sy)
Skews SkMatrix by sx on the x-axis and sy on the y-axis.
SkCanvas(const SkBitmap &bitmap)
Constructs a canvas that draws into bitmap.
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1455
QuadAAFlags
Experimental.
Definition: SkCanvas.h:1585
bool quickReject(const SkRect &rect) const
Returns true if SkRect rect, transformed by SkMatrix, can be quickly determined to be outside of clip...
void drawImageRect(const SkImage *, const SkRect &dst, const SkSamplingOptions &, const SkPaint *=nullptr)
SkCanvas()
Creates an empty SkCanvas with no backing device or pixels, with a width and height of zero.
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and rrect, with an aliased or anti-aliased ...
int saveLayerAlphaf(const SkRect *bounds, float alpha)
Saves SkMatrix and clip, and allocates SkSurface for subsequent drawing.
void drawAnnotation(const SkRect &rect, const char key[], const sk_sp< SkData > &value)
Associates SkRect on SkCanvas when an annotation; a key-value pair, where the key is a null-terminate...
Definition: SkCanvas.h:2114
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Draws circle at (cx, cy) with radius using clip, SkMatrix, and SkPaint paint.
SkData holds an immutable data buffer.
Definition: SkData.h:25
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:37
SkFont controls options applied when drawing and measuring text.
Definition: SkFont.h:36
Base class for image filters.
Definition: SkImageFilter.h:35
SkImage describes a two dimensional array of pixels to draw.
Definition: SkImage.h:270
4x4 matrix used by SkCanvas and other parts of Skia.
Definition: SkM44.h:150
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification.
Definition: SkMesh.h:261
Captures all drawing commands.
Definition: SkOverdrawCanvas.h:44
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
SkPath contain geometry.
Definition: SkPath.h:58
SkPicture records drawing commands made to SkCanvas.
Definition: SkPicture.h:44
SkPixmap provides a utility to pair SkImageInfo with pixels and row bytes.
Definition: SkPixmap.h:40
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
Definition: SkRRect.h:35
If a client wants to control the allocation of raster layers in a canvas, it should subclass SkRaster...
Definition: SkRasterHandleAllocator.h:37
void * Handle
Definition: SkRasterHandleAllocator.h:42
SkRegion describes the set of pixels used to clip SkCanvas.
Definition: SkRegion.h:30
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:35
Light weight class for managing strings.
Definition: SkString.h:118
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:52
SkSurface is responsible for managing the pixels that a canvas draws into.
Definition: SkSurface.h:161
SkTextBlob combines multiple text runs into an immutable container.
Definition: SkTextBlob.h:41
An immutable set of vertex data that can be used with SkCanvas::drawVertices.
Definition: SkVertices.h:24
T * get() const
Definition: SkRefCnt.h:303
Definition: SkCanvas.h:75
Definition: SkCanvas.h:73
Definition: SkCanvas.h:74
Definition: SkCanvas.h:42
This is used by the experimental API below.
Definition: SkCanvas.h:1596
ImageSetEntry(sk_sp< const SkImage > image, const SkRect &srcRect, const SkRect &dstRect, int matrixIndex, float alpha, unsigned aaFlags, bool hasClip)
ImageSetEntry & operator=(const ImageSetEntry &)
SkRect fSrcRect
Definition: SkCanvas.h:1609
ImageSetEntry(const ImageSetEntry &)
SkRect fDstRect
Definition: SkCanvas.h:1610
sk_sp< const SkImage > fImage
Definition: SkCanvas.h:1608
ImageSetEntry(sk_sp< const SkImage > image, const SkRect &srcRect, const SkRect &dstRect, float alpha, unsigned aaFlags)
SkCanvas::Lattice divides SkBitmap or SkImage into a rectangular grid.
Definition: SkCanvas.h:1528
int fYCount
number of y-coordinates
Definition: SkCanvas.h:1544
const SkIRect * fBounds
source bounds to draw from
Definition: SkCanvas.h:1545
RectType
Definition: SkCanvas.h:1534
@ kFixedColor
draws one of fColors into lattice rectangle
Definition: SkCanvas.h:1537
@ kTransparent
skips lattice rectangle by making it transparent
Definition: SkCanvas.h:1536
const int * fYDivs
y-axis values dividing bitmap
Definition: SkCanvas.h:1541
int fXCount
number of x-coordinates
Definition: SkCanvas.h:1543
const RectType * fRectTypes
array of fill types
Definition: SkCanvas.h:1542
const SkColor * fColors
array of colors
Definition: SkCanvas.h:1546
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1540
SaveLayerRec contains the state used to create the layer.
Definition: SkCanvas.h:675
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, SaveLayerFlags saveLayerFlags=0)
Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.
Definition: SkCanvas.h:689
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SaveLayerFlags saveLayerFlags)
Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.
Definition: SkCanvas.h:704
SaveLayerRec()
Sets fBounds, fPaint, and fBackdrop to nullptr.
Definition: SkCanvas.h:680
RGBA color value, holding four floating point components.
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:32
static constexpr SkIRect MakeEmpty()
Returns constructed SkIRect set to (0, 0, 0, 0).
Definition: SkRect.h:45
bool isEmpty() const
Returns true if width() or height() are zero or negative.
Definition: SkRect.h:202
Describes pixel dimensions and encoding.
Definition: SkImageInfo.h:194
static SkImageInfo MakeN32Premul(int width, int height)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType,...
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
static SkRect Make(const SkISize &size)
Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Definition: SkRect.h:669
bool isEmpty() const
Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBot...
Definition: SkRect.h:693
void set(const SkIRect &src)
Sets SkRect to src, promoting src members from integer to float.
Definition: SkRect.h:860
Definition: SkSamplingOptions.h:58