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 #include "core/layout/LayoutBlock.h" | 5 #include "core/layout/LayoutBlock.h" |
6 #include "core/layout/LayoutInline.h" | 6 #include "core/layout/LayoutInline.h" |
7 #include "core/layout/compositing/CompositedLayerMapping.h" | 7 #include "core/layout/compositing/CompositedLayerMapping.h" |
8 #include "core/paint/PaintControllerPaintTest.h" | 8 #include "core/paint/PaintControllerPaintTest.h" |
9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
| 13 struct PaintLayerPainterTestParam { |
| 14 PaintLayerPainterTestParam(FrameSettingOverrideFunction frameSettingOverride
, bool slimmingPaintV2) |
| 15 : frameSettingOverride(frameSettingOverride), slimmingPaintV2(slimmingPa
intV2) { } |
| 16 |
| 17 FrameSettingOverrideFunction frameSettingOverride; |
| 18 bool slimmingPaintV2; |
| 19 }; |
| 20 |
13 class PaintLayerPainterTest | 21 class PaintLayerPainterTest |
14 : public PaintControllerPaintTest | 22 : public PaintControllerPaintTestBase |
15 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | 23 , public testing::WithParamInterface<PaintLayerPainterTestParam> { |
16 USING_FAST_MALLOC(PaintLayerPainterTest); | 24 USING_FAST_MALLOC(PaintLayerPainterTest); |
17 public: | 25 public: |
18 FrameSettingOverrideFunction settingOverrider() const override { return GetP
aram(); } | 26 PaintLayerPainterTest() : PaintControllerPaintTestBase(GetParam().slimmingPa
intV2) { } |
| 27 FrameSettingOverrideFunction settingOverrider() const override { return GetP
aram().frameSettingOverride; } |
19 }; | 28 }; |
20 | 29 |
21 INSTANTIATE_TEST_CASE_P(All, PaintLayerPainterTest, ::testing::Values( | 30 INSTANTIATE_TEST_CASE_P(All, PaintLayerPainterTest, ::testing::Values( |
22 nullptr, | 31 PaintLayerPainterTestParam(nullptr, false), // non-root-layer-scrolls, slimm
ing-paint-v1 |
23 RootLayerScrollsFrameSettingOverride)); | 32 PaintLayerPainterTestParam(nullptr, true), // non-root-layer-scrolls, slimmi
ng-paint-v2 |
| 33 PaintLayerPainterTestParam(RootLayerScrollsFrameSettingOverride, false), //
root-layer-scrolls, slimming-paint-v1 |
| 34 PaintLayerPainterTestParam(RootLayerScrollsFrameSettingOverride, true))); //
root-layer-scrolls, slimming-paint-v2 |
24 | 35 |
25 TEST_P(PaintLayerPainterTest, CachedSubsequence) | 36 TEST_P(PaintLayerPainterTest, CachedSubsequence) |
26 { | 37 { |
27 setBodyInnerHTML( | 38 setBodyInnerHTML( |
28 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" | 39 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
29 " <div id='content1' style='position: absolute; width: 100px; height: 1
00px; background-color: red'></div>" | 40 " <div id='content1' style='position: absolute; width: 100px; height: 1
00px; background-color: red'></div>" |
30 "</div>" | 41 "</div>" |
31 "<div id='container2' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" | 42 "<div id='container2' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
32 " <div id='content2' style='position: absolute; width: 100px; height: 1
00px; background-color: green'></div>" | 43 " <div id='content2' style='position: absolute; width: 100px; height: 1
00px; background-color: green'></div>" |
33 "</div>"); | 44 "</div>"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), | 82 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
72 TestDisplayItem(container2Layer, DisplayItem::Subsequence), | 83 TestDisplayItem(container2Layer, DisplayItem::Subsequence), |
73 TestDisplayItem(container2, backgroundType), | 84 TestDisplayItem(container2, backgroundType), |
74 TestDisplayItem(content2, backgroundType), | 85 TestDisplayItem(content2, backgroundType), |
75 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), | 86 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
76 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); | 87 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
77 } | 88 } |
78 | 89 |
79 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) | 90 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) |
80 { | 91 { |
| 92 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable
this test for SPv2 temporarily. |
| 93 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 94 return; |
| 95 |
81 setBodyInnerHTML( | 96 setBodyInnerHTML( |
82 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" | 97 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
83 " <div id='content1' style='position: absolute; width: 100px; height: 1
00px; background-color: green'></div>" | 98 " <div id='content1' style='position: absolute; width: 100px; height: 1
00px; background-color: green'></div>" |
84 "</div>" | 99 "</div>" |
85 "<div id='container2' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" | 100 "<div id='container2' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
86 " <div id='content2a' style='position: absolute; width: 100px; height:
100px; background-color: green'></div>" | 101 " <div id='content2a' style='position: absolute; width: 100px; height:
100px; background-color: green'></div>" |
87 " <div id='content2b' style='position: absolute; top: 200px; width: 100
px; height: 100px; background-color: green'></div>" | 102 " <div id='content2b' style='position: absolute; top: 200px; width: 100
px; height: 100px; background-color: green'></div>" |
88 "</div>" | 103 "</div>" |
89 "<div id='container3' style='position: absolute; z-index: 2; left: 300px
; top: 0; width: 200px; height: 200px; background-color: blue'>" | 104 "<div id='container3' style='position: absolute; z-index: 2; left: 300px
; top: 0; width: 200px; height: 200px; background-color: blue'>" |
90 " <div id='content3' style='position: absolute; width: 200px; height: 2
00px; background-color: green'></div>" | 105 " <div id='content3' style='position: absolute; width: 200px; height: 2
00px; background-color: green'></div>" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); | 144 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
130 | 145 |
131 document().view()->updateAllLifecyclePhasesExceptPaint(); | 146 document().view()->updateAllLifecyclePhasesExceptPaint(); |
132 IntRect newInterestRect(0, 100, 300, 1000); | 147 IntRect newInterestRect(0, 100, 300, 1000); |
133 EXPECT_TRUE(paintWithoutCommit(&newInterestRect)); | 148 EXPECT_TRUE(paintWithoutCommit(&newInterestRect)); |
134 | 149 |
135 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce | 150 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce |
136 // because it was fully painted before; | 151 // because it was fully painted before; |
137 // Container2's intersection with the interest rect changes; | 152 // Container2's intersection with the interest rect changes; |
138 // Content2b is out of the interest rect and outputs nothing; | 153 // Content2b is out of the interest rect and outputs nothing; |
139 // Container3 becomes out of the interest rect and outputs empty subsequence
pair.. | 154 // Container3 becomes out of the interest rect and outputs empty subsequence
pair. |
140 EXPECT_EQ(7, numCachedNewItems()); | 155 EXPECT_EQ(7, numCachedNewItems()); |
141 | 156 |
142 commit(); | 157 commit(); |
143 | 158 |
144 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 14, | 159 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 14, |
145 TestDisplayItem(layoutView(), documentBackgroundType), | 160 TestDisplayItem(layoutView(), documentBackgroundType), |
146 TestDisplayItem(htmlLayer, DisplayItem::Subsequence), | 161 TestDisplayItem(htmlLayer, DisplayItem::Subsequence), |
147 TestDisplayItem(container1Layer, DisplayItem::Subsequence), | 162 TestDisplayItem(container1Layer, DisplayItem::Subsequence), |
148 TestDisplayItem(container1, backgroundType), | 163 TestDisplayItem(container1, backgroundType), |
149 TestDisplayItem(content1, backgroundType), | 164 TestDisplayItem(content1, backgroundType), |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 PaintLayer& layer = *table.layer(); | 517 PaintLayer& layer = *table.layer(); |
503 EXPECT_TRUE(layer.isSelfPaintingLayer()); | 518 EXPECT_TRUE(layer.isSelfPaintingLayer()); |
504 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 519 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
505 | 520 |
506 toHTMLElement(table.node())->setAttribute(HTMLNames::styleAttr, "position: r
elative; border-collapse: collapse"); | 521 toHTMLElement(table.node())->setAttribute(HTMLNames::styleAttr, "position: r
elative; border-collapse: collapse"); |
507 document().view()->updateAllLifecyclePhases(); | 522 document().view()->updateAllLifecyclePhases(); |
508 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 523 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
509 } | 524 } |
510 | 525 |
511 } // namespace blink | 526 } // namespace blink |
OLD | NEW |