@@ -441,12 +441,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNullColorspace) {
441441 std::move (data), image->imageInfo (), 10 * 4 );
442442
443443#if IMPELLER_SUPPORTS_RENDERING
444+ std::shared_ptr<impeller::Capabilities> capabilities =
445+ impeller::CapabilitiesBuilder ()
446+ .SetSupportsTextureToTextureBlits (true )
447+ .Build ();
444448 std::shared_ptr<impeller::Allocator> allocator =
445449 std::make_shared<impeller::TestImpellerAllocator>();
446450 std::optional<DecompressResult> decompressed =
447451 ImageDecoderImpeller::DecompressTexture (
448452 descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
449- /* supports_wide_gamut=*/ true , allocator);
453+ /* supports_wide_gamut=*/ true , capabilities, allocator);
450454 ASSERT_TRUE (decompressed.has_value ());
451455 ASSERT_EQ (decompressed->image_info .colorType (), kRGBA_8888_SkColorType );
452456 ASSERT_EQ (decompressed->image_info .colorSpace (), nullptr );
@@ -468,12 +472,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerPixelConversion32F) {
468472 std::move (data), image->imageInfo (), 10 * 16 );
469473
470474#if IMPELLER_SUPPORTS_RENDERING
475+ std::shared_ptr<impeller::Capabilities> capabilities =
476+ impeller::CapabilitiesBuilder ()
477+ .SetSupportsTextureToTextureBlits (true )
478+ .Build ();
471479 std::shared_ptr<impeller::Allocator> allocator =
472480 std::make_shared<impeller::TestImpellerAllocator>();
473481 std::optional<DecompressResult> decompressed =
474482 ImageDecoderImpeller::DecompressTexture (
475483 descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
476- /* supports_wide_gamut=*/ true , allocator);
484+ /* supports_wide_gamut=*/ true , capabilities, allocator);
477485
478486 ASSERT_TRUE (decompressed.has_value ());
479487 ASSERT_EQ (decompressed->image_info .colorType (), kRGBA_F16_SkColorType );
@@ -496,12 +504,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) {
496504 std::move (generator));
497505
498506#if IMPELLER_SUPPORTS_RENDERING
507+ std::shared_ptr<impeller::Capabilities> capabilities =
508+ impeller::CapabilitiesBuilder ()
509+ .SetSupportsTextureToTextureBlits (true )
510+ .Build ();
499511 std::shared_ptr<impeller::Allocator> allocator =
500512 std::make_shared<impeller::TestImpellerAllocator>();
501513 std::optional<DecompressResult> wide_result =
502514 ImageDecoderImpeller::DecompressTexture (
503515 descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
504- /* supports_wide_gamut=*/ true , allocator);
516+ /* supports_wide_gamut=*/ true , capabilities, allocator);
505517
506518 ASSERT_TRUE (wide_result.has_value ());
507519 ASSERT_EQ (wide_result->image_info .colorType (), kBGR_101010x_XR_SkColorType );
@@ -526,7 +538,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) {
526538 std::optional<DecompressResult> narrow_result =
527539 ImageDecoderImpeller::DecompressTexture (
528540 descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
529- /* supports_wide_gamut=*/ false , allocator);
541+ /* supports_wide_gamut=*/ false , capabilities, allocator);
530542
531543 ASSERT_TRUE (narrow_result.has_value ());
532544 ASSERT_EQ (narrow_result->image_info .colorType (), kRGBA_8888_SkColorType );
@@ -548,12 +560,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNonWideGamut) {
548560 std::move (generator));
549561
550562#if IMPELLER_SUPPORTS_RENDERING
563+ std::shared_ptr<impeller::Capabilities> capabilities =
564+ impeller::CapabilitiesBuilder ()
565+ .SetSupportsTextureToTextureBlits (true )
566+ .Build ();
551567 std::shared_ptr<impeller::Allocator> allocator =
552568 std::make_shared<impeller::TestImpellerAllocator>();
553569 std::optional<DecompressResult> result =
554570 ImageDecoderImpeller::DecompressTexture (
555571 descriptor.get (), SkISize::Make (600 , 200 ), {600 , 200 },
556- /* supports_wide_gamut=*/ true , allocator);
572+ /* supports_wide_gamut=*/ true , capabilities, allocator);
557573
558574 ASSERT_TRUE (result.has_value ());
559575 ASSERT_EQ (result->image_info .colorType (), kRGBA_8888_SkColorType );
@@ -802,31 +818,46 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) {
802818 EXPECT_EQ (compressed_image->alphaType (), kOpaque_SkAlphaType );
803819
804820#if IMPELLER_SUPPORTS_RENDERING
821+ std::shared_ptr<impeller::Capabilities> capabilities =
822+ impeller::CapabilitiesBuilder ()
823+ .SetSupportsTextureToTextureBlits (true )
824+ .Build ();
825+ std::shared_ptr<impeller::Capabilities> capabilities_no_blit =
826+ impeller::CapabilitiesBuilder ()
827+ .SetSupportsTextureToTextureBlits (false )
828+ .Build ();
805829 // Bitmap sizes reflect the original image size as resizing is done on the
806830 // GPU if the src size is smaller than the max texture size.
807831 std::shared_ptr<impeller::Allocator> allocator =
808832 std::make_shared<impeller::TestImpellerAllocator>();
809833 auto result_1 = ImageDecoderImpeller::DecompressTexture (
810834 descriptor.get (), SkISize::Make (6 , 2 ), {1000 , 1000 },
811- /* supports_wide_gamut=*/ false , allocator);
835+ /* supports_wide_gamut=*/ false , capabilities, allocator);
812836 EXPECT_EQ (result_1.sk_bitmap ->width (), 75 );
813837 EXPECT_EQ (result_1.sk_bitmap ->height (), 25 );
814838
815839 // Bitmap sizes reflect the scaled size if the source size is larger than
816840 // max texture size even if destination size isn't max texture size.
817841 auto result_2 = ImageDecoderImpeller::DecompressTexture (
818842 descriptor.get (), SkISize::Make (6 , 2 ), {10 , 10 },
819- /* supports_wide_gamut=*/ false , allocator);
843+ /* supports_wide_gamut=*/ false , capabilities, allocator);
820844 EXPECT_EQ (result_2.sk_bitmap ->width (), 6 );
821845 EXPECT_EQ (result_2.sk_bitmap ->height (), 2 );
822846
823847 // If the destination size is larger than the max texture size the image
824848 // is scaled down.
825849 auto result_3 = ImageDecoderImpeller::DecompressTexture (
826850 descriptor.get (), SkISize::Make (60 , 20 ), {10 , 10 },
827- /* supports_wide_gamut=*/ false , allocator);
851+ /* supports_wide_gamut=*/ false , capabilities, allocator);
828852 EXPECT_EQ (result_3.sk_bitmap ->width (), 10 );
829853 EXPECT_EQ (result_3.sk_bitmap ->height (), 10 );
854+
855+ // CPU resize is forced.
856+ auto result_4 = ImageDecoderImpeller::DecompressTexture (
857+ descriptor.get (), SkISize::Make (6 , 2 ), {1000 , 1000 },
858+ /* supports_wide_gamut=*/ false , capabilities_no_blit, allocator);
859+ EXPECT_EQ (result_4.sk_bitmap ->width (), 6 );
860+ EXPECT_EQ (result_4.sk_bitmap ->height (), 2 );
830861#endif // IMPELLER_SUPPORTS_RENDERING
831862}
832863
0 commit comments