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 "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "platform/graphics/paint/CachedDisplayItem.h" | |
10 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
11 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
12 #include "platform/graphics/paint/ClipRecorder.h" | 11 #include "platform/graphics/paint/ClipRecorder.h" |
13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 12 #include "platform/graphics/paint/DrawingDisplayItem.h" |
14 #include "platform/graphics/paint/DrawingRecorder.h" | 13 #include "platform/graphics/paint/DrawingRecorder.h" |
15 #include "platform/graphics/paint/SubsequenceRecorder.h" | 14 #include "platform/graphics/paint/SubsequenceRecorder.h" |
16 #include "platform/testing/FakeDisplayItemClient.h" | 15 #include "platform/testing/FakeDisplayItemClient.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 #include <memory> | 17 #include <memory> |
19 | 18 |
20 namespace blink { | 19 namespace blink { |
21 | 20 |
22 class PaintControllerTest : public ::testing::Test { | 21 class PaintControllerTest : public ::testing::Test { |
23 public: | 22 public: |
24 PaintControllerTest() | 23 PaintControllerTest() |
25 : m_paintController(PaintController::create()) | 24 : m_paintController(PaintController::create()) |
26 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
27 | 26 |
28 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) | 27 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) |
29 { | 28 { |
30 return paintArtifact.getDisplayItemList().visualRect(index); | 29 return paintArtifact.getDisplayItemList().visualRect(index); |
31 } | 30 } |
32 | 31 |
33 protected: | 32 protected: |
34 PaintController& getPaintController() { return *m_paintController; } | 33 PaintController& getPaintController() { return *m_paintController; } |
35 | 34 |
| 35 int numCachedNewItems() const { return m_paintController->m_numCachedNewItem
s; } |
| 36 |
| 37 #if DCHECK_IS_ON() |
| 38 int numSequentialMatches() const { return m_paintController->m_numSequential
Matches; } |
| 39 int numOutOfOrderMatches() const { return m_paintController->m_numOutOfOrder
Matches; } |
| 40 int numIndexedItems() const { return m_paintController->m_numIndexedItems; } |
| 41 #endif |
| 42 |
36 private: | 43 private: |
37 void TearDown() override | 44 void TearDown() override |
38 { | 45 { |
39 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 46 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
40 } | 47 } |
41 | 48 |
42 std::unique_ptr<PaintController> m_paintController; | 49 std::unique_ptr<PaintController> m_paintController; |
43 bool m_originalSlimmingPaintV2Enabled; | 50 bool m_originalSlimmingPaintV2Enabled; |
44 }; | 51 }; |
45 | 52 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 115 |
109 TEST_F(PaintControllerTest, UpdateBasic) | 116 TEST_F(PaintControllerTest, UpdateBasic) |
110 { | 117 { |
111 FakeDisplayItemClient first("first"); | 118 FakeDisplayItemClient first("first"); |
112 FakeDisplayItemClient second("second"); | 119 FakeDisplayItemClient second("second"); |
113 GraphicsContext context(getPaintController()); | 120 GraphicsContext context(getPaintController()); |
114 | 121 |
115 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); | 122 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); |
116 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20
0)); | 123 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20
0)); |
117 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); | 124 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 125 |
| 126 EXPECT_EQ(0, numCachedNewItems()); |
| 127 |
118 getPaintController().commitNewDisplayItems(); | 128 getPaintController().commitNewDisplayItems(); |
119 | 129 |
120 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 130 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
121 TestDisplayItem(first, backgroundDrawingType), | 131 TestDisplayItem(first, backgroundDrawingType), |
122 TestDisplayItem(second, backgroundDrawingType), | 132 TestDisplayItem(second, backgroundDrawingType), |
123 TestDisplayItem(first, foregroundDrawingType)); | 133 TestDisplayItem(first, foregroundDrawingType)); |
124 | 134 |
125 second.setDisplayItemsUncached(); | 135 second.setDisplayItemsUncached(); |
126 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); | 136 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); |
127 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); | 137 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 138 |
| 139 EXPECT_EQ(2, numCachedNewItems()); |
| 140 #if DCHECK_IS_ON() |
| 141 EXPECT_EQ(2, numSequentialMatches()); |
| 142 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 143 EXPECT_EQ(1, numIndexedItems()); |
| 144 #endif |
| 145 |
128 getPaintController().commitNewDisplayItems(); | 146 getPaintController().commitNewDisplayItems(); |
129 | 147 |
130 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 148 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
131 TestDisplayItem(first, backgroundDrawingType), | 149 TestDisplayItem(first, backgroundDrawingType), |
132 TestDisplayItem(first, foregroundDrawingType)); | 150 TestDisplayItem(first, foregroundDrawingType)); |
133 } | 151 } |
134 | 152 |
135 TEST_F(PaintControllerTest, UpdateSwapOrder) | 153 TEST_F(PaintControllerTest, UpdateSwapOrder) |
136 { | 154 { |
137 FakeDisplayItemClient first("first"); | 155 FakeDisplayItemClient first("first"); |
138 FakeDisplayItemClient second("second"); | 156 FakeDisplayItemClient second("second"); |
139 FakeDisplayItemClient unaffected("unaffected"); | 157 FakeDisplayItemClient unaffected("unaffected"); |
140 GraphicsContext context(getPaintController()); | 158 GraphicsContext context(getPaintController()); |
141 | 159 |
142 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 160 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 161 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
143 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 162 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 163 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
144 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); | 164 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 165 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10,
10)); |
145 getPaintController().commitNewDisplayItems(); | 166 getPaintController().commitNewDisplayItems(); |
146 | 167 |
147 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 168 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
148 TestDisplayItem(first, backgroundDrawingType), | 169 TestDisplayItem(first, backgroundDrawingType), |
| 170 TestDisplayItem(first, foregroundDrawingType), |
149 TestDisplayItem(second, backgroundDrawingType), | 171 TestDisplayItem(second, backgroundDrawingType), |
150 TestDisplayItem(unaffected, backgroundDrawingType)); | 172 TestDisplayItem(second, foregroundDrawingType), |
| 173 TestDisplayItem(unaffected, backgroundDrawingType), |
| 174 TestDisplayItem(unaffected, foregroundDrawingType)); |
151 | 175 |
152 second.setDisplayItemsUncached(); | |
153 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 176 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 177 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
154 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 178 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 179 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
155 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); | 180 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 181 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 182 |
| 183 EXPECT_EQ(6, numCachedNewItems()); |
| 184 #if DCHECK_IS_ON() |
| 185 EXPECT_EQ(5, numSequentialMatches()); // second, first foreground, unaffecte
d |
| 186 EXPECT_EQ(1, numOutOfOrderMatches()); // first |
| 187 EXPECT_EQ(2, numIndexedItems()); // first |
| 188 #endif |
| 189 |
156 getPaintController().commitNewDisplayItems(); | 190 getPaintController().commitNewDisplayItems(); |
157 | 191 |
158 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 192 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
159 TestDisplayItem(second, backgroundDrawingType), | 193 TestDisplayItem(second, backgroundDrawingType), |
| 194 TestDisplayItem(second, foregroundDrawingType), |
160 TestDisplayItem(first, backgroundDrawingType), | 195 TestDisplayItem(first, backgroundDrawingType), |
161 TestDisplayItem(unaffected, backgroundDrawingType)); | 196 TestDisplayItem(first, foregroundDrawingType), |
| 197 TestDisplayItem(unaffected, backgroundDrawingType), |
| 198 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 199 } |
| 200 |
| 201 TEST_F(PaintControllerTest, UpdateSwapOrderWithInvalidation) |
| 202 { |
| 203 FakeDisplayItemClient first("first"); |
| 204 FakeDisplayItemClient second("second"); |
| 205 FakeDisplayItemClient unaffected("unaffected"); |
| 206 GraphicsContext context(getPaintController()); |
| 207 |
| 208 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 209 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 210 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 211 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 212 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 213 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 214 getPaintController().commitNewDisplayItems(); |
| 215 |
| 216 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 217 TestDisplayItem(first, backgroundDrawingType), |
| 218 TestDisplayItem(first, foregroundDrawingType), |
| 219 TestDisplayItem(second, backgroundDrawingType), |
| 220 TestDisplayItem(second, foregroundDrawingType), |
| 221 TestDisplayItem(unaffected, backgroundDrawingType), |
| 222 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 223 |
| 224 first.setDisplayItemsUncached(); |
| 225 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 226 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 227 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 228 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 229 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 230 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 231 |
| 232 EXPECT_EQ(4, numCachedNewItems()); |
| 233 #if DCHECK_IS_ON() |
| 234 EXPECT_EQ(4, numSequentialMatches()); // second, unaffected |
| 235 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 236 EXPECT_EQ(2, numIndexedItems()); |
| 237 #endif |
| 238 |
| 239 getPaintController().commitNewDisplayItems(); |
| 240 |
| 241 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 242 TestDisplayItem(second, backgroundDrawingType), |
| 243 TestDisplayItem(second, foregroundDrawingType), |
| 244 TestDisplayItem(first, backgroundDrawingType), |
| 245 TestDisplayItem(first, foregroundDrawingType), |
| 246 TestDisplayItem(unaffected, backgroundDrawingType), |
| 247 TestDisplayItem(unaffected, foregroundDrawingType)); |
162 } | 248 } |
163 | 249 |
164 TEST_F(PaintControllerTest, UpdateNewItemInMiddle) | 250 TEST_F(PaintControllerTest, UpdateNewItemInMiddle) |
165 { | 251 { |
166 FakeDisplayItemClient first("first"); | 252 FakeDisplayItemClient first("first"); |
167 FakeDisplayItemClient second("second"); | 253 FakeDisplayItemClient second("second"); |
168 FakeDisplayItemClient third("third"); | 254 FakeDisplayItemClient third("third"); |
169 GraphicsContext context(getPaintController()); | 255 GraphicsContext context(getPaintController()); |
170 | 256 |
171 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 257 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
172 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 258 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
173 getPaintController().commitNewDisplayItems(); | 259 getPaintController().commitNewDisplayItems(); |
174 | 260 |
175 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 261 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
176 TestDisplayItem(first, backgroundDrawingType), | 262 TestDisplayItem(first, backgroundDrawingType), |
177 TestDisplayItem(second, backgroundDrawingType)); | 263 TestDisplayItem(second, backgroundDrawingType)); |
178 | 264 |
179 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 265 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
180 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50)
); | 266 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50)
); |
181 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 267 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 268 |
| 269 EXPECT_EQ(2, numCachedNewItems()); |
| 270 #if DCHECK_IS_ON() |
| 271 EXPECT_EQ(2, numSequentialMatches()); // first, second |
| 272 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 273 EXPECT_EQ(0, numIndexedItems()); |
| 274 #endif |
| 275 |
182 getPaintController().commitNewDisplayItems(); | 276 getPaintController().commitNewDisplayItems(); |
183 | 277 |
184 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 278 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
185 TestDisplayItem(first, backgroundDrawingType), | 279 TestDisplayItem(first, backgroundDrawingType), |
186 TestDisplayItem(third, backgroundDrawingType), | 280 TestDisplayItem(third, backgroundDrawingType), |
187 TestDisplayItem(second, backgroundDrawingType)); | 281 TestDisplayItem(second, backgroundDrawingType)); |
188 } | 282 } |
189 | 283 |
190 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases) | 284 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases) |
191 { | 285 { |
(...skipping 18 matching lines...) Expand all Loading... |
210 TestDisplayItem(second, foregroundDrawingType), | 304 TestDisplayItem(second, foregroundDrawingType), |
211 TestDisplayItem(third, foregroundDrawingType)); | 305 TestDisplayItem(third, foregroundDrawingType)); |
212 | 306 |
213 second.setDisplayItemsUncached(); | 307 second.setDisplayItemsUncached(); |
214 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 308 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
215 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 309 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
216 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; | 310 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; |
217 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); | 311 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
218 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); | 312 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
219 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; | 313 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; |
| 314 |
| 315 EXPECT_EQ(4, numCachedNewItems()); |
| 316 #if DCHECK_IS_ON() |
| 317 EXPECT_EQ(4, numSequentialMatches()); |
| 318 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 319 EXPECT_EQ(2, numIndexedItems()); |
| 320 #endif |
| 321 |
220 getPaintController().commitNewDisplayItems(); | 322 getPaintController().commitNewDisplayItems(); |
221 | 323 |
222 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 324 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
223 TestDisplayItem(first, backgroundDrawingType), | 325 TestDisplayItem(first, backgroundDrawingType), |
224 TestDisplayItem(second, backgroundDrawingType), | 326 TestDisplayItem(second, backgroundDrawingType), |
225 TestDisplayItem(third, backgroundDrawingType), | 327 TestDisplayItem(third, backgroundDrawingType), |
226 TestDisplayItem(first, foregroundDrawingType), | 328 TestDisplayItem(first, foregroundDrawingType), |
227 TestDisplayItem(second, foregroundDrawingType), | 329 TestDisplayItem(second, foregroundDrawingType), |
228 TestDisplayItem(third, foregroundDrawingType)); | 330 TestDisplayItem(third, foregroundDrawingType)); |
229 } | 331 } |
(...skipping 11 matching lines...) Expand all Loading... |
241 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 343 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
242 TestDisplayItem(second, backgroundDrawingType), | 344 TestDisplayItem(second, backgroundDrawingType), |
243 TestDisplayItem(second, foregroundDrawingType)); | 345 TestDisplayItem(second, foregroundDrawingType)); |
244 | 346 |
245 first.setDisplayItemsUncached(); | 347 first.setDisplayItemsUncached(); |
246 second.setDisplayItemsUncached(); | 348 second.setDisplayItemsUncached(); |
247 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 349 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
248 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 350 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
249 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 351 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
250 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 352 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 353 EXPECT_EQ(0, numCachedNewItems()); |
251 getPaintController().commitNewDisplayItems(); | 354 getPaintController().commitNewDisplayItems(); |
252 | 355 |
253 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 356 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
254 TestDisplayItem(first, backgroundDrawingType), | 357 TestDisplayItem(first, backgroundDrawingType), |
255 TestDisplayItem(first, foregroundDrawingType), | 358 TestDisplayItem(first, foregroundDrawingType), |
256 TestDisplayItem(second, backgroundDrawingType), | 359 TestDisplayItem(second, backgroundDrawingType), |
257 TestDisplayItem(second, foregroundDrawingType)); | 360 TestDisplayItem(second, foregroundDrawingType)); |
258 | 361 |
259 first.setDisplayItemsUncached(); | 362 first.setDisplayItemsUncached(); |
260 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 363 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
261 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 364 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 365 |
| 366 EXPECT_EQ(2, numCachedNewItems()); |
| 367 #if DCHECK_IS_ON() |
| 368 EXPECT_EQ(2, numSequentialMatches()); |
| 369 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 370 EXPECT_EQ(2, numIndexedItems()); |
| 371 #endif |
| 372 |
262 getPaintController().commitNewDisplayItems(); | 373 getPaintController().commitNewDisplayItems(); |
263 | 374 |
264 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 375 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
265 TestDisplayItem(second, backgroundDrawingType), | 376 TestDisplayItem(second, backgroundDrawingType), |
266 TestDisplayItem(second, foregroundDrawingType)); | 377 TestDisplayItem(second, foregroundDrawingType)); |
267 } | 378 } |
268 | 379 |
269 TEST_F(PaintControllerTest, UpdateAddLastOverlap) | 380 TEST_F(PaintControllerTest, UpdateAddLastOverlap) |
270 { | 381 { |
271 FakeDisplayItemClient first("first"); | 382 FakeDisplayItemClient first("first"); |
272 FakeDisplayItemClient second("second"); | 383 FakeDisplayItemClient second("second"); |
273 GraphicsContext context(getPaintController()); | 384 GraphicsContext context(getPaintController()); |
274 | 385 |
275 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 386 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
276 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 387 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
277 getPaintController().commitNewDisplayItems(); | 388 getPaintController().commitNewDisplayItems(); |
278 | 389 |
279 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 390 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
280 TestDisplayItem(first, backgroundDrawingType), | 391 TestDisplayItem(first, backgroundDrawingType), |
281 TestDisplayItem(first, foregroundDrawingType)); | 392 TestDisplayItem(first, foregroundDrawingType)); |
282 | 393 |
283 first.setDisplayItemsUncached(); | 394 first.setDisplayItemsUncached(); |
284 second.setDisplayItemsUncached(); | 395 second.setDisplayItemsUncached(); |
285 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 396 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
286 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 397 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
287 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 398 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
288 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 399 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 400 EXPECT_EQ(0, numCachedNewItems()); |
289 getPaintController().commitNewDisplayItems(); | 401 getPaintController().commitNewDisplayItems(); |
290 | 402 |
291 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 403 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
292 TestDisplayItem(first, backgroundDrawingType), | 404 TestDisplayItem(first, backgroundDrawingType), |
293 TestDisplayItem(first, foregroundDrawingType), | 405 TestDisplayItem(first, foregroundDrawingType), |
294 TestDisplayItem(second, backgroundDrawingType), | 406 TestDisplayItem(second, backgroundDrawingType), |
295 TestDisplayItem(second, foregroundDrawingType)); | 407 TestDisplayItem(second, foregroundDrawingType)); |
296 | 408 |
297 first.setDisplayItemsUncached(); | 409 first.setDisplayItemsUncached(); |
298 second.setDisplayItemsUncached(); | 410 second.setDisplayItemsUncached(); |
299 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 411 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
300 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 412 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 413 EXPECT_EQ(0, numCachedNewItems()); |
301 getPaintController().commitNewDisplayItems(); | 414 getPaintController().commitNewDisplayItems(); |
302 | 415 |
303 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 416 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
304 TestDisplayItem(first, backgroundDrawingType), | 417 TestDisplayItem(first, backgroundDrawingType), |
305 TestDisplayItem(first, foregroundDrawingType)); | 418 TestDisplayItem(first, foregroundDrawingType)); |
306 } | 419 } |
307 | 420 |
308 TEST_F(PaintControllerTest, UpdateClip) | 421 TEST_F(PaintControllerTest, UpdateClip) |
309 { | 422 { |
310 FakeDisplayItemClient first("first"); | 423 FakeDisplayItemClient first("first"); |
311 FakeDisplayItemClient second("second"); | 424 FakeDisplayItemClient second("second"); |
312 GraphicsContext context(getPaintController()); | 425 GraphicsContext context(getPaintController()); |
313 | 426 |
314 { | 427 { |
315 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2))
; | 428 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2))
; |
316 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150,
150)); | 429 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150,
150)); |
317 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); | 430 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); |
318 } | 431 } |
319 getPaintController().commitNewDisplayItems(); | 432 getPaintController().commitNewDisplayItems(); |
320 | 433 |
321 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 434 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
322 TestDisplayItem(first, clipType), | 435 TestDisplayItem(first, clipType), |
323 TestDisplayItem(first, backgroundDrawingType), | 436 TestDisplayItem(first, backgroundDrawingType), |
324 TestDisplayItem(second, backgroundDrawingType), | 437 TestDisplayItem(second, backgroundDrawingType), |
325 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); | 438 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); |
326 | 439 |
327 first.setDisplayItemsUncached(); | 440 first.setDisplayItemsUncached(); |
328 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 441 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
329 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); | 442 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); |
| 443 |
| 444 EXPECT_EQ(1, numCachedNewItems()); |
| 445 #if DCHECK_IS_ON() |
| 446 EXPECT_EQ(1, numSequentialMatches()); |
| 447 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 448 EXPECT_EQ(1, numIndexedItems()); |
| 449 #endif |
| 450 |
330 getPaintController().commitNewDisplayItems(); | 451 getPaintController().commitNewDisplayItems(); |
331 | 452 |
332 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 453 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
333 TestDisplayItem(first, backgroundDrawingType), | 454 TestDisplayItem(first, backgroundDrawingType), |
334 TestDisplayItem(second, backgroundDrawingType)); | 455 TestDisplayItem(second, backgroundDrawingType)); |
335 | 456 |
336 second.setDisplayItemsUncached(); | 457 second.setDisplayItemsUncached(); |
337 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 458 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
338 { | 459 { |
339 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)
); | 460 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)
); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 TestDisplayItem(container2, backgroundDrawingType), | 597 TestDisplayItem(container2, backgroundDrawingType), |
477 TestDisplayItem(content2, backgroundDrawingType), | 598 TestDisplayItem(content2, backgroundDrawingType), |
478 TestDisplayItem(content2, foregroundDrawingType), | 599 TestDisplayItem(content2, foregroundDrawingType), |
479 TestDisplayItem(container2, foregroundDrawingType), | 600 TestDisplayItem(container2, foregroundDrawingType), |
480 TestDisplayItem(container2, DisplayItem::EndSubsequence)); | 601 TestDisplayItem(container2, DisplayItem::EndSubsequence)); |
481 | 602 |
482 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. | 603 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
483 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer2)); | 604 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer2)); |
484 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer1)); | 605 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer1)); |
485 | 606 |
486 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 2, | 607 EXPECT_EQ(12, numCachedNewItems()); |
487 TestDisplayItem(container2, DisplayItem::CachedSubsequence), | 608 #if DCHECK_IS_ON() |
488 TestDisplayItem(container1, DisplayItem::CachedSubsequence)); | 609 EXPECT_EQ(1, numSequentialMatches()); |
| 610 EXPECT_EQ(1, numOutOfOrderMatches()); |
| 611 EXPECT_EQ(5, numIndexedItems()); |
| 612 #endif |
489 | 613 |
490 getPaintController().commitNewDisplayItems(); | 614 getPaintController().commitNewDisplayItems(); |
491 | 615 |
492 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, | 616 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, |
493 TestDisplayItem(container2, DisplayItem::Subsequence), | 617 TestDisplayItem(container2, DisplayItem::Subsequence), |
494 TestDisplayItem(container2, backgroundDrawingType), | 618 TestDisplayItem(container2, backgroundDrawingType), |
495 TestDisplayItem(content2, backgroundDrawingType), | 619 TestDisplayItem(content2, backgroundDrawingType), |
496 TestDisplayItem(content2, foregroundDrawingType), | 620 TestDisplayItem(content2, foregroundDrawingType), |
497 TestDisplayItem(container2, foregroundDrawingType), | 621 TestDisplayItem(container2, foregroundDrawingType), |
498 TestDisplayItem(container2, DisplayItem::EndSubsequence), | 622 TestDisplayItem(container2, DisplayItem::EndSubsequence), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 719 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
596 } | 720 } |
597 // Repaint container1 with foreground only. | 721 // Repaint container1 with foreground only. |
598 { | 722 { |
599 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context
, container1)); | 723 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context
, container1)); |
600 SubsequenceRecorder r(context, container1); | 724 SubsequenceRecorder r(context, container1); |
601 // Use cached subsequence of content1. | 725 // Use cached subsequence of content1. |
602 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context,
content1)); | 726 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context,
content1)); |
603 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); | 727 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); |
604 } | 728 } |
605 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 7, | 729 |
606 TestDisplayItem(content2, DisplayItem::Subsequence), | 730 EXPECT_EQ(4, numCachedNewItems()); |
607 TestDisplayItem(content2, foregroundDrawingType), | 731 #if DCHECK_IS_ON() |
608 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 732 EXPECT_EQ(1, numSequentialMatches()); |
609 TestDisplayItem(container1, DisplayItem::Subsequence), | 733 EXPECT_EQ(0, numOutOfOrderMatches()); |
610 TestDisplayItem(content1, DisplayItem::CachedSubsequence), | 734 EXPECT_EQ(2, numIndexedItems()); |
611 TestDisplayItem(container1, foregroundDrawingType), | 735 #endif |
612 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | |
613 | 736 |
614 getPaintController().commitNewDisplayItems(); | 737 getPaintController().commitNewDisplayItems(); |
615 | 738 |
616 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, | 739 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, |
617 TestDisplayItem(content2, DisplayItem::Subsequence), | 740 TestDisplayItem(content2, DisplayItem::Subsequence), |
618 TestDisplayItem(content2, foregroundDrawingType), | 741 TestDisplayItem(content2, foregroundDrawingType), |
619 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 742 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
620 | 743 |
621 TestDisplayItem(container1, DisplayItem::Subsequence), | 744 TestDisplayItem(container1, DisplayItem::Subsequence), |
622 TestDisplayItem(content1, DisplayItem::Subsequence), | 745 TestDisplayItem(content1, DisplayItem::Subsequence), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 | 783 |
661 // Draw again with nothing invalidated. | 784 // Draw again with nothing invalidated. |
662 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); | 785 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); |
663 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); | 786 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); |
664 | 787 |
665 getPaintController().beginSkippingCache(); | 788 getPaintController().beginSkippingCache(); |
666 drawRect(context, content, foregroundDrawingType, rect1); | 789 drawRect(context, content, foregroundDrawingType, rect1); |
667 drawRect(context, content, foregroundDrawingType, rect2); | 790 drawRect(context, content, foregroundDrawingType, rect2); |
668 getPaintController().endSkippingCache(); | 791 getPaintController().endSkippingCache(); |
669 | 792 |
670 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 3, | 793 EXPECT_EQ(1, numCachedNewItems()); |
671 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba
ckgroundDrawingType)), | 794 #if DCHECK_IS_ON() |
672 TestDisplayItem(content, foregroundDrawingType), | 795 EXPECT_EQ(1, numSequentialMatches()); |
673 TestDisplayItem(content, foregroundDrawingType)); | 796 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 797 EXPECT_EQ(0, numIndexedItems()); |
| 798 #endif |
674 | 799 |
675 getPaintController().commitNewDisplayItems(); | 800 getPaintController().commitNewDisplayItems(); |
676 | 801 |
677 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 802 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
678 TestDisplayItem(multicol, backgroundDrawingType), | 803 TestDisplayItem(multicol, backgroundDrawingType), |
679 TestDisplayItem(content, foregroundDrawingType), | 804 TestDisplayItem(content, foregroundDrawingType), |
680 TestDisplayItem(content, foregroundDrawingType)); | 805 TestDisplayItem(content, foregroundDrawingType)); |
681 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[1]).picture()); | 806 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[1]).picture()); |
682 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[2]).picture()); | 807 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[2]).picture()); |
683 | 808 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); | 1051 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); |
927 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); | 1052 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); |
928 for (int j = 0; j < 50; ++j) | 1053 for (int j = 0; j < 50; ++j) |
929 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; | 1054 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; |
930 getPaintController().commitNewDisplayItems(LayoutSize()); | 1055 getPaintController().commitNewDisplayItems(LayoutSize()); |
931 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); | 1056 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); |
932 } | 1057 } |
933 } | 1058 } |
934 | 1059 |
935 } // namespace blink | 1060 } // namespace blink |
OLD | NEW |