@@ -1880,6 +1880,83 @@ TEST_P(AiksTest, DrawPaintAbsorbsClears) {
18801880 ASSERT_EQ (picture.pass ->GetClearColor (), Color::CornflowerBlue ());
18811881}
18821882
1883+ TEST_P (AiksTest, ForegroundBlendSubpassCollapseOptimization) {
1884+ Canvas canvas;
1885+
1886+ canvas.SaveLayer ({
1887+ .color_filter =
1888+ [](FilterInput::Ref input) {
1889+ return ColorFilterContents::MakeBlend (
1890+ BlendMode::kColorDodge , {std::move (input)}, Color::Red ());
1891+ },
1892+ });
1893+
1894+ canvas.Translate ({500 , 300 , 0 });
1895+ canvas.Rotate (Radians (2 * kPi / 3 ));
1896+ canvas.DrawRect ({100 , 100 , 200 , 200 }, {.color = Color::Blue ()});
1897+
1898+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1899+ }
1900+
1901+ TEST_P (AiksTest, ColorMatrixFilterSubpassCollapseOptimization) {
1902+ Canvas canvas;
1903+
1904+ canvas.SaveLayer ({
1905+ .color_filter =
1906+ [](FilterInput::Ref input) {
1907+ return ColorFilterContents::MakeColorMatrix (
1908+ std::move (input), {.array = {
1909+ -1.0 , 0 , 0 , 1.0 , 0 , //
1910+ 0 , -1.0 , 0 , 1.0 , 0 , //
1911+ 0 , 0 , -1.0 , 1.0 , 0 , //
1912+ 1.0 , 1.0 , 1.0 , 1.0 , 0 //
1913+ }});
1914+ },
1915+ });
1916+
1917+ canvas.Translate ({500 , 300 , 0 });
1918+ canvas.Rotate (Radians (2 * kPi / 3 ));
1919+ canvas.DrawRect ({100 , 100 , 200 , 200 }, {.color = Color::Blue ()});
1920+
1921+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1922+ }
1923+
1924+ TEST_P (AiksTest, LinearToSrgbFilterSubpassCollapseOptimization) {
1925+ Canvas canvas;
1926+
1927+ canvas.SaveLayer ({
1928+ .color_filter =
1929+ [](FilterInput::Ref input) {
1930+ return ColorFilterContents::MakeLinearToSrgbFilter (
1931+ std::move (input));
1932+ },
1933+ });
1934+
1935+ canvas.Translate ({500 , 300 , 0 });
1936+ canvas.Rotate (Radians (2 * kPi / 3 ));
1937+ canvas.DrawRect ({100 , 100 , 200 , 200 }, {.color = Color::Blue ()});
1938+
1939+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1940+ }
1941+
1942+ TEST_P (AiksTest, SrgbToLinearFilterSubpassCollapseOptimization) {
1943+ Canvas canvas;
1944+
1945+ canvas.SaveLayer ({
1946+ .color_filter =
1947+ [](FilterInput::Ref input) {
1948+ return ColorFilterContents::MakeSrgbToLinearFilter (
1949+ std::move (input));
1950+ },
1951+ });
1952+
1953+ canvas.Translate ({500 , 300 , 0 });
1954+ canvas.Rotate (Radians (2 * kPi / 3 ));
1955+ canvas.DrawRect ({100 , 100 , 200 , 200 }, {.color = Color::Blue ()});
1956+
1957+ ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1958+ }
1959+
18831960static Picture BlendModeSaveLayerTest (BlendMode blend_mode) {
18841961 Canvas canvas;
18851962 canvas.DrawPaint ({.color = Color::CornflowerBlue ().WithAlpha (0.75 )});
0 commit comments