Flutter Engine
The Flutter Engine
Functions
canvas.cpp File Reference
#include "export.h"
#include "helpers.h"
#include "wrappers.h"
#include "third_party/skia/include/core/SkPoint3.h"
#include "third_party/skia/include/core/SkVertices.h"
#include "third_party/skia/include/utils/SkShadowUtils.h"
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"

Go to the source code of this file.

Functions

SKWASM_EXPORT void canvas_saveLayer (SkCanvas *canvas, SkRect *rect, SkPaint *paint, SkImageFilter *backdrop)
 
SKWASM_EXPORT void canvas_save (SkCanvas *canvas)
 
SKWASM_EXPORT void canvas_restore (SkCanvas *canvas)
 
SKWASM_EXPORT void canvas_restoreToCount (SkCanvas *canvas, int count)
 
SKWASM_EXPORT int canvas_getSaveCount (SkCanvas *canvas)
 
SKWASM_EXPORT void canvas_translate (SkCanvas *canvas, SkScalar dx, SkScalar dy)
 
SKWASM_EXPORT void canvas_scale (SkCanvas *canvas, SkScalar sx, SkScalar sy)
 
SKWASM_EXPORT void canvas_rotate (SkCanvas *canvas, SkScalar degrees)
 
SKWASM_EXPORT void canvas_skew (SkCanvas *canvas, SkScalar sx, SkScalar sy)
 
SKWASM_EXPORT void canvas_transform (SkCanvas *canvas, const SkM44 *matrix44)
 
SKWASM_EXPORT void canvas_clipRect (SkCanvas *canvas, const SkRect *rect, SkClipOp op, bool antialias)
 
SKWASM_EXPORT void canvas_clipRRect (SkCanvas *canvas, const SkScalar *rrectValues, bool antialias)
 
SKWASM_EXPORT void canvas_clipPath (SkCanvas *canvas, SkPath *path, bool antialias)
 
SKWASM_EXPORT void canvas_drawColor (SkCanvas *canvas, SkColor color, SkBlendMode blendMode)
 
SKWASM_EXPORT void canvas_drawLine (SkCanvas *canvas, SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawPaint (SkCanvas *canvas, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawRect (SkCanvas *canvas, SkRect *rect, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawRRect (SkCanvas *canvas, const SkScalar *rrectValues, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawDRRect (SkCanvas *canvas, const SkScalar *outerRrectValues, const SkScalar *innerRrectValues, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawOval (SkCanvas *canvas, const SkRect *rect, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawCircle (SkCanvas *canvas, SkScalar x, SkScalar y, SkScalar radius, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawArc (SkCanvas *canvas, const SkRect *rect, SkScalar startAngleDegrees, SkScalar sweepAngleDegrees, bool useCenter, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawPath (SkCanvas *canvas, SkPath *path, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawShadow (SkCanvas *canvas, SkPath *path, SkScalar elevation, SkScalar devicePixelRatio, SkColor color, bool transparentOccluder)
 
SKWASM_EXPORT void canvas_drawParagraph (SkCanvas *canvas, Paragraph *paragraph, SkScalar x, SkScalar y)
 
SKWASM_EXPORT void canvas_drawPicture (SkCanvas *canvas, SkPicture *picture)
 
SKWASM_EXPORT void canvas_drawImage (SkCanvas *canvas, SkImage *image, SkScalar offsetX, SkScalar offsetY, SkPaint *paint, FilterQuality quality)
 
SKWASM_EXPORT void canvas_drawImageRect (SkCanvas *canvas, SkImage *image, SkRect *sourceRect, SkRect *destRect, SkPaint *paint, FilterQuality quality)
 
SKWASM_EXPORT void canvas_drawImageNine (SkCanvas *canvas, SkImage *image, SkIRect *centerRect, SkRect *destinationRect, SkPaint *paint, FilterQuality quality)
 
SKWASM_EXPORT void canvas_drawVertices (SkCanvas *canvas, SkVertices *vertices, SkBlendMode mode, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawPoints (SkCanvas *canvas, SkCanvas::PointMode mode, SkPoint *points, int pointCount, SkPaint *paint)
 
SKWASM_EXPORT void canvas_drawAtlas (SkCanvas *canvas, SkImage *atlas, SkRSXform *transforms, SkRect *rects, SkColor *colors, int spriteCount, SkBlendMode mode, SkRect *cullRect, SkPaint *paint)
 
SKWASM_EXPORT void canvas_getTransform (SkCanvas *canvas, SkM44 *outTransform)
 
SKWASM_EXPORT void canvas_getLocalClipBounds (SkCanvas *canvas, SkRect *outRect)
 
SKWASM_EXPORT void canvas_getDeviceClipBounds (SkCanvas *canvas, SkIRect *outRect)
 

Function Documentation

◆ canvas_clipPath()

SKWASM_EXPORT void canvas_clipPath ( SkCanvas canvas,
SkPath path,
bool  antialias 
)

Definition at line 91 of file canvas.cpp.

93 {
94 canvas->clipPath(*path, antialias);
95}
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
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
Definition: switches.h:57

◆ canvas_clipRect()

SKWASM_EXPORT void canvas_clipRect ( SkCanvas canvas,
const SkRect rect,
SkClipOp  op,
bool  antialias 
)

Definition at line 78 of file canvas.cpp.

81 {
82 canvas->clipRect(*rect, op, antialias);
83}
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ canvas_clipRRect()

SKWASM_EXPORT void canvas_clipRRect ( SkCanvas canvas,
const SkScalar rrectValues,
bool  antialias 
)

Definition at line 85 of file canvas.cpp.

87 {
88 canvas->clipRRect(createRRect(rrectValues), antialias);
89}
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
SkRRect createRRect(const SkScalar *f)
Definition: helpers.h:19

◆ canvas_drawArc()

SKWASM_EXPORT void canvas_drawArc ( SkCanvas canvas,
const SkRect rect,
SkScalar  startAngleDegrees,
SkScalar  sweepAngleDegrees,
bool  useCenter,
SkPaint paint 
)

Definition at line 150 of file canvas.cpp.

155 {
156 canvas->drawArc(*rect, startAngleDegrees, sweepAngleDegrees, useCenter,
157 *paint);
158}
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition: SkCanvas.cpp:2728
const Paint & paint
Definition: color_source.cc:38

◆ canvas_drawAtlas()

SKWASM_EXPORT void canvas_drawAtlas ( SkCanvas canvas,
SkImage atlas,
SkRSXform transforms,
SkRect rects,
SkColor colors,
int  spriteCount,
SkBlendMode  mode,
SkRect cullRect,
SkPaint paint 
)

Definition at line 246 of file canvas.cpp.

254 {
255 canvas->drawAtlas(
256 atlas, transforms, rects, colors, spriteCount, mode,
258 paint);
259}
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)
Definition: SkCanvas.cpp:1810
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
PODArray< SkColor > colors
Definition: SkRecords.h:276
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
Definition: switches.h:228

◆ canvas_drawCircle()

SKWASM_EXPORT void canvas_drawCircle ( SkCanvas canvas,
SkScalar  x,
SkScalar  y,
SkScalar  radius,
SkPaint paint 
)

Definition at line 142 of file canvas.cpp.

146 {
147 canvas->drawCircle(x, y, radius, *paint);
148}
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
double y
double x

◆ canvas_drawColor()

SKWASM_EXPORT void canvas_drawColor ( SkCanvas canvas,
SkColor  color,
SkBlendMode  blendMode 
)

Definition at line 97 of file canvas.cpp.

99 {
100 canvas->drawColor(color, blendMode);
101}
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
DlColor color

◆ canvas_drawDRRect()

SKWASM_EXPORT void canvas_drawDRRect ( SkCanvas canvas,
const SkScalar outerRrectValues,
const SkScalar innerRrectValues,
SkPaint paint 
)

Definition at line 128 of file canvas.cpp.

131 {
132 canvas->drawDRRect(createRRect(outerRrectValues),
133 createRRect(innerRrectValues), *paint);
134}
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Definition: SkCanvas.cpp:1645

◆ canvas_drawImage()

SKWASM_EXPORT void canvas_drawImage ( SkCanvas canvas,
SkImage image,
SkScalar  offsetX,
SkScalar  offsetY,
SkPaint paint,
FilterQuality  quality 
)

Definition at line 200 of file canvas.cpp.

205 {
207 paint);
208}
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions samplingOptionsForQuality(FilterQuality quality)
Definition: helpers.h:47
SkScalar offsetX
SkScalar offsetY

◆ canvas_drawImageNine()

SKWASM_EXPORT void canvas_drawImageNine ( SkCanvas canvas,
SkImage image,
SkIRect centerRect,
SkRect destinationRect,
SkPaint paint,
FilterQuality  quality 
)

Definition at line 221 of file canvas.cpp.

226 {
227 canvas->drawImageNine(image, *centerRect, *destinationRect,
228 filterModeForQuality(quality), paint);
229}
void drawImageNine(const SkImage *image, const SkIRect &center, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Definition: SkCanvas.cpp:1769
SkFilterMode filterModeForQuality(FilterQuality quality)
Definition: helpers.h:36

◆ canvas_drawImageRect()

SKWASM_EXPORT void canvas_drawImageRect ( SkCanvas canvas,
SkImage image,
SkRect sourceRect,
SkRect destRect,
SkPaint paint,
FilterQuality  quality 
)

Definition at line 210 of file canvas.cpp.

215 {
216 canvas->drawImageRect(image, *sourceRect, *destRect,
219}
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333

◆ canvas_drawLine()

SKWASM_EXPORT void canvas_drawLine ( SkCanvas canvas,
SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkPaint paint 
)

Definition at line 103 of file canvas.cpp.

108 {
109 canvas->drawLine(x1, y1, x2, y2, *paint);
110}
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700

◆ canvas_drawOval()

SKWASM_EXPORT void canvas_drawOval ( SkCanvas canvas,
const SkRect rect,
SkPaint paint 
)

Definition at line 136 of file canvas.cpp.

138 {
139 canvas->drawOval(*rect, *paint);
140}
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698

◆ canvas_drawPaint()

SKWASM_EXPORT void canvas_drawPaint ( SkCanvas canvas,
SkPaint paint 
)

Definition at line 112 of file canvas.cpp.

112 {
113 canvas->drawPaint(*paint);
114}
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668

◆ canvas_drawParagraph()

SKWASM_EXPORT void canvas_drawParagraph ( SkCanvas canvas,
Paragraph paragraph,
SkScalar  x,
SkScalar  y 
)

Definition at line 189 of file canvas.cpp.

192 {
193 paragraph->paint(canvas, x, y);
194}
virtual void paint(SkCanvas *canvas, SkScalar x, SkScalar y)=0

◆ canvas_drawPath()

SKWASM_EXPORT void canvas_drawPath ( SkCanvas canvas,
SkPath path,
SkPaint paint 
)

Definition at line 160 of file canvas.cpp.

162 {
163 canvas->drawPath(*path, *paint);
164}
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747

◆ canvas_drawPicture()

SKWASM_EXPORT void canvas_drawPicture ( SkCanvas canvas,
SkPicture picture 
)

Definition at line 196 of file canvas.cpp.

196 {
197 canvas->drawPicture(picture);
198}
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299

◆ canvas_drawPoints()

SKWASM_EXPORT void canvas_drawPoints ( SkCanvas canvas,
SkCanvas::PointMode  mode,
SkPoint points,
int  pointCount,
SkPaint paint 
)

Definition at line 238 of file canvas.cpp.

242 {
243 canvas->drawPoints(mode, pointCount, points, *paint);
244}
static const int points[]
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710

◆ canvas_drawRect()

SKWASM_EXPORT void canvas_drawRect ( SkCanvas canvas,
SkRect rect,
SkPaint paint 
)

Definition at line 116 of file canvas.cpp.

118 {
119 canvas->drawRect(*rect, *paint);
120}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673

◆ canvas_drawRRect()

SKWASM_EXPORT void canvas_drawRRect ( SkCanvas canvas,
const SkScalar rrectValues,
SkPaint paint 
)

Definition at line 122 of file canvas.cpp.

124 {
125 canvas->drawRRect(createRRect(rrectValues), *paint);
126}
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705

◆ canvas_drawShadow()

SKWASM_EXPORT void canvas_drawShadow ( SkCanvas canvas,
SkPath path,
SkScalar  elevation,
SkScalar  devicePixelRatio,
SkColor  color,
bool  transparentOccluder 
)

Definition at line 166 of file canvas.cpp.

171 {
172 SkColor inAmbient =
173 SkColorSetA(color, kShadowAmbientAlpha * SkColorGetA(color));
174 SkColor inSpot = SkColorSetA(color, kShadowSpotAlpha * SkColorGetA(color));
175 SkColor outAmbient;
176 SkColor outSpot;
177 SkShadowUtils::ComputeTonalColors(inAmbient, inSpot, &outAmbient, &outSpot);
178 uint32_t flags = transparentOccluder
183 canvas, *path, SkPoint3::Make(0.0f, 0.0f, elevation * devicePixelRatio),
184 SkPoint3::Make(kShadowLightXOffset, kShadowLightYOffset,
185 kShadowLightHeight * devicePixelRatio),
186 devicePixelRatio * kShadowLightRadius, outAmbient, outSpot, flags);
187}
uint32_t SkColor
Definition: SkColor.h:37
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
Definition: SkColor.h:82
#define SkColorGetA(color)
Definition: SkColor.h:61
@ kDirectionalLight_ShadowFlag
Definition: SkShadowUtils.h:31
@ kTransparentOccluder_ShadowFlag
Definition: SkShadowUtils.h:27
@ kNone_ShadowFlag
Definition: SkShadowUtils.h:24
static void DrawShadow(SkCanvas *canvas, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, SkColor ambientColor, SkColor spotColor, uint32_t flags=SkShadowFlags::kNone_ShadowFlag)
static void ComputeTonalColors(SkColor inAmbientColor, SkColor inSpotColor, SkColor *outAmbientColor, SkColor *outSpotColor)
FlutterSemanticsFlag flags
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18

◆ canvas_drawVertices()

SKWASM_EXPORT void canvas_drawVertices ( SkCanvas canvas,
SkVertices vertices,
SkBlendMode  mode,
SkPaint paint 
)

Definition at line 231 of file canvas.cpp.

234 {
235 canvas->drawVertices(sk_ref_sp<SkVertices>(vertices), mode, *paint);
236}
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:1720

◆ canvas_getDeviceClipBounds()

SKWASM_EXPORT void canvas_getDeviceClipBounds ( SkCanvas canvas,
SkIRect outRect 
)

Definition at line 270 of file canvas.cpp.

271 {
272 *outRect = canvas->getDeviceClipBounds();
273}
SkIRect getDeviceClipBounds() const
Definition: SkCanvas.cpp:1607

◆ canvas_getLocalClipBounds()

SKWASM_EXPORT void canvas_getLocalClipBounds ( SkCanvas canvas,
SkRect outRect 
)

Definition at line 265 of file canvas.cpp.

266 {
267 *outRect = canvas->getLocalClipBounds();
268}
SkRect getLocalClipBounds() const
Definition: SkCanvas.cpp:1586

◆ canvas_getSaveCount()

SKWASM_EXPORT int canvas_getSaveCount ( SkCanvas canvas)

Definition at line 52 of file canvas.cpp.

52 {
53 return canvas->getSaveCount();
54}
int getSaveCount() const
Definition: SkCanvas.cpp:431

◆ canvas_getTransform()

SKWASM_EXPORT void canvas_getTransform ( SkCanvas canvas,
SkM44 outTransform 
)

Definition at line 261 of file canvas.cpp.

261 {
262 *outTransform = canvas->getLocalToDevice();
263}
SkM44 getLocalToDevice() const
Definition: SkCanvas.cpp:1633

◆ canvas_restore()

SKWASM_EXPORT void canvas_restore ( SkCanvas canvas)

Definition at line 44 of file canvas.cpp.

44 {
45 canvas->restore();
46}
void restore()
Definition: SkCanvas.cpp:461

◆ canvas_restoreToCount()

SKWASM_EXPORT void canvas_restoreToCount ( SkCanvas canvas,
int  count 
)

Definition at line 48 of file canvas.cpp.

48 {
49 canvas->restoreToCount(count);
50}
int count
Definition: FontMgrTest.cpp:50
void restoreToCount(int saveCount)
Definition: SkCanvas.cpp:478

◆ canvas_rotate()

SKWASM_EXPORT void canvas_rotate ( SkCanvas canvas,
SkScalar  degrees 
)

Definition at line 66 of file canvas.cpp.

66 {
67 canvas->rotate(degrees);
68}
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300

◆ canvas_save()

SKWASM_EXPORT void canvas_save ( SkCanvas canvas)

Definition at line 40 of file canvas.cpp.

40 {
41 canvas->save();
42}
int save()
Definition: SkCanvas.cpp:447

◆ canvas_saveLayer()

SKWASM_EXPORT void canvas_saveLayer ( SkCanvas canvas,
SkRect rect,
SkPaint paint,
SkImageFilter backdrop 
)

Definition at line 33 of file canvas.cpp.

36 {
38}
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191

◆ canvas_scale()

SKWASM_EXPORT void canvas_scale ( SkCanvas canvas,
SkScalar  sx,
SkScalar  sy 
)

Definition at line 62 of file canvas.cpp.

62 {
63 canvas->scale(sx, sy);
64}
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289

◆ canvas_skew()

SKWASM_EXPORT void canvas_skew ( SkCanvas canvas,
SkScalar  sx,
SkScalar  sy 
)

Definition at line 70 of file canvas.cpp.

70 {
71 canvas->skew(sx, sy);
72}
void skew(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1312

◆ canvas_transform()

SKWASM_EXPORT void canvas_transform ( SkCanvas canvas,
const SkM44 matrix44 
)

Definition at line 74 of file canvas.cpp.

74 {
75 canvas->concat(*matrix44);
76}
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318

◆ canvas_translate()

SKWASM_EXPORT void canvas_translate ( SkCanvas canvas,
SkScalar  dx,
SkScalar  dy 
)

Definition at line 56 of file canvas.cpp.

58 {
59 canvas->translate(dx, dy);
60}
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208