Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::Canvas Class Reference

#include <canvas.h>

Inheritance diagram for flutter::Canvas:
flutter::RefCountedDartWrappable< Canvas > flutter::DisplayListOpFlags fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~Canvas () override
 
void save ()
 
void saveLayerWithoutBounds (Dart_Handle paint_objects, Dart_Handle paint_data)
 
void saveLayer (double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void restore ()
 
int getSaveCount ()
 
void restoreToCount (int count)
 
void translate (double dx, double dy)
 
void scale (double sx, double sy)
 
void rotate (double radians)
 
void skew (double sx, double sy)
 
void transform (const tonic::Float64List &matrix4)
 
void getTransform (Dart_Handle matrix4_handle)
 
void clipRect (double left, double top, double right, double bottom, DlCanvas::ClipOp clipOp, bool doAntiAlias=true)
 
void clipRRect (const RRect &rrect, bool doAntiAlias=true)
 
void clipPath (const CanvasPath *path, bool doAntiAlias=true)
 
void getDestinationClipBounds (Dart_Handle rect_handle)
 
void getLocalClipBounds (Dart_Handle rect_handle)
 
void drawColor (SkColor color, DlBlendMode blend_mode)
 
void drawLine (double x1, double y1, double x2, double y2, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawPaint (Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawRect (double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawRRect (const RRect &rrect, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawDRRect (const RRect &outer, const RRect &inner, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawOval (double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawCircle (double x, double y, double radius, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawArc (double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool useCenter, Dart_Handle paint_objects, Dart_Handle paint_data)
 
void drawPath (const CanvasPath *path, Dart_Handle paint_objects, Dart_Handle paint_data)
 
Dart_Handle drawImage (const CanvasImage *image, double x, double y, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
 
Dart_Handle drawImageRect (const CanvasImage *image, double src_left, double src_top, double src_right, double src_bottom, double dst_left, double dst_top, double dst_right, double dst_bottom, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
 
Dart_Handle drawImageNine (const CanvasImage *image, double center_left, double center_top, double center_right, double center_bottom, double dst_left, double dst_top, double dst_right, double dst_bottom, Dart_Handle paint_objects, Dart_Handle paint_data, int bitmapSamplingIndex)
 
void drawPicture (Picture *picture)
 
void drawPoints (Dart_Handle paint_objects, Dart_Handle paint_data, DlCanvas::PointMode point_mode, const tonic::Float32List &points)
 
void drawVertices (const Vertices *vertices, DlBlendMode blend_mode, Dart_Handle paint_objects, Dart_Handle paint_data)
 
Dart_Handle drawAtlas (Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex, CanvasImage *atlas, Dart_Handle transforms_handle, Dart_Handle rects_handle, Dart_Handle colors_handle, DlBlendMode blend_mode, Dart_Handle cull_rect_handle)
 
void drawShadow (const CanvasPath *path, SkColor color, double elevation, bool transparentOccluder)
 
void Invalidate ()
 
DisplayListBuilderbuilder ()
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Canvas >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static void Create (Dart_Handle wrapper, PictureRecorder *recorder, double left, double top, double right, double bottom)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 21 of file canvas.h.

Constructor & Destructor Documentation

◆ ~Canvas()

flutter::Canvas::~Canvas ( )
override

Definition at line 48 of file canvas.cc.

48{}

Member Function Documentation

◆ builder()

DisplayListBuilder * flutter::Canvas::builder ( )
inline

Definition at line 189 of file canvas.h.

189{ return display_list_builder_.get(); }

◆ clipPath()

void flutter::Canvas::clipPath ( const CanvasPath path,
bool  doAntiAlias = true 
)

Definition at line 181 of file canvas.cc.

181 {
182 if (!path) {
184 ToDart("Canvas.clipPath called with non-genuine Path."));
185 return;
186 }
187 if (display_list_builder_) {
189 doAntiAlias);
190 }
191}
DisplayListBuilder * builder()
Definition canvas.h:189
void ClipPath(const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
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
Dart_Handle ToDart(const T &object)

◆ clipRect()

void flutter::Canvas::clipRect ( double  left,
double  top,
double  right,
double  bottom,
DlCanvas::ClipOp  clipOp,
bool  doAntiAlias = true 
)

Definition at line 161 of file canvas.cc.

166 {
167 if (display_list_builder_) {
169 SafeNarrow(right), SafeNarrow(bottom)),
170 clipOp, doAntiAlias);
171 }
172}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
void ClipRect(const SkRect &rect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
static float SafeNarrow(double value)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

◆ clipRRect()

void flutter::Canvas::clipRRect ( const RRect rrect,
bool  doAntiAlias = true 
)

Definition at line 174 of file canvas.cc.

174 {
175 if (display_list_builder_) {
177 doAntiAlias);
178 }
179}
void ClipRRect(const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
SkRRect rrect
Definition SkRecords.h:232

◆ Create()

void flutter::Canvas::Create ( Dart_Handle  wrapper,
PictureRecorder recorder,
double  left,
double  top,
double  right,
double  bottom 
)
static

Definition at line 23 of file canvas.cc.

28 {
30
31 if (!recorder) {
33 ToDart("Canvas constructor called with non-genuine PictureRecorder."));
34 return;
35 }
36
37 fml::RefPtr<Canvas> canvas =
38 fml::MakeRefCounted<Canvas>(recorder->BeginRecording(
40 SafeNarrow(bottom))));
41 recorder->set_canvas(canvas);
42 canvas->AssociateWithDartWrapper(wrapper);
43}
static void ThrowIfUIOperationsProhibited()

◆ drawArc()

void flutter::Canvas::drawArc ( double  left,
double  top,
double  right,
double  bottom,
double  startAngle,
double  sweepAngle,
bool  useCenter,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 335 of file canvas.cc.

343 {
344 Paint paint(paint_objects, paint_data);
345
346 FML_DCHECK(paint.isNotNull());
347 if (display_list_builder_) {
348 DlPaint dl_paint;
349 paint.paint(dl_paint, useCenter //
352 builder()->DrawArc(
354 SafeNarrow(bottom)),
355 SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
356 SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI), useCenter,
357 dl_paint);
358 }
359}
#define M_PI
void DrawArc(const SkRect &bounds, SkScalar start, SkScalar sweep, bool useCenter, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawArcWithCenterFlags
static constexpr DisplayListAttributeFlags kDrawArcNoCenterFlags
const Paint & paint
#define FML_DCHECK(condition)
Definition logging.h:103

◆ drawAtlas()

Dart_Handle flutter::Canvas::drawAtlas ( Dart_Handle  paint_objects,
Dart_Handle  paint_data,
int  filterQualityIndex,
CanvasImage atlas,
Dart_Handle  transforms_handle,
Dart_Handle  rects_handle,
Dart_Handle  colors_handle,
DlBlendMode  blend_mode,
Dart_Handle  cull_rect_handle 
)

Definition at line 562 of file canvas.cc.

570 {
571 Paint paint(paint_objects, paint_data);
572
573 if (!atlas) {
574 return ToDart(
575 "Canvas.drawAtlas or Canvas.drawRawAtlas called with "
576 "non-genuine Image.");
577 }
578
579 auto dl_image = atlas->image();
580 auto error = dl_image->get_error();
581 if (error) {
582 return ToDart(error.value());
583 }
584
585 static_assert(sizeof(SkRSXform) == sizeof(float) * 4,
586 "SkRSXform doesn't use floats.");
587 static_assert(sizeof(SkRect) == sizeof(float) * 4,
588 "SkRect doesn't use floats.");
589
590 auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
591
592 FML_DCHECK(paint.isNotNull());
593 if (display_list_builder_) {
594 tonic::Float32List transforms(transforms_handle);
595 tonic::Float32List rects(rects_handle);
596 tonic::Int32List colors(colors_handle);
597 tonic::Float32List cull_rect(cull_rect_handle);
598
599 DlPaint dl_paint;
600 const DlPaint* opt_paint = paint.paint(dl_paint, kDrawAtlasWithPaintFlags);
602 dl_image, reinterpret_cast<const SkRSXform*>(transforms.data()),
603 reinterpret_cast<const SkRect*>(rects.data()),
604 reinterpret_cast<const DlColor*>(colors.data()),
605 rects.num_elements() / 4, // SkRect have four floats.
606 blend_mode, sampling, reinterpret_cast<const SkRect*>(cull_rect.data()),
607 opt_paint);
608 }
609 return Dart_Null();
610}
void DrawAtlas(const sk_sp< DlImage > &atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cullRect, const DlPaint *paint=nullptr) override
static constexpr DisplayListAttributeFlags kDrawAtlasWithPaintFlags
static DlImageSampling SamplingFromIndex(int filterQualityIndex)
DART_EXPORT Dart_Handle Dart_Null(void)
const uint8_t uint32_t uint32_t GError ** error
sk_sp< const SkImage > atlas
Definition SkRecords.h:331
PODArray< SkColor > colors
Definition SkRecords.h:276
SkSamplingOptions sampling
Definition SkRecords.h:337

◆ drawCircle()

void flutter::Canvas::drawCircle ( double  x,
double  y,
double  radius,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 319 of file canvas.cc.

323 {
324 Paint paint(paint_objects, paint_data);
325
326 FML_DCHECK(paint.isNotNull());
327 if (display_list_builder_) {
328 DlPaint dl_paint;
329 paint.paint(dl_paint, kDrawCircleFlags);
331 SafeNarrow(radius), dl_paint);
332 }
333}
void DrawCircle(const SkPoint &center, SkScalar radius, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawCircleFlags
double y
double x
static constexpr SkPoint Make(float x, float y)

◆ drawColor()

void flutter::Canvas::drawColor ( SkColor  color,
DlBlendMode  blend_mode 
)

Definition at line 215 of file canvas.cc.

215 {
216 if (display_list_builder_) {
217 builder()->DrawColor(DlColor(color), blend_mode);
218 }
219}
SkColor4f color
void DrawColor(DlColor color, DlBlendMode mode) override

◆ drawDRRect()

void flutter::Canvas::drawDRRect ( const RRect outer,
const RRect inner,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 287 of file canvas.cc.

290 {
291 Paint paint(paint_objects, paint_data);
292
293 FML_DCHECK(paint.isNotNull());
294 if (display_list_builder_) {
295 DlPaint dl_paint;
296 paint.paint(dl_paint, kDrawDRRectFlags);
297 builder()->DrawDRRect(outer.sk_rrect, inner.sk_rrect, dl_paint);
298 }
299}
void DrawDRRect(const SkRRect &outer, const SkRRect &inner, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawDRRectFlags

◆ drawImage()

Dart_Handle flutter::Canvas::drawImage ( const CanvasImage image,
double  x,
double  y,
Dart_Handle  paint_objects,
Dart_Handle  paint_data,
int  filterQualityIndex 
)

Definition at line 379 of file canvas.cc.

384 {
385 Paint paint(paint_objects, paint_data);
386
387 FML_DCHECK(paint.isNotNull());
388 if (!image) {
389 return ToDart("Canvas.drawImage called with non-genuine Image.");
390 }
391
392 auto dl_image = image->image();
393 if (!dl_image) {
394 return Dart_Null();
395 }
396 auto error = dl_image->get_error();
397 if (error) {
398 return ToDart(error.value());
399 }
400
401 auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
402 if (display_list_builder_) {
403 DlPaint dl_paint;
404 const DlPaint* opt_paint = paint.paint(dl_paint, kDrawImageWithPaintFlags);
406 sampling, opt_paint);
407 }
408 return Dart_Null();
409}
void DrawImage(const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
static constexpr DisplayListAttributeFlags kDrawImageWithPaintFlags
sk_sp< SkImage > image
Definition examples.cpp:29

◆ drawImageNine()

Dart_Handle flutter::Canvas::drawImageNine ( const CanvasImage image,
double  center_left,
double  center_top,
double  center_right,
double  center_bottom,
double  dst_left,
double  dst_top,
double  dst_right,
double  dst_bottom,
Dart_Handle  paint_objects,
Dart_Handle  paint_data,
int  bitmapSamplingIndex 
)

Definition at line 454 of file canvas.cc.

465 {
466 Paint paint(paint_objects, paint_data);
467
468 FML_DCHECK(paint.isNotNull());
469 if (!image) {
470 return ToDart("Canvas.drawImageNine called with non-genuine Image.");
471 }
472 auto dl_image = image->image();
473 if (!dl_image) {
474 return Dart_Null();
475 }
476 auto error = dl_image->get_error();
477 if (error) {
478 return ToDart(error.value());
479 }
480
481 SkRect center =
482 SkRect::MakeLTRB(SafeNarrow(center_left), SafeNarrow(center_top),
483 SafeNarrow(center_right), SafeNarrow(center_bottom));
484 SkIRect icenter;
485 center.round(&icenter);
486 SkRect dst = SkRect::MakeLTRB(SafeNarrow(dst_left), SafeNarrow(dst_top),
487 SafeNarrow(dst_right), SafeNarrow(dst_bottom));
488 auto filter = ImageFilter::FilterModeFromIndex(bitmapSamplingIndex);
489 if (display_list_builder_) {
490 DlPaint dl_paint;
491 const DlPaint* opt_paint =
492 paint.paint(dl_paint, kDrawImageNineWithPaintFlags);
493 builder()->DrawImageNine(dl_image, icenter, dst, filter, opt_paint);
494 }
495 return Dart_Null();
496}
static SkScalar center(float pos0, float pos1)
void DrawImageNine(const sk_sp< DlImage > &image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, const DlPaint *paint=nullptr) override
static constexpr DisplayListAttributeFlags kDrawImageNineWithPaintFlags
static DlFilterMode FilterModeFromIndex(int index)
dst
Definition cp.py:12

◆ drawImageRect()

Dart_Handle flutter::Canvas::drawImageRect ( const CanvasImage image,
double  src_left,
double  src_top,
double  src_right,
double  src_bottom,
double  dst_left,
double  dst_top,
double  dst_right,
double  dst_bottom,
Dart_Handle  paint_objects,
Dart_Handle  paint_data,
int  filterQualityIndex 
)

Definition at line 411 of file canvas.cc.

422 {
423 Paint paint(paint_objects, paint_data);
424
425 FML_DCHECK(paint.isNotNull());
426 if (!image) {
427 return ToDart("Canvas.drawImageRect called with non-genuine Image.");
428 }
429
430 auto dl_image = image->image();
431 if (!dl_image) {
432 return Dart_Null();
433 }
434 auto error = dl_image->get_error();
435 if (error) {
436 return ToDart(error.value());
437 }
438
439 SkRect src = SkRect::MakeLTRB(SafeNarrow(src_left), SafeNarrow(src_top),
440 SafeNarrow(src_right), SafeNarrow(src_bottom));
441 SkRect dst = SkRect::MakeLTRB(SafeNarrow(dst_left), SafeNarrow(dst_top),
442 SafeNarrow(dst_right), SafeNarrow(dst_bottom));
443 auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
444 if (display_list_builder_) {
445 DlPaint dl_paint;
446 const DlPaint* opt_paint =
447 paint.paint(dl_paint, kDrawImageRectWithPaintFlags);
448 builder()->DrawImageRect(dl_image, src, dst, sampling, opt_paint,
450 }
451 return Dart_Null();
452}
void DrawImageRect(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast) override
static constexpr DisplayListAttributeFlags kDrawImageRectWithPaintFlags

◆ drawLine()

void flutter::Canvas::drawLine ( double  x1,
double  y1,
double  x2,
double  y2,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 221 of file canvas.cc.

226 {
227 Paint paint(paint_objects, paint_data);
228
229 FML_DCHECK(paint.isNotNull());
230 if (display_list_builder_) {
231 DlPaint dl_paint;
232 paint.paint(dl_paint, kDrawLineFlags);
235 dl_paint);
236 }
237}
void DrawLine(const SkPoint &p0, const SkPoint &p1, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawLineFlags

◆ drawOval()

void flutter::Canvas::drawOval ( double  left,
double  top,
double  right,
double  bottom,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 301 of file canvas.cc.

306 {
307 Paint paint(paint_objects, paint_data);
308
309 FML_DCHECK(paint.isNotNull());
310 if (display_list_builder_) {
311 DlPaint dl_paint;
312 paint.paint(dl_paint, kDrawOvalFlags);
314 SafeNarrow(right), SafeNarrow(bottom)),
315 dl_paint);
316 }
317}
void DrawOval(const SkRect &bounds, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawOvalFlags

◆ drawPaint()

void flutter::Canvas::drawPaint ( Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 239 of file canvas.cc.

239 {
240 Paint paint(paint_objects, paint_data);
241
242 FML_DCHECK(paint.isNotNull());
243 if (display_list_builder_) {
244 DlPaint dl_paint;
245 paint.paint(dl_paint, kDrawPaintFlags);
246 std::shared_ptr<const DlImageFilter> filter = dl_paint.getImageFilter();
247 if (filter && !filter->asColorFilter()) {
248 // drawPaint does an implicit saveLayer if an SkImageFilter is
249 // present that cannot be replaced by an SkColorFilter.
250 TRACE_EVENT0("flutter", "ui.Canvas::saveLayer (Recorded)");
251 }
252 builder()->DrawPaint(dl_paint);
253 }
254}
void DrawPaint(const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawPaintFlags
#define TRACE_EVENT0(category_group, name)

◆ drawPath()

void flutter::Canvas::drawPath ( const CanvasPath path,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 361 of file canvas.cc.

363 {
364 Paint paint(paint_objects, paint_data);
365
366 FML_DCHECK(paint.isNotNull());
367 if (!path) {
369 ToDart("Canvas.drawPath called with non-genuine Path."));
370 return;
371 }
372 if (display_list_builder_) {
373 DlPaint dl_paint;
374 paint.paint(dl_paint, kDrawPathFlags);
375 builder()->DrawPath(path->path(), dl_paint);
376 }
377}
void DrawPath(const SkPath &path, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawPathFlags

◆ drawPicture()

void flutter::Canvas::drawPicture ( Picture picture)

Definition at line 498 of file canvas.cc.

498 {
499 if (!picture) {
501 ToDart("Canvas.drawPicture called with non-genuine Picture."));
502 return;
503 }
504 if (picture->display_list()) {
505 if (display_list_builder_) {
506 builder()->DrawDisplayList(picture->display_list());
507 }
508 } else {
509 FML_DCHECK(false);
510 }
511}
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
sk_sp< const SkPicture > picture
Definition SkRecords.h:299

◆ drawPoints()

void flutter::Canvas::drawPoints ( Dart_Handle  paint_objects,
Dart_Handle  paint_data,
DlCanvas::PointMode  point_mode,
const tonic::Float32List &  points 
)

Definition at line 513 of file canvas.cc.

516 {
517 Paint paint(paint_objects, paint_data);
518
519 static_assert(sizeof(SkPoint) == sizeof(float) * 2,
520 "SkPoint doesn't use floats.");
521
522 FML_DCHECK(paint.isNotNull());
523 if (display_list_builder_) {
524 DlPaint dl_paint;
525 switch (point_mode) {
527 paint.paint(dl_paint, kDrawPointsAsPointsFlags);
528 break;
530 paint.paint(dl_paint, kDrawPointsAsLinesFlags);
531 break;
533 paint.paint(dl_paint, kDrawPointsAsPolygonFlags);
534 break;
535 }
536 builder()->DrawPoints(point_mode,
537 points.num_elements() / 2, // SkPoints have 2 floats
538 reinterpret_cast<const SkPoint*>(points.data()),
539 dl_paint);
540 }
541}
static const int points[]
void DrawPoints(PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawPointsAsLinesFlags
static constexpr DisplayListAttributeFlags kDrawPointsAsPolygonFlags
static constexpr DisplayListAttributeFlags kDrawPointsAsPointsFlags
@ kLines
draw each separate pair of points as a line segment
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately

◆ drawRect()

void flutter::Canvas::drawRect ( double  left,
double  top,
double  right,
double  bottom,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 256 of file canvas.cc.

261 {
262 Paint paint(paint_objects, paint_data);
263
264 FML_DCHECK(paint.isNotNull());
265 if (display_list_builder_) {
266 DlPaint dl_paint;
267 paint.paint(dl_paint, kDrawRectFlags);
269 SafeNarrow(right), SafeNarrow(bottom)),
270 dl_paint);
271 }
272}
void DrawRect(const SkRect &rect, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawRectFlags

◆ drawRRect()

void flutter::Canvas::drawRRect ( const RRect rrect,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 274 of file canvas.cc.

276 {
277 Paint paint(paint_objects, paint_data);
278
279 FML_DCHECK(paint.isNotNull());
280 if (display_list_builder_) {
281 DlPaint dl_paint;
282 paint.paint(dl_paint, kDrawRRectFlags);
283 builder()->DrawRRect(rrect.sk_rrect, dl_paint);
284 }
285}
void DrawRRect(const SkRRect &rrect, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawRRectFlags

◆ drawShadow()

void flutter::Canvas::drawShadow ( const CanvasPath path,
SkColor  color,
double  elevation,
bool  transparentOccluder 
)

Definition at line 612 of file canvas.cc.

615 {
616 if (!path) {
618 ToDart("Canvas.drawShader called with non-genuine Path."));
619 return;
620 }
621
622 // Not using SafeNarrow because DPR will always be a relatively small number.
623 const ViewportMetrics* metrics =
625 SkScalar dpr;
626 // TODO(dkwingsmt): We should support rendering shadows on non-implicit views.
627 // However, currently this method has no way to get the target view ID.
628 if (metrics == nullptr) {
629 dpr = 1.0f;
630 } else {
631 dpr = static_cast<float>(metrics->device_pixel_ratio);
632 }
633 if (display_list_builder_) {
634 // The DrawShadow mechanism results in non-public operations to be
635 // performed on the canvas involving an SkDrawShadowRec. Since we
636 // cannot include the header that defines that structure, we cannot
637 // record an operation that it injects into an SkCanvas. To prevent
638 // that situation we bypass the canvas interface and inject the
639 // shadow parameters directly into the underlying DisplayList.
640 // See: https://bugs.chromium.org/p/skia/issues/detail?id=12125
641 builder()->DrawShadow(path->path(), DlColor(color), SafeNarrow(elevation),
642 transparentOccluder, dpr);
643 }
644}
void DrawShadow(const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
const ViewportMetrics * GetMetrics(int view_id)
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration.
PlatformConfiguration * platform_configuration() const
static UIDartState * Current()
float SkScalar
Definition extension.cpp:12

◆ drawVertices()

void flutter::Canvas::drawVertices ( const Vertices vertices,
DlBlendMode  blend_mode,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 543 of file canvas.cc.

546 {
547 Paint paint(paint_objects, paint_data);
548
549 if (!vertices) {
551 ToDart("Canvas.drawVertices called with non-genuine Vertices."));
552 return;
553 }
554 FML_DCHECK(paint.isNotNull());
555 if (display_list_builder_) {
556 DlPaint dl_paint;
557 paint.paint(dl_paint, kDrawVerticesFlags);
558 builder()->DrawVertices(vertices->vertices(), blend_mode, dl_paint);
559 }
560}
void DrawVertices(const DlVertices *vertices, DlBlendMode mode, const DlPaint &paint) override
static constexpr DisplayListAttributeFlags kDrawVerticesFlags

◆ getDestinationClipBounds()

void flutter::Canvas::getDestinationClipBounds ( Dart_Handle  rect_handle)

Definition at line 193 of file canvas.cc.

193 {
194 if (display_list_builder_) {
195 auto rect = tonic::Float64List(rect_handle);
197 rect[0] = bounds.fLeft;
198 rect[1] = bounds.fTop;
199 rect[2] = bounds.fRight;
200 rect[3] = bounds.fBottom;
201 }
202}
SkRect GetDestinationClipBounds() const override
Definition dl_builder.h:132
Optional< SkRect > bounds
Definition SkRecords.h:189
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

◆ getLocalClipBounds()

void flutter::Canvas::getLocalClipBounds ( Dart_Handle  rect_handle)

Definition at line 204 of file canvas.cc.

204 {
205 if (display_list_builder_) {
206 auto rect = tonic::Float64List(rect_handle);
208 rect[0] = bounds.fLeft;
209 rect[1] = bounds.fTop;
210 rect[2] = bounds.fRight;
211 rect[3] = bounds.fBottom;
212 }
213}
SkRect GetLocalClipBounds() const override
Definition dl_builder.h:139

◆ getSaveCount()

int flutter::Canvas::getSaveCount ( )

Definition at line 96 of file canvas.cc.

96 {
97 if (display_list_builder_) {
98 return builder()->GetSaveCount();
99 } else {
100 return 0;
101 }
102}
int GetSaveCount() const override
Definition dl_builder.h:58

◆ getTransform()

void flutter::Canvas::getTransform ( Dart_Handle  matrix4_handle)

Definition at line 148 of file canvas.cc.

148 {
149 if (display_list_builder_) {
151 SkScalar m44_values[16];
152 // The Float array stored by Dart Matrix4 is in column-major order
153 sk_m44.getColMajor(m44_values);
154 auto matrix4 = tonic::Float64List(matrix4_handle);
155 for (int i = 0; i < 16; i++) {
156 matrix4[i] = m44_values[i];
157 }
158 }
159}
Definition SkM44.h:150
void getColMajor(SkScalar v[]) const
Definition SkM44.h:256
SkM44 GetTransformFullPerspective() const override
Definition dl_builder.h:106

◆ Invalidate()

void flutter::Canvas::Invalidate ( )

Definition at line 646 of file canvas.cc.

646 {
647 display_list_builder_ = nullptr;
648 if (dart_wrapper()) {
650 }
651}
Dart_WeakPersistentHandle dart_wrapper() const

◆ restore()

void flutter::Canvas::restore ( )

Definition at line 90 of file canvas.cc.

90 {
91 if (display_list_builder_) {
92 builder()->Restore();
93 }
94}

◆ restoreToCount()

void flutter::Canvas::restoreToCount ( int  count)

Definition at line 104 of file canvas.cc.

104 {
105 if (display_list_builder_ && count < getSaveCount()) {
107 }
108}
int count
int getSaveCount()
Definition canvas.cc:96
void RestoreToCount(int restore_count) override

◆ rotate()

void flutter::Canvas::rotate ( double  radians)

Definition at line 122 of file canvas.cc.

122 {
123 if (display_list_builder_) {
124 builder()->Rotate(SafeNarrow(radians) * 180.0f / static_cast<float>(M_PI));
125 }
126}
void Rotate(SkScalar degrees) override

◆ save()

void flutter::Canvas::save ( )

Definition at line 50 of file canvas.cc.

50 {
51 if (display_list_builder_) {
52 builder()->Save();
53 }
54}

◆ saveLayer()

void flutter::Canvas::saveLayer ( double  left,
double  top,
double  right,
double  bottom,
Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 70 of file canvas.cc.

75 {
76 Paint paint(paint_objects, paint_data);
77
78 FML_DCHECK(paint.isNotNull());
80 SafeNarrow(right), SafeNarrow(bottom));
81 if (display_list_builder_) {
82 DlPaint dl_paint;
83 const DlPaint* save_paint = paint.paint(dl_paint, kSaveLayerWithPaintFlags);
84 FML_DCHECK(save_paint);
85 TRACE_EVENT0("flutter", "ui.Canvas::saveLayer (Recorded)");
86 builder()->SaveLayer(&bounds, save_paint);
87 }
88}
void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr) override
static constexpr DisplayListAttributeFlags kSaveLayerWithPaintFlags

◆ saveLayerWithoutBounds()

void flutter::Canvas::saveLayerWithoutBounds ( Dart_Handle  paint_objects,
Dart_Handle  paint_data 
)

Definition at line 56 of file canvas.cc.

57 {
58 Paint paint(paint_objects, paint_data);
59
60 FML_DCHECK(paint.isNotNull());
61 if (display_list_builder_) {
62 DlPaint dl_paint;
63 const DlPaint* save_paint = paint.paint(dl_paint, kSaveLayerWithPaintFlags);
64 FML_DCHECK(save_paint);
65 TRACE_EVENT0("flutter", "ui.Canvas::saveLayer (Recorded)");
66 builder()->SaveLayer(nullptr, save_paint);
67 }
68}

◆ scale()

void flutter::Canvas::scale ( double  sx,
double  sy 
)

Definition at line 116 of file canvas.cc.

116 {
117 if (display_list_builder_) {
118 builder()->Scale(SafeNarrow(sx), SafeNarrow(sy));
119 }
120}
void Scale(SkScalar sx, SkScalar sy) override

◆ skew()

void flutter::Canvas::skew ( double  sx,
double  sy 
)

Definition at line 128 of file canvas.cc.

128 {
129 if (display_list_builder_) {
130 builder()->Skew(SafeNarrow(sx), SafeNarrow(sy));
131 }
132}
void Skew(SkScalar sx, SkScalar sy) override

◆ transform()

void flutter::Canvas::transform ( const tonic::Float64List &  matrix4)

Definition at line 134 of file canvas.cc.

134 {
135 // The Float array stored by Dart Matrix4 is in column-major order
136 // Both DisplayList and SkM44 constructor take row-major matrix order
137 if (display_list_builder_) {
138 // clang-format off
140 SafeNarrow(matrix4[ 0]), SafeNarrow(matrix4[ 4]), SafeNarrow(matrix4[ 8]), SafeNarrow(matrix4[12]),
141 SafeNarrow(matrix4[ 1]), SafeNarrow(matrix4[ 5]), SafeNarrow(matrix4[ 9]), SafeNarrow(matrix4[13]),
142 SafeNarrow(matrix4[ 2]), SafeNarrow(matrix4[ 6]), SafeNarrow(matrix4[10]), SafeNarrow(matrix4[14]),
143 SafeNarrow(matrix4[ 3]), SafeNarrow(matrix4[ 7]), SafeNarrow(matrix4[11]), SafeNarrow(matrix4[15]));
144 // clang-format on
145 }
146}
void TransformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override

◆ translate()

void flutter::Canvas::translate ( double  dx,
double  dy 
)

Definition at line 110 of file canvas.cc.

110 {
111 if (display_list_builder_) {
113 }
114}
void Translate(SkScalar tx, SkScalar ty) override

The documentation for this class was generated from the following files: