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 <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class PaintControllerPaintTestBase : public RenderingTest { | 18 class PaintControllerPaintTestBase : public RenderingTest { |
19 public: | 19 public: |
20 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) | 20 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) |
21 : m_originalSlimmingPaintInvalidationEnabled(RuntimeEnabledFeatures::sli mmingPaintInvalidationEnabled()) | 21 : m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) |
22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) | |
23 , m_enableSlimmingPaintV2(enableSlimmingPaintV2) | 22 , m_enableSlimmingPaintV2(enableSlimmingPaintV2) |
24 { } | 23 { |
24 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(enableSlimmingPaintV2) ; | |
25 } | |
26 | |
27 ~PaintControllerPaintTestBase() | |
28 { | |
29 CHECK_EQ(m_enableSlimmingPaintV2, RuntimeEnabledFeatures::slimmingPaintV 2Enabled()); | |
30 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); | |
31 } | |
25 | 32 |
26 protected: | 33 protected: |
27 LayoutView& layoutView() { return *document().layoutView(); } | 34 LayoutView& layoutView() { return *document().layoutView(); } |
28 PaintController& rootPaintController() { return layoutView().layer()->graphi csLayerBacking()->getPaintController(); } | 35 PaintController& rootPaintController() { return layoutView().layer()->graphi csLayerBacking()->getPaintController(); } |
29 | 36 |
30 void SetUp() override | 37 void SetUp() override |
31 { | 38 { |
32 RenderingTest::SetUp(); | 39 RenderingTest::SetUp(); |
33 enableCompositing(); | 40 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 } | 41 } |
41 | 42 |
42 bool paintWithoutCommit(const IntRect* interestRect = nullptr) | 43 bool paintWithoutCommit(const IntRect* interestRect = nullptr) |
43 { | 44 { |
44 // Only root graphics layer is supported. | 45 // Only root graphics layer is supported. |
45 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); | 46 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); |
46 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in terestRect)) { | 47 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in terestRect)) { |
47 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle an); | 48 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle an); |
48 return false; | 49 return false; |
49 } | 50 } |
(...skipping 19 matching lines...) Expand all Loading... | |
69 for (auto& item : displayItemList) { | 70 for (auto& item : displayItemList) { |
70 if (item.client() == client && item.getType() == type) | 71 if (item.client() == client && item.getType() == type) |
71 return true; | 72 return true; |
72 } | 73 } |
73 return false; | 74 return false; |
74 } | 75 } |
75 | 76 |
76 int numCachedNewItems() { return rootPaintController().m_numCachedNewItems; } | 77 int numCachedNewItems() { return rootPaintController().m_numCachedNewItems; } |
77 | 78 |
78 private: | 79 private: |
79 bool m_originalSlimmingPaintInvalidationEnabled; | |
esprehn
2016/08/25 23:59:24
is this unrelated, why did this change in this pat
trchen
2016/08/26 00:15:11
Yes, it is a drive-by change.
This flag wasn't to
| |
80 bool m_originalSlimmingPaintV2Enabled; | 80 bool m_originalSlimmingPaintV2Enabled; |
81 bool m_enableSlimmingPaintV2; | 81 bool m_enableSlimmingPaintV2; |
82 }; | 82 }; |
83 | 83 |
84 class PaintControllerPaintTest : public PaintControllerPaintTestBase { | 84 class PaintControllerPaintTest : public PaintControllerPaintTestBase { |
85 public: | 85 public: |
86 PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { } | 86 PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { } |
87 }; | 87 }; |
88 | 88 |
89 class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTe stBase { | 89 class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTe stBase { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 } while (false); | 128 } while (false); |
129 | 129 |
130 // Shorter names for frequently used display item types in tests. | 130 // Shorter names for frequently used display item types in tests. |
131 const DisplayItem::Type backgroundType = DisplayItem::BoxDecorationBackground; | 131 const DisplayItem::Type backgroundType = DisplayItem::BoxDecorationBackground; |
132 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground); | 132 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground); |
133 const DisplayItem::Type documentBackgroundType = DisplayItem::DocumentBackground ; | 133 const DisplayItem::Type documentBackgroundType = DisplayItem::DocumentBackground ; |
134 | 134 |
135 } // namespace blink | 135 } // namespace blink |
136 | 136 |
137 #endif // PaintControllerPaintTest_h | 137 #endif // PaintControllerPaintTest_h |
OLD | NEW |