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

Commit a5c79b9

Browse files
author
Emmanuel Garcia
committed
Debug test
1 parent 389edb1 commit a5c79b9

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

shell/platform/android/external_view_embedder/external_view_embedder.cc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void AndroidExternalViewEmbedder::SubmitFrame(
8484
return;
8585
}
8686

87-
std::unordered_map<int64_t, std::list<SkRect>> overlay_layers;
87+
std::unordered_map<int64_t, SkRect> overlay_layers;
8888
std::unordered_map<int64_t, sk_sp<SkPicture>> pictures;
8989
SkCanvas* background_canvas = frame->SkiaCanvas();
9090
auto current_frame_view_count = composition_order_.size();
@@ -101,10 +101,8 @@ void AndroidExternalViewEmbedder::SubmitFrame(
101101
FML_CHECK(picture);
102102
pictures.insert({view_id, picture});
103103

104-
overlay_layers.insert({view_id, {}});
105-
106104
sk_sp<RTree> rtree = view_rtrees_.at(view_id);
107-
SkRect joined_rect;
105+
SkRect joined_rect = SkRect::MakeEmpty();
108106

109107
// Determinate if Flutter UI intersects with any of the previous
110108
// platform views stacked by z position.
@@ -128,14 +126,18 @@ void AndroidExternalViewEmbedder::SubmitFrame(
128126
}
129127
}
130128

129+
if (joined_rect.isEmpty()) {
130+
continue;
131+
}
132+
131133
// Subpixels in the platform may not align with the canvas subpixels.
132134
//
133135
// To workaround it, round the floating point bounds and make the rect
134136
// slightly larger.
135137
//
136138
// For example, {0.3, 0.5, 3.1, 4.7} becomes {0, 0, 4, 5}.
137139
joined_rect.set(joined_rect.roundOut());
138-
overlay_layers.at(view_id).push_back(joined_rect);
140+
overlay_layers.insert({view_id, joined_rect});
139141
// Clip the background canvas, so it doesn't contain any of the pixels
140142
// drawn on the overlay layer.
141143
background_canvas->clipRect(joined_rect, SkClipOp::kDifference);
@@ -166,16 +168,15 @@ void AndroidExternalViewEmbedder::SubmitFrame(
166168
params.sizePoints().height() * device_pixel_ratio_,
167169
params.mutatorsStack() //
168170
);
169-
for (const SkRect& overlay_rect : overlay_layers.at(view_id)) {
170-
std::unique_ptr<SurfaceFrame> frame =
171-
CreateSurfaceIfNeeded(context, //
172-
view_id, //
173-
pictures.at(view_id), //
174-
overlay_rect //
175-
);
176-
if (should_submit_current_frame) {
177-
frame->Submit();
178-
}
171+
const SkRect& overlay_rect = overlay_layers.at(view_id);
172+
std::unique_ptr<SurfaceFrame> frame =
173+
CreateSurfaceIfNeeded(context, //
174+
view_id, //
175+
pictures.at(view_id), //
176+
overlay_rect //
177+
);
178+
if (should_submit_current_frame) {
179+
frame->Submit();
179180
}
180181
}
181182
}

shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -517,48 +517,54 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame__overlayComposition) {
517517
EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
518518
embedder->BeginFrame(frame_size, nullptr, 1.5, raster_thread_merger);
519519

520-
// Add first Android view.
521-
SkMatrix matrix1;
522-
MutatorsStack stack1;
523-
stack1.PushTransform(SkMatrix::Translate(0, 0));
524-
525-
embedder->PrerollCompositeEmbeddedView(
526-
0, std::make_unique<EmbeddedViewParams>(matrix1, SkSize::Make(200, 200),
527-
stack1));
528-
EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
529-
300, 300, stack1));
520+
{
521+
// Add first Android view.
522+
SkMatrix matrix;
523+
MutatorsStack stack;
524+
stack.PushTransform(SkMatrix::Translate(0, 0));
525+
526+
embedder->PrerollCompositeEmbeddedView(
527+
0, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(200, 200),
528+
stack));
529+
EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
530+
300, 300, stack));
531+
}
530532

531533
auto rect_paint = SkPaint();
532534
rect_paint.setColor(SkColors::kCyan);
533535
rect_paint.setStyle(SkPaint::Style::kFill_Style);
534536

535537
// This simulates Flutter UI that intersects with the first Android view.
536538
embedder->CompositeEmbeddedView(0)->drawRect(
537-
SkRect::MakeXYWH(25, 25, 50, 150), rect_paint);
538-
539-
// Add second Android view.
540-
SkMatrix matrix2;
541-
MutatorsStack stack2;
542-
stack2.PushTransform(SkMatrix::Translate(0, 100));
543-
544-
embedder->PrerollCompositeEmbeddedView(
545-
1, std::make_unique<EmbeddedViewParams>(matrix2, SkSize::Make(100, 100),
546-
stack2));
547-
EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(1, 0, 0, 100, 100,
548-
150, 150, stack2));
539+
SkRect::MakeXYWH(25, 25, 80, 150), rect_paint);
549540

541+
{
542+
// Add second Android view.
543+
SkMatrix matrix;
544+
MutatorsStack stack;
545+
stack.PushTransform(SkMatrix::Translate(0, 100));
546+
547+
embedder->PrerollCompositeEmbeddedView(
548+
1, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(100, 100),
549+
stack));
550+
EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(1, 0, 0, 100, 100,
551+
150, 150, stack));
552+
}
550553
// This simulates Flutter UI that intersects with the first and second Android
551554
// views.
552-
embedder->CompositeEmbeddedView(1)->drawRect(SkRect::MakeXYWH(25, 25, 50, 50),
555+
embedder->CompositeEmbeddedView(1)->drawRect(SkRect::MakeXYWH(25, 25, 80, 50),
553556
rect_paint);
554557

558+
embedder->CompositeEmbeddedView(1)->drawRect(
559+
SkRect::MakeXYWH(75, 75, 30, 100), rect_paint);
560+
555561
EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
556562
.WillRepeatedly([&]() {
557563
return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
558564
1, window);
559565
});
560566

561-
EXPECT_CALL(*jni_mock, FlutterViewDisplayOverlaySurface(1, 25, 25, 50, 150))
567+
EXPECT_CALL(*jni_mock, FlutterViewDisplayOverlaySurface(1, 25, 25, 80, 150))
562568
.Times(2);
563569

564570
auto surface_frame = std::make_unique<SurfaceFrame>(

testing/run_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def RunCCTests(build_dir, filter):
124124
]
125125
shuffle_flags = non_repeatable_shuffle_flags + [
126126
"--gtest_repeat=2",
127-
"--gmock_verbose=info",
128127
]
129128

130129
RunEngineExecutable(build_dir, 'client_wrapper_glfw_unittests', filter, shuffle_flags)

0 commit comments

Comments
 (0)