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

Commit e04bc2b

Browse files
xsterknopp
andauthored
Cherrypick #29783 to flutter-2.8-candidate.6 (#29812)
* PhysicalShapeLayer: Only push cull rect during diff if clipping (#29783) * add branch to test for CI Co-authored-by: Matej Knopp <[email protected]>
1 parent 766f3a5 commit e04bc2b

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enabled_branches:
1111
- dev
1212
- beta
1313
- stable
14+
- flutter-2.8-candidate.6
1415

1516
platform_properties:
1617
linux:

flow/layers/physical_shape_layer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ void PhysicalShapeLayer::Diff(DiffContext* context, const Layer* old_layer) {
4646

4747
context->AddLayerBounds(bounds);
4848

49-
if (context->PushCullRect(bounds)) {
49+
// Only push cull rect if there is clip.
50+
if (clip_behavior_ == Clip::none || context->PushCullRect(bounds)) {
5051
DiffChildren(context, prev);
5152
}
5253
context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());

flow/layers/physical_shape_layer_unittests.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "flutter/flow/layers/physical_shape_layer.h"
66

7+
#include "flutter/flow/testing/diff_context_test.h"
78
#include "flutter/flow/testing/layer_test.h"
89
#include "flutter/flow/testing/mock_layer.h"
910
#include "flutter/fml/macros.h"
@@ -350,5 +351,43 @@ TEST_F(PhysicalShapeLayerTest, Readback) {
350351
EXPECT_TRUE(ReadbackResult(context, save_layer, reader, true));
351352
}
352353

354+
using PhysicalShapeLayerDiffTest = DiffContextTest;
355+
356+
TEST_F(PhysicalShapeLayerDiffTest, NoClipPaintRegion) {
357+
MockLayerTree tree1;
358+
const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100));
359+
auto layer =
360+
std::make_shared<PhysicalShapeLayer>(SK_ColorGREEN, SK_ColorBLACK,
361+
0.0f, // elevation
362+
layer_path, Clip::none);
363+
364+
const SkPath layer_path2 =
365+
SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200));
366+
auto layer2 = std::make_shared<MockLayer>(layer_path2);
367+
layer->Add(layer2);
368+
tree1.root()->Add(layer);
369+
370+
auto damage = DiffLayerTree(tree1, MockLayerTree());
371+
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 400, 400));
372+
}
373+
374+
TEST_F(PhysicalShapeLayerDiffTest, ClipPaintRegion) {
375+
MockLayerTree tree1;
376+
const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100));
377+
auto layer =
378+
std::make_shared<PhysicalShapeLayer>(SK_ColorGREEN, SK_ColorBLACK,
379+
0.0f, // elevation
380+
layer_path, Clip::hardEdge);
381+
382+
const SkPath layer_path2 =
383+
SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200));
384+
auto layer2 = std::make_shared<MockLayer>(layer_path2);
385+
layer->Add(layer2);
386+
tree1.root()->Add(layer);
387+
388+
auto damage = DiffLayerTree(tree1, MockLayerTree());
389+
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 100, 100));
390+
}
391+
353392
} // namespace testing
354393
} // namespace flutter

0 commit comments

Comments
 (0)