| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| 10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 flags.setAntiAlias(true); | 1916 flags.setAntiAlias(true); |
| 1917 for (unsigned i = 0; i < count; i++) | 1917 for (unsigned i = 0; i < count; i++) |
| 1918 context.DrawPath(path, flags); | 1918 context.DrawPath(path, flags); |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) { | 1921 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) { |
| 1922 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1922 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1923 GraphicsContext context(GetPaintController()); | 1923 GraphicsContext context(GetPaintController()); |
| 1924 DrawPath(context, client, kBackgroundDrawingType, 1); | 1924 DrawPath(context, client, kBackgroundDrawingType, 1); |
| 1925 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1925 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1926 EXPECT_TRUE( | 1926 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 1); |
| 1927 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization()); | |
| 1928 } | 1927 } |
| 1929 | 1928 |
| 1930 TEST_F(PaintControllerTestBase, | 1929 TEST_F(PaintControllerTestBase, |
| 1931 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) { | 1930 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) { |
| 1932 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1931 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1933 GraphicsContext context(GetPaintController()); | 1932 GraphicsContext context(GetPaintController()); |
| 1934 | 1933 |
| 1935 DrawPath(context, client, kBackgroundDrawingType, 50); | 1934 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1936 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1935 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1937 EXPECT_FALSE( | 1936 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 1938 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization()); | |
| 1939 } | 1937 } |
| 1940 | 1938 |
| 1941 TEST_F(PaintControllerTestBase, | 1939 TEST_F(PaintControllerTestBase, |
| 1942 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) { | 1940 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) { |
| 1943 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1941 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1944 GraphicsContext context(GetPaintController()); | 1942 GraphicsContext context(GetPaintController()); |
| 1945 GetPaintController().BeginSkippingCache(); | 1943 GetPaintController().BeginSkippingCache(); |
| 1946 | 1944 |
| 1947 for (int i = 0; i < 50; ++i) | 1945 for (int i = 0; i < 50; ++i) |
| 1948 DrawPath(context, client, kBackgroundDrawingType, 50); | 1946 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1949 | 1947 |
| 1950 GetPaintController().EndSkippingCache(); | 1948 GetPaintController().EndSkippingCache(); |
| 1951 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1949 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1952 EXPECT_FALSE( | 1950 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50 * 50); |
| 1953 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization()); | |
| 1954 } | 1951 } |
| 1955 | 1952 |
| 1956 TEST_F(PaintControllerTestBase, | 1953 TEST_F(PaintControllerTestBase, |
| 1957 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) { | 1954 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) { |
| 1958 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1955 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1959 | 1956 |
| 1960 { | 1957 { |
| 1961 GraphicsContext context(GetPaintController()); | 1958 GraphicsContext context(GetPaintController()); |
| 1962 DrawPath(context, client, kBackgroundDrawingType, 50); | 1959 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1963 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1960 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1964 EXPECT_FALSE(GetPaintController() | 1961 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 1965 .GetPaintArtifact() | |
| 1966 .IsSuitableForGpuRasterization()); | |
| 1967 } | 1962 } |
| 1968 | 1963 |
| 1969 client.SetDisplayItemsUncached(); | 1964 client.SetDisplayItemsUncached(); |
| 1970 | 1965 |
| 1971 { | 1966 { |
| 1972 GraphicsContext context(GetPaintController()); | 1967 GraphicsContext context(GetPaintController()); |
| 1973 DrawPath(context, client, kBackgroundDrawingType, 50); | 1968 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1974 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1969 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1975 EXPECT_FALSE(GetPaintController() | 1970 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 1976 .GetPaintArtifact() | |
| 1977 .IsSuitableForGpuRasterization()); | |
| 1978 } | 1971 } |
| 1979 } | 1972 } |
| 1980 | 1973 |
| 1981 TEST_F(PaintControllerTestBase, | 1974 TEST_F(PaintControllerTestBase, |
| 1982 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) { | 1975 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) { |
| 1983 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1976 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1984 | 1977 |
| 1985 { | 1978 { |
| 1986 GraphicsContext context(GetPaintController()); | 1979 GraphicsContext context(GetPaintController()); |
| 1987 DrawPath(context, client, kBackgroundDrawingType, 50); | 1980 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1988 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1981 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1989 EXPECT_FALSE(GetPaintController() | 1982 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 1990 .GetPaintArtifact() | |
| 1991 .IsSuitableForGpuRasterization()); | |
| 1992 } | 1983 } |
| 1993 | 1984 |
| 1994 { | 1985 { |
| 1995 GraphicsContext context(GetPaintController()); | 1986 GraphicsContext context(GetPaintController()); |
| 1996 DrawPath(context, client, kBackgroundDrawingType, 50); | 1987 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 1997 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 1988 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 1998 EXPECT_FALSE(GetPaintController() | 1989 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 1999 .GetPaintArtifact() | |
| 2000 .IsSuitableForGpuRasterization()); | |
| 2001 } | 1990 } |
| 2002 } | 1991 } |
| 2003 | 1992 |
| 2004 TEST_F( | 1993 TEST_F( |
| 2005 PaintControllerTestBase, | 1994 PaintControllerTestBase, |
| 2006 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence)
{ | 1995 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence)
{ |
| 2007 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1996 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 2008 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); | 1997 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); |
| 2009 | 1998 |
| 2010 GraphicsContext context(GetPaintController()); | 1999 GraphicsContext context(GetPaintController()); |
| 2011 { | 2000 { |
| 2012 SubsequenceRecorder subsequence_recorder(context, container); | 2001 SubsequenceRecorder subsequence_recorder(context, container); |
| 2013 DrawPath(context, client, kBackgroundDrawingType, 50); | 2002 DrawPath(context, client, kBackgroundDrawingType, 50); |
| 2014 } | 2003 } |
| 2015 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 2004 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 2016 EXPECT_FALSE( | 2005 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 2017 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization()); | |
| 2018 | 2006 |
| 2019 EXPECT_TRUE( | 2007 EXPECT_TRUE( |
| 2020 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container)); | 2008 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container)); |
| 2021 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 2009 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 2022 EXPECT_FALSE( | 2010 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50); |
| 2023 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization()); | |
| 2024 | 2011 |
| 2025 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 2012 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 2026 DisplayItemClient::EndShouldKeepAliveAllClients(); | 2013 DisplayItemClient::EndShouldKeepAliveAllClients(); |
| 2027 #endif | 2014 #endif |
| 2028 } | 2015 } |
| 2029 | 2016 |
| 2030 // Temporarily disabled (pref regressions due to GPU veto stickiness: | 2017 // Temporarily disabled (pref regressions due to GPU veto stickiness: |
| 2031 // http://crbug.com/603969). | 2018 // http://crbug.com/603969). |
| 2032 TEST_F(PaintControllerTestBase, | 2019 TEST_F(PaintControllerTestBase, |
| 2033 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) { | 2020 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) { |
| 2034 Path path; | 2021 Path path; |
| 2035 path.AddLineTo(FloatPoint(50, 50)); | 2022 path.AddLineTo(FloatPoint(50, 50)); |
| 2036 path.AddLineTo(FloatPoint(100, 0)); | 2023 path.AddLineTo(FloatPoint(100, 0)); |
| 2037 path.AddLineTo(FloatPoint(50, 100)); | 2024 path.AddLineTo(FloatPoint(50, 100)); |
| 2038 path.CloseSubpath(); | 2025 path.CloseSubpath(); |
| 2039 | 2026 |
| 2040 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 2027 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 2041 GraphicsContext context(GetPaintController()); | 2028 GraphicsContext context(GetPaintController()); |
| 2042 | 2029 |
| 2043 // Run twice for empty/non-empty m_currentPaintArtifact coverage. | 2030 // Run twice for empty/non-empty m_currentPaintArtifact coverage. |
| 2044 for (int i = 0; i < 2; ++i) { | 2031 for (int i = 0; i < 2; ++i) { |
| 2045 for (int j = 0; j < 50; ++j) | 2032 for (int j = 0; j < 50; ++j) |
| 2046 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client, | 2033 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client, |
| 2047 path); | 2034 path); |
| 2048 DrawRect(context, client, kBackgroundDrawingType, | 2035 DrawRect(context, client, kBackgroundDrawingType, |
| 2049 FloatRect(0, 0, 100, 100)); | 2036 FloatRect(0, 0, 100, 100)); |
| 2050 for (int j = 0; j < 50; ++j) | 2037 for (int j = 0; j < 50; ++j) |
| 2051 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client); | 2038 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client); |
| 2052 GetPaintController().CommitNewDisplayItems(LayoutSize()); | 2039 GetPaintController().CommitNewDisplayItems(LayoutSize()); |
| 2053 EXPECT_FALSE(GetPaintController() | 2040 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50 * i); |
| 2054 .GetPaintArtifact() | |
| 2055 .IsSuitableForGpuRasterization()); | |
| 2056 } | 2041 } |
| 2057 } | 2042 } |
| 2058 | 2043 |
| 2059 // Death tests don't work properly on Android. | 2044 // Death tests don't work properly on Android. |
| 2060 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2045 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 2061 | 2046 |
| 2062 class PaintControllerUnderInvalidationTest | 2047 class PaintControllerUnderInvalidationTest |
| 2063 : public PaintControllerTestBase, | 2048 : public PaintControllerTestBase, |
| 2064 private ScopedPaintUnderInvalidationCheckingForTest { | 2049 private ScopedPaintUnderInvalidationCheckingForTest { |
| 2065 public: | 2050 public: |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2318 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { | 2303 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { |
| 2319 // We allow invalidated display item clients as long as they would produce the | 2304 // We allow invalidated display item clients as long as they would produce the |
| 2320 // same display items. The cases of changed display items are tested by other | 2305 // same display items. The cases of changed display items are tested by other |
| 2321 // test cases. | 2306 // test cases. |
| 2322 TestInvalidationInSubsequence(); | 2307 TestInvalidationInSubsequence(); |
| 2323 } | 2308 } |
| 2324 | 2309 |
| 2325 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2310 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 2326 | 2311 |
| 2327 } // namespace blink | 2312 } // namespace blink |
| OLD | NEW |