From 647a0306744da0ad280f6ff88629efa785639643 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 15 Aug 2024 08:53:57 -0700 Subject: [PATCH 1/5] Hooks up framework wide gamut color to the engine. --- lib/ui/painting/paint.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/ui/painting/paint.cc b/lib/ui/painting/paint.cc index ab746738bb96c..3807ff30ce038 100644 --- a/lib/ui/painting/paint.cc +++ b/lib/ui/painting/paint.cc @@ -71,14 +71,8 @@ DlColor ReadColor(const tonic::DartByteData& byte_data) { // Invert alpha so 0 initialized buffer has default value; float alpha = 1.f - float_data[kColorAlphaIndex]; uint32_t colorspace = uint_data[kColorSpaceIndex]; - (void)colorspace; - uint32_t encoded_color = - static_cast(std::round(alpha * 255.f)) << 24 | // - static_cast(std::round(red * 255.f)) << 16 | // - static_cast(std::round(green * 255.f)) << 8 | // - static_cast(std::round(blue * 255.f)) << 0; - // TODO(gaaclarke): Pass down color info to DlColor. - return DlColor(encoded_color); + return DlColor(alpha, red, green, blue, + static_cast(colorspace)); } } // namespace From 67cd75133fec4627488463bff1e4ce97f3f5aa53 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 29 Aug 2024 14:42:34 -0700 Subject: [PATCH 2/5] disabled that test for opengles --- impeller/display_list/aiks_dl_vertices_unittests.cc | 4 ++++ testing/impeller_golden_tests_output.txt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/impeller/display_list/aiks_dl_vertices_unittests.cc b/impeller/display_list/aiks_dl_vertices_unittests.cc index fdcd5b2b68d42..ff8d1d51fb788 100644 --- a/impeller/display_list/aiks_dl_vertices_unittests.cc +++ b/impeller/display_list/aiks_dl_vertices_unittests.cc @@ -355,6 +355,10 @@ TEST_P(AiksTest, DrawVerticesPremultipliesColors) { } TEST_P(AiksTest, DrawVerticesWithInvalidIndices) { + if (GetBackend() == PlaygroundBackend::kOpenGLES) { + // TODO(https://github.com/flutter/flutter/issues/154368): Re-enable. + GTEST_SKIP() << "Test acts erratically on OpenGLES."; + } std::vector positions = { SkPoint::Make(100, 300), SkPoint::Make(200, 100), SkPoint::Make(300, 300), SkPoint::Make(200, 500)}; diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index f212cbfa0f28b..e2f8bcb6640e4 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -615,7 +615,6 @@ impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_Metal.pn impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_OpenGLES.png impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_Vulkan.png impeller_Play_AiksTest_DrawVerticesWithInvalidIndices_Metal.png -impeller_Play_AiksTest_DrawVerticesWithInvalidIndices_OpenGLES.png impeller_Play_AiksTest_DrawVerticesWithInvalidIndices_Vulkan.png impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_Metal.png impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_OpenGLES.png From 9a5403dd5ef8ceee9f565b383d33a1302d0ad1a5 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 29 Aug 2024 15:10:47 -0700 Subject: [PATCH 3/5] jonah feedback --- .../display_list/aiks_dl_vertices_unittests.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/impeller/display_list/aiks_dl_vertices_unittests.cc b/impeller/display_list/aiks_dl_vertices_unittests.cc index ff8d1d51fb788..b931073219bf0 100644 --- a/impeller/display_list/aiks_dl_vertices_unittests.cc +++ b/impeller/display_list/aiks_dl_vertices_unittests.cc @@ -12,6 +12,7 @@ #include "flutter/display_list/dl_color.h" #include "flutter/display_list/dl_paint.h" #include "flutter/testing/testing.h" +#include "impeller/display_list/dl_dispatcher.h" #include "impeller/display_list/dl_image_impeller.h" namespace impeller { @@ -355,10 +356,6 @@ TEST_P(AiksTest, DrawVerticesPremultipliesColors) { } TEST_P(AiksTest, DrawVerticesWithInvalidIndices) { - if (GetBackend() == PlaygroundBackend::kOpenGLES) { - // TODO(https://github.com/flutter/flutter/issues/154368): Re-enable. - GTEST_SKIP() << "Test acts erratically on OpenGLES."; - } std::vector positions = { SkPoint::Make(100, 300), SkPoint::Make(200, 100), SkPoint::Make(300, 300), SkPoint::Make(200, 500)}; @@ -379,7 +376,15 @@ TEST_P(AiksTest, DrawVerticesWithInvalidIndices) { builder.DrawRect(SkRect::MakeLTRB(0, 0, 400, 400), paint); builder.DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint); - ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); + if (GetBackend() == PlaygroundBackend::kOpenGLES) { + // TODO(https://github.com/flutter/flutter/issues/154368): Re-enable. + AiksContext renderer(GetContext(), nullptr); + std::shared_ptr image = + DisplayListToTexture(builder.Build(), {1024, 768}, renderer); + EXPECT_TRUE(image); + } else { + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); + } } // All four vertices should form a solid red rectangle with no gaps. From 555c462721a8489681074f34bdfb74d309459488 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 29 Aug 2024 15:13:45 -0700 Subject: [PATCH 4/5] jonah feedback --- impeller/display_list/aiks_dl_vertices_unittests.cc | 13 ++++--------- testing/impeller_golden_tests_output.txt | 2 -- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/impeller/display_list/aiks_dl_vertices_unittests.cc b/impeller/display_list/aiks_dl_vertices_unittests.cc index b931073219bf0..e66ac91996534 100644 --- a/impeller/display_list/aiks_dl_vertices_unittests.cc +++ b/impeller/display_list/aiks_dl_vertices_unittests.cc @@ -376,15 +376,10 @@ TEST_P(AiksTest, DrawVerticesWithInvalidIndices) { builder.DrawRect(SkRect::MakeLTRB(0, 0, 400, 400), paint); builder.DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint); - if (GetBackend() == PlaygroundBackend::kOpenGLES) { - // TODO(https://github.com/flutter/flutter/issues/154368): Re-enable. - AiksContext renderer(GetContext(), nullptr); - std::shared_ptr image = - DisplayListToTexture(builder.Build(), {1024, 768}, renderer); - EXPECT_TRUE(image); - } else { - ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); - } + AiksContext renderer(GetContext(), nullptr); + std::shared_ptr image = + DisplayListToTexture(builder.Build(), {1024, 768}, renderer); + EXPECT_TRUE(image); } // All four vertices should form a solid red rectangle with no gaps. diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index e2f8bcb6640e4..d219c257836a9 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -614,8 +614,6 @@ impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOr impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_Metal.png impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_OpenGLES.png impeller_Play_AiksTest_DrawVerticesTextureCoordinatesWithFragmentShader_Vulkan.png -impeller_Play_AiksTest_DrawVerticesWithInvalidIndices_Metal.png -impeller_Play_AiksTest_DrawVerticesWithInvalidIndices_Vulkan.png impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_Metal.png impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_OpenGLES.png impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_Vulkan.png From 0a90ec7e6e9cfec124fd40848cbfede08fbe7833 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 29 Aug 2024 15:33:06 -0700 Subject: [PATCH 5/5] brought back the colorspace conversion --- lib/ui/painting/paint.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ui/painting/paint.cc b/lib/ui/painting/paint.cc index 3807ff30ce038..19a535520c1d3 100644 --- a/lib/ui/painting/paint.cc +++ b/lib/ui/painting/paint.cc @@ -71,8 +71,11 @@ DlColor ReadColor(const tonic::DartByteData& byte_data) { // Invert alpha so 0 initialized buffer has default value; float alpha = 1.f - float_data[kColorAlphaIndex]; uint32_t colorspace = uint_data[kColorSpaceIndex]; - return DlColor(alpha, red, green, blue, - static_cast(colorspace)); + + DlColor dl_color(alpha, red, green, blue, + static_cast(colorspace)); + + return dl_color.withColorSpace(DlColorSpace::kExtendedSRGB); } } // namespace