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

Commit 3734ef3

Browse files
author
Emmanuel Garcia
committed
Fix composition
1 parent 23a35d0 commit 3734ef3

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

shell/platform/android/external_view_embedder/external_view_embedder.cc

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ void AndroidExternalViewEmbedder::SubmitFrame(
104104
overlay_layers.insert({view_id, {}});
105105

106106
sk_sp<RTree> rtree = view_rtrees_.at(view_id);
107+
SkRect joined_rect;
108+
107109
// Determinate if Flutter UI intersects with any of the previous
108110
// platform views stacked by z position.
109111
//
@@ -116,33 +118,26 @@ void AndroidExternalViewEmbedder::SubmitFrame(
116118
// Each rect corresponds to a native view that renders Flutter UI.
117119
std::list<SkRect> intersection_rects =
118120
rtree->searchNonOverlappingDrawnRects(current_view_rect);
119-
auto allocation_size = intersection_rects.size();
120121

121122
// Limit the number of native views, so it doesn't grow forever.
122123
//
123124
// In this case, the rects are merged into a single one that is the union
124125
// of all the rects.
125-
if (allocation_size > kMaxLayerAllocations) {
126-
SkRect joined_rect;
127-
for (const SkRect& rect : intersection_rects) {
128-
joined_rect.join(rect);
129-
}
130-
intersection_rects.clear();
131-
intersection_rects.push_back(joined_rect);
132-
}
133-
for (SkRect& intersection_rect : intersection_rects) {
134-
// Subpixels in the platform may not align with the canvas subpixels.
135-
//
136-
// To workaround it, round the floating point bounds and make the rect
137-
// slightly larger. For example, {0.3, 0.5, 3.1, 4.7} becomes {0, 0, 4,
138-
// 5}.
139-
intersection_rect.set(intersection_rect.roundOut());
140-
overlay_layers.at(view_id).push_back(intersection_rect);
141-
// Clip the background canvas, so it doesn't contain any of the pixels
142-
// drawn on the overlay layer.
143-
background_canvas->clipRect(intersection_rect, SkClipOp::kDifference);
126+
for (const SkRect& rect : intersection_rects) {
127+
joined_rect.join(rect);
144128
}
145129
}
130+
131+
// Subpixels in the platform may not align with the canvas subpixels.
132+
//
133+
// To workaround it, round the floating point bounds and make the rect
134+
// slightly larger. For example, {0.3, 0.5, 3.1, 4.7} becomes {0, 0, 4,
135+
// 5}.
136+
joined_rect.set(joined_rect.roundOut());
137+
overlay_layers.at(view_id).push_back(joined_rect);
138+
// Clip the background canvas, so it doesn't contain any of the pixels
139+
// drawn on the overlay layer.
140+
background_canvas->clipRect(joined_rect, SkClipOp::kDifference);
146141
background_canvas->drawPicture(pictures.at(view_id));
147142
}
148143
// Submit the background canvas frame before switching the GL context to

shell/platform/android/external_view_embedder/external_view_embedder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder {
8080
SkRect GetViewRect(int view_id) const;
8181

8282
private:
83-
static const int kMaxLayerAllocations = 2;
84-
8583
// The number of frames the rasterizer task runner will continue
8684
// to run on the platform thread after no platform view is rendered.
8785
//

0 commit comments

Comments
 (0)