Flutter Engine
The Flutter Engine
dl_sk_canvas.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
6#define FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
7
8#if !SLIMPELLER
9
10#include "flutter/display_list/dl_canvas.h"
11#include "flutter/display_list/skia/dl_sk_types.h"
13
14namespace flutter {
15
16// -----------------------------------------------------------------------------
17/// @brief Backend implementation of |DlCanvas| for |SkCanvas|.
18///
19/// @see DlCanvas
20class DlSkCanvasAdapter final : public virtual DlCanvas {
21 public:
22 DlSkCanvasAdapter() : delegate_(nullptr) {}
23 explicit DlSkCanvasAdapter(SkCanvas* canvas) : delegate_(canvas) {}
24 ~DlSkCanvasAdapter() override = default;
25
27 SkCanvas* canvas() { return delegate_; }
28
29 SkISize GetBaseLayerSize() const override;
30 SkImageInfo GetImageInfo() const override;
31
32 void Save() override;
33 void SaveLayer(const SkRect* bounds,
34 const DlPaint* paint = nullptr,
35 const DlImageFilter* backdrop = nullptr) override;
36 void Restore() override;
37 int GetSaveCount() const override;
38 void RestoreToCount(int restore_count) override;
39
40 void Translate(SkScalar tx, SkScalar ty) override;
41 void Scale(SkScalar sx, SkScalar sy) override;
42 void Rotate(SkScalar degrees) override;
43 void Skew(SkScalar sx, SkScalar sy) override;
44
45 // clang-format off
46
47 // 2x3 2D affine subset of a 4x4 transform in row major order
49 SkScalar myx, SkScalar myy, SkScalar myt) override;
50 // full 4x4 transform in row major order
52 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
53 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
54 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
55 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
56 // clang-format on
57 void TransformReset() override;
58 void Transform(const SkMatrix* matrix) override;
59 void Transform(const SkM44* matrix44) override;
60 void SetTransform(const SkMatrix* matrix) override;
61 void SetTransform(const SkM44* matrix44) override;
64
65 /// Returns the 4x4 full perspective transform representing all transform
66 /// operations executed so far in this DisplayList within the enclosing
67 /// save stack.
68 SkM44 GetTransformFullPerspective() const override;
69 /// Returns the 3x3 partial perspective transform representing all transform
70 /// operations executed so far in this DisplayList within the enclosing
71 /// save stack.
72 SkMatrix GetTransform() const override;
73
74 void ClipRect(const SkRect& rect, ClipOp clip_op, bool is_aa) override;
75 void ClipRRect(const SkRRect& rrect, ClipOp clip_op, bool is_aa) override;
76 void ClipPath(const SkPath& path, ClipOp clip_op, bool is_aa) override;
77
78 /// Conservative estimate of the bounds of all outstanding clip operations
79 /// measured in the coordinate space within which this DisplayList will
80 /// be rendered.
81 SkRect GetDestinationClipBounds() const override;
82 /// Conservative estimate of the bounds of all outstanding clip operations
83 /// transformed into the local coordinate space in which currently
84 /// recorded rendering operations are interpreted.
85 SkRect GetLocalClipBounds() const override;
86
87 /// Return true iff the supplied bounds are easily shown to be outside
88 /// of the current clip bounds. This method may conservatively return
89 /// false if it cannot make the determination.
90 bool QuickReject(const SkRect& bounds) const override;
91
92 void DrawPaint(const DlPaint& paint) override;
93 void DrawColor(DlColor color, DlBlendMode mode) override;
94 void DrawLine(const SkPoint& p0,
95 const SkPoint& p1,
96 const DlPaint& paint) override;
97 void DrawDashedLine(const DlPoint& p0,
98 const DlPoint& p1,
99 DlScalar on_length,
100 DlScalar off_length,
101 const DlPaint& paint) override;
102 void DrawRect(const SkRect& rect, const DlPaint& paint) override;
103 void DrawOval(const SkRect& bounds, const DlPaint& paint) override;
104 void DrawCircle(const SkPoint& center,
105 SkScalar radius,
106 const DlPaint& paint) override;
107 void DrawRRect(const SkRRect& rrect, const DlPaint& paint) override;
108 void DrawDRRect(const SkRRect& outer,
109 const SkRRect& inner,
110 const DlPaint& paint) override;
111 void DrawPath(const SkPath& path, const DlPaint& paint) override;
112 void DrawArc(const SkRect& bounds,
113 SkScalar start,
114 SkScalar sweep,
115 bool useCenter,
116 const DlPaint& paint) override;
118 uint32_t count,
119 const SkPoint pts[],
120 const DlPaint& paint) override;
121 void DrawVertices(const DlVertices* vertices,
123 const DlPaint& paint) override;
124 void DrawImage(const sk_sp<DlImage>& image,
125 const SkPoint point,
127 const DlPaint* paint = nullptr) override;
128 void DrawImageRect(
129 const sk_sp<DlImage>& image,
130 const SkRect& src,
131 const SkRect& dst,
133 const DlPaint* paint = nullptr,
134 SrcRectConstraint constraint = SrcRectConstraint::kFast) override;
136 const SkIRect& center,
137 const SkRect& dst,
138 DlFilterMode filter,
139 const DlPaint* paint = nullptr) override;
140 void DrawAtlas(const sk_sp<DlImage>& atlas,
141 const SkRSXform xform[],
142 const SkRect tex[],
143 const DlColor colors[],
144 int count,
147 const SkRect* cullRect,
148 const DlPaint* paint = nullptr) override;
149 void DrawDisplayList(const sk_sp<DisplayList> display_list,
150 SkScalar opacity = SK_Scalar1) override;
151 void DrawTextBlob(const sk_sp<SkTextBlob>& blob,
152 SkScalar x,
153 SkScalar y,
154 const DlPaint& paint) override;
155 void DrawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
156 SkScalar x,
157 SkScalar y,
158 const DlPaint& paint) override;
159 void DrawShadow(const SkPath& path,
160 const DlColor color,
161 const SkScalar elevation,
162 bool transparent_occluder,
163 SkScalar dpr) override;
164
165 void Flush() override;
166
167 private:
168 SkCanvas* delegate_;
169};
170
171} // namespace flutter
172
173#endif // !SLIMPELLER
174
175#endif // FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
int count
Definition: FontMgrTest.cpp:50
#define SK_Scalar1
Definition: SkScalar.h:18
Definition: SkM44.h:150
Definition: SkPath.h:59
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
virtual void Transform(const SkMatrix *matrix)=0
virtual void SetTransform(const SkMatrix *matrix)=0
Backend implementation of |DlCanvas| for |SkCanvas|.
Definition: dl_sk_canvas.h:20
void DrawPoints(PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint) override
~DlSkCanvasAdapter() override=default
void Skew(SkScalar sx, SkScalar sy) override
Definition: dl_sk_canvas.cc:89
SkRect GetDestinationClipBounds() const override
int GetSaveCount() const override
Definition: dl_sk_canvas.cc:69
void TransformReset() override
void DrawArc(const SkRect &bounds, SkScalar start, SkScalar sweep, bool useCenter, const DlPaint &paint) override
SkRect GetLocalClipBounds() const override
void DrawCircle(const SkPoint &center, SkScalar radius, const DlPaint &paint) override
void DrawColor(DlColor color, DlBlendMode mode) override
void DrawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const DlPaint &paint) override
void SetTransform(const SkMatrix *matrix) override
void ClipPath(const SkPath &path, ClipOp clip_op, bool is_aa) override
void Transform(const SkMatrix *matrix) override
void DrawRRect(const SkRRect &rrect, 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
void ClipRect(const SkRect &rect, ClipOp clip_op, bool is_aa) override
void Translate(SkScalar tx, SkScalar ty) override
Definition: dl_sk_canvas.cc:77
void ClipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa) override
void DrawLine(const SkPoint &p0, const SkPoint &p1, const DlPaint &paint) override
void Rotate(SkScalar degrees) override
Definition: dl_sk_canvas.cc:85
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
void DrawVertices(const DlVertices *vertices, DlBlendMode mode, const DlPaint &paint) override
void DrawImageNine(const sk_sp< DlImage > &image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, const DlPaint *paint=nullptr) override
SkMatrix GetTransform() const override
void DrawRect(const SkRect &rect, const DlPaint &paint) override
void DrawShadow(const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void Transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) override
Definition: dl_sk_canvas.cc:96
void DrawOval(const SkRect &bounds, const DlPaint &paint) 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
SkISize GetBaseLayerSize() const override
Definition: dl_sk_canvas.cc:43
void DrawImage(const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
DlSkCanvasAdapter(SkCanvas *canvas)
Definition: dl_sk_canvas.h:23
void DrawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y, const DlPaint &paint) override
void Scale(SkScalar sx, SkScalar sy) override
Definition: dl_sk_canvas.cc:81
SkM44 GetTransformFullPerspective() const override
void set_canvas(SkCanvas *canvas)
Definition: dl_sk_canvas.cc:39
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
void DrawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length, const DlPaint &paint) override
void DrawDRRect(const SkRRect &outer, const SkRRect &inner, const DlPaint &paint) override
void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr) override
Definition: dl_sk_canvas.cc:55
void RestoreToCount(int restore_count) override
Definition: dl_sk_canvas.cc:73
SkImageInfo GetImageInfo() const override
Definition: dl_sk_canvas.cc:47
bool QuickReject(const SkRect &bounds) const override
void DrawPaint(const DlPaint &paint) override
void DrawPath(const SkPath &path, const DlPaint &paint) override
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
const Paint & paint
Definition: color_source.cc:38
DlColor color
float SkScalar
Definition: extension.cpp:12
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
impeller::Scalar DlScalar
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
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
dst
Definition: cp.py:12
Definition: SkRect.h:32
Definition: SkSize.h:16