Flutter Engine
The 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#include "flutter/display_list/dl_canvas.h"
9#include "flutter/display_list/skia/dl_sk_types.h"
11
12namespace flutter {
13
14// -----------------------------------------------------------------------------
15/// @brief Backend implementation of |DlCanvas| for |SkCanvas|.
16///
17/// @see DlCanvas
18class DlSkCanvasAdapter final : public virtual DlCanvas {
19 public:
20 DlSkCanvasAdapter() : delegate_(nullptr) {}
21 explicit DlSkCanvasAdapter(SkCanvas* canvas) : delegate_(canvas) {}
22 ~DlSkCanvasAdapter() override = default;
23
25 SkCanvas* canvas() { return delegate_; }
26
27 SkISize GetBaseLayerSize() const override;
28 SkImageInfo GetImageInfo() const override;
29
30 void Save() override;
31 void SaveLayer(const SkRect* bounds,
32 const DlPaint* paint = nullptr,
33 const DlImageFilter* backdrop = nullptr) override;
34 void Restore() override;
35 int GetSaveCount() const override;
36 void RestoreToCount(int restore_count) override;
37
38 void Translate(SkScalar tx, SkScalar ty) override;
39 void Scale(SkScalar sx, SkScalar sy) override;
40 void Rotate(SkScalar degrees) override;
41 void Skew(SkScalar sx, SkScalar sy) override;
42
43 // clang-format off
44
45 // 2x3 2D affine subset of a 4x4 transform in row major order
47 SkScalar myx, SkScalar myy, SkScalar myt) override;
48 // full 4x4 transform in row major order
50 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
51 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
52 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
53 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
54 // clang-format on
55 void TransformReset() override;
56 void Transform(const SkMatrix* matrix) override;
57 void Transform(const SkM44* matrix44) override;
58 void SetTransform(const SkMatrix* matrix) override;
59 void SetTransform(const SkM44* matrix44) override;
62
63 /// Returns the 4x4 full perspective transform representing all transform
64 /// operations executed so far in this DisplayList within the enclosing
65 /// save stack.
66 SkM44 GetTransformFullPerspective() const override;
67 /// Returns the 3x3 partial perspective transform representing all transform
68 /// operations executed so far in this DisplayList within the enclosing
69 /// save stack.
70 SkMatrix GetTransform() const override;
71
72 void ClipRect(const SkRect& rect, ClipOp clip_op, bool is_aa) override;
73 void ClipRRect(const SkRRect& rrect, ClipOp clip_op, bool is_aa) override;
74 void ClipPath(const SkPath& path, ClipOp clip_op, bool is_aa) override;
75
76 /// Conservative estimate of the bounds of all outstanding clip operations
77 /// measured in the coordinate space within which this DisplayList will
78 /// be rendered.
79 SkRect GetDestinationClipBounds() const override;
80 /// Conservative estimate of the bounds of all outstanding clip operations
81 /// transformed into the local coordinate space in which currently
82 /// recorded rendering operations are interpreted.
83 SkRect GetLocalClipBounds() const override;
84
85 /// Return true iff the supplied bounds are easily shown to be outside
86 /// of the current clip bounds. This method may conservatively return
87 /// false if it cannot make the determination.
88 bool QuickReject(const SkRect& bounds) const override;
89
90 void DrawPaint(const DlPaint& paint) override;
91 void DrawColor(DlColor color, DlBlendMode mode) override;
92 void DrawLine(const SkPoint& p0,
93 const SkPoint& p1,
94 const DlPaint& paint) override;
95 void DrawRect(const SkRect& rect, const DlPaint& paint) override;
96 void DrawOval(const SkRect& bounds, const DlPaint& paint) override;
97 void DrawCircle(const SkPoint& center,
98 SkScalar radius,
99 const DlPaint& paint) override;
100 void DrawRRect(const SkRRect& rrect, const DlPaint& paint) override;
101 void DrawDRRect(const SkRRect& outer,
102 const SkRRect& inner,
103 const DlPaint& paint) override;
104 void DrawPath(const SkPath& path, const DlPaint& paint) override;
105 void DrawArc(const SkRect& bounds,
107 SkScalar sweep,
108 bool useCenter,
109 const DlPaint& paint) override;
111 uint32_t count,
112 const SkPoint pts[],
113 const DlPaint& paint) override;
114 void DrawVertices(const DlVertices* vertices,
116 const DlPaint& paint) override;
117 void DrawImage(const sk_sp<DlImage>& image,
118 const SkPoint point,
119 DlImageSampling sampling,
120 const DlPaint* paint = nullptr) override;
121 void DrawImageRect(
122 const sk_sp<DlImage>& image,
123 const SkRect& src,
124 const SkRect& dst,
125 DlImageSampling sampling,
126 const DlPaint* paint = nullptr,
127 SrcRectConstraint constraint = SrcRectConstraint::kFast) override;
129 const SkIRect& center,
130 const SkRect& dst,
131 DlFilterMode filter,
132 const DlPaint* paint = nullptr) override;
133 void DrawAtlas(const sk_sp<DlImage>& atlas,
134 const SkRSXform xform[],
135 const SkRect tex[],
136 const DlColor colors[],
137 int count,
139 DlImageSampling sampling,
140 const SkRect* cullRect,
141 const DlPaint* paint = nullptr) override;
142 void DrawDisplayList(const sk_sp<DisplayList> display_list,
143 SkScalar opacity = SK_Scalar1) override;
144 void DrawTextBlob(const sk_sp<SkTextBlob>& blob,
145 SkScalar x,
146 SkScalar y,
147 const DlPaint& paint) override;
148 void DrawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
149 SkScalar x,
150 SkScalar y,
151 const DlPaint& paint) override;
152 void DrawShadow(const SkPath& path,
153 const DlColor color,
154 const SkScalar elevation,
155 bool transparent_occluder,
156 SkScalar dpr) override;
157
158 void Flush() override;
159
160 private:
161 SkCanvas* delegate_;
162};
163
164} // namespace flutter
165
166#endif // FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
int count
SkColor4f color
#define SK_Scalar1
Definition SkScalar.h:18
static SkScalar center(float pos0, float pos1)
Definition SkM44.h:150
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
virtual void Transform(const SkMatrix *matrix)=0
virtual void SetTransform(const SkMatrix *matrix)=0
Backend implementation of |DlCanvas| for |SkCanvas|.
void DrawPoints(PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint) override
~DlSkCanvasAdapter() override=default
void Skew(SkScalar sx, SkScalar sy) override
SkRect GetDestinationClipBounds() const override
int GetSaveCount() const override
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 Translate(SkScalar tx, SkScalar ty) override
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
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
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
void DrawImage(const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
DlSkCanvasAdapter(SkCanvas *canvas)
void DrawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y, const DlPaint &paint) override
SkM44 GetTransformFullPerspective() const override
void set_canvas(SkCanvas *canvas)
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) 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
void RestoreToCount(int restore_count) override
SkImageInfo GetImageInfo() const override
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
sk_sp< SkImage > image
Definition examples.cpp:29
float SkScalar
Definition extension.cpp:12
double y
double x
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