Skip to content

Commit f825ccc

Browse files
authored
[DisplayList] Delete all legacy Skia-oriented method overloads in DlCanvas (#164054)
Delete remaining DlCanvas method overloads that were allowing the use of Skia geometry objects in rendering code. The only remaining uses of Skia classes in the DlCanvas interface are SkImageInfo and SkTextBlob.
1 parent 7d56be4 commit f825ccc

File tree

57 files changed

+347
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+347
-637
lines changed

engine/src/flutter/common/graphics/texture.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "flutter/display_list/dl_canvas.h"
1111
#include "flutter/fml/macros.h"
1212
#include "flutter/fml/synchronization/waitable_event.h"
13-
#include "third_party/skia/include/core/SkCanvas.h"
14-
#include "third_party/skia/include/core/SkSamplingOptions.h"
1513

1614
class GrDirectContext;
1715

@@ -50,7 +48,7 @@ class Texture : public ContextListener {
5048

5149
// Called from raster thread.
5250
virtual void Paint(PaintContext& context,
53-
const SkRect& bounds,
51+
const DlRect& bounds,
5452
bool freeze,
5553
const DlImageSampling sampling) = 0;
5654

engine/src/flutter/display_list/dl_builder.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,9 @@ void DisplayListBuilder::ClipPath(const DlPath& path,
10771077
ClipOval(rect, clip_op, is_aa);
10781078
return;
10791079
}
1080-
SkRRect rrect;
1081-
if (path.IsSkRRect(&rrect)) {
1082-
ClipRRect(rrect, clip_op, is_aa);
1080+
DlRoundRect rrect;
1081+
if (path.IsRoundRect(&rrect)) {
1082+
ClipRoundRect(rrect, clip_op, is_aa);
10831083
return;
10841084
}
10851085
}

engine/src/flutter/display_list/dl_builder.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
4141
DisplayListBuilder(DlScalar width, DlScalar height)
4242
: DisplayListBuilder(DlRect::MakeWH(width, height)) {}
4343

44-
explicit DisplayListBuilder(const SkRect& cull_rect,
45-
bool prepare_rtree = false)
46-
: DisplayListBuilder(ToDlRect(cull_rect), prepare_rtree) {}
47-
4844
~DisplayListBuilder();
4945

5046
// |DlCanvas|
@@ -208,6 +204,9 @@ class DisplayListBuilder final : public virtual DlCanvas,
208204
DlImageSampling sampling,
209205
const DlPaint* paint = nullptr,
210206
DlSrcRectConstraint constraint = DlSrcRectConstraint::kFast) override;
207+
// include overloads from the virtual base class
208+
using DlCanvas::DrawImageRect;
209+
211210
// |DlCanvas|
212211
void DrawImageNine(const sk_sp<DlImage>& image,
213212
const DlIRect& center,
@@ -254,8 +253,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
254253

255254
sk_sp<DisplayList> Build();
256255

257-
ENABLE_DL_CANVAS_BACKWARDS_COMPATIBILITY
258-
259256
private:
260257
void Init(bool prepare_rtree);
261258

engine/src/flutter/display_list/dl_canvas.h

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
#include "flutter/display_list/geometry/dl_path.h"
1515
#include "flutter/display_list/image/dl_image.h"
1616

17-
#include "third_party/skia/include/core/SkM44.h"
18-
#include "third_party/skia/include/core/SkMatrix.h"
19-
#include "third_party/skia/include/core/SkPath.h"
20-
#include "third_party/skia/include/core/SkRRect.h"
21-
#include "third_party/skia/include/core/SkRect.h"
2217
#include "third_party/skia/include/core/SkTextBlob.h"
2318

2419
#include "impeller/typographer/text_frame.h"
@@ -215,203 +210,6 @@ class DlCanvas {
215210
float elevation,
216211
DlScalar dpr,
217212
const DlMatrix& ctm);
218-
219-
// -----------------------------------------------------------------
220-
// SkObject Compatibility section - deprecated...
221-
// -----------------------------------------------------------------
222-
223-
SkISize GetBaseLayerSize() const {
224-
return ToSkISize(GetBaseLayerDimensions());
225-
}
226-
227-
void SaveLayer(const SkRect* bounds,
228-
const DlPaint* paint = nullptr,
229-
const DlImageFilter* backdrop = nullptr,
230-
std::optional<int64_t> backdrop_id = std::nullopt) {
231-
SaveLayer(ToOptDlRect(bounds), paint, backdrop, backdrop_id);
232-
}
233-
234-
void Transform(const SkMatrix& matrix) { Transform(ToDlMatrix(matrix)); }
235-
void Transform(const SkM44& m44) { Transform(ToDlMatrix(m44)); }
236-
void SetTransform(const SkMatrix* matrix) {
237-
if (matrix) {
238-
SetTransform(*matrix);
239-
}
240-
}
241-
void SetTransform(const SkM44* matrix44) {
242-
if (matrix44) {
243-
SetTransform(*matrix44);
244-
}
245-
}
246-
void SetTransform(const SkMatrix& matrix) {
247-
SetTransform(ToDlMatrix(matrix));
248-
}
249-
void SetTransform(const SkM44& m44) { SetTransform(ToDlMatrix(m44)); }
250-
251-
/// Returns the 4x4 full perspective transform representing all transform
252-
/// operations executed so far in this DisplayList within the enclosing
253-
/// save stack.
254-
SkM44 GetTransformFullPerspective() const { return ToSkM44(GetMatrix()); }
255-
/// Returns the 3x3 partial perspective transform representing all transform
256-
/// operations executed so far in this DisplayList within the enclosing
257-
/// save stack.
258-
SkMatrix GetTransform() const { return ToSkMatrix(GetMatrix()); }
259-
260-
void ClipRect(const SkRect& rect,
261-
DlClipOp clip_op = DlClipOp::kIntersect,
262-
bool is_aa = false) {
263-
ClipRect(ToDlRect(rect), clip_op, is_aa);
264-
}
265-
void ClipOval(const SkRect& bounds,
266-
DlClipOp clip_op = DlClipOp::kIntersect,
267-
bool is_aa = false) {
268-
ClipOval(ToDlRect(bounds), clip_op, is_aa);
269-
}
270-
void ClipRRect(const SkRRect& rrect,
271-
DlClipOp clip_op = DlClipOp::kIntersect,
272-
bool is_aa = false) {
273-
ClipRoundRect(ToDlRoundRect(rrect), clip_op, is_aa);
274-
}
275-
void ClipPath(const SkPath& path,
276-
DlClipOp clip_op = DlClipOp::kIntersect,
277-
bool is_aa = false) {
278-
ClipPath(DlPath(path), clip_op, is_aa);
279-
}
280-
281-
SkRect GetDestinationClipBounds() const {
282-
return ToSkRect(GetDestinationClipCoverage());
283-
}
284-
SkRect GetLocalClipBounds() const { return ToSkRect(GetLocalClipCoverage()); }
285-
bool QuickReject(const SkRect& bounds) const {
286-
return QuickReject(ToDlRect(bounds));
287-
}
288-
289-
void DrawLine(const SkPoint& p0, const SkPoint& p1, const DlPaint& paint) {
290-
DrawLine(ToDlPoint(p0), ToDlPoint(p1), paint);
291-
}
292-
void DrawRect(const SkRect& rect, const DlPaint& paint) {
293-
DrawRect(ToDlRect(rect), paint);
294-
}
295-
void DrawOval(const SkRect& bounds, const DlPaint& paint) {
296-
DrawOval(ToDlRect(bounds), paint);
297-
}
298-
void DrawCircle(const SkPoint& center,
299-
DlScalar radius,
300-
const DlPaint& paint) {
301-
DrawCircle(ToDlPoint(center), radius, paint);
302-
}
303-
void DrawRRect(const SkRRect& rrect, const DlPaint& paint) {
304-
DrawRoundRect(ToDlRoundRect(rrect), paint);
305-
}
306-
void DrawDRRect(const SkRRect& outer,
307-
const SkRRect& inner,
308-
const DlPaint& paint) {
309-
DrawDiffRoundRect(ToDlRoundRect(outer), ToDlRoundRect(inner), paint);
310-
}
311-
void DrawPath(const SkPath& path, const DlPaint& paint) {
312-
DrawPath(DlPath(path), paint);
313-
}
314-
void DrawArc(const SkRect& bounds,
315-
DlScalar start,
316-
DlScalar sweep,
317-
bool useCenter,
318-
const DlPaint& paint) {
319-
DrawArc(ToDlRect(bounds), start, sweep, useCenter, paint);
320-
}
321-
void DrawPoints(DlPointMode mode,
322-
uint32_t count,
323-
const SkPoint pts[],
324-
const DlPaint& paint) {
325-
DrawPoints(mode, count, ToDlPoints(pts), paint);
326-
}
327-
void DrawImage(const sk_sp<DlImage>& image,
328-
const SkPoint& point,
329-
DlImageSampling sampling,
330-
const DlPaint* paint = nullptr) {
331-
DrawImage(image, ToDlPoint(point), sampling, paint);
332-
}
333-
void DrawImageRect(
334-
const sk_sp<DlImage>& image,
335-
const SkRect& src,
336-
const SkRect& dst,
337-
DlImageSampling sampling,
338-
const DlPaint* paint = nullptr,
339-
DlSrcRectConstraint constraint = DlSrcRectConstraint::kFast) {
340-
DrawImageRect(image, ToDlRect(src), ToDlRect(dst), sampling, paint,
341-
constraint);
342-
}
343-
void DrawImageRect(
344-
const sk_sp<DlImage>& image,
345-
const SkIRect& src,
346-
const SkRect& dst,
347-
DlImageSampling sampling,
348-
const DlPaint* paint = nullptr,
349-
DlSrcRectConstraint constraint = DlSrcRectConstraint::kFast) {
350-
DrawImageRect(image, ToDlRect(src), ToDlRect(dst), sampling, paint,
351-
constraint);
352-
}
353-
void DrawImageRect(
354-
const sk_sp<DlImage>& image,
355-
const SkRect& dst,
356-
DlImageSampling sampling,
357-
const DlPaint* paint = nullptr,
358-
DlSrcRectConstraint constraint = DlSrcRectConstraint::kFast) {
359-
DrawImageRect(image, image->GetBounds(), ToDlRect(dst), sampling, paint,
360-
constraint);
361-
}
362-
void DrawImageNine(const sk_sp<DlImage>& image,
363-
const SkIRect& center,
364-
const SkRect& dst,
365-
DlFilterMode filter,
366-
const DlPaint* paint = nullptr) {
367-
DrawImageNine(image, ToDlIRect(center), ToDlRect(dst), filter, paint);
368-
}
369-
void DrawShadow(const SkPath& path,
370-
const DlColor color,
371-
const DlScalar elevation,
372-
bool transparent_occluder,
373-
DlScalar dpr) {
374-
DrawShadow(DlPath(path), color, elevation, transparent_occluder, dpr);
375-
}
376-
377-
static SkRect ComputeShadowBounds(const SkPath& path,
378-
float elevation,
379-
DlScalar dpr,
380-
const SkMatrix& ctm) {
381-
return ToSkRect(
382-
ComputeShadowBounds(DlPath(path), elevation, dpr, ToDlMatrix(ctm)));
383-
}
384-
385-
#define ENABLE_DL_CANVAS_BACKWARDS_COMPATIBILITY \
386-
using DlCanvas::GetBaseLayerSize; \
387-
\
388-
using DlCanvas::SaveLayer; \
389-
\
390-
using DlCanvas::Transform; \
391-
using DlCanvas::SetTransform; \
392-
using DlCanvas::GetTransformFullPerspective; \
393-
using DlCanvas::GetTransform; \
394-
\
395-
using DlCanvas::ClipRect; \
396-
using DlCanvas::ClipOval; \
397-
using DlCanvas::ClipPath; \
398-
\
399-
using DlCanvas::GetDestinationClipBounds; \
400-
using DlCanvas::GetLocalClipBounds; \
401-
using DlCanvas::QuickReject; \
402-
\
403-
using DlCanvas::DrawLine; \
404-
using DlCanvas::DrawRect; \
405-
using DlCanvas::DrawOval; \
406-
using DlCanvas::DrawCircle; \
407-
using DlCanvas::DrawPath; \
408-
using DlCanvas::DrawArc; \
409-
using DlCanvas::DrawPoints; \
410-
using DlCanvas::DrawImage; \
411-
using DlCanvas::DrawImageRect; \
412-
using DlCanvas::DrawImageNine; \
413-
using DlCanvas::DrawAtlas; \
414-
using DlCanvas::DrawShadow;
415213
};
416214

417215
class DlAutoCanvasRestore {

engine/src/flutter/display_list/skia/dl_sk_canvas.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ class DlSkCanvasAdapter final : public virtual DlCanvas {
165165

166166
void Flush() override;
167167

168-
ENABLE_DL_CANVAS_BACKWARDS_COMPATIBILITY
169-
170168
private:
171169
SkCanvas* delegate_;
172170
};

engine/src/flutter/display_list/testing/dl_test_snippets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static const std::shared_ptr<DlVertices> kTestVertices2 =
203203

204204
static sk_sp<DisplayList> MakeTestDisplayList(int w, int h, SkColor color) {
205205
DisplayListBuilder builder;
206-
builder.DrawRect(SkRect::MakeWH(w, h), DlPaint(DlColor(color)));
206+
builder.DrawRect(DlRect::MakeWH(w, h), DlPaint(DlColor(color)));
207207
return builder.Build();
208208
}
209209
static sk_sp<DisplayList> TestDisplayList1 =

engine/src/flutter/flow/compositor_context.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ void CompositorContext::ScopedFrame::PaintLayerTreeSkia(
169169

170170
if (needs_save_layer) {
171171
TRACE_EVENT0("flutter", "Canvas::saveLayer");
172-
SkRect bounds = SkRect::Make(ToSkISize(layer_tree.frame_size()));
172+
DlRect bounds = DlRect::MakeSize(layer_tree.frame_size());
173173
DlPaint paint;
174174
paint.setBlendMode(DlBlendMode::kSrc);
175-
canvas()->SaveLayer(&bounds, &paint);
175+
canvas()->SaveLayer(bounds, &paint);
176176
}
177177
canvas()->Clear(DlColor::kTransparent());
178178
}

engine/src/flutter/flow/embedded_views.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace flutter {
88

99
DisplayListEmbedderViewSlice::DisplayListEmbedderViewSlice(SkRect view_bounds) {
1010
builder_ = std::make_unique<DisplayListBuilder>(
11-
/*bounds=*/view_bounds,
11+
/*bounds=*/ToDlRect(view_bounds),
1212
/*prepare_rtree=*/true);
1313
}
1414

engine/src/flutter/flow/layers/layer_state_stack_unittests.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,41 +91,41 @@ TEST(LayerStateStack, OldDelegateIsRolledBack) {
9191
DisplayListBuilder builder2;
9292
DlCanvas& canvas = builder2;
9393

94-
ASSERT_TRUE(builder.GetTransform().isIdentity());
95-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
94+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
95+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
9696

9797
state_stack.set_delegate(&builder);
9898

99-
ASSERT_TRUE(builder.GetTransform().isIdentity());
100-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
99+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
100+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
101101

102102
auto mutator = state_stack.save();
103103
mutator.translate({10, 10});
104104

105-
ASSERT_EQ(builder.GetTransform(), SkMatrix::Translate(10, 10));
106-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
105+
ASSERT_EQ(builder.GetMatrix(), DlMatrix::MakeTranslation({10, 10}));
106+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
107107

108108
state_stack.set_delegate(&canvas);
109109

110-
ASSERT_TRUE(builder.GetTransform().isIdentity());
111-
ASSERT_EQ(canvas.GetTransform(), SkMatrix::Translate(10, 10));
110+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
111+
ASSERT_EQ(canvas.GetMatrix(), DlMatrix::MakeTranslation({10, 10}));
112112

113113
state_stack.set_preroll_delegate(DlRect::MakeWH(100, 100));
114114

115-
ASSERT_TRUE(builder.GetTransform().isIdentity());
116-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
115+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
116+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
117117

118118
state_stack.set_delegate(&builder);
119119
state_stack.clear_delegate();
120120

121-
ASSERT_TRUE(builder.GetTransform().isIdentity());
122-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
121+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
122+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
123123

124124
state_stack.set_delegate(&canvas);
125125
state_stack.clear_delegate();
126126

127-
ASSERT_TRUE(builder.GetTransform().isIdentity());
128-
ASSERT_TRUE(canvas.GetTransform().isIdentity());
127+
ASSERT_TRUE(builder.GetMatrix().IsIdentity());
128+
ASSERT_TRUE(canvas.GetMatrix().IsIdentity());
129129
}
130130

131131
TEST(LayerStateStack, Opacity) {

engine/src/flutter/flow/layers/texture_layer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void TextureLayer::Paint(PaintContext& context) const {
6363
.aiks_context = context.aiks_context,
6464
.paint = context.state_stack.fill(paint),
6565
};
66-
texture->Paint(ctx, ToSkRect(paint_bounds()), freeze_, sampling_);
66+
texture->Paint(ctx, paint_bounds(), freeze_, sampling_);
6767
}
6868

6969
} // namespace flutter

0 commit comments

Comments
 (0)