8#ifndef SkCanvas_DEFINED
9#define SkCanvas_DEFINED
41#ifndef SK_SUPPORT_LEGACY_GETTOTALMATRIX
42#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
134 static std::unique_ptr<SkCanvas> MakeRasterDirect(
const SkImageInfo&
info,
void* pixels,
216#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
219 enum class ColorBehavior {
299 virtual SkISize getBaseLayerSize()
const;
417 bool readPixels(
const SkImageInfo& dstInfo,
void* dstPixels,
size_t dstRowBytes,
455 bool readPixels(
const SkPixmap& pixmap,
int srcX,
int srcY);
530 bool writePixels(
const SkImageInfo&
info,
const void* pixels,
size_t rowBytes,
int x,
int y);
662 return this->saveLayerAlphaf(
bounds, alpha * (1.0f / 255));
671 kPreserveLCDText_SaveLayerFlag = 1 << 1,
672 kInitWithPrevious_SaveLayerFlag = 1 << 2,
674 kF16ColorType = 1 << 4,
679 static constexpr int kMaxFiltersPerLayer = 16;
780 , fColorSpace(colorSpace)
791 SkScalar fExperimentalBackdropScale = 1.f;
812 int saveLayer(
const SaveLayerRec& layerRec);
833 int getSaveCount()
const;
845 void restoreToCount(
int saveCount);
935 void concat(
const SkM44&);
1007 void androidFramework_setDeviceClipRestriction(
const SkIRect&
rect);
1134 SkRect getLocalClipBounds()
const;
1146 *
bounds = this->getLocalClipBounds();
1147 return !
bounds->isEmpty();
1159 SkIRect getDeviceClipBounds()
const;
1170 *
bounds = this->getDeviceClipBounds();
1171 return !
bounds->isEmpty();
1183 this->drawColor(SkColor4f::FromColor(
color),
mode);
1200 this->clear(SkColor4f::FromColor(
color));
1307 this->drawPoint(
p.x(),
p.y(),
paint);
1335 this->drawLine(p0.
x(), p0.
y(), p1.
x(), p1.
y(),
paint);
1361 this->drawRect(r,
paint);
1659 kLeft_QuadAAFlag = 0b0001,
1660 kTop_QuadAAFlag = 0b0010,
1661 kRight_QuadAAFlag = 0b0100,
1662 kBottom_QuadAAFlag = 0b1000,
1664 kNone_QuadAAFlags = 0b0000,
1665 kAll_QuadAAFlags = 0b1111,
1671 int matrixIndex,
float alpha,
unsigned aaFlags,
bool hasClip);
1674 float alpha,
unsigned aaFlags);
1684 int fMatrixIndex = -1;
1686 unsigned fAAFlags = kNone_QuadAAFlags;
1687 bool fHasClip =
false;
1747 SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1860 const uint32_t clusters[],
int textByteCount,
const char utf8text[],
2201 virtual bool isClipEmpty()
const;
2210 virtual bool isClipRect()
const;
2217 SkM44 getLocalToDevice()
const;
2223 return this->getLocalToDevice().asM33();
2226#ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
2255 virtual bool onPeekPixels(
SkPixmap* pixmap);
2256 virtual bool onAccessTopLayerPixels(
SkPixmap* pixmap);
2271 return kFullLayer_SaveLayerStrategy;
2312 virtual void onDrawImageLattice2(
const SkImage*,
const Lattice&,
const SkRect&
dst,
2317 virtual void onDrawEdgeAAImageSet2(
const ImageSetEntry imageSet[],
int count,
2345 virtual void onResetClip();
2347 virtual void onDiscard();
2359 enum class PredrawFlags :
unsigned {
2361 kOpaqueShaderOverride = 1,
2362 kNonOpaqueShaderOverride = 2,
2363 kCheckForOverwrite = 4,
2364 kSkipMaskFilterAutoLayer = 8,
2375 [[nodiscard]]
bool predrawNotify(
bool willOverwritesEntireSurface =
false);
2379 std::optional<AutoLayerForImageFilter> aboutToDraw(
2383 std::optional<AutoLayerForImageFilter> aboutToDraw(
2385 const SkRect* rawBounds =
nullptr);
2391 return fRootDevice.get();
2409 FilterSpan imageFilters,
2418 BackImage(
const BackImage&);
2419 BackImage(BackImage&&);
2420 BackImage& operator=(
const BackImage&);
2432 std::unique_ptr<Layer> fLayer;
2438 std::unique_ptr<BackImage> fBackImage;
2440 int fDeferredSaveCount = 0;
2443 MCRec(
const MCRec*
prev);
2449 bool layerIsCoverage);
2455 static constexpr int kMCRecSize = 96;
2456 static constexpr int kMCRecCount = 32;
2458 intptr_t fMCRecStorage[kMCRecSize * kMCRecCount /
sizeof(intptr_t)];
2470 std::unique_ptr<SkRasterHandleAllocator> fAllocator;
2481 int fClipRestrictionSaveCount = -1;
2484 void checkForDeferredSave();
2485 void internalSetMatrix(
const SkM44&);
2487 friend class SkAndroidFrameworkUtils;
2497 template <
typename Key>
2533 int only_axis_aligned_saveBehind(
const SkRect* subset);
2539 void drawClippedToSaveBehind(
const SkPaint&);
2555 void internalSaveBehind(
const SkRect*);
2557 void internalConcat44(
const SkM44&);
2560 void internalSave();
2561 void internalRestore();
2563 enum class DeviceCompatibleWithFilter :
bool {
2584 DeviceCompatibleWithFilter compat,
2587 bool srcIsCoverageLayer =
false);
2594 bool wouldOverwriteEntireSurface(
const SkRect*,
const SkPaint*,
2601 bool androidFramework_isClipAA()
const;
2608 void internal_private_resetClip();
2614 SkRect fQuickRejectBounds;
2618 SkRect computeDeviceClipBounds(
bool outsetForAA=
true)
const;
2624 std::optional<AutoLayerForImageFilter> attemptBlurredRRectDraw(
const SkRRect&,
2628 class AutoUpdateQRBounds;
2629 void validateClip()
const;
2631 std::unique_ptr<sktext::GlyphRunBuilder> fScratchGlyphRunBuilder;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static float prev(float f)
@ kSrcOver
r = s + (1-sa)*d
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static bool left(const SkPoint &p0, const SkPoint &p1)
static SkScalar center(float pos0, float pos1)
SkAutoCanvasRestore(SkCanvas *canvas, bool doSave)
static std::unique_ptr< SkCanvas > MakeRasterDirectN32(int width, int height, SkPMColor *pixels, size_t rowBytes)
friend constexpr SkEnumBitMask< PredrawFlags > operator|(PredrawFlags, PredrawFlags)
void clipPath(const SkPath &path, bool doAntiAlias=false)
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
void drawArc(const SkArc &arc, const SkPaint &paint)
void drawPoint(SkPoint p, const SkPaint &paint)
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPicture(const sk_sp< SkPicture > &picture)
void clipRect(const SkRect &rect, SkClipOp op)
void clear(const SkColor4f &color)
SkMatrix getLocalToDeviceAs3x3() const
void drawString(const SkString &str, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
virtual void didScale(SkScalar, SkScalar)
virtual void didSetM44(const SkM44 &)
bool getLocalClipBounds(SkRect *bounds) const
virtual void didRestore()
void clipRRect(const SkRRect &rrect, SkClipOp op)
friend constexpr SkEnumBitMask< PredrawFlags > operator^(PredrawFlags, PredrawFlags)
virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &)
void clipPath(const SkPath &path, SkClipOp op)
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
void clipRect(const SkRect &rect, bool doAntiAlias=false)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
int saveLayer(const SkRect &bounds, 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)
@ kFullLayer_SaveLayerStrategy
@ kNoLayer_SaveLayerStrategy
void drawIRect(const SkIRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SrcRectConstraint constraint)
bool getDeviceClipBounds(SkIRect *bounds) const
virtual void willRestore()
friend constexpr SkEnumBitMask< PredrawFlags > operator~(PredrawFlags)
virtual SkPaintFilterCanvas * internal_private_asPaintFilterCanvas() const
void restoreToCount(int saveCount)
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, SkColor color, SkBlendMode mode)
virtual void didTranslate(SkScalar, SkScalar)
void drawImage(const sk_sp< SkImage > &image, SkScalar left, SkScalar top)
void drawPicture(const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint)
void clipRRect(const SkRRect &rrect, bool doAntiAlias=false)
friend constexpr SkEnumBitMask< PredrawFlags > operator&(PredrawFlags, PredrawFlags)
virtual void didConcat44(const SkM44 &)
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst)
void drawCircle(SkPoint center, SkScalar radius, const SkPaint &paint)
void drawImage(const sk_sp< SkImage > &image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
virtual bool onDoSaveBehind(const SkRect *)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void drawPicture(const SkPicture *picture)
void drawLine(SkPoint p0, SkPoint p1, const SkPaint &paint)
void drawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const SkPaint &paint)
@ kLines_PointMode
draw each pair of points as a line segment
@ kPolygon_PointMode
draw the array of points as a open polygon
@ kPoints_PointMode
draw each point separately
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
void drawAnnotation(const SkRect &rect, const char key[], const sk_sp< SkData > &value)
constexpr bool empty() const
constexpr size_t size() const
const char * c_str() const
FlutterSemanticsFlag flags
static void drawPath(SkPath &path, SkCanvas *canvas, SkColor color, const SkRect &clip, SkPaint::Cap cap, SkPaint::Join join, SkPaint::Style style, SkPathFillType fill, SkScalar strokeWidth)
experimental_DrawEdgeAAImageSet(r.set.get(), r.count, r.dstClips, r.preViewMatrices, r.sampling, r.paint, r.constraint)) template<> void Draw
clipRRect(r.rrect, r.opAA.op(), r.opAA.aa())) DRAW(ClipRect
SkCanvas::SaveLayerFlags saveLayerFlags
drawTextBlob(r.blob.get(), r.x, r.y, r.paint)) DRAW(DrawSlug
sk_sp< const SkImage > atlas
unsigned useCenter Optional< SkMatrix > matrix
drawSlug(r.slug.get(), r.paint)) DRAW(DrawAtlas
Optional< SkRect > bounds
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
PODArray< SkPoint > dstClips
drawAnnotation(r.rect, r.key.c_str(), r.value.get())) DRAW(DrawEdgeAAQuad
sk_sp< const SkImage > image
ClipOpAndAA opAA SkRegion region
sk_sp< const SkPicture > picture
clipPath(r.path, r.opAA.op(), r.opAA.aa())) DRAW(ClipRRect
sk_sp< const SkImageFilter > backdrop
experimental_DrawEdgeAAQuad(r.rect, r.clip, r.aa, r.color, r.mode)) DRAW(DrawEdgeAAImageSet
drawPicture(r.picture.get(), &r.matrix, r.paint)) DRAW(DrawTextBlob
PODArray< SkRSXform > xforms
sk_sp< SkBlender > blender SkRect rect
PODArray< SkMatrix > preViewMatrices
drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.sampling, r.cull, r.paint)) DRAW(DrawAnnotation
PODArray< SkColor > colors
SkSamplingOptions sampling
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
DlCanvas::PointMode PointMode
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))
ImageSetEntry(const ImageSetEntry &)
ImageSetEntry & operator=(const ImageSetEntry &)
sk_sp< const SkImage > fImage
int fYCount
number of y-coordinates
const SkIRect * fBounds
source bounds to draw from
@ kFixedColor
draws one of fColors into lattice rectangle
@ kTransparent
skips lattice rectangle by making it transparent
const int * fYDivs
y-axis values dividing bitmap
int fXCount
number of x-coordinates
const RectType * fRectTypes
array of fill types
const SkColor * fColors
array of colors
const int * fXDivs
x-axis values dividing bitmap
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, SaveLayerFlags saveLayerFlags=0)
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SaveLayerFlags saveLayerFlags)
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, const SkColorSpace *colorSpace, SaveLayerFlags saveLayerFlags)
static constexpr SkIRect MakeEmpty()
static SkImageInfo MakeN32Premul(int width, int height)
constexpr float y() const
constexpr float x() const
static SkRect Make(const SkISize &size)
void set(const SkIRect &src)