Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp

Issue 2876033005: Track slow paths in DisplayItemList (Closed)
Patch Set: danakj review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 flags.setAntiAlias(true); 1901 flags.setAntiAlias(true);
1902 for (unsigned i = 0; i < count; i++) 1902 for (unsigned i = 0; i < count; i++)
1903 context.DrawPath(path, flags); 1903 context.DrawPath(path, flags);
1904 } 1904 }
1905 1905
1906 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) { 1906 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) {
1907 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1907 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1908 GraphicsContext context(GetPaintController()); 1908 GraphicsContext context(GetPaintController());
1909 DrawPath(context, client, kBackgroundDrawingType, 1); 1909 DrawPath(context, client, kBackgroundDrawingType, 1);
1910 GetPaintController().CommitNewDisplayItems(); 1910 GetPaintController().CommitNewDisplayItems();
1911 EXPECT_TRUE( 1911 EXPECT_EQ(1, GetPaintController().GetPaintArtifact().NumSlowPaths());
1912 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1913 } 1912 }
1914 1913
1915 TEST_F(PaintControllerTestBase, 1914 TEST_F(PaintControllerTestBase,
1916 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) { 1915 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) {
1917 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1916 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1918 GraphicsContext context(GetPaintController()); 1917 GraphicsContext context(GetPaintController());
1919 1918
1920 DrawPath(context, client, kBackgroundDrawingType, 50); 1919 DrawPath(context, client, kBackgroundDrawingType, 50);
1921 GetPaintController().CommitNewDisplayItems(); 1920 GetPaintController().CommitNewDisplayItems();
1922 EXPECT_FALSE( 1921 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1923 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1924 } 1922 }
1925 1923
1926 TEST_F(PaintControllerTestBase, 1924 TEST_F(PaintControllerTestBase,
1927 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) { 1925 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) {
1928 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1926 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1929 GraphicsContext context(GetPaintController()); 1927 GraphicsContext context(GetPaintController());
1930 GetPaintController().BeginSkippingCache(); 1928 GetPaintController().BeginSkippingCache();
1931 1929
1932 for (int i = 0; i < 50; ++i) 1930 for (int i = 0; i < 50; ++i)
1933 DrawPath(context, client, kBackgroundDrawingType, 50); 1931 DrawPath(context, client, kBackgroundDrawingType, 50);
1934 1932
1935 GetPaintController().EndSkippingCache(); 1933 GetPaintController().EndSkippingCache();
1936 GetPaintController().CommitNewDisplayItems(); 1934 GetPaintController().CommitNewDisplayItems();
1937 EXPECT_FALSE( 1935 EXPECT_EQ(50 * 50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1938 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1939 } 1936 }
1940 1937
1941 TEST_F(PaintControllerTestBase, 1938 TEST_F(PaintControllerTestBase,
1942 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) { 1939 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) {
1943 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1940 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1944 1941
1945 { 1942 {
1946 GraphicsContext context(GetPaintController()); 1943 GraphicsContext context(GetPaintController());
1947 DrawPath(context, client, kBackgroundDrawingType, 50); 1944 DrawPath(context, client, kBackgroundDrawingType, 50);
1948 GetPaintController().CommitNewDisplayItems(); 1945 GetPaintController().CommitNewDisplayItems();
1949 EXPECT_FALSE(GetPaintController() 1946 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1950 .GetPaintArtifact()
1951 .IsSuitableForGpuRasterization());
1952 } 1947 }
1953 1948
1954 client.SetDisplayItemsUncached(); 1949 client.SetDisplayItemsUncached();
1955 1950
1956 { 1951 {
1957 GraphicsContext context(GetPaintController()); 1952 GraphicsContext context(GetPaintController());
1958 DrawPath(context, client, kBackgroundDrawingType, 50); 1953 DrawPath(context, client, kBackgroundDrawingType, 50);
1959 GetPaintController().CommitNewDisplayItems(); 1954 GetPaintController().CommitNewDisplayItems();
1960 EXPECT_FALSE(GetPaintController() 1955 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1961 .GetPaintArtifact()
1962 .IsSuitableForGpuRasterization());
1963 } 1956 }
1964 } 1957 }
1965 1958
1966 TEST_F(PaintControllerTestBase, 1959 TEST_F(PaintControllerTestBase,
1967 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) { 1960 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) {
1968 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1961 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1969 1962
1970 { 1963 {
1971 GraphicsContext context(GetPaintController()); 1964 GraphicsContext context(GetPaintController());
1972 DrawPath(context, client, kBackgroundDrawingType, 50); 1965 DrawPath(context, client, kBackgroundDrawingType, 50);
1973 GetPaintController().CommitNewDisplayItems(); 1966 GetPaintController().CommitNewDisplayItems();
1974 EXPECT_FALSE(GetPaintController() 1967 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1975 .GetPaintArtifact()
1976 .IsSuitableForGpuRasterization());
1977 } 1968 }
1978 1969
1979 { 1970 {
1980 GraphicsContext context(GetPaintController()); 1971 GraphicsContext context(GetPaintController());
1981 DrawPath(context, client, kBackgroundDrawingType, 50); 1972 DrawPath(context, client, kBackgroundDrawingType, 50);
1982 GetPaintController().CommitNewDisplayItems(); 1973 GetPaintController().CommitNewDisplayItems();
1983 EXPECT_FALSE(GetPaintController() 1974 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
1984 .GetPaintArtifact()
1985 .IsSuitableForGpuRasterization());
1986 } 1975 }
1987 } 1976 }
1988 1977
1989 TEST_F( 1978 TEST_F(
1990 PaintControllerTestBase, 1979 PaintControllerTestBase,
1991 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence) { 1980 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence) {
1992 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1981 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1993 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); 1982 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100));
1994 1983
1995 GraphicsContext context(GetPaintController()); 1984 GraphicsContext context(GetPaintController());
1996 { 1985 {
1997 SubsequenceRecorder subsequence_recorder(context, container); 1986 SubsequenceRecorder subsequence_recorder(context, container);
1998 DrawPath(context, client, kBackgroundDrawingType, 50); 1987 DrawPath(context, client, kBackgroundDrawingType, 50);
1999 } 1988 }
2000 GetPaintController().CommitNewDisplayItems(); 1989 GetPaintController().CommitNewDisplayItems();
2001 EXPECT_FALSE( 1990 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
2002 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
2003 1991
2004 EXPECT_TRUE( 1992 EXPECT_TRUE(
2005 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container)); 1993 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container));
2006 GetPaintController().CommitNewDisplayItems(); 1994 GetPaintController().CommitNewDisplayItems();
2007 EXPECT_FALSE( 1995 EXPECT_EQ(50, GetPaintController().GetPaintArtifact().NumSlowPaths());
2008 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
2009 1996
2010 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 1997 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
2011 DisplayItemClient::EndShouldKeepAliveAllClients(); 1998 DisplayItemClient::EndShouldKeepAliveAllClients();
2012 #endif 1999 #endif
2013 } 2000 }
2014 2001
2015 // Temporarily disabled (pref regressions due to GPU veto stickiness: 2002 // Temporarily disabled (pref regressions due to GPU veto stickiness:
2016 // http://crbug.com/603969). 2003 // http://crbug.com/603969).
2017 TEST_F(PaintControllerTestBase, 2004 TEST_F(PaintControllerTestBase,
2018 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) { 2005 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) {
2019 Path path; 2006 Path path;
2020 path.AddLineTo(FloatPoint(50, 50)); 2007 path.AddLineTo(FloatPoint(50, 50));
2021 path.AddLineTo(FloatPoint(100, 0)); 2008 path.AddLineTo(FloatPoint(100, 0));
2022 path.AddLineTo(FloatPoint(50, 100)); 2009 path.AddLineTo(FloatPoint(50, 100));
2023 path.CloseSubpath(); 2010 path.CloseSubpath();
2024 2011
2025 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 2012 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
2026 GraphicsContext context(GetPaintController()); 2013 GraphicsContext context(GetPaintController());
2027 2014
2028 // Run twice for empty/non-empty m_currentPaintArtifact coverage. 2015 // Run twice for empty/non-empty m_currentPaintArtifact coverage.
2029 for (int i = 0; i < 2; ++i) { 2016 for (int i = 0; i < 2; ++i) {
2030 for (int j = 0; j < 50; ++j) 2017 for (int j = 0; j < 50; ++j)
2031 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client, 2018 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client,
2032 path); 2019 path);
2033 DrawRect(context, client, kBackgroundDrawingType, 2020 DrawRect(context, client, kBackgroundDrawingType,
2034 FloatRect(0, 0, 100, 100)); 2021 FloatRect(0, 0, 100, 100));
2035 for (int j = 0; j < 50; ++j) 2022 for (int j = 0; j < 50; ++j)
2036 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client); 2023 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client);
2037 GetPaintController().CommitNewDisplayItems(); 2024 GetPaintController().CommitNewDisplayItems();
2038 EXPECT_FALSE(GetPaintController() 2025 EXPECT_EQ(50 * i, GetPaintController().GetPaintArtifact().NumSlowPaths());
2039 .GetPaintArtifact()
2040 .IsSuitableForGpuRasterization());
2041 } 2026 }
2042 } 2027 }
2043 2028
2044 TEST_F(PaintControllerTestBase, BeginAndEndFrame) { 2029 TEST_F(PaintControllerTestBase, BeginAndEndFrame) {
2045 class FakeFrame {}; 2030 class FakeFrame {};
2046 2031
2047 // PaintController should have one null frame in the stack since beginning. 2032 // PaintController should have one null frame in the stack since beginning.
2048 GetPaintController().SetFirstPainted(); 2033 GetPaintController().SetFirstPainted();
2049 FrameFirstPaint result = GetPaintController().EndFrame(nullptr); 2034 FrameFirstPaint result = GetPaintController().EndFrame(nullptr);
2050 EXPECT_TRUE(result.first_painted); 2035 EXPECT_TRUE(result.first_painted);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { 2331 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) {
2347 // We allow invalidated display item clients as long as they would produce the 2332 // We allow invalidated display item clients as long as they would produce the
2348 // same display items. The cases of changed display items are tested by other 2333 // same display items. The cases of changed display items are tested by other
2349 // test cases. 2334 // test cases.
2350 TestInvalidationInSubsequence(); 2335 TestInvalidationInSubsequence();
2351 } 2336 }
2352 2337
2353 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2338 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2354 2339
2355 } // namespace blink 2340 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698