|
4 | 4 |
|
5 | 5 | #include "flutter/flow/layers/physical_shape_layer.h" |
6 | 6 |
|
| 7 | +#include "flutter/flow/testing/diff_context_test.h" |
7 | 8 | #include "flutter/flow/testing/layer_test.h" |
8 | 9 | #include "flutter/flow/testing/mock_layer.h" |
9 | 10 | #include "flutter/fml/macros.h" |
@@ -350,5 +351,43 @@ TEST_F(PhysicalShapeLayerTest, Readback) { |
350 | 351 | EXPECT_TRUE(ReadbackResult(context, save_layer, reader, true)); |
351 | 352 | } |
352 | 353 |
|
| 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 | + |
353 | 392 | } // namespace testing |
354 | 393 | } // namespace flutter |
0 commit comments