@@ -441,12 +441,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNullColorspace) {
441
441
std::move (data), image->imageInfo (), 10 * 4 );
442
442
443
443
#if IMPELLER_SUPPORTS_RENDERING
444
+ std::shared_ptr<impeller::Capabilities> capabilities =
445
+ impeller::CapabilitiesBuilder ()
446
+ .SetSupportsTextureToTextureBlits (true )
447
+ .Build ();
444
448
std::shared_ptr<impeller::Allocator> allocator =
445
449
std::make_shared<impeller::TestImpellerAllocator>();
446
450
std::optional<DecompressResult> decompressed =
447
451
ImageDecoderImpeller::DecompressTexture (
448
452
descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
449
- /* supports_wide_gamut=*/ true , allocator);
453
+ /* supports_wide_gamut=*/ true , capabilities, allocator);
450
454
ASSERT_TRUE (decompressed.has_value ());
451
455
ASSERT_EQ (decompressed->image_info .colorType (), kRGBA_8888_SkColorType );
452
456
ASSERT_EQ (decompressed->image_info .colorSpace (), nullptr );
@@ -468,12 +472,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerPixelConversion32F) {
468
472
std::move (data), image->imageInfo (), 10 * 16 );
469
473
470
474
#if IMPELLER_SUPPORTS_RENDERING
475
+ std::shared_ptr<impeller::Capabilities> capabilities =
476
+ impeller::CapabilitiesBuilder ()
477
+ .SetSupportsTextureToTextureBlits (true )
478
+ .Build ();
471
479
std::shared_ptr<impeller::Allocator> allocator =
472
480
std::make_shared<impeller::TestImpellerAllocator>();
473
481
std::optional<DecompressResult> decompressed =
474
482
ImageDecoderImpeller::DecompressTexture (
475
483
descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
476
- /* supports_wide_gamut=*/ true , allocator);
484
+ /* supports_wide_gamut=*/ true , capabilities, allocator);
477
485
478
486
ASSERT_TRUE (decompressed.has_value ());
479
487
ASSERT_EQ (decompressed->image_info .colorType (), kRGBA_F16_SkColorType );
@@ -496,12 +504,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) {
496
504
std::move (generator));
497
505
498
506
#if IMPELLER_SUPPORTS_RENDERING
507
+ std::shared_ptr<impeller::Capabilities> capabilities =
508
+ impeller::CapabilitiesBuilder ()
509
+ .SetSupportsTextureToTextureBlits (true )
510
+ .Build ();
499
511
std::shared_ptr<impeller::Allocator> allocator =
500
512
std::make_shared<impeller::TestImpellerAllocator>();
501
513
std::optional<DecompressResult> wide_result =
502
514
ImageDecoderImpeller::DecompressTexture (
503
515
descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
504
- /* supports_wide_gamut=*/ true , allocator);
516
+ /* supports_wide_gamut=*/ true , capabilities, allocator);
505
517
506
518
ASSERT_TRUE (wide_result.has_value ());
507
519
ASSERT_EQ (wide_result->image_info .colorType (), kBGR_101010x_XR_SkColorType );
@@ -526,7 +538,7 @@ TEST_F(ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque) {
526
538
std::optional<DecompressResult> narrow_result =
527
539
ImageDecoderImpeller::DecompressTexture (
528
540
descriptor.get (), SkISize::Make (100 , 100 ), {100 , 100 },
529
- /* supports_wide_gamut=*/ false , allocator);
541
+ /* supports_wide_gamut=*/ false , capabilities, allocator);
530
542
531
543
ASSERT_TRUE (narrow_result.has_value ());
532
544
ASSERT_EQ (narrow_result->image_info .colorType (), kRGBA_8888_SkColorType );
@@ -548,12 +560,16 @@ TEST_F(ImageDecoderFixtureTest, ImpellerNonWideGamut) {
548
560
std::move (generator));
549
561
550
562
#if IMPELLER_SUPPORTS_RENDERING
563
+ std::shared_ptr<impeller::Capabilities> capabilities =
564
+ impeller::CapabilitiesBuilder ()
565
+ .SetSupportsTextureToTextureBlits (true )
566
+ .Build ();
551
567
std::shared_ptr<impeller::Allocator> allocator =
552
568
std::make_shared<impeller::TestImpellerAllocator>();
553
569
std::optional<DecompressResult> result =
554
570
ImageDecoderImpeller::DecompressTexture (
555
571
descriptor.get (), SkISize::Make (600 , 200 ), {600 , 200 },
556
- /* supports_wide_gamut=*/ true , allocator);
572
+ /* supports_wide_gamut=*/ true , capabilities, allocator);
557
573
558
574
ASSERT_TRUE (result.has_value ());
559
575
ASSERT_EQ (result->image_info .colorType (), kRGBA_8888_SkColorType );
@@ -802,31 +818,46 @@ TEST(ImageDecoderTest, VerifySimpleDecoding) {
802
818
EXPECT_EQ (compressed_image->alphaType (), kOpaque_SkAlphaType );
803
819
804
820
#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 ();
805
829
// Bitmap sizes reflect the original image size as resizing is done on the
806
830
// GPU if the src size is smaller than the max texture size.
807
831
std::shared_ptr<impeller::Allocator> allocator =
808
832
std::make_shared<impeller::TestImpellerAllocator>();
809
833
auto result_1 = ImageDecoderImpeller::DecompressTexture (
810
834
descriptor.get (), SkISize::Make (6 , 2 ), {1000 , 1000 },
811
- /* supports_wide_gamut=*/ false , allocator);
835
+ /* supports_wide_gamut=*/ false , capabilities, allocator);
812
836
EXPECT_EQ (result_1.sk_bitmap ->width (), 75 );
813
837
EXPECT_EQ (result_1.sk_bitmap ->height (), 25 );
814
838
815
839
// Bitmap sizes reflect the scaled size if the source size is larger than
816
840
// max texture size even if destination size isn't max texture size.
817
841
auto result_2 = ImageDecoderImpeller::DecompressTexture (
818
842
descriptor.get (), SkISize::Make (6 , 2 ), {10 , 10 },
819
- /* supports_wide_gamut=*/ false , allocator);
843
+ /* supports_wide_gamut=*/ false , capabilities, allocator);
820
844
EXPECT_EQ (result_2.sk_bitmap ->width (), 6 );
821
845
EXPECT_EQ (result_2.sk_bitmap ->height (), 2 );
822
846
823
847
// If the destination size is larger than the max texture size the image
824
848
// is scaled down.
825
849
auto result_3 = ImageDecoderImpeller::DecompressTexture (
826
850
descriptor.get (), SkISize::Make (60 , 20 ), {10 , 10 },
827
- /* supports_wide_gamut=*/ false , allocator);
851
+ /* supports_wide_gamut=*/ false , capabilities, allocator);
828
852
EXPECT_EQ (result_3.sk_bitmap ->width (), 10 );
829
853
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 );
830
861
#endif // IMPELLER_SUPPORTS_RENDERING
831
862
}
832
863
0 commit comments