Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3b75e3d

Browse files
authored
[Impeller] Reland DlAiksCanvas (#45232)
Relands #45131 Fixes flutter/flutter#132416 Differences from last time: - Some minor merge conflict fixes - Use the RTree to get the bounds instead of recalculating the bounds - Make the iOS platform view controller implementation use the impeller-aware slices instead of the display list ones. This has been fixed for Android and the desktop embedding, but I missed iOS. The unit tests weren't actually running before I branched for my PR, @zanderso fixed them up separately and this resulted in catching the failures on post submit last time.
1 parent 64ae66a commit 3b75e3d

File tree

92 files changed

+2697
-466
lines changed

Some content is hidden

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

92 files changed

+2697
-466
lines changed

ci/licenses_golden/excluded_files

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
../../../flutter/display_list/benchmarking/dl_complexity_unittests.cc
3333
../../../flutter/display_list/display_list_unittests.cc
3434
../../../flutter/display_list/dl_color_unittests.cc
35+
../../../flutter/display_list/dl_op_spy_unittests.cc
3536
../../../flutter/display_list/dl_paint_unittests.cc
3637
../../../flutter/display_list/dl_vertices_unittests.cc
3738
../../../flutter/display_list/effects/dl_color_filter_unittests.cc
@@ -53,6 +54,7 @@
5354
../../../flutter/flow/flow_run_all_unittests.cc
5455
../../../flutter/flow/frame_timings_recorder_unittests.cc
5556
../../../flutter/flow/gl_context_switch_unittests.cc
57+
../../../flutter/flow/layers/aiks_layer_unittests.cc
5658
../../../flutter/flow/layers/backdrop_filter_layer_unittests.cc
5759
../../../flutter/flow/layers/checkerboard_layertree_unittests.cc
5860
../../../flutter/flow/layers/clip_path_layer_unittests.cc
@@ -222,7 +224,6 @@
222224
../../../flutter/runtime/type_conversions_unittests.cc
223225
../../../flutter/shell/common/animator_unittests.cc
224226
../../../flutter/shell/common/context_options_unittests.cc
225-
../../../flutter/shell/common/dl_op_spy_unittests.cc
226227
../../../flutter/shell/common/engine_unittests.cc
227228
../../../flutter/shell/common/fixtures
228229
../../../flutter/shell/common/input_events_unittests.cc

ci/licenses_golden/licenses_flutter

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ ORIGIN: ../../../flutter/display_list/dl_op_recorder.cc + ../../../flutter/LICEN
735735
ORIGIN: ../../../flutter/display_list/dl_op_recorder.h + ../../../flutter/LICENSE
736736
ORIGIN: ../../../flutter/display_list/dl_op_records.cc + ../../../flutter/LICENSE
737737
ORIGIN: ../../../flutter/display_list/dl_op_records.h + ../../../flutter/LICENSE
738+
ORIGIN: ../../../flutter/display_list/dl_op_spy.cc + ../../../flutter/LICENSE
739+
ORIGIN: ../../../flutter/display_list/dl_op_spy.h + ../../../flutter/LICENSE
738740
ORIGIN: ../../../flutter/display_list/dl_paint.cc + ../../../flutter/LICENSE
739741
ORIGIN: ../../../flutter/display_list/dl_paint.h + ../../../flutter/LICENSE
740742
ORIGIN: ../../../flutter/display_list/dl_sampling_options.h + ../../../flutter/LICENSE
@@ -789,6 +791,8 @@ ORIGIN: ../../../flutter/flow/frame_timings.cc + ../../../flutter/LICENSE
789791
ORIGIN: ../../../flutter/flow/frame_timings.h + ../../../flutter/LICENSE
790792
ORIGIN: ../../../flutter/flow/layer_snapshot_store.cc + ../../../flutter/LICENSE
791793
ORIGIN: ../../../flutter/flow/layer_snapshot_store.h + ../../../flutter/LICENSE
794+
ORIGIN: ../../../flutter/flow/layers/aiks_layer.cc + ../../../flutter/LICENSE
795+
ORIGIN: ../../../flutter/flow/layers/aiks_layer.h + ../../../flutter/LICENSE
792796
ORIGIN: ../../../flutter/flow/layers/backdrop_filter_layer.cc + ../../../flutter/LICENSE
793797
ORIGIN: ../../../flutter/flow/layers/backdrop_filter_layer.h + ../../../flutter/LICENSE
794798
ORIGIN: ../../../flutter/flow/layers/cacheable_layer.cc + ../../../flutter/LICENSE
@@ -1167,6 +1171,8 @@ ORIGIN: ../../../flutter/impeller/core/texture_descriptor.cc + ../../../flutter/
11671171
ORIGIN: ../../../flutter/impeller/core/texture_descriptor.h + ../../../flutter/LICENSE
11681172
ORIGIN: ../../../flutter/impeller/core/vertex_buffer.cc + ../../../flutter/LICENSE
11691173
ORIGIN: ../../../flutter/impeller/core/vertex_buffer.h + ../../../flutter/LICENSE
1174+
ORIGIN: ../../../flutter/impeller/display_list/dl_aiks_canvas.cc + ../../../flutter/LICENSE
1175+
ORIGIN: ../../../flutter/impeller/display_list/dl_aiks_canvas.h + ../../../flutter/LICENSE
11701176
ORIGIN: ../../../flutter/impeller/display_list/dl_dispatcher.cc + ../../../flutter/LICENSE
11711177
ORIGIN: ../../../flutter/impeller/display_list/dl_dispatcher.h + ../../../flutter/LICENSE
11721178
ORIGIN: ../../../flutter/impeller/display_list/dl_image_impeller.cc + ../../../flutter/LICENSE
@@ -2247,8 +2253,6 @@ ORIGIN: ../../../flutter/shell/common/display.cc + ../../../flutter/LICENSE
22472253
ORIGIN: ../../../flutter/shell/common/display.h + ../../../flutter/LICENSE
22482254
ORIGIN: ../../../flutter/shell/common/display_manager.cc + ../../../flutter/LICENSE
22492255
ORIGIN: ../../../flutter/shell/common/display_manager.h + ../../../flutter/LICENSE
2250-
ORIGIN: ../../../flutter/shell/common/dl_op_spy.cc + ../../../flutter/LICENSE
2251-
ORIGIN: ../../../flutter/shell/common/dl_op_spy.h + ../../../flutter/LICENSE
22522256
ORIGIN: ../../../flutter/shell/common/engine.cc + ../../../flutter/LICENSE
22532257
ORIGIN: ../../../flutter/shell/common/engine.h + ../../../flutter/LICENSE
22542258
ORIGIN: ../../../flutter/shell/common/pipeline.cc + ../../../flutter/LICENSE
@@ -3485,6 +3489,8 @@ FILE: ../../../flutter/display_list/dl_op_recorder.cc
34853489
FILE: ../../../flutter/display_list/dl_op_recorder.h
34863490
FILE: ../../../flutter/display_list/dl_op_records.cc
34873491
FILE: ../../../flutter/display_list/dl_op_records.h
3492+
FILE: ../../../flutter/display_list/dl_op_spy.cc
3493+
FILE: ../../../flutter/display_list/dl_op_spy.h
34883494
FILE: ../../../flutter/display_list/dl_paint.cc
34893495
FILE: ../../../flutter/display_list/dl_paint.h
34903496
FILE: ../../../flutter/display_list/dl_sampling_options.h
@@ -3539,6 +3545,8 @@ FILE: ../../../flutter/flow/frame_timings.cc
35393545
FILE: ../../../flutter/flow/frame_timings.h
35403546
FILE: ../../../flutter/flow/layer_snapshot_store.cc
35413547
FILE: ../../../flutter/flow/layer_snapshot_store.h
3548+
FILE: ../../../flutter/flow/layers/aiks_layer.cc
3549+
FILE: ../../../flutter/flow/layers/aiks_layer.h
35423550
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.cc
35433551
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.h
35443552
FILE: ../../../flutter/flow/layers/cacheable_layer.cc
@@ -3917,6 +3925,8 @@ FILE: ../../../flutter/impeller/core/texture_descriptor.cc
39173925
FILE: ../../../flutter/impeller/core/texture_descriptor.h
39183926
FILE: ../../../flutter/impeller/core/vertex_buffer.cc
39193927
FILE: ../../../flutter/impeller/core/vertex_buffer.h
3928+
FILE: ../../../flutter/impeller/display_list/dl_aiks_canvas.cc
3929+
FILE: ../../../flutter/impeller/display_list/dl_aiks_canvas.h
39203930
FILE: ../../../flutter/impeller/display_list/dl_dispatcher.cc
39213931
FILE: ../../../flutter/impeller/display_list/dl_dispatcher.h
39223932
FILE: ../../../flutter/impeller/display_list/dl_image_impeller.cc
@@ -5002,8 +5012,6 @@ FILE: ../../../flutter/shell/common/display.cc
50025012
FILE: ../../../flutter/shell/common/display.h
50035013
FILE: ../../../flutter/shell/common/display_manager.cc
50045014
FILE: ../../../flutter/shell/common/display_manager.h
5005-
FILE: ../../../flutter/shell/common/dl_op_spy.cc
5006-
FILE: ../../../flutter/shell/common/dl_op_spy.h
50075015
FILE: ../../../flutter/shell/common/engine.cc
50085016
FILE: ../../../flutter/shell/common/engine.h
50095017
FILE: ../../../flutter/shell/common/pipeline.cc

display_list/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ source_set("display_list") {
4343
"dl_op_recorder.h",
4444
"dl_op_records.cc",
4545
"dl_op_records.h",
46+
"dl_op_spy.cc",
47+
"dl_op_spy.h",
4648
"dl_paint.cc",
4749
"dl_paint.h",
4850
"dl_sampling_options.h",
@@ -111,6 +113,7 @@ if (enable_unittests) {
111113
"benchmarking/dl_complexity_unittests.cc",
112114
"display_list_unittests.cc",
113115
"dl_color_unittests.cc",
116+
"dl_op_spy_unittests.cc",
114117
"dl_paint_unittests.cc",
115118
"dl_vertices_unittests.cc",
116119
"effects/dl_color_filter_unittests.cc",

display_list/display_list.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DisplayList::DisplayList(DlStorage&& storage,
3333
bool can_apply_group_opacity,
3434
bool is_ui_thread_safe,
3535
bool modifies_transparent_black,
36-
sk_sp<const DlRTree> rtree)
36+
std::shared_ptr<const DlRTree> rtree)
3737
: storage_(std::move(storage)),
3838
op_count_(op_count),
3939
nested_byte_count_(nested_byte_count),

display_list/display_list.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class DisplayList : public SkRefCnt {
234234
const SkRect& bounds() const { return bounds_; }
235235

236236
bool has_rtree() const { return rtree_ != nullptr; }
237-
sk_sp<const DlRTree> rtree() const { return rtree_; }
237+
std::shared_ptr<const DlRTree> rtree() const { return rtree_; }
238238

239239
bool Equals(const DisplayList* other) const;
240240
bool Equals(const DisplayList& other) const { return Equals(&other); }
@@ -300,7 +300,7 @@ class DisplayList : public SkRefCnt {
300300
bool can_apply_group_opacity,
301301
bool is_ui_thread_safe,
302302
bool modifies_transparent_black,
303-
sk_sp<const DlRTree> rtree);
303+
std::shared_ptr<const DlRTree> rtree);
304304

305305
static uint32_t next_unique_id();
306306

@@ -317,7 +317,7 @@ class DisplayList : public SkRefCnt {
317317
const bool is_ui_thread_safe_;
318318
const bool modifies_transparent_black_;
319319

320-
const sk_sp<const DlRTree> rtree_;
320+
const std::shared_ptr<const DlRTree> rtree_;
321321

322322
void Dispatch(DlOpReceiver& ctx,
323323
uint8_t* ptr,

display_list/display_list_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ TEST_F(DisplayListTest, FlatDrawPointsProducesBounds) {
19321932
}
19331933
}
19341934

1935-
static void test_rtree(const sk_sp<const DlRTree>& rtree,
1935+
static void test_rtree(const std::shared_ptr<const DlRTree>& rtree,
19361936
const SkRect& query,
19371937
std::vector<SkRect> expected_rects,
19381938
const std::vector<int>& expected_indices) {

display_list/dl_canvas.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include "third_party/skia/include/core/SkRect.h"
1919
#include "third_party/skia/include/core/SkTextBlob.h"
2020

21+
namespace impeller {
22+
struct Picture;
23+
} // namespace impeller
24+
2125
namespace flutter {
2226

2327
//------------------------------------------------------------------------------
@@ -61,7 +65,12 @@ class DlCanvas {
6165
const DlImageFilter* backdrop = nullptr) = 0;
6266
virtual void Restore() = 0;
6367
virtual int GetSaveCount() const = 0;
64-
virtual void RestoreToCount(int restore_count) = 0;
68+
virtual void RestoreToCount(int restore_count) {
69+
FML_DCHECK(restore_count <= GetSaveCount());
70+
while (restore_count < GetSaveCount() && GetSaveCount() > 1) {
71+
Restore();
72+
}
73+
}
6574

6675
virtual void Translate(SkScalar tx, SkScalar ty) = 0;
6776
virtual void Scale(SkScalar sx, SkScalar sy) = 0;
@@ -201,6 +210,9 @@ class DlCanvas {
201210
const DlPaint* paint = nullptr) = 0;
202211
virtual void DrawDisplayList(const sk_sp<DisplayList> display_list,
203212
SkScalar opacity = SK_Scalar1) = 0;
213+
virtual void DrawImpellerPicture(
214+
const std::shared_ptr<const impeller::Picture>& picture,
215+
SkScalar opacity = SK_Scalar1) = 0;
204216
virtual void DrawTextBlob(const sk_sp<SkTextBlob>& blob,
205217
SkScalar x,
206218
SkScalar y,

display_list/dl_canvas_to_receiver.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,12 @@ void DlCanvasToReceiver::DrawDisplayList(const sk_sp<DisplayList> display_list,
811811
: OpResult::kPreservesTransparency,
812812
display_list->can_apply_group_opacity());
813813
}
814+
void DlCanvasToReceiver::DrawImpellerPicture(
815+
const std::shared_ptr<const impeller::Picture>& picture,
816+
SkScalar opacity) {
817+
FML_LOG(ERROR) << "Cannot draw Impeller Picture in to a a display list.";
818+
FML_DCHECK(false);
819+
}
814820
void DlCanvasToReceiver::DrawTextBlob(const sk_sp<SkTextBlob>& blob,
815821
SkScalar x,
816822
SkScalar y,

display_list/dl_canvas_to_receiver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "flutter/display_list/dl_op_receiver.h"
1111
#include "flutter/fml/macros.h"
1212

13+
namespace impeller {
14+
struct Picture;
15+
}
16+
1317
namespace flutter {
1418

1519
class DlCanvasReceiver : public DlOpReceiver {
@@ -337,6 +341,10 @@ class DlCanvasToReceiver : public virtual DlCanvas, //
337341
void DrawDisplayList(const sk_sp<DisplayList> display_list,
338342
SkScalar opacity = SK_Scalar1) override;
339343
// |DlCanvas|
344+
void DrawImpellerPicture(
345+
const std::shared_ptr<const impeller::Picture>& picture,
346+
SkScalar opacity = SK_Scalar1) override;
347+
// |DlCanvas|
340348
void DrawTextBlob(const sk_sp<SkTextBlob>& blob,
341349
SkScalar x,
342350
SkScalar y,

shell/common/dl_op_spy.cc renamed to display_list/dl_op_spy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/shell/common/dl_op_spy.h"
5+
#include "flutter/display_list/dl_op_spy.h"
66

77
namespace flutter {
88

0 commit comments

Comments
 (0)