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 "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
7 | 7 |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "core/layout/LayoutText.h" | 9 #include "core/layout/LayoutText.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
11 #include "core/layout/line/InlineTextBox.h" | 11 #include "core/layout/line/InlineTextBox.h" |
12 #include "core/page/FocusController.h" | 12 #include "core/page/FocusController.h" |
13 #include "core/paint/DeprecatedPaintLayer.h" | 13 #include "core/paint/DeprecatedPaintLayer.h" |
14 #include "core/paint/DeprecatedPaintLayerPainter.h" | 14 #include "core/paint/DeprecatedPaintLayerPainter.h" |
15 #include "core/paint/LayerClipRecorder.h" | 15 #include "core/paint/LayerClipRecorder.h" |
16 #include "core/paint/LayoutObjectDrawingRecorder.h" | 16 #include "core/paint/LayoutObjectDrawingRecorder.h" |
17 #include "core/paint/ScopeRecorder.h" | 17 #include "core/paint/ScopeRecorder.h" |
18 #include "core/paint/SubtreeRecorder.h" | 18 #include "core/paint/SubtreeRecorder.h" |
19 #include "platform/graphics/GraphicsContext.h" | 19 #include "platform/graphics/GraphicsContext.h" |
20 #include "platform/graphics/GraphicsLayer.h" | 20 #include "platform/graphics/GraphicsLayer.h" |
21 #include "platform/graphics/paint/DrawingDisplayItem.h" | 21 #include "platform/graphics/paint/DrawingDisplayItem.h" |
22 #include <gtest/gtest.h> | 22 #include <gtest/gtest.h> |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 class DisplayItemListPaintTest : public RenderingTest { | 26 class DisplayItemListPaintTest : public RenderingTest { |
27 public: | 27 public: |
28 DisplayItemListPaintTest() | 28 DisplayItemListPaintTest() |
29 : m_layoutView(nullptr) | 29 : m_layoutView(nullptr) |
30 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } | 30 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
31 | 31 |
32 protected: | 32 protected: |
33 LayoutView& layoutView() { return *m_layoutView; } | 33 LayoutView& layoutView() { return *m_layoutView; } |
34 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 34 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
35 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList(
).m_newDisplayItems; } | 35 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList(
).m_newDisplayItems; } |
36 | 36 |
37 private: | 37 private: |
38 void SetUp() override | 38 void SetUp() override |
39 { | 39 { |
40 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 40 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 41 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
41 | 42 |
42 RenderingTest::SetUp(); | 43 RenderingTest::SetUp(); |
43 enableCompositing(); | 44 enableCompositing(); |
44 | 45 |
45 m_layoutView = document().view()->layoutView(); | 46 m_layoutView = document().view()->layoutView(); |
46 ASSERT_TRUE(m_layoutView); | 47 ASSERT_TRUE(m_layoutView); |
47 } | 48 } |
48 | 49 |
49 void TearDown() override | 50 void TearDown() override |
50 { | 51 { |
51 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); | 52 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
52 } | 53 } |
53 | 54 |
54 LayoutView* m_layoutView; | 55 LayoutView* m_layoutView; |
55 bool m_originalSlimmingPaintEnabled; | 56 bool m_originalSlimmingPaintV2Enabled; |
56 }; | 57 }; |
57 | 58 |
58 class TestDisplayItem : public DisplayItem { | 59 class TestDisplayItem : public DisplayItem { |
59 public: | 60 public: |
60 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display
Item(client, type, sizeof(*this)) { } | 61 TestDisplayItem(const DisplayItemClientWrapper& client, Type type) : Display
Item(client, type, sizeof(*this)) { } |
61 | 62 |
62 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); } | 63 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); } |
63 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO
T_REACHED(); } | 64 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO
T_REACHED(); } |
64 }; | 65 }; |
65 | 66 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC
lient())); | 144 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC
lient())); |
144 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl
ient())); | 145 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl
ient())); |
145 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); | 146 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); |
146 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); | 147 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); |
147 rootDisplayItemList().commitNewDisplayItems(); | 148 rootDisplayItemList().commitNewDisplayItems(); |
148 | 149 |
149 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 150 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
150 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 151 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
151 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 152 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
152 | 153 |
153 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, | 154 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 5, |
154 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 155 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 156 TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(Pain
tPhaseForeground)), |
155 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 157 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
156 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 158 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
| 159 TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintP
haseForeground))); |
157 } | 160 } |
158 | 161 |
159 } // namespace blink | 162 } // namespace blink |
OLD | NEW |