@@ -1101,6 +1101,76 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
11011101 ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
11021102}
11031103
1104+ // This makes sure the WideGamut named tests use 16bit float pixel format.
1105+ TEST_P (AiksTest, F16WideGamut) {
1106+ if (GetParam () != PlaygroundBackend::kMetal ) {
1107+ GTEST_SKIP_ (" This backend doesn't yet support wide gamut." );
1108+ }
1109+ EXPECT_EQ (GetContext ()->GetCapabilities ()->GetDefaultColorFormat (),
1110+ PixelFormat::kR16G16B16A16Float );
1111+ EXPECT_FALSE (IsAlphaClampedToOne (
1112+ GetContext ()->GetCapabilities ()->GetDefaultColorFormat ()));
1113+ }
1114+
1115+ TEST_P (AiksTest, NotF16) {
1116+ EXPECT_TRUE (IsAlphaClampedToOne (
1117+ GetContext ()->GetCapabilities ()->GetDefaultColorFormat ()));
1118+ }
1119+
1120+ // Bug: https://github.com/flutter/flutter/issues/142549
1121+ TEST_P (AiksTest, BlendModePlusAlphaWideGamut) {
1122+ if (GetParam () != PlaygroundBackend::kMetal ) {
1123+ GTEST_SKIP_ (" This backend doesn't yet support wide gamut." );
1124+ }
1125+ EXPECT_EQ (GetContext ()->GetCapabilities ()->GetDefaultColorFormat (),
1126+ PixelFormat::kR16G16B16A16Float );
1127+ auto texture = CreateTextureForFixture (" airplane.jpg" ,
1128+ /* enable_mipmapping=*/ true );
1129+
1130+ Canvas canvas;
1131+ canvas.Scale (GetContentScale ());
1132+ canvas.DrawPaint ({.color = Color (0.9 , 1.0 , 0.9 , 1.0 )});
1133+ canvas.SaveLayer ({});
1134+ Paint paint;
1135+ paint.blend_mode = BlendMode::kPlus ;
1136+ paint.color = Color::Red ();
1137+ canvas.DrawRect (Rect::MakeXYWH (100 , 100 , 400 , 400 ), paint);
1138+ paint.color = Color::White ();
1139+ canvas.DrawImageRect (
1140+ std::make_shared<Image>(texture), Rect::MakeSize (texture->GetSize ()),
1141+ Rect::MakeXYWH (100 , 100 , 400 , 400 ).Expand (-100 , -100 ), paint);
1142+ canvas.Restore ();
1143+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1144+ }
1145+
1146+ // Bug: https://github.com/flutter/flutter/issues/142549
1147+ TEST_P (AiksTest, BlendModePlusAlphaColorFilterWideGamut) {
1148+ if (GetParam () != PlaygroundBackend::kMetal ) {
1149+ GTEST_SKIP_ (" This backend doesn't yet support wide gamut." );
1150+ }
1151+ EXPECT_EQ (GetContext ()->GetCapabilities ()->GetDefaultColorFormat (),
1152+ PixelFormat::kR16G16B16A16Float );
1153+ auto texture = CreateTextureForFixture (" airplane.jpg" ,
1154+ /* enable_mipmapping=*/ true );
1155+
1156+ Canvas canvas;
1157+ canvas.Scale (GetContentScale ());
1158+ canvas.DrawPaint ({.color = Color (0.1 , 0.2 , 0.1 , 1.0 )});
1159+ canvas.SaveLayer ({
1160+ .color_filter =
1161+ ColorFilter::MakeBlend (BlendMode::kPlus , Color (Vector4{1 , 0 , 0 , 1 })),
1162+ });
1163+ Paint paint;
1164+ paint.color = Color::Red ();
1165+ canvas.DrawRect (Rect::MakeXYWH (100 , 100 , 400 , 400 ), paint);
1166+ paint.color = Color::White ();
1167+ canvas.DrawImageRect (
1168+ std::make_shared<Image>(texture), Rect::MakeSize (texture->GetSize ()),
1169+ Rect::MakeXYWH (100 , 100 , 400 , 400 ).Expand (-100 , -100 ), paint);
1170+ canvas.Restore ();
1171+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1172+ }
1173+
11041174TEST_P (AiksTest, ColorWheel) {
11051175 // Compare with https://fiddle.skia.org/c/@BlendModes
11061176
0 commit comments