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