|
18 | 18 | #include "flutter/display_list/dl_paint.h" |
19 | 19 | #include "flutter/impeller/display_list/dl_image_impeller.h" |
20 | 20 | #include "flutter/impeller/geometry/scalar.h" |
| 21 | +#include "fml/synchronization/count_down_latch.h" |
| 22 | +#include "impeller/core/device_buffer.h" |
21 | 23 | #include "impeller/display_list/aiks_context.h" |
22 | 24 | #include "impeller/display_list/dl_dispatcher.h" |
23 | 25 | #include "impeller/playground/playground.h" |
@@ -827,6 +829,57 @@ TEST_P(AiksTest, FramebufferAdvancedBlendCoverage) { |
827 | 829 | ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); |
828 | 830 | } |
829 | 831 |
|
| 832 | +// Regression test for https://github.com/flutter/flutter/issues/179547. |
| 833 | +TEST_P(AiksTest, FramebufferBlendDifferenceNoDiagonalSeam) { |
| 834 | + DisplayListBuilder builder; |
| 835 | + builder.DrawPaint(DlPaint().setColor(DlColor::kBlack())); |
| 836 | + |
| 837 | + // Use a non-fullscreen rect so Canvas does not fold it into clear_color. |
| 838 | + DlPaint rect_paint; |
| 839 | + rect_paint.setColor(DlColor::kWhite()); |
| 840 | + rect_paint.setBlendMode(DlBlendMode::kDifference); |
| 841 | + builder.DrawRect(DlRect::MakeXYWH(2, 2, 12, 12), rect_paint); |
| 842 | + |
| 843 | + std::shared_ptr<Context> context = GetContext(); |
| 844 | + AiksContext renderer(context, nullptr); |
| 845 | + auto out_texture = |
| 846 | + DisplayListToTexture(builder.Build(), ISize{16, 16}, renderer); |
| 847 | + ASSERT_TRUE(out_texture); |
| 848 | + |
| 849 | + DeviceBufferDescriptor readback_desc; |
| 850 | + readback_desc.size = |
| 851 | + out_texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel(); |
| 852 | + readback_desc.readback = true; |
| 853 | + readback_desc.storage_mode = StorageMode::kHostVisible; |
| 854 | + auto readback = context->GetResourceAllocator()->CreateBuffer(readback_desc); |
| 855 | + ASSERT_TRUE(readback); |
| 856 | + |
| 857 | + auto cmd = context->CreateCommandBuffer(); |
| 858 | + auto blit = cmd->CreateBlitPass(); |
| 859 | + ASSERT_TRUE(blit->AddCopy(out_texture, readback)); |
| 860 | + ASSERT_TRUE(blit->EncodeCommands()); |
| 861 | + auto latch = std::make_shared<fml::CountDownLatch>(1u); |
| 862 | + ASSERT_TRUE( |
| 863 | + context->GetCommandQueue() |
| 864 | + ->Submit({cmd}, |
| 865 | + [latch](CommandBuffer::Status) { latch->CountDown(); }) |
| 866 | + .ok()); |
| 867 | + latch->Wait(); |
| 868 | + |
| 869 | + // |Black(0) - White(1)| = White(255) across all 4 RGBA8/BGRA8 channels inside |
| 870 | + // [2..14, 2..14]. Without masking subpassLoad by gl_SampleMaskIn, pixels |
| 871 | + // along the FramebufferBlend quad's diagonal seam drop to ~191. |
| 872 | + const uint8_t* bytes = readback->OnGetContents(); |
| 873 | + for (int y = 3; y < 13; ++y) { |
| 874 | + for (int x = 3; x < 13; ++x) { |
| 875 | + const uint8_t* px = bytes + (y * 16 + x) * 4; |
| 876 | + EXPECT_NEAR(px[0], 255, 2) << "Seam at (" << x << ", " << y << ")"; |
| 877 | + EXPECT_NEAR(px[1], 255, 2) << "Seam at (" << x << ", " << y << ")"; |
| 878 | + EXPECT_NEAR(px[2], 255, 2) << "Seam at (" << x << ", " << y << ")"; |
| 879 | + } |
| 880 | + } |
| 881 | +} |
| 882 | + |
830 | 883 | TEST_P(AiksTest, ColorWheel) { |
831 | 884 | // Compare with https://fiddle.skia.org/c/@BlendModes |
832 | 885 |
|
|
0 commit comments