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 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 FrameFirstPaint result = GetPaintController().EndFrame(nullptr); | |
Xianzhu
2017/05/09 23:13:08
Add a SetXXXPainted() before this line to ensure i
Zhen Wang
2017/05/09 23:26:24
Done.
| |
2064 EXPECT_FALSE(result.first_painted); | |
2065 EXPECT_FALSE(result.text_painted); | |
2066 EXPECT_FALSE(result.image_painted); | |
2067 // Readd the null frame. | |
2068 GetPaintController().BeginFrame(nullptr); | |
2069 | |
2070 std::unique_ptr<FakeFrame> frame1(new FakeFrame); | |
2071 GetPaintController().BeginFrame(frame1.get()); | |
2072 GetPaintController().SetFirstPainted(); | |
2073 GetPaintController().SetTextPainted(); | |
2074 GetPaintController().SetImagePainted(); | |
2075 | |
2076 result = GetPaintController().EndFrame(frame1.get()); | |
2077 EXPECT_TRUE(result.first_painted); | |
2078 EXPECT_TRUE(result.text_painted); | |
2079 EXPECT_TRUE(result.image_painted); | |
2080 | |
2081 std::unique_ptr<FakeFrame> frame2(new FakeFrame); | |
2082 GetPaintController().BeginFrame(frame2.get()); | |
2083 GetPaintController().SetFirstPainted(); | |
2084 | |
2085 std::unique_ptr<FakeFrame> frame3(new FakeFrame); | |
2086 GetPaintController().BeginFrame(frame3.get()); | |
2087 GetPaintController().SetTextPainted(); | |
2088 GetPaintController().SetImagePainted(); | |
2089 | |
2090 result = GetPaintController().EndFrame(frame3.get()); | |
2091 EXPECT_FALSE(result.first_painted); | |
2092 EXPECT_TRUE(result.text_painted); | |
2093 EXPECT_TRUE(result.image_painted); | |
2094 | |
2095 result = GetPaintController().EndFrame(frame2.get()); | |
2096 EXPECT_TRUE(result.first_painted); | |
2097 EXPECT_FALSE(result.text_painted); | |
2098 EXPECT_FALSE(result.image_painted); | |
2099 } | |
2100 | |
2059 // Death tests don't work properly on Android. | 2101 // Death tests don't work properly on Android. |
2060 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2102 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
2061 | 2103 |
2062 class PaintControllerUnderInvalidationTest | 2104 class PaintControllerUnderInvalidationTest |
2063 : public PaintControllerTestBase, | 2105 : public PaintControllerTestBase, |
2064 private ScopedPaintUnderInvalidationCheckingForTest { | 2106 private ScopedPaintUnderInvalidationCheckingForTest { |
2065 public: | 2107 public: |
2066 PaintControllerUnderInvalidationTest() | 2108 PaintControllerUnderInvalidationTest() |
2067 : PaintControllerTestBase(), | 2109 : PaintControllerTestBase(), |
2068 ScopedPaintUnderInvalidationCheckingForTest(true) {} | 2110 ScopedPaintUnderInvalidationCheckingForTest(true) {} |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2318 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { | 2360 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { |
2319 // We allow invalidated display item clients as long as they would produce the | 2361 // 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 | 2362 // same display items. The cases of changed display items are tested by other |
2321 // test cases. | 2363 // test cases. |
2322 TestInvalidationInSubsequence(); | 2364 TestInvalidationInSubsequence(); |
2323 } | 2365 } |
2324 | 2366 |
2325 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2367 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
2326 | 2368 |
2327 } // namespace blink | 2369 } // namespace blink |
OLD | NEW |