From 918747506bc625aa34c18cbb1c1176de42be471a Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 11 Nov 2024 13:10:54 -0800 Subject: [PATCH 1/9] force gles to use software resize. --- lib/ui/painting/image_decoder_impeller.cc | 7 +++++-- lib/ui/painting/image_decoder_impeller.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 6a1118954a9be..10d37d7de9d29 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -114,6 +114,7 @@ DecompressResult ImageDecoderImpeller::DecompressTexture( SkISize target_size, impeller::ISize max_texture_size, bool supports_wide_gamut, + bool force_cpu_resize, const std::shared_ptr& allocator) { TRACE_EVENT0("impeller", __FUNCTION__); if (!descriptor) { @@ -238,7 +239,7 @@ DecompressResult ImageDecoderImpeller::DecompressTexture( : std::optional(image_info.makeDimensions(target_size)); if (source_size.width() > max_texture_size.width || - source_size.height() > max_texture_size.height) { + source_size.height() > max_texture_size.height || force_cpu_resize) { //---------------------------------------------------------------------------- /// 2. If the decoded image isn't the requested target size and the src size /// exceeds the device max texture size, perform a slow CPU reisze. @@ -529,7 +530,9 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, // Always decompress on the concurrent runner. auto bitmap_result = DecompressTexture( raw_descriptor, target_size, max_size_supported, - supports_wide_gamut, context->GetResourceAllocator()); + supports_wide_gamut, + context->GetCapabilities()->SupportsTextureToTextureBlits(), + context->GetResourceAllocator()); if (!bitmap_result.device_buffer) { result(nullptr, bitmap_result.decode_error); return; diff --git a/lib/ui/painting/image_decoder_impeller.h b/lib/ui/painting/image_decoder_impeller.h index 1d956a30a936c..fb6949f2e3326 100644 --- a/lib/ui/painting/image_decoder_impeller.h +++ b/lib/ui/painting/image_decoder_impeller.h @@ -68,6 +68,7 @@ class ImageDecoderImpeller final : public ImageDecoder { SkISize target_size, impeller::ISize max_texture_size, bool supports_wide_gamut, + bool force_cpu_resize, const std::shared_ptr& allocator); /// @brief Create a device private texture from the provided host buffer. From 9874f49e99527080da502753fb5b53dc3990db36 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 11 Nov 2024 13:12:19 -0800 Subject: [PATCH 2/9] invert condition. --- lib/ui/painting/image_decoder_impeller.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 10d37d7de9d29..d563a22147f7c 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -530,8 +530,9 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, // Always decompress on the concurrent runner. auto bitmap_result = DecompressTexture( raw_descriptor, target_size, max_size_supported, - supports_wide_gamut, - context->GetCapabilities()->SupportsTextureToTextureBlits(), + /*supports_wide_gamut=*/supports_wide_gamut, + /*force_cpu_resize=*/ + !context->GetCapabilities()->SupportsTextureToTextureBlits(), context->GetResourceAllocator()); if (!bitmap_result.device_buffer) { result(nullptr, bitmap_result.decode_error); From abde368e5125a72e2663674355d1cdd7677bda2f Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 11 Nov 2024 13:33:16 -0800 Subject: [PATCH 3/9] Fix unittests. --- lib/ui/painting/image_decoder_no_gl_unittests.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ui/painting/image_decoder_no_gl_unittests.cc b/lib/ui/painting/image_decoder_no_gl_unittests.cc index d935fa2e3e9f9..a7cea8708b360 100644 --- a/lib/ui/painting/image_decoder_no_gl_unittests.cc +++ b/lib/ui/painting/image_decoder_no_gl_unittests.cc @@ -100,7 +100,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3) { std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(wide_result.has_value()); ASSERT_EQ(wide_result->image_info.colorType(), kRGBA_F16_SkColorType); ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB()); @@ -124,7 +124,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -157,7 +157,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng) { std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType); ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB()); @@ -180,7 +180,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -210,7 +210,7 @@ TEST(ImageDecoderNoGLTest, ImepllerUnmultipliedAlphaPng) { std::optional result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(11, 11), {11, 11}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); ASSERT_EQ(result->image_info.colorType(), kRGBA_8888_SkColorType); const SkPixmap& pixmap = result->sk_bitmap->pixmap(); From aec6be92647dc733a9ae542cc5c22f19f6dc13f2 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 11 Nov 2024 16:55:29 -0800 Subject: [PATCH 4/9] update unittests. --- lib/ui/painting/image_decoder_unittests.cc | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/ui/painting/image_decoder_unittests.cc b/lib/ui/painting/image_decoder_unittests.cc index 69096eeca3866..0db6a35640b01 100644 --- a/lib/ui/painting/image_decoder_unittests.cc +++ b/lib/ui/painting/image_decoder_unittests.cc @@ -446,7 +446,8 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNullColorspace) { std::optional decompressed = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, + /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(decompressed.has_value()); ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_8888_SkColorType); ASSERT_EQ(decompressed->image_info.colorSpace(), nullptr); @@ -473,7 +474,8 @@ TEST_F(ImageDecoderFixtureTest, ImpellerPixelConversion32F) { std::optional decompressed = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, + /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(decompressed.has_value()); ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_F16_SkColorType); @@ -501,7 +503,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) { std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(wide_result.has_value()); ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType); @@ -526,7 +528,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -553,7 +555,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNonWideGamut) { std::optional result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(600, 200), {600, 200}, - /*supports_wide_gamut=*/true, allocator); + /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); ASSERT_TRUE(result.has_value()); ASSERT_EQ(result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -808,7 +810,7 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { std::make_shared(); auto result_1 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(6, 2), {1000, 1000}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); EXPECT_EQ(result_1.sk_bitmap->width(), 75); EXPECT_EQ(result_1.sk_bitmap->height(), 25); @@ -816,7 +818,7 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { // max texture size even if destination size isn't max texture size. auto result_2 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(6, 2), {10, 10}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); EXPECT_EQ(result_2.sk_bitmap->width(), 6); EXPECT_EQ(result_2.sk_bitmap->height(), 2); @@ -824,9 +826,16 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { // is scaled down. auto result_3 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(60, 20), {10, 10}, - /*supports_wide_gamut=*/false, allocator); + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); EXPECT_EQ(result_3.sk_bitmap->width(), 10); EXPECT_EQ(result_3.sk_bitmap->height(), 10); + + // CPU resize is forced. + auto result_4 = ImageDecoderImpeller::DecompressTexture( + descriptor.get(), SkISize::Make(6, 2), {1000, 1000}, + /*supports_wide_gamut=*/false, /*force_cpu_resize=*/true, allocator); + EXPECT_EQ(result_4.sk_bitmap->width(), 6); + EXPECT_EQ(result_4.sk_bitmap->height(), 2); #endif // IMPELLER_SUPPORTS_RENDERING } From d11c8dea474dc4b2f6f3de38e3afe0af556a1ef2 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 12 Nov 2024 10:37:01 -0800 Subject: [PATCH 5/9] check caps. --- lib/ui/painting/image_decoder_impeller.cc | 9 ++++--- lib/ui/painting/image_decoder_impeller.h | 3 ++- .../painting/image_decoder_no_gl_unittests.cc | 24 +++++++++++++++---- lib/ui/painting/image_decoder_unittests.cc | 16 +++++++++---- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index d563a22147f7c..4134e444d53a9 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -114,7 +114,7 @@ DecompressResult ImageDecoderImpeller::DecompressTexture( SkISize target_size, impeller::ISize max_texture_size, bool supports_wide_gamut, - bool force_cpu_resize, + const std::shared_ptr& capabilities, const std::shared_ptr& allocator) { TRACE_EVENT0("impeller", __FUNCTION__); if (!descriptor) { @@ -239,7 +239,8 @@ DecompressResult ImageDecoderImpeller::DecompressTexture( : std::optional(image_info.makeDimensions(target_size)); if (source_size.width() > max_texture_size.width || - source_size.height() > max_texture_size.height || force_cpu_resize) { + source_size.height() > max_texture_size.height || + !capabilities->SupportsTextureToTextureBlits()) { //---------------------------------------------------------------------------- /// 2. If the decoded image isn't the requested target size and the src size /// exceeds the device max texture size, perform a slow CPU reisze. @@ -531,9 +532,7 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, auto bitmap_result = DecompressTexture( raw_descriptor, target_size, max_size_supported, /*supports_wide_gamut=*/supports_wide_gamut, - /*force_cpu_resize=*/ - !context->GetCapabilities()->SupportsTextureToTextureBlits(), - context->GetResourceAllocator()); + context->GetCapabilities(), context->GetResourceAllocator()); if (!bitmap_result.device_buffer) { result(nullptr, bitmap_result.decode_error); return; diff --git a/lib/ui/painting/image_decoder_impeller.h b/lib/ui/painting/image_decoder_impeller.h index fb6949f2e3326..3a1e5172a9917 100644 --- a/lib/ui/painting/image_decoder_impeller.h +++ b/lib/ui/painting/image_decoder_impeller.h @@ -11,6 +11,7 @@ #include "flutter/lib/ui/painting/image_decoder.h" #include "impeller/core/formats.h" #include "impeller/geometry/size.h" +#include "impeller/renderer/capabilities.h" #include "include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -68,7 +69,7 @@ class ImageDecoderImpeller final : public ImageDecoder { SkISize target_size, impeller::ISize max_texture_size, bool supports_wide_gamut, - bool force_cpu_resize, + const std::shared_ptr& capabilities, const std::shared_ptr& allocator); /// @brief Create a device private texture from the provided host buffer. diff --git a/lib/ui/painting/image_decoder_no_gl_unittests.cc b/lib/ui/painting/image_decoder_no_gl_unittests.cc index a7cea8708b360..7ed932ffa8cc7 100644 --- a/lib/ui/painting/image_decoder_no_gl_unittests.cc +++ b/lib/ui/painting/image_decoder_no_gl_unittests.cc @@ -3,8 +3,10 @@ // found in the LICENSE file. #include "flutter/lib/ui/painting/image_decoder_no_gl_unittests.h" +#include #include "flutter/fml/endianness.h" +#include "impeller/renderer/capabilities.h" #include "include/core/SkColorType.h" namespace flutter { @@ -80,6 +82,10 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3) { #endif auto data = flutter::testing::OpenFixtureAsSkData("DisplayP3Logo.png"); auto image = SkImages::DeferredFromEncodedData(data); + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); ASSERT_TRUE(image != nullptr); ASSERT_EQ(SkISize::Make(100, 100), image->dimensions()); @@ -100,7 +106,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3) { std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_TRUE(wide_result.has_value()); ASSERT_EQ(wide_result->image_info.colorType(), kRGBA_F16_SkColorType); ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB()); @@ -124,7 +130,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -137,6 +143,10 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng) { #endif auto data = flutter::testing::OpenFixtureAsSkData("WideGamutIndexed.png"); auto image = SkImages::DeferredFromEncodedData(data); + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); ASSERT_TRUE(image != nullptr); ASSERT_EQ(SkISize::Make(100, 100), image->dimensions()); @@ -157,7 +167,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng) { std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType); ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB()); @@ -180,7 +190,7 @@ TEST(ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -193,6 +203,10 @@ TEST(ImageDecoderNoGLTest, ImepllerUnmultipliedAlphaPng) { #endif auto data = flutter::testing::OpenFixtureAsSkData("unmultiplied_alpha.png"); auto image = SkImages::DeferredFromEncodedData(data); + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(false) + .Build(); ASSERT_TRUE(image != nullptr); ASSERT_EQ(SkISize::Make(11, 11), image->dimensions()); @@ -210,7 +224,7 @@ TEST(ImageDecoderNoGLTest, ImepllerUnmultipliedAlphaPng) { std::optional result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(11, 11), {11, 11}, - /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_EQ(result->image_info.colorType(), kRGBA_8888_SkColorType); const SkPixmap& pixmap = result->sk_bitmap->pixmap(); diff --git a/lib/ui/painting/image_decoder_unittests.cc b/lib/ui/painting/image_decoder_unittests.cc index 0db6a35640b01..ac46dac362202 100644 --- a/lib/ui/painting/image_decoder_unittests.cc +++ b/lib/ui/painting/image_decoder_unittests.cc @@ -804,13 +804,21 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { EXPECT_EQ(compressed_image->alphaType(), kOpaque_SkAlphaType); #if IMPELLER_SUPPORTS_RENDERING + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); + std::shared_ptr capabilities_no_blit = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(false) + .Build(); // Bitmap sizes reflect the original image size as resizing is done on the // GPU if the src size is smaller than the max texture size. std::shared_ptr allocator = std::make_shared(); auto result_1 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(6, 2), {1000, 1000}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); EXPECT_EQ(result_1.sk_bitmap->width(), 75); EXPECT_EQ(result_1.sk_bitmap->height(), 25); @@ -818,7 +826,7 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { // max texture size even if destination size isn't max texture size. auto result_2 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(6, 2), {10, 10}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); EXPECT_EQ(result_2.sk_bitmap->width(), 6); EXPECT_EQ(result_2.sk_bitmap->height(), 2); @@ -826,14 +834,14 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) { // is scaled down. auto result_3 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(60, 20), {10, 10}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); EXPECT_EQ(result_3.sk_bitmap->width(), 10); EXPECT_EQ(result_3.sk_bitmap->height(), 10); // CPU resize is forced. auto result_4 = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(6, 2), {1000, 1000}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/true, allocator); + /*supports_wide_gamut=*/false, capabilities_no_blit, allocator); EXPECT_EQ(result_4.sk_bitmap->width(), 6); EXPECT_EQ(result_4.sk_bitmap->height(), 2); #endif // IMPELLER_SUPPORTS_RENDERING From acf8b3fd55ded192f95e2b666b0124c21430ac83 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 12 Nov 2024 10:47:41 -0800 Subject: [PATCH 6/9] ++ --- impeller/renderer/backend/gles/capabilities_gles.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/impeller/renderer/backend/gles/capabilities_gles.cc b/impeller/renderer/backend/gles/capabilities_gles.cc index 6fe142bbe5ab2..b0c523252a61a 100644 --- a/impeller/renderer/backend/gles/capabilities_gles.cc +++ b/impeller/renderer/backend/gles/capabilities_gles.cc @@ -158,6 +158,8 @@ bool CapabilitiesGLES::SupportsSSBO() const { } bool CapabilitiesGLES::SupportsTextureToTextureBlits() const { + // TODO(158388): switch this to true for improved performance + // on GLES 3.0+ devices. return false; } From e27de0917e90b70bf3b72f2512b7d7d9adec92b5 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 12 Nov 2024 10:51:09 -0800 Subject: [PATCH 7/9] fix caps. --- lib/ui/painting/image_decoder_unittests.cc | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/ui/painting/image_decoder_unittests.cc b/lib/ui/painting/image_decoder_unittests.cc index ac46dac362202..1e41ab5cc82e3 100644 --- a/lib/ui/painting/image_decoder_unittests.cc +++ b/lib/ui/painting/image_decoder_unittests.cc @@ -441,13 +441,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNullColorspace) { std::move(data), image->imageInfo(), 10 * 4); #if IMPELLER_SUPPORTS_RENDERING + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); std::shared_ptr allocator = std::make_shared(); std::optional decompressed = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, - /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_TRUE(decompressed.has_value()); ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_8888_SkColorType); ASSERT_EQ(decompressed->image_info.colorSpace(), nullptr); @@ -469,13 +472,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerPixelConversion32F) { std::move(data), image->imageInfo(), 10 * 16); #if IMPELLER_SUPPORTS_RENDERING + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); std::shared_ptr allocator = std::make_shared(); std::optional decompressed = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, - /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_TRUE(decompressed.has_value()); ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_F16_SkColorType); @@ -498,12 +504,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) { std::move(generator)); #if IMPELLER_SUPPORTS_RENDERING + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); std::shared_ptr allocator = std::make_shared(); std::optional wide_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_TRUE(wide_result.has_value()); ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType); @@ -528,7 +538,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) { std::optional narrow_result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(100, 100), {100, 100}, - /*supports_wide_gamut=*/false, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/false, capabilities, allocator); ASSERT_TRUE(narrow_result.has_value()); ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType); @@ -550,12 +560,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNonWideGamut) { std::move(generator)); #if IMPELLER_SUPPORTS_RENDERING + std::shared_ptr capabilities = + impeller::CapabilitiesBuilder() + .SetSupportsTextureToTextureBlits(true) + .Build(); std::shared_ptr allocator = std::make_shared(); std::optional result = ImageDecoderImpeller::DecompressTexture( descriptor.get(), SkISize::Make(600, 200), {600, 200}, - /*supports_wide_gamut=*/true, /*force_cpu_resize=*/false, allocator); + /*supports_wide_gamut=*/true, capabilities, allocator); ASSERT_TRUE(result.has_value()); ASSERT_EQ(result->image_info.colorType(), kRGBA_8888_SkColorType); From 83280c8320d84680888d36045fa9919335c5e679 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 12 Nov 2024 10:58:12 -0800 Subject: [PATCH 8/9] update doc comment. --- impeller/renderer/backend/gles/capabilities_gles.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/impeller/renderer/backend/gles/capabilities_gles.cc b/impeller/renderer/backend/gles/capabilities_gles.cc index b0c523252a61a..18a5e1accb9e6 100644 --- a/impeller/renderer/backend/gles/capabilities_gles.cc +++ b/impeller/renderer/backend/gles/capabilities_gles.cc @@ -158,8 +158,9 @@ bool CapabilitiesGLES::SupportsSSBO() const { } bool CapabilitiesGLES::SupportsTextureToTextureBlits() const { - // TODO(158388): switch this to true for improved performance - // on GLES 3.0+ devices. + // TODO(158523): Switch this to true for improved performance + // on GLES 3.0+ devices. Note that this wasn't enabled because + // there were some rendering issues on some devices. return false; } From 4b2f2f5950f2604ea6fe192678fd999805243708 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 12 Nov 2024 15:25:56 -0800 Subject: [PATCH 9/9] ++ --- lib/ui/painting/image_decoder_no_gl_unittests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/painting/image_decoder_no_gl_unittests.cc b/lib/ui/painting/image_decoder_no_gl_unittests.cc index 7ed932ffa8cc7..04a0229c112dd 100644 --- a/lib/ui/painting/image_decoder_no_gl_unittests.cc +++ b/lib/ui/painting/image_decoder_no_gl_unittests.cc @@ -205,7 +205,7 @@ TEST(ImageDecoderNoGLTest, ImepllerUnmultipliedAlphaPng) { auto image = SkImages::DeferredFromEncodedData(data); std::shared_ptr capabilities = impeller::CapabilitiesBuilder() - .SetSupportsTextureToTextureBlits(false) + .SetSupportsTextureToTextureBlits(true) .Build(); ASSERT_TRUE(image != nullptr); ASSERT_EQ(SkISize::Make(11, 11), image->dimensions());