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;
77 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_GANESH)
218 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
221 enum class ColorBehavior {
644 return this->saveLayer(&bounds, paint);
672 return this->saveLayerAlphaf(bounds, alpha * (1.0f / 255));
681 kPreserveLCDText_SaveLayerFlag = 1 << 1,
682 kInitWithPrevious_SaveLayerFlag = 1 << 2,
684 kF16ColorType = 1 << 4,
707 :
SaveLayerRec(bounds, paint, nullptr, 1.f, saveLayerFlags) {}
723 :
SaveLayerRec(bounds, paint, backdrop, 1.f, saveLayerFlags) {}
744 friend class SkCanvasPriv;
750 , fBackdrop(backdrop)
751 , fSaveLayerFlags(saveLayerFlags)
752 , fExperimentalBackdropScale(backdropScale) {}
756 SkScalar fExperimentalBackdropScale = 1.f;
941 this->clipRect(rect, op,
false);
995 this->clipRRect(rrect, op,
false);
1035 this->clipPath(path, op,
false);
1111 *bounds = this->getLocalClipBounds();
1135 *bounds = this->getDeviceClipBounds();
1148 this->drawColor(SkColor4f::FromColor(color), mode);
1165 this->clear(SkColor4f::FromColor(color));
1272 this->drawPoint(p.
x(), p.
y(), paint);
1300 this->drawLine(p0.
x(), p0.
y(), p1.
x(), p1.
y(), paint);
1326 this->drawRect(r, paint);
1411 this->drawCircle(center.
x(), center.
y(), radius, paint);
1435 bool useCenter,
const SkPaint& paint);
1494 this->drawImage(image.
get(), x, y, sampling, paint);
1503 this->drawImageRect(image.
get(), src, dst, sampling, paint, constraint);
1507 this->drawImageRect(image.
get(), dst, sampling, paint);
1603 kLeft_QuadAAFlag = 0b0001,
1604 kTop_QuadAAFlag = 0b0010,
1605 kRight_QuadAAFlag = 0b0100,
1606 kBottom_QuadAAFlag = 0b1000,
1608 kNone_QuadAAFlags = 0b0000,
1609 kAll_QuadAAFlags = 0b1111,
1615 int matrixIndex,
float alpha,
unsigned aaFlags,
bool hasClip);
1618 float alpha,
unsigned aaFlags);
1628 int fMatrixIndex = -1;
1630 unsigned fAAFlags = kNone_QuadAAFlags;
1631 bool fHasClip =
false;
1657 this->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, SkColor4f::FromColor(color), mode);
1804 const uint32_t clusters[],
int textByteCount,
const char utf8text[],
1894 this->drawTextBlob(blob.
get(), x, y, paint);
1906 this->drawPicture(picture,
nullptr,
nullptr);
1918 this->drawPicture(picture.
get());
1951 this->drawPicture(picture.
get(), matrix, paint);
1994 #if defined(SK_ENABLE_SKSL)
2133 this->drawAnnotation(rect, key, value.
get());
2168 return this->getLocalToDevice().asM33();
2171 #ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
2186 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_GANESH)
2188 SkIRect topLayerBounds()
const;
2223 return kFullLayer_SaveLayerStrategy;
2246 bool useCenter,
const SkPaint& paint);
2276 #ifdef SK_ENABLE_SKSL
2303 #if (defined(SK_GANESH) || defined(SK_GRAPHITE))
2307 const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint);
2311 virtual void onDrawSlug(
const sktext::gpu::Slug* slug);
2316 enum ShaderOverrideOpacity {
2317 kNone_ShaderOverrideOpacity,
2318 kOpaque_ShaderOverrideOpacity,
2319 kNotOpaque_ShaderOverrideOpacity,
2325 bool SK_WARN_UNUSED_RESULT predrawNotify(
bool willOverwritesEntireSurface =
false);
2326 bool SK_WARN_UNUSED_RESULT predrawNotify(
const SkRect*,
const SkPaint*, ShaderOverrideOpacity);
2328 enum class CheckForOverwrite : bool {
2333 std::optional<AutoLayerForImageFilter> aboutToDraw(
2336 const SkRect* rawBounds =
nullptr,
2337 CheckForOverwrite = CheckForOverwrite::kNo,
2338 ShaderOverrideOpacity = kNone_ShaderOverrideOpacity);
2342 SkBaseDevice* baseDevice()
const {
2343 SkASSERT(fBaseDevice);
2344 return fBaseDevice.get();
2349 SkBaseDevice* topDevice()
const;
2367 BackImage(
const BackImage&);
2368 BackImage(BackImage&&);
2369 BackImage& operator=(
const BackImage&);
2381 std::unique_ptr<Layer> fLayer;
2385 SkBaseDevice* fDevice;
2387 std::unique_ptr<BackImage> fBackImage;
2389 int fDeferredSaveCount = 0;
2391 MCRec(SkBaseDevice* device);
2392 MCRec(
const MCRec* prev);
2399 void reset(SkBaseDevice* device);
2403 static constexpr
int kMCRecSize = 96;
2404 static constexpr
int kMCRecCount = 32;
2406 intptr_t fMCRecStorage[kMCRecSize * kMCRecCount /
sizeof(intptr_t)];
2418 std::unique_ptr<SkRasterHandleAllocator> fAllocator;
2420 SkSurface_Base* fSurfaceBase;
2421 SkSurface_Base* getSurfaceBase()
const {
return fSurfaceBase; }
2422 void setSurfaceBase(SkSurface_Base* sb) {
2425 friend class SkSurface_Base;
2426 friend class SkSurface_Ganesh;
2429 int fClipRestrictionSaveCount = -1;
2432 void checkForDeferredSave();
2433 void internalSetMatrix(
const SkM44&);
2435 friend class SkAndroidFrameworkUtils;
2436 friend class SkCanvasPriv;
2437 friend class AutoLayerForImageFilter;
2438 friend class SkSurface_Raster;
2439 friend class SkNoDrawCanvas;
2440 friend class SkNWayCanvas;
2441 friend class SkPictureRecord;
2444 friend class SkRecords::Draw;
2445 template <
typename Key>
2446 friend class SkTestCanvas;
2460 #if (defined(SK_GANESH) || defined(SK_GRAPHITE))
2461 friend class sktext::gpu::Slug;
2471 void drawSlug(
const sktext::gpu::Slug* slug);
2482 int only_axis_aligned_saveBehind(
const SkRect* subset);
2488 void drawClippedToSaveBehind(
const SkPaint&);
2490 void resetForNextPicture(
const SkIRect& bounds);
2493 friend class SkCanvasStateUtils;
2499 bool internalQuickReject(
const SkRect& bounds,
const SkPaint& paint,
2502 void internalDrawPaint(
const SkPaint& paint);
2504 void internalSaveBehind(
const SkRect*);
2506 void internalConcat44(
const SkM44&);
2509 void internalSave();
2510 void internalRestore();
2512 enum class DeviceCompatibleWithFilter : bool {
2531 void internalDrawDeviceWithFilter(SkBaseDevice* src, SkBaseDevice* dst,
2533 DeviceCompatibleWithFilter compat,
2541 bool wouldOverwriteEntireSurface(
const SkRect*,
const SkPaint*, ShaderOverrideOpacity)
const;
2553 bool androidFramework_isClipAA()
const;
2560 void internal_private_resetClip();
2562 virtual SkPaintFilterCanvas* internal_private_asPaintFilterCanvas()
const {
return nullptr; }
2566 SkRect fQuickRejectBounds;
2570 SkRect computeDeviceClipBounds(
bool outsetForAA=
true)
const;
2572 class AutoUpdateQRBounds;
2573 void validateClip()
const;
2575 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
sktext::gpu::Slug GrSlug
Definition: SkCanvas.h:84
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:179
Definition: GrBackendSurface.h:77
Definition: GrRecordingContext.h:45
Stack helper class calls SkCanvas::restoreToCount when SkAutoCanvasRestore goes out of scope.
Definition: SkCanvas.h:2585
void restore()
Restores SkCanvas to saved state immediately.
Definition: SkCanvas.h:2615
SkAutoCanvasRestore(SkCanvas *canvas, bool doSave)
Preserves SkCanvas::save() count.
Definition: SkCanvas.h:2594
~SkAutoCanvasRestore()
Restores SkCanvas to saved state.
Definition: SkCanvas.h:2606
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:108
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:165
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:1048
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 GrRecordingContext * recordingContext()
Returns GPU context of the GPU surface associated with SkCanvas.
virtual void onClipRRect(const SkRRect &rrect, SkClipOp op, ClipEdgeStyle edgeStyle)
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....
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:1505
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)
virtual skgpu::graphite::Recorder * recorder()
Returns Recorder for the GPU surface associated with SkCanvas.
void translate(SkScalar dx, SkScalar dy)
Translates SkMatrix by dx along the x-axis and dy along the y-axis.
void drawPoint(SkPoint p, const SkPaint &paint)
Draws point p using clip, SkMatrix and SkPaint paint.
Definition: SkCanvas.h:1271
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:956
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:1147
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:1917
void flush()
Triggers the immediate execution of all pending draw operations.
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:940
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:1173
SkMatrix getLocalToDeviceAs3x3() const
Throws away the 3rd row and column in the matrix, so be warned.
Definition: SkCanvas.h:2167
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:1189
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 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:1776
virtual void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
virtual void didScale(SkScalar, SkScalar)
Definition: SkCanvas.h:2234
virtual void didSetM44(const SkM44 &)
Definition: SkCanvas.h:2232
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:1110
virtual void didRestore()
Definition: SkCanvas.h:2229
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:994
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:2222
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:1034
void drawColor(const SkColor4f &color, SkBlendMode mode=SkBlendMode::kSrcOver)
Fills clip with color color.
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
Definition: SkCanvas.h:671
void clipRect(const SkRect &rect, bool doAntiAlias=false)
Replaces clip with the intersection of clip and rect.
Definition: SkCanvas.h:952
SrcRectConstraint
Definition: SkCanvas.h:1485
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1486
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1487
int saveLayer(const SkRect &bounds, const SkPaint *paint)
Saves SkMatrix and clip, and allocates a SkSurface for subsequent drawing.
Definition: SkCanvas.h:643
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:2215
@ kFullLayer_SaveLayerStrategy
Definition: SkCanvas.h:2216
@ kNoLayer_SaveLayerStrategy
Definition: SkCanvas.h:2217
virtual void onClipRect(const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle)
virtual SkImageInfo onImageInfo() const
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:1323
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:1164
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:687
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:1500
bool getDeviceClipBounds(SkIRect *bounds) const
Returns SkIRect bounds of clip, unaffected by SkMatrix.
Definition: SkCanvas.h:1134
SkSurface * getSurface() const
Sometimes a canvas is owned by a surface.
virtual void willRestore()
Definition: SkCanvas.h:2228
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:1655
virtual void didTranslate(SkScalar, SkScalar)
Definition: SkCanvas.h:2233
void drawImage(const sk_sp< SkImage > &image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1475
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:1949
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:1005
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:680
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:2231
SkCanvas(sk_sp< SkBaseDevice > device)
Private.
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:1595
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:1410
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Draws SkRRect outer and inner using clip, SkMatrix, and SkPaint paint.
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:1492
ClipEdgeStyle
Definition: SkCanvas.h:2289
@ kHard_ClipEdgeStyle
Definition: SkCanvas.h:2290
virtual void onDrawGlyphRunList(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
virtual bool onDoSaveBehind(const SkRect *)
Definition: SkCanvas.h:2227
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:1747
void drawPicture(const SkPicture *picture)
Draws SkPicture picture, using clip and SkMatrix.
Definition: SkCanvas.h:1905
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:2220
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:1299
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:1893
PointMode
Definition: SkCanvas.h:1205
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1207
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1208
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1206
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:1472
QuadAAFlags
Experimental.
Definition: SkCanvas.h:1602
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:2132
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:26
Base class for image filters.
Definition: SkImageFilter.h:30
SkImage describes a two dimensional array of pixels to draw.
Definition: SkImage.h:255
4x4 matrix used by SkCanvas and other parts of Skia.
Definition: SkM44.h:146
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
Captures all drawing commands.
Definition: SkOverdrawCanvas.h:19
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:39
SkPixmap provides a utility to pair SkImageInfo with pixels and row bytes.
Definition: SkPixmap.h:41
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
Definition: SkRefCnt.h:119
SkRegion describes the set of pixels used to clip SkCanvas.
Definition: SkRegion.h:24
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:39
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:168
SkTextBlob combines multiple text runs into an immutable container.
Definition: SkTextBlob.h:32
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:1613
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:1626
ImageSetEntry(const ImageSetEntry &)
SkRect fDstRect
Definition: SkCanvas.h:1627
sk_sp< const SkImage > fImage
Definition: SkCanvas.h:1625
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:1545
int fYCount
number of y-coordinates
Definition: SkCanvas.h:1561
const SkIRect * fBounds
source bounds to draw from
Definition: SkCanvas.h:1562
RectType
Definition: SkCanvas.h:1551
@ kFixedColor
draws one of fColors into lattice rectangle
Definition: SkCanvas.h:1554
@ kTransparent
skips lattice rectangle by making it transparent
Definition: SkCanvas.h:1553
const int * fYDivs
y-axis values dividing bitmap
Definition: SkCanvas.h:1558
int fXCount
number of x-coordinates
Definition: SkCanvas.h:1560
const RectType * fRectTypes
array of fill types
Definition: SkCanvas.h:1559
const SkColor * fColors
array of colors
Definition: SkCanvas.h:1563
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1557
SaveLayerRec contains the state used to create the layer.
Definition: SkCanvas.h:692
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, SaveLayerFlags saveLayerFlags=0)
Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.
Definition: SkCanvas.h:706
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SaveLayerFlags saveLayerFlags)
Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.
Definition: SkCanvas.h:721
SaveLayerRec()
Sets fBounds, fPaint, and fBackdrop to nullptr.
Definition: SkCanvas.h:697
RGBA color value, holding four floating point components.
SkIPoint holds two 32-bit integer coordinates.
Definition: SkPoint.h:27
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:31
bool isEmpty() const
Returns true if width() or height() are zero or negative.
Definition: SkRect.h:203
static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
Returns constructed SkIRect set to (0, 0, 0, 0).
Definition: SkRect.h:44
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,...
SkPoint holds two 32-bit floating point coordinates.
Definition: SkPoint.h:162
constexpr SkScalar y() const
Returns y-axis value of SkPoint or vector.
Definition: SkPoint.h:186
constexpr SkScalar x() const
Returns x-axis value of SkPoint or vector.
Definition: SkPoint.h:180
SkRect holds four SkScalar coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:583
static SkRect Make(const SkISize &size)
Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Definition: SkRect.h:672
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:696
void set(const SkIRect &src)
Sets SkRect to src, promoting src members from integer to scalar.
Definition: SkRect.h:863
Definition: SkSamplingOptions.h:58