Skip to content

Commit

Permalink
Correctly offset the cull rect of the opacity layer. (#50928)
Browse files Browse the repository at this point in the history
This fixes flutter/flutter#140999. Previously, the cull rect would be misplaced causing many elements to not render at all.
  • Loading branch information
eyebrowsoffire authored Feb 26, 2024
1 parent 99dd2c8 commit add0f51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/web_ui/lib/src/engine/layers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class OpacityOperation implements LayerOperation {
if (offset != ui.Offset.zero) {
canvas.save();
canvas.translate(offset.dx, offset.dy);
cullRect = cullRect.shift(-offset);
}
canvas.saveLayer(
cullRect,
Expand Down
6 changes: 3 additions & 3 deletions lib/web_ui/test/ui/scene_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ Future<void> testMain() async {
);
}));

sceneBuilder.pushOpacity(0x7F);
sceneBuilder.pushOpacity(0x7F, offset: const ui.Offset(150, 150));
sceneBuilder.addPicture(ui.Offset.zero, drawPicture((ui.Canvas canvas) {
final ui.Paint paint = ui.Paint()..color = const ui.Color(0xFFFF0000);
canvas.drawCircle(
const ui.Offset(125, 150),
const ui.Offset(-25, 0),
50,
paint
);
canvas.drawCircle(
const ui.Offset(175, 150),
const ui.Offset(25, 0),
50,
paint
);
Expand Down

0 comments on commit add0f51

Please sign in to comment.