OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef PaintControllerPaintTest_h | 5 #ifndef PaintControllerPaintTest_h |
6 #define PaintControllerPaintTest_h | 6 #define PaintControllerPaintTest_h |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
12 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
13 #include "platform/graphics/GraphicsLayer.h" | 13 #include "platform/graphics/GraphicsLayer.h" |
| 14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
14 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class PaintControllerPaintTestBase : public RenderingTest { | 19 class PaintControllerPaintTestBase |
| 20 : private ScopedSlimmingPaintV2ForTest |
| 21 , public RenderingTest { |
19 public: | 22 public: |
20 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) | 23 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) : ScopedSlimmingPai
ntV2ForTest(enableSlimmingPaintV2) { } |
21 : m_originalSlimmingPaintInvalidationEnabled(RuntimeEnabledFeatures::sli
mmingPaintInvalidationEnabled()) | |
22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) | |
23 , m_enableSlimmingPaintV2(enableSlimmingPaintV2) | |
24 { } | |
25 | 24 |
26 protected: | 25 protected: |
27 LayoutView& layoutView() { return *document().layoutView(); } | 26 LayoutView& layoutView() { return *document().layoutView(); } |
28 PaintController& rootPaintController() { return layoutView().layer()->graphi
csLayerBacking()->getPaintController(); } | 27 PaintController& rootPaintController() { return layoutView().layer()->graphi
csLayerBacking()->getPaintController(); } |
29 | 28 |
30 void SetUp() override | 29 void SetUp() override |
31 { | 30 { |
32 RenderingTest::SetUp(); | 31 RenderingTest::SetUp(); |
33 enableCompositing(); | 32 enableCompositing(); |
34 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_enableSlimmingPaintV
2); | |
35 } | |
36 void TearDown() override | |
37 { | |
38 RuntimeEnabledFeatures::setSlimmingPaintInvalidationEnabled(m_originalSl
immingPaintInvalidationEnabled); | |
39 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | |
40 } | 33 } |
41 | 34 |
42 bool paintWithoutCommit(const IntRect* interestRect = nullptr) | 35 bool paintWithoutCommit(const IntRect* interestRect = nullptr) |
43 { | 36 { |
44 // Only root graphics layer is supported. | 37 // Only root graphics layer is supported. |
45 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); | 38 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); |
46 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in
terestRect)) { | 39 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in
terestRect)) { |
47 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle
an); | 40 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle
an); |
48 return false; | 41 return false; |
49 } | 42 } |
(...skipping 17 matching lines...) Expand all Loading... |
67 bool displayItemListContains(const DisplayItemList& displayItemList, Display
ItemClient& client, DisplayItem::Type type) | 60 bool displayItemListContains(const DisplayItemList& displayItemList, Display
ItemClient& client, DisplayItem::Type type) |
68 { | 61 { |
69 for (auto& item : displayItemList) { | 62 for (auto& item : displayItemList) { |
70 if (item.client() == client && item.getType() == type) | 63 if (item.client() == client && item.getType() == type) |
71 return true; | 64 return true; |
72 } | 65 } |
73 return false; | 66 return false; |
74 } | 67 } |
75 | 68 |
76 int numCachedNewItems() { return rootPaintController().m_numCachedNewItems;
} | 69 int numCachedNewItems() { return rootPaintController().m_numCachedNewItems;
} |
77 | |
78 private: | |
79 bool m_originalSlimmingPaintInvalidationEnabled; | |
80 bool m_originalSlimmingPaintV2Enabled; | |
81 bool m_enableSlimmingPaintV2; | |
82 }; | 70 }; |
83 | 71 |
84 class PaintControllerPaintTest : public PaintControllerPaintTestBase { | 72 class PaintControllerPaintTest : public PaintControllerPaintTestBase { |
85 public: | 73 public: |
86 PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { } | 74 PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { } |
87 }; | 75 }; |
88 | 76 |
89 class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTe
stBase { | 77 class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTe
stBase { |
90 public: | 78 public: |
91 PaintControllerPaintTestForSlimmingPaintV2() : PaintControllerPaintTestBase(
true) { } | 79 PaintControllerPaintTestForSlimmingPaintV2() : PaintControllerPaintTestBase(
true) { } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } while (false); | 116 } while (false); |
129 | 117 |
130 // Shorter names for frequently used display item types in tests. | 118 // Shorter names for frequently used display item types in tests. |
131 const DisplayItem::Type backgroundType = DisplayItem::BoxDecorationBackground; | 119 const DisplayItem::Type backgroundType = DisplayItem::BoxDecorationBackground; |
132 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground); | 120 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground); |
133 const DisplayItem::Type documentBackgroundType = DisplayItem::DocumentBackground
; | 121 const DisplayItem::Type documentBackgroundType = DisplayItem::DocumentBackground
; |
134 | 122 |
135 } // namespace blink | 123 } // namespace blink |
136 | 124 |
137 #endif // PaintControllerPaintTest_h | 125 #endif // PaintControllerPaintTest_h |
OLD | NEW |