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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h

Issue 1415143005: Preparation for enabling slimming paint synchronized painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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/GraphicsLayer.h" 12 #include "platform/graphics/GraphicsLayer.h"
13 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class PaintControllerPaintTest : public RenderingTest { 17 class PaintControllerPaintTestBase : public RenderingTest {
18 public: 18 public:
19 PaintControllerPaintTest() 19 PaintControllerPaintTestBase(bool enableSlimmingPaintV2)
20 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu res::slimmingPaintSynchronizedPaintingEnabled()) 20 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu res::slimmingPaintSynchronizedPaintingEnabled())
21 , m_originalSlimmingPaintOffsetCachingEnabled(RuntimeEnabledFeatures::sl immingPaintOffsetCachingEnabled()) 21 , m_originalSlimmingPaintOffsetCachingEnabled(RuntimeEnabledFeatures::sl immingPaintOffsetCachingEnabled())
22 { } 22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled())
23 , m_enableSlimmingPaintV2(enableSlimmingPaintV2)
24 { }
23 25
24 protected: 26 protected:
25 LayoutView& layoutView() { return *document().layoutView(); } 27 LayoutView& layoutView() { return *document().layoutView(); }
26 PaintController& rootPaintController() { return *layoutView().layer()->graph icsLayerBacking()->paintController(); } 28 PaintController& rootPaintController() { return *layoutView().layer()->graph icsLayerBacking()->paintController(); }
27 29
28 private:
29 void SetUp() override 30 void SetUp() override
30 { 31 {
31 RenderingTest::SetUp(); 32 RenderingTest::SetUp();
32 enableCompositing(); 33 enableCompositing();
33 GraphicsLayer::setDrawDebugRedFillForTesting(false); 34 GraphicsLayer::setDrawDebugRedFillForTesting(false);
35 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_enableSlimmingPaintV 2);
34 } 36 }
35 void TearDown() override 37 void TearDown() override
36 { 38 {
37 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(m_or iginalSlimmingPaintSynchronizedPaintingEnabled); 39 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(m_or iginalSlimmingPaintSynchronizedPaintingEnabled);
38 RuntimeEnabledFeatures::setSlimmingPaintOffsetCachingEnabled(m_originalS limmingPaintOffsetCachingEnabled); 40 RuntimeEnabledFeatures::setSlimmingPaintOffsetCachingEnabled(m_originalS limmingPaintOffsetCachingEnabled);
41 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled);
39 GraphicsLayer::setDrawDebugRedFillForTesting(true); 42 GraphicsLayer::setDrawDebugRedFillForTesting(true);
40 } 43 }
41 44
42 bool m_originalSlimmingPaintSynchronizedPaintingEnabled;
43 bool m_originalSlimmingPaintOffsetCachingEnabled;
44 };
45
46 // Slimming paint v2 has subtly different behavior on some paint tests. This
47 // class is used to test only v2 behavior while maintaining v1 test coverage.
48 class PaintControllerPaintTestForSlimmingPaintV2 : public RenderingTest {
49 public:
50 PaintControllerPaintTestForSlimmingPaintV2()
51 : m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
52
53 protected:
54 LayoutView& layoutView() { return *document().layoutView(); }
55 PaintController& rootPaintController() { return *layoutView().layer()->graph icsLayerBacking()->paintController(); }
56
57 // Expose some document lifecycle steps for checking new display items befor e commiting. 45 // Expose some document lifecycle steps for checking new display items befor e commiting.
58 void updateLifecyclePhasesToPaintClean(const LayoutRect* interestRect = null ptr) 46 void updateLifecyclePhasesToPaintClean(const LayoutRect* interestRect = null ptr)
59 { 47 {
60 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp ositingCleanPlusScrolling, nullptr); 48 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp ositingCleanPlusScrolling, nullptr);
61 document().view()->invalidateTreeIfNeededRecursive(); 49 document().view()->invalidateTreeIfNeededRecursive();
62 document().view()->updatePaintProperties(); 50 document().view()->updatePaintProperties();
63 document().view()->synchronizedPaint(interestRect); 51 document().view()->synchronizedPaint(interestRect);
64 } 52 }
65 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); } 53 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); }
66 54
67 private: 55 private:
68 void SetUp() override 56 bool m_originalSlimmingPaintSynchronizedPaintingEnabled;
69 { 57 bool m_originalSlimmingPaintOffsetCachingEnabled;
70 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 58 bool m_originalSlimmingPaintV2Enabled;
59 bool m_enableSlimmingPaintV2;
60 };
71 61
72 RenderingTest::SetUp(); 62 class PaintControllerPaintTest : public PaintControllerPaintTestBase {
73 enableCompositing(); 63 public:
74 GraphicsLayer::setDrawDebugRedFillForTesting(false); 64 PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { }
75 } 65 };
76 66
77 void TearDown() override 67 class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTe stBase {
78 { 68 public:
79 GraphicsLayer::setDrawDebugRedFillForTesting(true); 69 PaintControllerPaintTestForSlimmingPaintV2() : PaintControllerPaintTestBase( true) { }
80 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); 70 };
81 }
82 71
83 bool m_originalSlimmingPaintV2Enabled; 72 class PaintControllerPaintTestForSlimmingPaintV1AndV2
Xianzhu 2015/10/28 18:10:23 With this we can run the same test for both v1 and
73 : public PaintControllerPaintTestBase
74 , public testing::WithParamInterface<bool> {
75 public:
76 PaintControllerPaintTestForSlimmingPaintV1AndV2() : PaintControllerPaintTest Base(GetParam()) { }
84 }; 77 };
85 78
86 class TestDisplayItem final : public DisplayItem { 79 class TestDisplayItem final : public DisplayItem {
87 public: 80 public:
88 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display Item(client, type, sizeof(*this)) { } 81 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display Item(client, type, sizeof(*this)) { }
89 82
90 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); } 83 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); }
91 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO T_REACHED(); } 84 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO T_REACHED(); }
92 }; 85 };
93 86
(...skipping 23 matching lines...) Expand all
117 const DisplayItem::Type cachedBackgroundType = DisplayItem::drawingTypeToCachedD rawingType(backgroundType); 110 const DisplayItem::Type cachedBackgroundType = DisplayItem::drawingTypeToCachedD rawingType(backgroundType);
118 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground); 111 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground);
119 const DisplayItem::Type cachedForegroundType = DisplayItem::drawingTypeToCachedD rawingType(foregroundType); 112 const DisplayItem::Type cachedForegroundType = DisplayItem::drawingTypeToCachedD rawingType(foregroundType);
120 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP ositiveZOrder; 113 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP ositiveZOrder;
121 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu bsequenceType(subsequenceType); 114 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu bsequenceType(subsequenceType);
122 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa chedSubsequenceType(subsequenceType); 115 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa chedSubsequenceType(subsequenceType);
123 116
124 } // namespace blink 117 } // namespace blink
125 118
126 #endif // PaintControllerPaintTest_h 119 #endif // PaintControllerPaintTest_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698