|
7 | 7 | #include "display_list/dl_tile_mode.h" |
8 | 8 | #include "display_list/effects/dl_color_source.h" |
9 | 9 | #include "display_list/effects/dl_mask_filter.h" |
10 | | -#include "flutter/impeller/display_list/aiks_unittests.h" |
11 | | - |
12 | 10 | #include "flutter/display_list/dl_builder.h" |
13 | 11 | #include "flutter/display_list/dl_color.h" |
14 | 12 | #include "flutter/display_list/dl_paint.h" |
| 13 | +#include "flutter/fml/build_config.h" |
| 14 | +#include "flutter/impeller/display_list/aiks_unittests.h" |
15 | 15 | #include "flutter/testing/testing.h" |
16 | 16 | #include "impeller/geometry/matrix.h" |
17 | 17 | #include "impeller/typographer/backends/skia/text_frame_skia.h" |
@@ -483,5 +483,81 @@ TEST_P(AiksTest, TextForegroundShaderWithTransform) { |
483 | 483 | ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); |
484 | 484 | } |
485 | 485 |
|
| 486 | +// Regression test for https://github.com/flutter/flutter/issues/157885. |
| 487 | +TEST_P(AiksTest, DifferenceClipsMustRenderIdenticallyAcrossBackends) { |
| 488 | + DisplayListBuilder builder; |
| 489 | + |
| 490 | + DlPaint paint; |
| 491 | + DlColor clear_color(1.0, 0.5, 0.5, 0.5, DlColorSpace::kSRGB); |
| 492 | + paint.setColor(clear_color); |
| 493 | + builder.DrawPaint(paint); |
| 494 | + |
| 495 | + DlMatrix identity = { |
| 496 | + 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, |
| 497 | + 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, |
| 498 | + }; |
| 499 | + builder.Save(); |
| 500 | + builder.Transform(identity); |
| 501 | + |
| 502 | + DlRect frame = DlRect::MakeLTRB(1.0, 1.0, 1278.0, 763.0); |
| 503 | + DlColor white(1.0, 1.0, 1.0, 1.0, DlColorSpace::kSRGB); |
| 504 | + paint.setColor(white); |
| 505 | + builder.DrawRect(frame, paint); |
| 506 | + |
| 507 | + builder.Save(); |
| 508 | + builder.ClipRect(frame, DlCanvas::ClipOp::kIntersect); |
| 509 | + |
| 510 | + DlMatrix rect_xform = { |
| 511 | + 0.8241262, 0.56640625, 0.0, 0.0, -0.56640625, 0.8241262, 0.0, 0.0, |
| 512 | + 0.0, 0.0, 1.0, 0.0, 271.1137, 489.4733, 0.0, 1.0, |
| 513 | + }; |
| 514 | + builder.Save(); |
| 515 | + builder.Transform(rect_xform); |
| 516 | + |
| 517 | + DlRect rect = DlRect::MakeLTRB(0.0, 0.0, 100.0, 100.0); |
| 518 | + DlColor bluish(1.0, 0.184, 0.501, 0.929, DlColorSpace::kSRGB); |
| 519 | + paint.setColor(bluish); |
| 520 | + DlRoundRect rrect = DlRoundRect::MakeRectRadius(rect, 18.0); |
| 521 | + builder.DrawRoundRect(rrect, paint); |
| 522 | + |
| 523 | + builder.Save(); |
| 524 | + builder.ClipRect(rect, DlCanvas::ClipOp::kIntersect); |
| 525 | + builder.Restore(); |
| 526 | + |
| 527 | + builder.Restore(); |
| 528 | + |
| 529 | + DlMatrix path_xform = { |
| 530 | + 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, |
| 531 | + 0.0, 0.0, 1.0, 0.0, 675.0, 279.5, 0.0, 1.0, |
| 532 | + }; |
| 533 | + builder.Save(); |
| 534 | + builder.Transform(path_xform); |
| 535 | + |
| 536 | + SkPath path; |
| 537 | + path.moveTo(87.5, 349.5); |
| 538 | + path.lineTo(25.0, 29.5); |
| 539 | + path.lineTo(150.0, 118.0); |
| 540 | + path.lineTo(25.0, 118.0); |
| 541 | + path.lineTo(150.0, 29.5); |
| 542 | + path.close(); |
| 543 | + |
| 544 | + DlColor fill_color(1.0, 1.0, 0.0, 0.0, DlColorSpace::kSRGB); |
| 545 | + DlColor stroke_color(1.0, 0.0, 0.0, 0.0, DlColorSpace::kSRGB); |
| 546 | + paint.setColor(fill_color); |
| 547 | + paint.setDrawStyle(DlDrawStyle::kFill); |
| 548 | + builder.DrawPath(DlPath(path), paint); |
| 549 | + |
| 550 | + paint.setColor(stroke_color); |
| 551 | + paint.setStrokeWidth(2.0); |
| 552 | + paint.setDrawStyle(DlDrawStyle::kStroke); |
| 553 | + builder.DrawPath(path, paint); |
| 554 | + |
| 555 | + builder.Restore(); |
| 556 | + builder.Restore(); |
| 557 | + builder.Restore(); |
| 558 | + |
| 559 | + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); |
| 560 | +} |
| 561 | + |
486 | 562 | } // namespace testing |
487 | 563 | } // namespace impeller |
0 commit comments