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 "core/layout/compositing/CompositedLayerMapping.h" | 6 #include "core/layout/compositing/CompositedLayerMapping.h" |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/layout/LayoutBoxModelObject.h" | 9 #include "core/layout/LayoutBoxModelObject.h" |
10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
| 11 #include "core/layout/LayoutView.h" |
11 #include "core/paint/PaintLayer.h" | 12 #include "core/paint/PaintLayer.h" |
12 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class CompositedLayerMappingTest : public RenderingTest { | 17 class CompositedLayerMappingTest : public RenderingTest { |
17 public: | 18 public: |
18 CompositedLayerMappingTest() | 19 CompositedLayerMappingTest() |
19 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu
res::slimmingPaintSynchronizedPaintingEnabled()) { } | 20 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu
res::slimmingPaintSynchronizedPaintingEnabled()) { } |
20 | 21 |
21 protected: | 22 protected: |
22 IntRect computeInterestRect(const GraphicsLayer* graphicsLayer, LayoutObject
* owningLayoutObject) | 23 IntRect recomputeInterestRect(const GraphicsLayer* graphicsLayer, LayoutObje
ct* owningLayoutObject) |
23 { | 24 { |
24 return CompositedLayerMapping::computeInterestRect(graphicsLayer, owning
LayoutObject); | 25 return CompositedLayerMapping::recomputeInterestRect(graphicsLayer, owni
ngLayoutObject); |
25 } | 26 } |
26 | 27 |
27 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) | 28 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) |
28 { | 29 { |
29 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); | 30 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); |
30 } | 31 } |
31 | 32 |
| 33 IntRect previousInterestRect(const GraphicsLayer* graphicsLayer) |
| 34 { |
| 35 return graphicsLayer->m_previousInterestRect; |
| 36 } |
| 37 |
32 private: | 38 private: |
33 void SetUp() override | 39 void SetUp() override |
34 { | 40 { |
35 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true
); | 41 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true
); |
36 | 42 |
37 RenderingTest::SetUp(); | 43 RenderingTest::SetUp(); |
38 enableCompositing(); | 44 enableCompositing(); |
39 GraphicsLayer::setDrawDebugRedFillForTesting(false); | 45 GraphicsLayer::setDrawDebugRedFillForTesting(false); |
40 } | 46 } |
41 | 47 |
42 void TearDown() override | 48 void TearDown() override |
43 { | 49 { |
44 GraphicsLayer::setDrawDebugRedFillForTesting(true); | 50 GraphicsLayer::setDrawDebugRedFillForTesting(true); |
45 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(m_or
iginalSlimmingPaintSynchronizedPaintingEnabled); | 51 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(m_or
iginalSlimmingPaintSynchronizedPaintingEnabled); |
46 } | 52 } |
47 | 53 |
48 bool m_originalSlimmingPaintSynchronizedPaintingEnabled; | 54 bool m_originalSlimmingPaintSynchronizedPaintingEnabled; |
49 }; | 55 }; |
50 | 56 |
51 static void printRect(IntRect rect) | 57 #define EXPECT_RECT_EQ(expected, actual) \ |
52 { | 58 do { \ |
53 fprintf(stderr, "[x=%d y=%d maxX=%d maxY=%d]\n", rect.x(), rect.y(), rect.ma
xX(), rect.maxY()); | 59 EXPECT_EQ(expected.x(), actual.x()); \ |
54 } | 60 EXPECT_EQ(expected.y(), actual.y()); \ |
55 | 61 EXPECT_EQ(expected.width(), actual.width()); \ |
56 static bool checkRectsEqual(const IntRect& expected, const IntRect& actual) | 62 EXPECT_EQ(expected.height(), actual.height()); \ |
57 { | 63 } while (false) |
58 if (expected != actual) { | |
59 fprintf(stderr, "Expected: "); | |
60 printRect(expected); | |
61 fprintf(stderr, "Actual: "); | |
62 printRect(actual); | |
63 return false; | |
64 } | |
65 return true; | |
66 } | |
67 | 64 |
68 TEST_F(CompositedLayerMappingTest, SimpleInterestRect) | 65 TEST_F(CompositedLayerMappingTest, SimpleInterestRect) |
69 { | 66 { |
70 setBodyInnerHTML("<div id='target' style='width: 200px; height: 200px; will-
change: transform'></div>"); | 67 setBodyInnerHTML("<div id='target' style='width: 200px; height: 200px; will-
change: transform'></div>"); |
71 | 68 |
72 document().view()->updateAllLifecyclePhases(); | 69 document().view()->updateAllLifecyclePhases(); |
73 Element* element = document().getElementById("target"); | 70 Element* element = document().getElementById("target"); |
74 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 71 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
75 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 72 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
76 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(pai
ntLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 73 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), recomputeInterestRect(paintLayer->gr
aphicsLayerBacking(), paintLayer->layoutObject())); |
77 } | 74 } |
78 | 75 |
79 TEST_F(CompositedLayerMappingTest, TallLayerInterestRect) | 76 TEST_F(CompositedLayerMappingTest, TallLayerInterestRect) |
80 { | 77 { |
81 setBodyInnerHTML("<div id='target' style='width: 200px; height: 10000px; wil
l-change: transform'></div>"); | 78 setBodyInnerHTML("<div id='target' style='width: 200px; height: 10000px; wil
l-change: transform'></div>"); |
82 | 79 |
83 document().view()->updateAllLifecyclePhases(); | 80 document().view()->updateAllLifecyclePhases(); |
84 Element* element = document().getElementById("target"); | 81 Element* element = document().getElementById("target"); |
85 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 82 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
86 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); | 83 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); |
87 // Screen-space visible content rect is [8, 8, 200, 600]. Mapping back to lo
cal, adding 4000px in all directions, then | 84 // Screen-space visible content rect is [8, 8, 200, 600]. Mapping back to lo
cal, adding 4000px in all directions, then |
88 // clipping, yields this rect. | 85 // clipping, yields this rect. |
89 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4592), computeInterestRect(pa
intLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 86 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592), recomputeInterestRect(paintLayer->g
raphicsLayerBacking(), paintLayer->layoutObject())); |
90 } | 87 } |
91 | 88 |
92 TEST_F(CompositedLayerMappingTest, RotatedInterestRect) | 89 TEST_F(CompositedLayerMappingTest, RotatedInterestRect) |
93 { | 90 { |
94 setBodyInnerHTML( | 91 setBodyInnerHTML( |
95 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; transform: rotateZ(45deg)'></div>"); | 92 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; transform: rotateZ(45deg)'></div>"); |
96 | 93 |
97 document().view()->updateAllLifecyclePhases(); | 94 document().view()->updateAllLifecyclePhases(); |
98 Element* element = document().getElementById("target"); | 95 Element* element = document().getElementById("target"); |
99 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 96 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
100 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 97 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
101 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(pai
ntLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 98 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), recomputeInterestRect(paintLayer->gr
aphicsLayerBacking(), paintLayer->layoutObject())); |
102 } | 99 } |
103 | 100 |
104 TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect) | 101 TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect) |
105 { | 102 { |
106 // It's rotated 90 degrees about the X axis, which means its visual content
rect is empty, and so the interest rect is the | 103 // It's rotated 90 degrees about the X axis, which means its visual content
rect is empty, and so the interest rect is the |
107 // default (0, 0, 4000, 4000) intersected with the layer bounds. | 104 // default (0, 0, 4000, 4000) intersected with the layer bounds. |
108 setBodyInnerHTML( | 105 setBodyInnerHTML( |
109 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateY(90deg)'></div>"); | 106 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateY(90deg)'></div>"); |
110 | 107 |
111 document().view()->updateAllLifecyclePhases(); | 108 document().view()->updateAllLifecyclePhases(); |
112 Element* element = document().getElementById("target"); | 109 Element* element = document().getElementById("target"); |
113 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 110 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
114 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 111 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
115 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4000), computeInterestRect(pa
intLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 112 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000), recomputeInterestRect(paintLayer->g
raphicsLayerBacking(), paintLayer->layoutObject())); |
116 } | 113 } |
117 | 114 |
118 TEST_F(CompositedLayerMappingTest, 3D45DegRotatedTallInterestRect) | 115 TEST_F(CompositedLayerMappingTest, 3D45DegRotatedTallInterestRect) |
119 { | 116 { |
120 setBodyInnerHTML( | 117 setBodyInnerHTML( |
121 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateY(45deg)'></div>"); | 118 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateY(45deg)'></div>"); |
122 | 119 |
123 document().view()->updateAllLifecyclePhases(); | 120 document().view()->updateAllLifecyclePhases(); |
124 Element* element = document().getElementById("target"); | 121 Element* element = document().getElementById("target"); |
125 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 122 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
126 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 123 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
127 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4592), computeInterestRect(pa
intLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 124 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592), recomputeInterestRect(paintLayer->g
raphicsLayerBacking(), paintLayer->layoutObject())); |
128 } | 125 } |
129 | 126 |
130 TEST_F(CompositedLayerMappingTest, RotatedTallInterestRect) | 127 TEST_F(CompositedLayerMappingTest, RotatedTallInterestRect) |
131 { | 128 { |
132 setBodyInnerHTML( | 129 setBodyInnerHTML( |
133 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateZ(45deg)'></div>"); | 130 "<div id='target' style='width: 200px; height: 10000px; will-change: tra
nsform; transform: rotateZ(45deg)'></div>"); |
134 | 131 |
135 document().view()->updateAllLifecyclePhases(); | 132 document().view()->updateAllLifecyclePhases(); |
136 Element* element = document().getElementById("target"); | 133 Element* element = document().getElementById("target"); |
137 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 134 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
138 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 135 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
139 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4000), computeInterestRect(pa
intLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 136 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000), recomputeInterestRect(paintLayer->g
raphicsLayerBacking(), paintLayer->layoutObject())); |
140 } | 137 } |
141 | 138 |
142 TEST_F(CompositedLayerMappingTest, WideLayerInterestRect) | 139 TEST_F(CompositedLayerMappingTest, WideLayerInterestRect) |
143 { | 140 { |
144 setBodyInnerHTML("<div id='target' style='width: 10000px; height: 200px; wil
l-change: transform'></div>"); | 141 setBodyInnerHTML("<div id='target' style='width: 10000px; height: 200px; wil
l-change: transform'></div>"); |
145 | 142 |
146 document().view()->updateAllLifecyclePhases(); | 143 document().view()->updateAllLifecyclePhases(); |
147 Element* element = document().getElementById("target"); | 144 Element* element = document().getElementById("target"); |
148 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 145 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
149 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 146 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
150 // Screen-space visible content rect is [8, 8, 800, 200] (the screen is 800x
600). | 147 // Screen-space visible content rect is [8, 8, 800, 200] (the screen is 800x
600). |
151 // Mapping back to local, adding 4000px in all directions, then clipping, yi
elds this rect. | 148 // Mapping back to local, adding 4000px in all directions, then clipping, yi
elds this rect. |
152 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4792, 200), computeInterestRect(pa
intLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 149 EXPECT_RECT_EQ(IntRect(0, 0, 4792, 200), recomputeInterestRect(paintLayer->g
raphicsLayerBacking(), paintLayer->layoutObject())); |
153 } | 150 } |
154 | 151 |
155 TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect) | 152 TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect) |
156 { | 153 { |
157 setBodyInnerHTML( | 154 setBodyInnerHTML( |
158 "<div id='target' style='width: 300px; height: 400px; will-change: trans
form; position: fixed; top: 100px; left: 200px;'></div>"); | 155 "<div id='target' style='width: 300px; height: 400px; will-change: trans
form; position: fixed; top: 100px; left: 200px;'></div>"); |
159 | 156 |
160 document().view()->updateAllLifecyclePhases(); | 157 document().view()->updateAllLifecyclePhases(); |
161 Element* element = document().getElementById("target"); | 158 Element* element = document().getElementById("target"); |
162 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 159 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
163 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 160 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
164 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 300, 400), computeInterestRect(pai
ntLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 161 EXPECT_RECT_EQ(IntRect(0, 0, 300, 400), recomputeInterestRect(paintLayer->gr
aphicsLayerBacking(), paintLayer->layoutObject())); |
165 } | 162 } |
166 | 163 |
167 TEST_F(CompositedLayerMappingTest, LayerOffscreenInterestRect) | 164 TEST_F(CompositedLayerMappingTest, LayerOffscreenInterestRect) |
168 { | 165 { |
169 setBodyInnerHTML( | 166 setBodyInnerHTML( |
170 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; position: absolute; top: 9000px; left: 0px;'>" | 167 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; position: absolute; top: 9000px; left: 0px;'>" |
171 "</div>"); | 168 "</div>"); |
172 | 169 |
173 document().view()->updateAllLifecyclePhases(); | 170 document().view()->updateAllLifecyclePhases(); |
174 Element* element = document().getElementById("target"); | 171 Element* element = document().getElementById("target"); |
175 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 172 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
176 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); | 173 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); |
177 // Offscreen layers are painted as usual. | 174 // Offscreen layers are painted as usual. |
178 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(pai
ntLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 175 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), recomputeInterestRect(paintLayer->gr
aphicsLayerBacking(), paintLayer->layoutObject())); |
179 } | 176 } |
180 | 177 |
181 TEST_F(CompositedLayerMappingTest, ScrollingLayerInterestRect) | 178 TEST_F(CompositedLayerMappingTest, ScrollingLayerInterestRect) |
182 { | 179 { |
183 setBodyInnerHTML( | 180 setBodyInnerHTML( |
184 "<style>div::-webkit-scrollbar{ width: 5px; }</style>" | 181 "<style>div::-webkit-scrollbar{ width: 5px; }</style>" |
185 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; overflow: scroll'>" | 182 "<div id='target' style='width: 200px; height: 200px; will-change: trans
form; overflow: scroll'>" |
186 "<div style='width: 100px; height: 10000px'></div></div>"); | 183 "<div style='width: 100px; height: 10000px'></div></div>"); |
187 | 184 |
188 document().view()->updateAllLifecyclePhases(); | 185 document().view()->updateAllLifecyclePhases(); |
189 Element* element = document().getElementById("target"); | 186 Element* element = document().getElementById("target"); |
190 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 187 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
191 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); | 188 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); |
192 // Offscreen layers are painted as usual. | 189 // Offscreen layers are painted as usual. |
193 ASSERT_TRUE(paintLayer->compositedLayerMapping()->scrollingLayer()); | 190 ASSERT_TRUE(paintLayer->compositedLayerMapping()->scrollingLayer()); |
194 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 195, 4592), computeInterestRect(pa
intLayer->graphicsLayerBackingForScrolling(), paintLayer->layoutObject()))); | 191 EXPECT_RECT_EQ(IntRect(0, 0, 195, 4592), recomputeInterestRect(paintLayer->g
raphicsLayerBackingForScrolling(), paintLayer->layoutObject())); |
195 } | 192 } |
196 | 193 |
197 TEST_F(CompositedLayerMappingTest, ClippedBigLayer) | 194 TEST_F(CompositedLayerMappingTest, ClippedBigLayer) |
198 { | 195 { |
199 setBodyInnerHTML( | 196 setBodyInnerHTML( |
200 "<div style='width: 1px; height: 1px; overflow: hidden'>" | 197 "<div style='width: 1px; height: 1px; overflow: hidden'>" |
201 "<div id='target' style='width: 10000px; height: 10000px; will-change: t
ransform'></div></div>"); | 198 "<div id='target' style='width: 10000px; height: 10000px; will-change: t
ransform'></div></div>"); |
202 | 199 |
203 document().view()->updateAllLifecyclePhases(); | 200 document().view()->updateAllLifecyclePhases(); |
204 Element* element = document().getElementById("target"); | 201 Element* element = document().getElementById("target"); |
205 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 202 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
206 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); | 203 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); |
207 // Offscreen layers are painted as usual. | 204 // Offscreen layers are painted as usual. |
208 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4001, 4001), computeInterestRect(p
aintLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 205 EXPECT_RECT_EQ(IntRect(0, 0, 4001, 4001), recomputeInterestRect(paintLayer->
graphicsLayerBacking(), paintLayer->layoutObject())); |
209 } | 206 } |
210 | 207 |
211 TEST_F(CompositedLayerMappingTest, ClippingMaskLayer) | 208 TEST_F(CompositedLayerMappingTest, ClippingMaskLayer) |
212 { | 209 { |
213 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 210 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
214 return; | 211 return; |
215 | 212 |
216 const AtomicString styleWithoutClipping = "backface-visibility: hidden; widt
h: 200px; height: 200px"; | 213 const AtomicString styleWithoutClipping = "backface-visibility: hidden; widt
h: 200px; height: 200px"; |
217 const AtomicString styleWithBorderRadius = styleWithoutClipping + "; border-
radius: 10px"; | 214 const AtomicString styleWithBorderRadius = styleWithoutClipping + "; border-
radius: 10px"; |
218 const AtomicString styleWithClipPath = styleWithoutClipping + "; -webkit-cli
p-path: inset(10px)"; | 215 const AtomicString styleWithClipPath = styleWithoutClipping + "; -webkit-cli
p-path: inset(10px)"; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 newInterestRect.move(512, 0); | 296 newInterestRect.move(512, 0); |
300 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); | 297 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); |
301 newInterestRect.move(0, 512); | 298 newInterestRect.move(0, 512); |
302 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); | 299 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); |
303 newInterestRect.move(1, 0); | 300 newInterestRect.move(1, 0); |
304 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); | 301 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); |
305 newInterestRect.move(-1, 1); | 302 newInterestRect.move(-1, 1); |
306 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); | 303 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); |
307 } | 304 } |
308 | 305 |
| 306 TEST_F(CompositedLayerMappingTest, InterestRectChangeOnScroll) |
| 307 { |
| 308 setBodyInnerHTML( |
| 309 "<style>" |
| 310 " ::-webkit-scrollbar { width: 0; height: 0; }" |
| 311 " body { margin: 0; }" |
| 312 "</style>" |
| 313 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); |
| 314 |
| 315 document().view()->updateAllLifecyclePhases(); |
| 316 GraphicsLayer* rootScrollingLayer = document().layoutView()->layer()->graphi
csLayerBackingForScrolling(); |
| 317 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), previousInterestRect(rootScrollingL
ayer)); |
| 318 |
| 319 document().view()->setScrollPosition(IntPoint(0, 300), ProgrammaticScroll); |
| 320 document().view()->updateAllLifecyclePhases(); |
| 321 // Still use the previous interest rect because the recomputed rect hasn't c
hanged enough. |
| 322 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900), recomputeInterestRect(rootScrolling
Layer, document().layoutView())); |
| 323 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), previousInterestRect(rootScrollingL
ayer)); |
| 324 |
| 325 document().view()->setScrollPosition(IntPoint(0, 600), ProgrammaticScroll); |
| 326 document().view()->updateAllLifecyclePhases(); |
| 327 // Use recomputed interest rect because it changed enough. |
| 328 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), recomputeInterestRect(rootScrolling
Layer, document().layoutView())); |
| 329 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), previousInterestRect(rootScrollingL
ayer)); |
| 330 |
| 331 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll); |
| 332 document().view()->updateAllLifecyclePhases(); |
| 333 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), recomputeInterestRect(rootScroll
ingLayer, document().layoutView())); |
| 334 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli
ngLayer)); |
| 335 |
| 336 document().view()->setScrollPosition(IntPoint(0, 9000), ProgrammaticScroll); |
| 337 document().view()->updateAllLifecyclePhases(); |
| 338 // Still use the previous interest rect because it contains the recomputed i
nterest rect. |
| 339 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), recomputeInterestRect(rootScroll
ingLayer, document().layoutView())); |
| 340 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli
ngLayer)); |
| 341 |
| 342 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll); |
| 343 // Use recomputed interest rect because it changed enough. |
| 344 document().view()->updateAllLifecyclePhases(); |
| 345 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), recomputeInterestRect(rootScrolling
Layer, document().layoutView())); |
| 346 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), previousInterestRect(rootScrollingL
ayer)); |
| 347 } |
| 348 |
| 349 TEST_F(CompositedLayerMappingTest, InterestRectShouldNotChangeOnPaintInvalidatio
n) |
| 350 { |
| 351 setBodyInnerHTML( |
| 352 "<style>" |
| 353 " ::-webkit-scrollbar { width: 0; height: 0; }" |
| 354 " body { margin: 0; }" |
| 355 "</style>" |
| 356 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); |
| 357 |
| 358 GraphicsLayer* rootScrollingLayer = document().layoutView()->layer()->graphi
csLayerBackingForScrolling(); |
| 359 |
| 360 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll); |
| 361 document().view()->updateAllLifecyclePhases(); |
| 362 document().view()->setScrollPosition(IntPoint(0, 9400), ProgrammaticScroll); |
| 363 // The above code creates an interest rect bigger than the interest rect if
recomputed now. |
| 364 document().view()->updateAllLifecyclePhases(); |
| 365 EXPECT_RECT_EQ(IntRect(0, 5400, 800, 4600), recomputeInterestRect(rootScroll
ingLayer, document().layoutView())); |
| 366 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli
ngLayer)); |
| 367 |
| 368 // Paint invalidation and repaint should not change previous paint interest
rect. |
| 369 document().getElementById("div")->setTextContent("Change"); |
| 370 document().view()->updateAllLifecyclePhases(); |
| 371 EXPECT_RECT_EQ(IntRect(0, 5400, 800, 4600), recomputeInterestRect(rootScroll
ingLayer, document().layoutView())); |
| 372 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), previousInterestRect(rootScrolli
ngLayer)); |
| 373 } |
| 374 |
309 } // namespace blink | 375 } // namespace blink |
OLD | NEW |