Flutter Engine
 
Loading...
Searching...
No Matches
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
12
13namespace impeller {
14class TextFrame;
15}
16
17namespace flutter {
18
19// -----------------------------------------------------------------------------
20/// @brief Backend implementation of |DlCanvas| for |SkCanvas|.
21///
22/// @see DlCanvas
23class DlSkCanvasAdapter final : public virtual DlCanvas {
24 public:
25 DlSkCanvasAdapter() : delegate_(nullptr) {}
26 explicit DlSkCanvasAdapter(SkCanvas* canvas) : delegate_(canvas) {}
27 ~DlSkCanvasAdapter() override = default;
28
29 void set_canvas(SkCanvas* canvas);
30 SkCanvas* canvas() { return delegate_; }
31
32 DlISize GetBaseLayerDimensions() const override;
33 SkImageInfo GetImageInfo() const override;
34
35 void Save() override;
36 void SaveLayer(const std::optional<DlRect>& bounds,
37 const DlPaint* paint = nullptr,
38 const DlImageFilter* backdrop = nullptr,
39 std::optional<int64_t> backdrop_id = std::nullopt) override;
40 void Restore() override;
41 int GetSaveCount() const override;
42 void RestoreToCount(int restore_count) override;
43
44 void Translate(DlScalar tx, DlScalar ty) override;
45 void Scale(DlScalar sx, DlScalar sy) override;
46 void Rotate(DlScalar degrees) override;
47 void Skew(DlScalar sx, DlScalar sy) override;
48
49 // clang-format off
50
51 // 2x3 2D affine subset of a 4x4 transform in row major order
53 DlScalar myx, DlScalar myy, DlScalar myt) override;
54 // full 4x4 transform in row major order
56 DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt,
57 DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt,
58 DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt,
59 DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override;
60 // clang-format on
61 void TransformReset() override;
62 void Transform(const DlMatrix& matrix) override;
63 void SetTransform(const DlMatrix& matrix) 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 DlMatrix GetMatrix() const override;
69
70 void ClipRect(const DlRect& rect, DlClipOp clip_op, bool is_aa) override;
71 void ClipOval(const DlRect& bounds, DlClipOp clip_op, bool is_aa) override;
72 void ClipRoundRect(const DlRoundRect& rrect,
73 DlClipOp clip_op,
74 bool is_aa) override;
76 DlClipOp clip_op,
77 bool is_aa) override;
78 void ClipPath(const DlPath& path, DlClipOp clip_op, bool is_aa) override;
79
80 /// Conservative estimate of the bounds of all outstanding clip operations
81 /// measured in the coordinate space within which this DisplayList will
82 /// be rendered.
83 DlRect GetDestinationClipCoverage() const override;
84 /// Conservative estimate of the bounds of all outstanding clip operations
85 /// transformed into the local coordinate space in which currently
86 /// recorded rendering operations are interpreted.
87 DlRect GetLocalClipCoverage() const override;
88
89 /// Return true iff the supplied bounds are easily shown to be outside
90 /// of the current clip bounds. This method may conservatively return
91 /// false if it cannot make the determination.
92 bool QuickReject(const DlRect& bounds) const override;
93
94 void DrawPaint(const DlPaint& paint) override;
95 void DrawColor(DlColor color, DlBlendMode mode) override;
96 void DrawLine(const DlPoint& p0,
97 const DlPoint& p1,
98 const DlPaint& paint) override;
99 void DrawDashedLine(const DlPoint& p0,
100 const DlPoint& p1,
101 DlScalar on_length,
102 DlScalar off_length,
103 const DlPaint& paint) override;
104 void DrawRect(const DlRect& rect, const DlPaint& paint) override;
105 void DrawOval(const DlRect& bounds, const DlPaint& paint) override;
106 void DrawCircle(const DlPoint& center,
107 DlScalar radius,
108 const DlPaint& paint) override;
109 void DrawRoundRect(const DlRoundRect& rrect, const DlPaint& paint) override;
110 void DrawDiffRoundRect(const DlRoundRect& outer,
111 const DlRoundRect& inner,
112 const DlPaint& paint) override;
114 const DlPaint& paint) override;
115 void DrawPath(const DlPath& path, const DlPaint& paint) override;
116 void DrawArc(const DlRect& bounds,
117 DlScalar start,
118 DlScalar sweep,
119 bool useCenter,
120 const DlPaint& paint) override;
121 void DrawPoints(DlPointMode mode,
122 uint32_t count,
123 const DlPoint pts[],
124 const DlPaint& paint) override;
125 void DrawVertices(const std::shared_ptr<DlVertices>& vertices,
126 DlBlendMode mode,
127 const DlPaint& paint) override;
128 void DrawImage(const sk_sp<DlImage>& image,
129 const DlPoint& point,
130 DlImageSampling sampling,
131 const DlPaint* paint = nullptr) override;
132 void DrawImageRect(
133 const sk_sp<DlImage>& image,
134 const DlRect& src,
135 const DlRect& dst,
136 DlImageSampling sampling,
137 const DlPaint* paint = nullptr,
138 DlSrcRectConstraint constraint = DlSrcRectConstraint::kFast) override;
139 void DrawImageNine(const sk_sp<DlImage>& image,
140 const DlIRect& center,
141 const DlRect& dst,
142 DlFilterMode filter,
143 const DlPaint* paint = nullptr) override;
144 void DrawAtlas(const sk_sp<DlImage>& atlas,
145 const DlRSTransform xform[],
146 const DlRect tex[],
147 const DlColor colors[],
148 int count,
149 DlBlendMode mode,
150 DlImageSampling sampling,
151 const DlRect* cullRect,
152 const DlPaint* paint = nullptr) override;
153 void DrawDisplayList(const sk_sp<DisplayList> display_list,
154 DlScalar opacity = SK_Scalar1) override;
155 void DrawText(const std::shared_ptr<DlText>& text,
156 DlScalar x,
157 DlScalar y,
158 const DlPaint& paint) override;
159 void DrawShadow(const DlPath& path,
160 const DlColor color,
161 const DlScalar elevation,
162 bool transparent_occluder,
163 DlScalar 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_
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
Backend implementation of |DlCanvas| for |SkCanvas|.
~DlSkCanvasAdapter() override=default
void DrawRect(const DlRect &rect, const DlPaint &paint) override
void Transform(const DlMatrix &matrix) override
void Scale(DlScalar sx, DlScalar sy) override
void Rotate(DlScalar degrees) override
int GetSaveCount() const override
void ClipOval(const DlRect &bounds, DlClipOp clip_op, bool is_aa) override
void DrawRoundSuperellipse(const DlRoundSuperellipse &rse, const DlPaint &paint) override
void TransformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
void TransformReset() override
void Skew(DlScalar sx, DlScalar sy) override
void DrawPoints(DlPointMode mode, uint32_t count, const DlPoint pts[], const DlPaint &paint) override
void DrawColor(DlColor color, DlBlendMode mode) override
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
void SetTransform(const DlMatrix &matrix) override
void ClipPath(const DlPath &path, DlClipOp clip_op, bool is_aa) override
void DrawPath(const DlPath &path, const DlPaint &paint) override
void DrawLine(const DlPoint &p0, const DlPoint &p1, const DlPaint &paint) override
DlISize GetBaseLayerDimensions() const override
void Translate(DlScalar tx, DlScalar ty) override
void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) override
DlMatrix GetMatrix() const override
void DrawDiffRoundRect(const DlRoundRect &outer, const DlRoundRect &inner, const DlPaint &paint) override
void DrawShadow(const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
Draws the shadow of the given |path| rendered in the provided |color| (which is only consulted for it...
DlRect GetLocalClipCoverage() const override
void DrawRoundRect(const DlRoundRect &rrect, const DlPaint &paint) override
void DrawVertices(const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode, const DlPaint &paint) override
DlRect GetDestinationClipCoverage() const override
void DrawAtlas(const sk_sp< DlImage > &atlas, const DlRSTransform xform[], const DlRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const DlRect *cullRect, const DlPaint *paint=nullptr) override
void ClipRect(const DlRect &rect, DlClipOp clip_op, bool is_aa) override
void DrawArc(const DlRect &bounds, DlScalar start, DlScalar sweep, bool useCenter, const DlPaint &paint) override
void ClipRoundSuperellipse(const DlRoundSuperellipse &rse, DlClipOp clip_op, bool is_aa) override
bool QuickReject(const DlRect &bounds) const override
void DrawImageNine(const sk_sp< DlImage > &image, const DlIRect &center, const DlRect &dst, DlFilterMode filter, const DlPaint *paint=nullptr) override
void DrawCircle(const DlPoint &center, DlScalar radius, const DlPaint &paint) override
DlSkCanvasAdapter(SkCanvas *canvas)
void DrawImageRect(const sk_sp< DlImage > &image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1) override
void set_canvas(SkCanvas *canvas)
void DrawOval(const DlRect &bounds, const DlPaint &paint) override
void DrawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length, const DlPaint &paint) override
void ClipRoundRect(const DlRoundRect &rrect, DlClipOp clip_op, bool is_aa) override
void RestoreToCount(int restore_count) override
SkImageInfo GetImageInfo() const override
void Transform2DAffine(DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt) override
void DrawPaint(const DlPaint &paint) override
int32_t x
FlutterVulkanImage * image
std::u16string text
double y
impeller::Scalar DlScalar
DlPointMode
Definition dl_types.h:15
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 switch_defs.h:52
DlSrcRectConstraint
Definition dl_types.h:21
BlendMode
Definition color.h:58
A 4x4 matrix using column-major storage.
Definition matrix.h:37
#define DrawText