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

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

Issue 2876033005: Track slow paths in DisplayItemList (Closed)
Patch Set: Rebase 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 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 flags.setAntiAlias(true); 1917 flags.setAntiAlias(true);
1918 for (unsigned i = 0; i < count; i++) 1918 for (unsigned i = 0; i < count; i++)
1919 context.DrawPath(path, flags); 1919 context.DrawPath(path, flags);
1920 } 1920 }
1921 1921
1922 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) { 1922 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) {
1923 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1923 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1924 GraphicsContext context(GetPaintController()); 1924 GraphicsContext context(GetPaintController());
1925 DrawPath(context, client, kBackgroundDrawingType, 1); 1925 DrawPath(context, client, kBackgroundDrawingType, 1);
1926 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1926 GetPaintController().CommitNewDisplayItems(LayoutSize());
1927 EXPECT_TRUE( 1927 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 1);
danakj 2017/05/31 18:03:38 These EXPECT_EQ's are backwards, expected first
1928 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1929 } 1928 }
1930 1929
1931 TEST_F(PaintControllerTestBase, 1930 TEST_F(PaintControllerTestBase,
1932 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) { 1931 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPaths) {
1933 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1932 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1934 GraphicsContext context(GetPaintController()); 1933 GraphicsContext context(GetPaintController());
1935 1934
1936 DrawPath(context, client, kBackgroundDrawingType, 50); 1935 DrawPath(context, client, kBackgroundDrawingType, 50);
1937 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1936 GetPaintController().CommitNewDisplayItems(LayoutSize());
1938 EXPECT_FALSE( 1937 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
1939 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1940 } 1938 }
1941 1939
1942 TEST_F(PaintControllerTestBase, 1940 TEST_F(PaintControllerTestBase,
1943 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) { 1941 IsNotSuitableForGpuRasterizationMultiplePaintRecordsSinglePathEach) {
1944 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1942 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1945 GraphicsContext context(GetPaintController()); 1943 GraphicsContext context(GetPaintController());
1946 GetPaintController().BeginSkippingCache(); 1944 GetPaintController().BeginSkippingCache();
1947 1945
1948 for (int i = 0; i < 50; ++i) 1946 for (int i = 0; i < 50; ++i)
1949 DrawPath(context, client, kBackgroundDrawingType, 50); 1947 DrawPath(context, client, kBackgroundDrawingType, 50);
1950 1948
1951 GetPaintController().EndSkippingCache(); 1949 GetPaintController().EndSkippingCache();
1952 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1950 GetPaintController().CommitNewDisplayItems(LayoutSize());
1953 EXPECT_FALSE( 1951 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50 * 50);
1954 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
1955 } 1952 }
1956 1953
1957 TEST_F(PaintControllerTestBase, 1954 TEST_F(PaintControllerTestBase,
1958 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) { 1955 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsTwoPaints) {
1959 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1956 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1960 1957
1961 { 1958 {
1962 GraphicsContext context(GetPaintController()); 1959 GraphicsContext context(GetPaintController());
1963 DrawPath(context, client, kBackgroundDrawingType, 50); 1960 DrawPath(context, client, kBackgroundDrawingType, 50);
1964 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1961 GetPaintController().CommitNewDisplayItems(LayoutSize());
1965 EXPECT_FALSE(GetPaintController() 1962 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
1966 .GetPaintArtifact()
1967 .IsSuitableForGpuRasterization());
1968 } 1963 }
1969 1964
1970 client.SetDisplayItemsUncached(); 1965 client.SetDisplayItemsUncached();
1971 1966
1972 { 1967 {
1973 GraphicsContext context(GetPaintController()); 1968 GraphicsContext context(GetPaintController());
1974 DrawPath(context, client, kBackgroundDrawingType, 50); 1969 DrawPath(context, client, kBackgroundDrawingType, 50);
1975 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1970 GetPaintController().CommitNewDisplayItems(LayoutSize());
1976 EXPECT_FALSE(GetPaintController() 1971 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
1977 .GetPaintArtifact()
1978 .IsSuitableForGpuRasterization());
1979 } 1972 }
1980 } 1973 }
1981 1974
1982 TEST_F(PaintControllerTestBase, 1975 TEST_F(PaintControllerTestBase,
1983 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) { 1976 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCached) {
1984 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1977 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1985 1978
1986 { 1979 {
1987 GraphicsContext context(GetPaintController()); 1980 GraphicsContext context(GetPaintController());
1988 DrawPath(context, client, kBackgroundDrawingType, 50); 1981 DrawPath(context, client, kBackgroundDrawingType, 50);
1989 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1982 GetPaintController().CommitNewDisplayItems(LayoutSize());
1990 EXPECT_FALSE(GetPaintController() 1983 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
1991 .GetPaintArtifact()
1992 .IsSuitableForGpuRasterization());
1993 } 1984 }
1994 1985
1995 { 1986 {
1996 GraphicsContext context(GetPaintController()); 1987 GraphicsContext context(GetPaintController());
1997 DrawPath(context, client, kBackgroundDrawingType, 50); 1988 DrawPath(context, client, kBackgroundDrawingType, 50);
1998 GetPaintController().CommitNewDisplayItems(LayoutSize()); 1989 GetPaintController().CommitNewDisplayItems(LayoutSize());
1999 EXPECT_FALSE(GetPaintController() 1990 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
2000 .GetPaintArtifact()
2001 .IsSuitableForGpuRasterization());
2002 } 1991 }
2003 } 1992 }
2004 1993
2005 TEST_F( 1994 TEST_F(
2006 PaintControllerTestBase, 1995 PaintControllerTestBase,
2007 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence) { 1996 IsNotSuitableForGpuRasterizationSinglePaintRecordManyPathsCachedSubsequence) {
2008 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1997 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
2009 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); 1998 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100));
2010 1999
2011 GraphicsContext context(GetPaintController()); 2000 GraphicsContext context(GetPaintController());
2012 { 2001 {
2013 SubsequenceRecorder subsequence_recorder(context, container); 2002 SubsequenceRecorder subsequence_recorder(context, container);
2014 DrawPath(context, client, kBackgroundDrawingType, 50); 2003 DrawPath(context, client, kBackgroundDrawingType, 50);
2015 } 2004 }
2016 GetPaintController().CommitNewDisplayItems(LayoutSize()); 2005 GetPaintController().CommitNewDisplayItems(LayoutSize());
2017 EXPECT_FALSE( 2006 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
2018 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
2019 2007
2020 EXPECT_TRUE( 2008 EXPECT_TRUE(
2021 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container)); 2009 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container));
2022 GetPaintController().CommitNewDisplayItems(LayoutSize()); 2010 GetPaintController().CommitNewDisplayItems(LayoutSize());
2023 EXPECT_FALSE( 2011 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50);
2024 GetPaintController().GetPaintArtifact().IsSuitableForGpuRasterization());
2025 2012
2026 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 2013 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
2027 DisplayItemClient::EndShouldKeepAliveAllClients(); 2014 DisplayItemClient::EndShouldKeepAliveAllClients();
2028 #endif 2015 #endif
2029 } 2016 }
2030 2017
2031 // Temporarily disabled (pref regressions due to GPU veto stickiness: 2018 // Temporarily disabled (pref regressions due to GPU veto stickiness:
2032 // http://crbug.com/603969). 2019 // http://crbug.com/603969).
2033 TEST_F(PaintControllerTestBase, 2020 TEST_F(PaintControllerTestBase,
2034 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) { 2021 DISABLED_IsNotSuitableForGpuRasterizationConcaveClipPath) {
2035 Path path; 2022 Path path;
2036 path.AddLineTo(FloatPoint(50, 50)); 2023 path.AddLineTo(FloatPoint(50, 50));
2037 path.AddLineTo(FloatPoint(100, 0)); 2024 path.AddLineTo(FloatPoint(100, 0));
2038 path.AddLineTo(FloatPoint(50, 100)); 2025 path.AddLineTo(FloatPoint(50, 100));
2039 path.CloseSubpath(); 2026 path.CloseSubpath();
2040 2027
2041 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 2028 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
2042 GraphicsContext context(GetPaintController()); 2029 GraphicsContext context(GetPaintController());
2043 2030
2044 // Run twice for empty/non-empty m_currentPaintArtifact coverage. 2031 // Run twice for empty/non-empty m_currentPaintArtifact coverage.
2045 for (int i = 0; i < 2; ++i) { 2032 for (int i = 0; i < 2; ++i) {
2046 for (int j = 0; j < 50; ++j) 2033 for (int j = 0; j < 50; ++j)
2047 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client, 2034 GetPaintController().CreateAndAppend<BeginClipPathDisplayItem>(client,
2048 path); 2035 path);
2049 DrawRect(context, client, kBackgroundDrawingType, 2036 DrawRect(context, client, kBackgroundDrawingType,
2050 FloatRect(0, 0, 100, 100)); 2037 FloatRect(0, 0, 100, 100));
2051 for (int j = 0; j < 50; ++j) 2038 for (int j = 0; j < 50; ++j)
2052 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client); 2039 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client);
2053 GetPaintController().CommitNewDisplayItems(LayoutSize()); 2040 GetPaintController().CommitNewDisplayItems(LayoutSize());
2054 EXPECT_FALSE(GetPaintController() 2041 EXPECT_EQ(GetPaintController().GetPaintArtifact().NumSlowPaths(), 50 * i);
2055 .GetPaintArtifact()
2056 .IsSuitableForGpuRasterization());
2057 } 2042 }
2058 } 2043 }
2059 2044
2060 TEST_F(PaintControllerTestBase, BeginAndEndFrame) { 2045 TEST_F(PaintControllerTestBase, BeginAndEndFrame) {
2061 class FakeFrame {}; 2046 class FakeFrame {};
2062 2047
2063 // PaintController should have one null frame in the stack since beginning. 2048 // PaintController should have one null frame in the stack since beginning.
2064 GetPaintController().SetFirstPainted(); 2049 GetPaintController().SetFirstPainted();
2065 FrameFirstPaint result = GetPaintController().EndFrame(nullptr); 2050 FrameFirstPaint result = GetPaintController().EndFrame(nullptr);
2066 EXPECT_TRUE(result.first_painted); 2051 EXPECT_TRUE(result.first_painted);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { 2347 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) {
2363 // We allow invalidated display item clients as long as they would produce the 2348 // We allow invalidated display item clients as long as they would produce the
2364 // same display items. The cases of changed display items are tested by other 2349 // same display items. The cases of changed display items are tested by other
2365 // test cases. 2350 // test cases.
2366 TestInvalidationInSubsequence(); 2351 TestInvalidationInSubsequence();
2367 } 2352 }
2368 2353
2369 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2354 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2370 2355
2371 } // namespace blink 2356 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698