5#include "flutter/lib/ui/painting/canvas.h"
9#include "flutter/display_list/dl_builder.h"
10#include "flutter/lib/ui/floating_point.h"
11#include "flutter/lib/ui/painting/image.h"
12#include "flutter/lib/ui/painting/image_filter.h"
13#include "flutter/lib/ui/painting/paint.h"
14#include "flutter/lib/ui/ui_dart_state.h"
15#include "flutter/lib/ui/window/platform_configuration.h"
33 ToDart(
"Canvas constructor called with non-genuine PictureRecorder."));
42 canvas->AssociateWithDartWrapper(wrapper);
51 if (display_list_builder_) {
61 if (display_list_builder_) {
65 TRACE_EVENT0(
"flutter",
"ui.Canvas::saveLayer (Recorded)");
81 if (display_list_builder_) {
85 TRACE_EVENT0(
"flutter",
"ui.Canvas::saveLayer (Recorded)");
91 if (display_list_builder_) {
97 if (display_list_builder_) {
111 if (display_list_builder_) {
117 if (display_list_builder_) {
123 if (display_list_builder_) {
129 if (display_list_builder_) {
137 if (display_list_builder_) {
149 if (display_list_builder_) {
154 auto matrix4 = tonic::Float64List(matrix4_handle);
155 for (
int i = 0;
i < 16;
i++) {
156 matrix4[
i] = m44_values[
i];
167 if (display_list_builder_) {
170 clipOp, doAntiAlias);
175 if (display_list_builder_) {
184 ToDart(
"Canvas.clipPath called with non-genuine Path."));
187 if (display_list_builder_) {
194 if (display_list_builder_) {
195 auto rect = tonic::Float64List(rect_handle);
205 if (display_list_builder_) {
206 auto rect = tonic::Float64List(rect_handle);
216 if (display_list_builder_) {
230 if (display_list_builder_) {
243 if (display_list_builder_) {
246 std::shared_ptr<const DlImageFilter> filter = dl_paint.
getImageFilter();
247 if (filter && !filter->asColorFilter()) {
250 TRACE_EVENT0(
"flutter",
"ui.Canvas::saveLayer (Recorded)");
265 if (display_list_builder_) {
280 if (display_list_builder_) {
294 if (display_list_builder_) {
310 if (display_list_builder_) {
327 if (display_list_builder_) {
347 if (display_list_builder_) {
349 paint.paint(dl_paint, useCenter
369 ToDart(
"Canvas.drawPath called with non-genuine Path."));
372 if (display_list_builder_) {
384 int filterQualityIndex) {
389 return ToDart(
"Canvas.drawImage called with non-genuine Image.");
392 auto dl_image =
image->image();
396 auto error = dl_image->get_error();
402 if (display_list_builder_) {
422 int filterQualityIndex) {
427 return ToDart(
"Canvas.drawImageRect called with non-genuine Image.");
430 auto dl_image =
image->image();
434 auto error = dl_image->get_error();
444 if (display_list_builder_) {
458 double center_bottom,
465 int bitmapSamplingIndex) {
470 return ToDart(
"Canvas.drawImageNine called with non-genuine Image.");
472 auto dl_image =
image->image();
476 auto error = dl_image->get_error();
485 center.round(&icenter);
489 if (display_list_builder_) {
501 ToDart(
"Canvas.drawPicture called with non-genuine Picture."));
505 if (display_list_builder_) {
516 const tonic::Float32List&
points) {
519 static_assert(
sizeof(
SkPoint) ==
sizeof(
float) * 2,
520 "SkPoint doesn't use floats.");
523 if (display_list_builder_) {
525 switch (point_mode) {
537 points.num_elements() / 2,
551 ToDart(
"Canvas.drawVertices called with non-genuine Vertices."));
555 if (display_list_builder_) {
564 int filterQualityIndex,
575 "Canvas.drawAtlas or Canvas.drawRawAtlas called with "
576 "non-genuine Image.");
579 auto dl_image =
atlas->image();
580 auto error = dl_image->get_error();
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.");
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);
602 dl_image,
reinterpret_cast<const SkRSXform*
>(transforms.data()),
603 reinterpret_cast<const SkRect*
>(rects.data()),
605 rects.num_elements() / 4,
606 blend_mode,
sampling,
reinterpret_cast<const SkRect*
>(cull_rect.data()),
615 bool transparentOccluder) {
618 ToDart(
"Canvas.drawShader called with non-genuine Path."));
628 if (metrics ==
nullptr) {
633 if (display_list_builder_) {
642 transparentOccluder, dpr);
647 display_list_builder_ =
nullptr;
static const int points[]
void getColMajor(SkScalar v[]) const
void drawLine(double x1, double y1, double x2, double y2, 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 drawShadow(const CanvasPath *path, SkColor color, double elevation, bool transparentOccluder)
void rotate(double radians)
void drawOval(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
static void Create(Dart_Handle wrapper, PictureRecorder *recorder, double left, double top, double right, double bottom)
void drawRect(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
void translate(double dx, double dy)
void clipRect(double left, double top, double right, double bottom, DlCanvas::ClipOp clipOp, bool doAntiAlias=true)
void clipRRect(const RRect &rrect, bool doAntiAlias=true)
DisplayListBuilder * builder()
void drawColor(SkColor color, DlBlendMode blend_mode)
void transform(const tonic::Float64List &matrix4)
void drawRRect(const RRect &rrect, Dart_Handle paint_objects, Dart_Handle paint_data)
void skew(double sx, double sy)
void clipPath(const CanvasPath *path, bool doAntiAlias=true)
Dart_Handle drawImage(const CanvasImage *image, double x, double y, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
void restoreToCount(int count)
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)
void drawVertices(const Vertices *vertices, DlBlendMode blend_mode, Dart_Handle paint_objects, Dart_Handle paint_data)
void getTransform(Dart_Handle matrix4_handle)
void drawCircle(double x, double y, double radius, Dart_Handle paint_objects, Dart_Handle paint_data)
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 saveLayerWithoutBounds(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 drawDRRect(const RRect &outer, const RRect &inner, Dart_Handle paint_objects, Dart_Handle paint_data)
void scale(double sx, double sy)
void getLocalClipBounds(Dart_Handle rect_handle)
void drawPoints(Dart_Handle paint_objects, Dart_Handle paint_data, DlCanvas::PointMode point_mode, const tonic::Float32List &points)
void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data)
void getDestinationClipBounds(Dart_Handle rect_handle)
void drawPath(const CanvasPath *path, 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 Skew(SkScalar sx, SkScalar sy) override
void DrawLine(const SkPoint &p0, const SkPoint &p1, const DlPaint &paint) override
void RestoreToCount(int restore_count) override
void DrawDRRect(const SkRRect &outer, const SkRRect &inner, const DlPaint &paint) override
void DrawVertices(const DlVertices *vertices, DlBlendMode mode, const DlPaint &paint) override
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
SkRect GetLocalClipBounds() const override
void DrawRect(const SkRect &rect, const DlPaint &paint) override
void DrawColor(DlColor color, DlBlendMode mode) override
void DrawOval(const SkRect &bounds, const DlPaint &paint) override
void ClipRRect(const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
void Translate(SkScalar tx, SkScalar ty) override
void DrawRRect(const SkRRect &rrect, const DlPaint &paint) override
void Scale(SkScalar sx, SkScalar sy) override
void DrawPath(const SkPath &path, const DlPaint &paint) override
void Rotate(SkScalar degrees) override
void DrawCircle(const SkPoint ¢er, SkScalar radius, const DlPaint &paint) override
void DrawPoints(PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint) override
void DrawImage(const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
void DrawShadow(const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void DrawPaint(const DlPaint &paint) override
void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr) override
SkM44 GetTransformFullPerspective() const override
void ClipRect(const SkRect &rect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
void DrawImageRect(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
SkRect GetDestinationClipBounds() const override
void ClipPath(const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
void DrawImageNine(const sk_sp< DlImage > &image, const SkIRect ¢er, const SkRect &dst, DlFilterMode filter, const DlPaint *paint=nullptr) override
int GetSaveCount() const override
void DrawArc(const SkRect &bounds, SkScalar start, SkScalar sweep, bool useCenter, const DlPaint &paint) override
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 kDrawVerticesFlags
static constexpr DisplayListAttributeFlags kDrawArcWithCenterFlags
static constexpr DisplayListAttributeFlags kDrawPaintFlags
static constexpr DisplayListAttributeFlags kDrawArcNoCenterFlags
static constexpr DisplayListAttributeFlags kDrawImageRectWithPaintFlags
static constexpr DisplayListAttributeFlags kDrawOvalFlags
static constexpr DisplayListAttributeFlags kDrawPointsAsLinesFlags
static constexpr DisplayListAttributeFlags kDrawPointsAsPolygonFlags
static constexpr DisplayListAttributeFlags kDrawCircleFlags
static constexpr DisplayListAttributeFlags kDrawPathFlags
static constexpr DisplayListAttributeFlags kDrawAtlasWithPaintFlags
static constexpr DisplayListAttributeFlags kDrawLineFlags
static constexpr DisplayListAttributeFlags kSaveLayerWithPaintFlags
static constexpr DisplayListAttributeFlags kDrawPointsAsPointsFlags
static constexpr DisplayListAttributeFlags kDrawImageWithPaintFlags
static constexpr DisplayListAttributeFlags kDrawImageNineWithPaintFlags
static constexpr DisplayListAttributeFlags kDrawRRectFlags
static constexpr DisplayListAttributeFlags kDrawDRRectFlags
static constexpr DisplayListAttributeFlags kDrawRectFlags
@ 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
std::shared_ptr< const DlImageFilter > getImageFilter() const
static DlImageSampling SamplingFromIndex(int filterQualityIndex)
static DlFilterMode FilterModeFromIndex(int index)
sk_sp< DisplayListBuilder > BeginRecording(SkRect bounds)
void set_canvas(fml::RefPtr< Canvas > canvas)
PlatformConfiguration * platform_configuration() const
static UIDartState * Current()
static void ThrowIfUIOperationsProhibited()
const DlVertices * vertices() const
Dart_WeakPersistentHandle dart_wrapper() const
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
DART_EXPORT Dart_Handle Dart_Null(void)
const uint8_t uint32_t uint32_t GError ** error
#define FML_DCHECK(condition)
sk_sp< const SkImage > atlas
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< const SkPicture > picture
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
SkSamplingOptions sampling
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, FlutterGpuTestClass)
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
static float SafeNarrow(double value)
Dart_Handle ToDart(const T &object)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
double device_pixel_ratio
#define TRACE_EVENT0(category_group, name)