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

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

Issue 2872793002: Notify paint for each frame (Closed)
Patch Set: fix layout test Created 3 years, 7 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 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 FloatRect(0, 0, 100, 100)); 2049 FloatRect(0, 0, 100, 100));
2050 for (int j = 0; j < 50; ++j) 2050 for (int j = 0; j < 50; ++j)
2051 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client); 2051 GetPaintController().CreateAndAppend<EndClipPathDisplayItem>(client);
2052 GetPaintController().CommitNewDisplayItems(LayoutSize()); 2052 GetPaintController().CommitNewDisplayItems(LayoutSize());
2053 EXPECT_FALSE(GetPaintController() 2053 EXPECT_FALSE(GetPaintController()
2054 .GetPaintArtifact() 2054 .GetPaintArtifact()
2055 .IsSuitableForGpuRasterization()); 2055 .IsSuitableForGpuRasterization());
2056 } 2056 }
2057 } 2057 }
2058 2058
2059 TEST_F(PaintControllerTestBase, BeginAndEndFrame) {
2060 class FakeFrame {};
2061
2062 // PaintController should have one null frame in the stack since beginning.
2063 GetPaintController().SetFirstPainted();
2064 FrameFirstPaint result = GetPaintController().EndFrame(nullptr);
2065 EXPECT_TRUE(result.first_painted);
2066 EXPECT_FALSE(result.text_painted);
2067 EXPECT_FALSE(result.image_painted);
2068 // Readd the null frame.
2069 GetPaintController().BeginFrame(nullptr);
2070
2071 std::unique_ptr<FakeFrame> frame1(new FakeFrame);
2072 GetPaintController().BeginFrame(frame1.get());
2073 GetPaintController().SetFirstPainted();
2074 GetPaintController().SetTextPainted();
2075 GetPaintController().SetImagePainted();
2076
2077 result = GetPaintController().EndFrame(frame1.get());
2078 EXPECT_TRUE(result.first_painted);
2079 EXPECT_TRUE(result.text_painted);
2080 EXPECT_TRUE(result.image_painted);
2081
2082 std::unique_ptr<FakeFrame> frame2(new FakeFrame);
2083 GetPaintController().BeginFrame(frame2.get());
2084 GetPaintController().SetFirstPainted();
2085
2086 std::unique_ptr<FakeFrame> frame3(new FakeFrame);
2087 GetPaintController().BeginFrame(frame3.get());
2088 GetPaintController().SetTextPainted();
2089 GetPaintController().SetImagePainted();
2090
2091 result = GetPaintController().EndFrame(frame3.get());
2092 EXPECT_FALSE(result.first_painted);
2093 EXPECT_TRUE(result.text_painted);
2094 EXPECT_TRUE(result.image_painted);
2095
2096 result = GetPaintController().EndFrame(frame2.get());
2097 EXPECT_TRUE(result.first_painted);
2098 EXPECT_FALSE(result.text_painted);
2099 EXPECT_FALSE(result.image_painted);
2100 }
2101
2059 // Death tests don't work properly on Android. 2102 // Death tests don't work properly on Android.
2060 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2103 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2061 2104
2062 class PaintControllerUnderInvalidationTest 2105 class PaintControllerUnderInvalidationTest
2063 : public PaintControllerTestBase, 2106 : public PaintControllerTestBase,
2064 private ScopedPaintUnderInvalidationCheckingForTest { 2107 private ScopedPaintUnderInvalidationCheckingForTest {
2065 public: 2108 public:
2066 PaintControllerUnderInvalidationTest() 2109 PaintControllerUnderInvalidationTest()
2067 : PaintControllerTestBase(), 2110 : PaintControllerTestBase(),
2068 ScopedPaintUnderInvalidationCheckingForTest(true) {} 2111 ScopedPaintUnderInvalidationCheckingForTest(true) {}
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { 2361 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) {
2319 // We allow invalidated display item clients as long as they would produce the 2362 // 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 2363 // same display items. The cases of changed display items are tested by other
2321 // test cases. 2364 // test cases.
2322 TestInvalidationInSubsequence(); 2365 TestInvalidationInSubsequence();
2323 } 2366 }
2324 2367
2325 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2368 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2326 2369
2327 } // namespace blink 2370 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698