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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp

Issue 2480863002: DCHECK that paint properties are never null (Closed)
Patch Set: dcheckmate Created 4 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 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/ClipPathDisplayItem.h" 9 #include "platform/graphics/paint/ClipPathDisplayItem.h"
10 #include "platform/graphics/paint/ClipPathRecorder.h" 10 #include "platform/graphics/paint/ClipPathRecorder.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 int numIndexedItems() const { return m_paintController->m_numIndexedItems; } 47 int numIndexedItems() const { return m_paintController->m_numIndexedItems; }
48 #endif 48 #endif
49 49
50 void TearDown() override { m_featuresBackup.restore(); } 50 void TearDown() override { m_featuresBackup.restore(); }
51 51
52 private: 52 private:
53 std::unique_ptr<PaintController> m_paintController; 53 std::unique_ptr<PaintController> m_paintController;
54 RuntimeEnabledFeatures::Backup m_featuresBackup; 54 RuntimeEnabledFeatures::Backup m_featuresBackup;
55 }; 55 };
56 56
57 PaintChunkProperties rootPaintChunkProperties() {
58 PaintChunkProperties rootProperties;
59 rootProperties.transform = TransformPaintPropertyNode::root();
60 rootProperties.clip = ClipPaintPropertyNode::root();
61 rootProperties.effect = EffectPaintPropertyNode::root();
62 rootProperties.scroll = ScrollPaintPropertyNode::root();
63 return rootProperties;
64 }
65
57 const DisplayItem::Type foregroundDrawingType = 66 const DisplayItem::Type foregroundDrawingType =
58 static_cast<DisplayItem::Type>(DisplayItem::kDrawingPaintPhaseFirst + 4); 67 static_cast<DisplayItem::Type>(DisplayItem::kDrawingPaintPhaseFirst + 4);
59 const DisplayItem::Type backgroundDrawingType = 68 const DisplayItem::Type backgroundDrawingType =
60 DisplayItem::kDrawingPaintPhaseFirst; 69 DisplayItem::kDrawingPaintPhaseFirst;
61 const DisplayItem::Type clipType = DisplayItem::kClipFirst; 70 const DisplayItem::Type clipType = DisplayItem::kClipFirst;
62 71
63 class TestDisplayItem final : public DisplayItem { 72 class TestDisplayItem final : public DisplayItem {
64 public: 73 public:
65 TestDisplayItem(const FakeDisplayItemClient& client, Type type) 74 TestDisplayItem(const FakeDisplayItemClient& client, Type type)
66 : DisplayItem(client, type, sizeof(*this)) {} 75 : DisplayItem(client, type, sizeof(*this)) {}
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 INSTANTIATE_TEST_CASE_P(All, 168 INSTANTIATE_TEST_CASE_P(All,
160 PaintControllerTest, 169 PaintControllerTest,
161 ::testing::Values(SPv1, 170 ::testing::Values(SPv1,
162 SPv2, 171 SPv2,
163 UnderInvalidationCheckingSPv1, 172 UnderInvalidationCheckingSPv1,
164 UnderInvalidationCheckingSPv2)); 173 UnderInvalidationCheckingSPv2));
165 174
166 TEST_P(PaintControllerTest, NestedRecorders) { 175 TEST_P(PaintControllerTest, NestedRecorders) {
167 GraphicsContext context(getPaintController()); 176 GraphicsContext context(getPaintController());
168 FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200)); 177 FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200));
169 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 178 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
170 getPaintController().updateCurrentPaintChunkProperties( 179 getPaintController().updateCurrentPaintChunkProperties(
171 &m_rootPaintChunkId, PaintChunkProperties()); 180 &m_rootPaintChunkId, rootPaintChunkProperties());
181 }
172 182
173 drawClippedRect(context, client, clipType, backgroundDrawingType, 183 drawClippedRect(context, client, clipType, backgroundDrawingType,
174 FloatRect(100, 100, 200, 200)); 184 FloatRect(100, 100, 200, 200));
175 getPaintController().commitNewDisplayItems(); 185 getPaintController().commitNewDisplayItems();
176 186
177 EXPECT_DISPLAY_LIST( 187 EXPECT_DISPLAY_LIST(
178 getPaintController().getDisplayItemList(), 3, 188 getPaintController().getDisplayItemList(), 3,
179 TestDisplayItem(client, clipType), 189 TestDisplayItem(client, clipType),
180 TestDisplayItem(client, backgroundDrawingType), 190 TestDisplayItem(client, backgroundDrawingType),
181 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); 191 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType)));
182 192
183 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 193 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
184 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 194 EXPECT_EQ(1u, getPaintController().paintChunks().size());
185 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 195 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
186 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 196 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
187 } 197 }
188 } 198 }
189 199
190 TEST_P(PaintControllerTest, UpdateBasic) { 200 TEST_P(PaintControllerTest, UpdateBasic) {
191 FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); 201 FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300));
192 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); 202 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200));
193 GraphicsContext context(getPaintController()); 203 GraphicsContext context(getPaintController());
194 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 204 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
195 getPaintController().updateCurrentPaintChunkProperties( 205 getPaintController().updateCurrentPaintChunkProperties(
196 &m_rootPaintChunkId, PaintChunkProperties()); 206 &m_rootPaintChunkId, rootPaintChunkProperties());
207 }
197 208
198 drawRect(context, first, backgroundDrawingType, 209 drawRect(context, first, backgroundDrawingType,
199 FloatRect(100, 100, 300, 300)); 210 FloatRect(100, 100, 300, 300));
200 drawRect(context, second, backgroundDrawingType, 211 drawRect(context, second, backgroundDrawingType,
201 FloatRect(100, 100, 200, 200)); 212 FloatRect(100, 100, 200, 200));
202 drawRect(context, first, foregroundDrawingType, 213 drawRect(context, first, foregroundDrawingType,
203 FloatRect(100, 100, 300, 300)); 214 FloatRect(100, 100, 300, 300));
204 215
205 EXPECT_EQ(0, numCachedNewItems()); 216 EXPECT_EQ(0, numCachedNewItems());
206 217
207 getPaintController().commitNewDisplayItems(); 218 getPaintController().commitNewDisplayItems();
208 219
209 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 220 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
210 TestDisplayItem(first, backgroundDrawingType), 221 TestDisplayItem(first, backgroundDrawingType),
211 TestDisplayItem(second, backgroundDrawingType), 222 TestDisplayItem(second, backgroundDrawingType),
212 TestDisplayItem(first, foregroundDrawingType)); 223 TestDisplayItem(first, foregroundDrawingType));
213 224
214 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 225 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
215 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 226 EXPECT_EQ(1u, getPaintController().paintChunks().size());
216 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 227 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
217 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 228 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
218 229
219 getPaintController().updateCurrentPaintChunkProperties( 230 getPaintController().updateCurrentPaintChunkProperties(
220 &m_rootPaintChunkId, PaintChunkProperties()); 231 &m_rootPaintChunkId, rootPaintChunkProperties());
221 } 232 }
222 233
223 drawRect(context, first, backgroundDrawingType, 234 drawRect(context, first, backgroundDrawingType,
224 FloatRect(100, 100, 300, 300)); 235 FloatRect(100, 100, 300, 300));
225 drawRect(context, first, foregroundDrawingType, 236 drawRect(context, first, foregroundDrawingType,
226 FloatRect(100, 100, 300, 300)); 237 FloatRect(100, 100, 300, 300));
227 238
228 EXPECT_EQ(2, numCachedNewItems()); 239 EXPECT_EQ(2, numCachedNewItems());
229 #ifndef NDEBUG 240 #ifndef NDEBUG
230 EXPECT_EQ(2, numSequentialMatches()); 241 EXPECT_EQ(2, numSequentialMatches());
(...skipping 14 matching lines...) Expand all
245 UnorderedElementsAre(FloatRect( 256 UnorderedElementsAre(FloatRect(
246 100, 100, 200, 200))); // |second| disappeared from the chunk. 257 100, 100, 200, 200))); // |second| disappeared from the chunk.
247 } 258 }
248 } 259 }
249 260
250 TEST_P(PaintControllerTest, UpdateSwapOrder) { 261 TEST_P(PaintControllerTest, UpdateSwapOrder) {
251 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 262 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
252 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 263 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
253 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); 264 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10));
254 GraphicsContext context(getPaintController()); 265 GraphicsContext context(getPaintController());
255 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 266 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
256 getPaintController().updateCurrentPaintChunkProperties( 267 getPaintController().updateCurrentPaintChunkProperties(
257 &m_rootPaintChunkId, PaintChunkProperties()); 268 &m_rootPaintChunkId, rootPaintChunkProperties());
269 }
258 270
259 drawRect(context, first, backgroundDrawingType, 271 drawRect(context, first, backgroundDrawingType,
260 FloatRect(100, 100, 100, 100)); 272 FloatRect(100, 100, 100, 100));
261 drawRect(context, first, foregroundDrawingType, 273 drawRect(context, first, foregroundDrawingType,
262 FloatRect(100, 100, 100, 100)); 274 FloatRect(100, 100, 100, 100));
263 drawRect(context, second, backgroundDrawingType, 275 drawRect(context, second, backgroundDrawingType,
264 FloatRect(100, 100, 50, 200)); 276 FloatRect(100, 100, 50, 200));
265 drawRect(context, second, foregroundDrawingType, 277 drawRect(context, second, foregroundDrawingType,
266 FloatRect(100, 100, 50, 200)); 278 FloatRect(100, 100, 50, 200));
267 drawRect(context, unaffected, backgroundDrawingType, 279 drawRect(context, unaffected, backgroundDrawingType,
268 FloatRect(300, 300, 10, 10)); 280 FloatRect(300, 300, 10, 10));
269 drawRect(context, unaffected, foregroundDrawingType, 281 drawRect(context, unaffected, foregroundDrawingType,
270 FloatRect(300, 300, 10, 10)); 282 FloatRect(300, 300, 10, 10));
271 getPaintController().commitNewDisplayItems(); 283 getPaintController().commitNewDisplayItems();
272 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
273 getPaintController().updateCurrentPaintChunkProperties(
274 &m_rootPaintChunkId, PaintChunkProperties());
275 284
276 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 285 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
277 TestDisplayItem(first, backgroundDrawingType), 286 TestDisplayItem(first, backgroundDrawingType),
278 TestDisplayItem(first, foregroundDrawingType), 287 TestDisplayItem(first, foregroundDrawingType),
279 TestDisplayItem(second, backgroundDrawingType), 288 TestDisplayItem(second, backgroundDrawingType),
280 TestDisplayItem(second, foregroundDrawingType), 289 TestDisplayItem(second, foregroundDrawingType),
281 TestDisplayItem(unaffected, backgroundDrawingType), 290 TestDisplayItem(unaffected, backgroundDrawingType),
282 TestDisplayItem(unaffected, foregroundDrawingType)); 291 TestDisplayItem(unaffected, foregroundDrawingType));
283 292
293 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
294 getPaintController().updateCurrentPaintChunkProperties(
295 &m_rootPaintChunkId, rootPaintChunkProperties());
296 }
284 drawRect(context, second, backgroundDrawingType, 297 drawRect(context, second, backgroundDrawingType,
285 FloatRect(100, 100, 50, 200)); 298 FloatRect(100, 100, 50, 200));
286 drawRect(context, second, foregroundDrawingType, 299 drawRect(context, second, foregroundDrawingType,
287 FloatRect(100, 100, 50, 200)); 300 FloatRect(100, 100, 50, 200));
288 drawRect(context, first, backgroundDrawingType, 301 drawRect(context, first, backgroundDrawingType,
289 FloatRect(100, 100, 100, 100)); 302 FloatRect(100, 100, 100, 100));
290 drawRect(context, first, foregroundDrawingType, 303 drawRect(context, first, foregroundDrawingType,
291 FloatRect(100, 100, 100, 100)); 304 FloatRect(100, 100, 100, 100));
292 drawRect(context, unaffected, backgroundDrawingType, 305 drawRect(context, unaffected, backgroundDrawingType,
293 FloatRect(300, 300, 10, 10)); 306 FloatRect(300, 300, 10, 10));
(...skipping 23 matching lines...) Expand all
317 UnorderedElementsAre( 330 UnorderedElementsAre(
318 FloatRect(100, 100, 50, 200))); // Bounds of |second|. 331 FloatRect(100, 100, 50, 200))); // Bounds of |second|.
319 } 332 }
320 } 333 }
321 334
322 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) { 335 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) {
323 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 336 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
324 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 337 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
325 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); 338 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10));
326 GraphicsContext context(getPaintController()); 339 GraphicsContext context(getPaintController());
327 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 340 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
328 getPaintController().updateCurrentPaintChunkProperties( 341 getPaintController().updateCurrentPaintChunkProperties(
329 &m_rootPaintChunkId, PaintChunkProperties()); 342 &m_rootPaintChunkId, rootPaintChunkProperties());
343 }
330 344
331 drawRect(context, first, backgroundDrawingType, 345 drawRect(context, first, backgroundDrawingType,
332 FloatRect(100, 100, 100, 100)); 346 FloatRect(100, 100, 100, 100));
333 drawRect(context, first, foregroundDrawingType, 347 drawRect(context, first, foregroundDrawingType,
334 FloatRect(100, 100, 100, 100)); 348 FloatRect(100, 100, 100, 100));
335 drawRect(context, second, backgroundDrawingType, 349 drawRect(context, second, backgroundDrawingType,
336 FloatRect(100, 100, 50, 200)); 350 FloatRect(100, 100, 50, 200));
337 drawRect(context, second, foregroundDrawingType, 351 drawRect(context, second, foregroundDrawingType,
338 FloatRect(100, 100, 50, 200)); 352 FloatRect(100, 100, 50, 200));
339 drawRect(context, unaffected, backgroundDrawingType, 353 drawRect(context, unaffected, backgroundDrawingType,
340 FloatRect(300, 300, 10, 10)); 354 FloatRect(300, 300, 10, 10));
341 drawRect(context, unaffected, foregroundDrawingType, 355 drawRect(context, unaffected, foregroundDrawingType,
342 FloatRect(300, 300, 10, 10)); 356 FloatRect(300, 300, 10, 10));
343 getPaintController().commitNewDisplayItems(); 357 getPaintController().commitNewDisplayItems();
344 358
345 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 359 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
346 TestDisplayItem(first, backgroundDrawingType), 360 TestDisplayItem(first, backgroundDrawingType),
347 TestDisplayItem(first, foregroundDrawingType), 361 TestDisplayItem(first, foregroundDrawingType),
348 TestDisplayItem(second, backgroundDrawingType), 362 TestDisplayItem(second, backgroundDrawingType),
349 TestDisplayItem(second, foregroundDrawingType), 363 TestDisplayItem(second, foregroundDrawingType),
350 TestDisplayItem(unaffected, backgroundDrawingType), 364 TestDisplayItem(unaffected, backgroundDrawingType),
351 TestDisplayItem(unaffected, foregroundDrawingType)); 365 TestDisplayItem(unaffected, foregroundDrawingType));
352 366
353 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 367 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
354 getPaintController().updateCurrentPaintChunkProperties( 368 getPaintController().updateCurrentPaintChunkProperties(
355 &m_rootPaintChunkId, PaintChunkProperties()); 369 &m_rootPaintChunkId, rootPaintChunkProperties());
370 }
356 371
357 first.setDisplayItemsUncached(); 372 first.setDisplayItemsUncached();
358 drawRect(context, second, backgroundDrawingType, 373 drawRect(context, second, backgroundDrawingType,
359 FloatRect(100, 100, 50, 200)); 374 FloatRect(100, 100, 50, 200));
360 drawRect(context, second, foregroundDrawingType, 375 drawRect(context, second, foregroundDrawingType,
361 FloatRect(100, 100, 50, 200)); 376 FloatRect(100, 100, 50, 200));
362 drawRect(context, first, backgroundDrawingType, 377 drawRect(context, first, backgroundDrawingType,
363 FloatRect(100, 100, 100, 100)); 378 FloatRect(100, 100, 100, 100));
364 drawRect(context, first, foregroundDrawingType, 379 drawRect(context, first, foregroundDrawingType,
365 FloatRect(100, 100, 100, 100)); 380 FloatRect(100, 100, 100, 100));
(...skipping 28 matching lines...) Expand all
394 // No need to invalidate raster of |second|, because the client (|first|) 409 // No need to invalidate raster of |second|, because the client (|first|)
395 // which swapped order with it has been invalidated. 410 // which swapped order with it has been invalidated.
396 } 411 }
397 } 412 }
398 413
399 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) { 414 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) {
400 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 415 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
401 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 416 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
402 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); 417 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50));
403 GraphicsContext context(getPaintController()); 418 GraphicsContext context(getPaintController());
404 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 419 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
405 getPaintController().updateCurrentPaintChunkProperties( 420 getPaintController().updateCurrentPaintChunkProperties(
406 &m_rootPaintChunkId, PaintChunkProperties()); 421 &m_rootPaintChunkId, rootPaintChunkProperties());
422 }
407 423
408 drawRect(context, first, backgroundDrawingType, 424 drawRect(context, first, backgroundDrawingType,
409 FloatRect(100, 100, 100, 100)); 425 FloatRect(100, 100, 100, 100));
410 drawRect(context, second, backgroundDrawingType, 426 drawRect(context, second, backgroundDrawingType,
411 FloatRect(100, 100, 50, 200)); 427 FloatRect(100, 100, 50, 200));
412 getPaintController().commitNewDisplayItems(); 428 getPaintController().commitNewDisplayItems();
413 429
414 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 430 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
415 TestDisplayItem(first, backgroundDrawingType), 431 TestDisplayItem(first, backgroundDrawingType),
416 TestDisplayItem(second, backgroundDrawingType)); 432 TestDisplayItem(second, backgroundDrawingType));
417 433
418 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 434 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
419 getPaintController().updateCurrentPaintChunkProperties( 435 getPaintController().updateCurrentPaintChunkProperties(
420 &m_rootPaintChunkId, PaintChunkProperties()); 436 &m_rootPaintChunkId, rootPaintChunkProperties());
437 }
421 438
422 drawRect(context, first, backgroundDrawingType, 439 drawRect(context, first, backgroundDrawingType,
423 FloatRect(100, 100, 100, 100)); 440 FloatRect(100, 100, 100, 100));
424 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50)); 441 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50));
425 drawRect(context, second, backgroundDrawingType, 442 drawRect(context, second, backgroundDrawingType,
426 FloatRect(100, 100, 50, 200)); 443 FloatRect(100, 100, 50, 200));
427 444
428 EXPECT_EQ(2, numCachedNewItems()); 445 EXPECT_EQ(2, numCachedNewItems());
429 #ifndef NDEBUG 446 #ifndef NDEBUG
430 EXPECT_EQ(2, numSequentialMatches()); // first, second 447 EXPECT_EQ(2, numSequentialMatches()); // first, second
(...skipping 15 matching lines...) Expand all
446 UnorderedElementsAre(FloatRect( 463 UnorderedElementsAre(FloatRect(
447 125, 100, 200, 50))); // |third| newly appeared in the chunk. 464 125, 100, 200, 50))); // |third| newly appeared in the chunk.
448 } 465 }
449 } 466 }
450 467
451 TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) { 468 TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) {
452 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 469 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
453 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 470 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
454 FakeDisplayItemClient third("third", LayoutRect(300, 100, 50, 50)); 471 FakeDisplayItemClient third("third", LayoutRect(300, 100, 50, 50));
455 GraphicsContext context(getPaintController()); 472 GraphicsContext context(getPaintController());
456 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 473 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
457 getPaintController().updateCurrentPaintChunkProperties( 474 getPaintController().updateCurrentPaintChunkProperties(
458 &m_rootPaintChunkId, PaintChunkProperties()); 475 &m_rootPaintChunkId, rootPaintChunkProperties());
476 }
459 477
460 drawRect(context, first, backgroundDrawingType, 478 drawRect(context, first, backgroundDrawingType,
461 FloatRect(100, 100, 100, 100)); 479 FloatRect(100, 100, 100, 100));
462 drawRect(context, second, backgroundDrawingType, 480 drawRect(context, second, backgroundDrawingType,
463 FloatRect(100, 100, 50, 200)); 481 FloatRect(100, 100, 50, 200));
464 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)); 482 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50));
465 drawRect(context, first, foregroundDrawingType, 483 drawRect(context, first, foregroundDrawingType,
466 FloatRect(100, 100, 100, 100)); 484 FloatRect(100, 100, 100, 100));
467 drawRect(context, second, foregroundDrawingType, 485 drawRect(context, second, foregroundDrawingType,
468 FloatRect(100, 100, 50, 200)); 486 FloatRect(100, 100, 50, 200));
469 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)); 487 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50));
470 getPaintController().commitNewDisplayItems(); 488 getPaintController().commitNewDisplayItems();
471 489
472 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 490 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
473 TestDisplayItem(first, backgroundDrawingType), 491 TestDisplayItem(first, backgroundDrawingType),
474 TestDisplayItem(second, backgroundDrawingType), 492 TestDisplayItem(second, backgroundDrawingType),
475 TestDisplayItem(third, backgroundDrawingType), 493 TestDisplayItem(third, backgroundDrawingType),
476 TestDisplayItem(first, foregroundDrawingType), 494 TestDisplayItem(first, foregroundDrawingType),
477 TestDisplayItem(second, foregroundDrawingType), 495 TestDisplayItem(second, foregroundDrawingType),
478 TestDisplayItem(third, foregroundDrawingType)); 496 TestDisplayItem(third, foregroundDrawingType));
479 497
480 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 498 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
481 getPaintController().updateCurrentPaintChunkProperties( 499 getPaintController().updateCurrentPaintChunkProperties(
482 &m_rootPaintChunkId, PaintChunkProperties()); 500 &m_rootPaintChunkId, rootPaintChunkProperties());
501 }
483 502
484 second.setDisplayItemsUncached(); 503 second.setDisplayItemsUncached();
485 drawRect(context, first, backgroundDrawingType, 504 drawRect(context, first, backgroundDrawingType,
486 FloatRect(100, 100, 100, 100)); 505 FloatRect(100, 100, 100, 100));
487 drawRect(context, second, backgroundDrawingType, 506 drawRect(context, second, backgroundDrawingType,
488 FloatRect(100, 100, 50, 200)); 507 FloatRect(100, 100, 50, 200));
489 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)); 508 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50));
490 drawRect(context, first, foregroundDrawingType, 509 drawRect(context, first, foregroundDrawingType,
491 FloatRect(100, 100, 100, 100)); 510 FloatRect(100, 100, 100, 100));
492 drawRect(context, second, foregroundDrawingType, 511 drawRect(context, second, foregroundDrawingType,
(...skipping 23 matching lines...) Expand all
516 UnorderedElementsAre( 535 UnorderedElementsAre(
517 FloatRect(100, 100, 50, 200), // Old bounds of |second|. 536 FloatRect(100, 100, 50, 200), // Old bounds of |second|.
518 FloatRect(100, 100, 50, 200))); // New bounds of |second|. 537 FloatRect(100, 100, 50, 200))); // New bounds of |second|.
519 } 538 }
520 } 539 }
521 540
522 TEST_P(PaintControllerTest, UpdateAddFirstOverlap) { 541 TEST_P(PaintControllerTest, UpdateAddFirstOverlap) {
523 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); 542 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150));
524 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); 543 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50));
525 GraphicsContext context(getPaintController()); 544 GraphicsContext context(getPaintController());
526 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 545 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
527 getPaintController().updateCurrentPaintChunkProperties( 546 getPaintController().updateCurrentPaintChunkProperties(
528 &m_rootPaintChunkId, PaintChunkProperties()); 547 &m_rootPaintChunkId, rootPaintChunkProperties());
548 }
529 549
530 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)); 550 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50));
531 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)); 551 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50));
532 getPaintController().commitNewDisplayItems(); 552 getPaintController().commitNewDisplayItems();
533 553
534 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 554 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
535 TestDisplayItem(second, backgroundDrawingType), 555 TestDisplayItem(second, backgroundDrawingType),
536 TestDisplayItem(second, foregroundDrawingType)); 556 TestDisplayItem(second, foregroundDrawingType));
537 557
538 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 558 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
539 getPaintController().updateCurrentPaintChunkProperties( 559 getPaintController().updateCurrentPaintChunkProperties(
540 &m_rootPaintChunkId, PaintChunkProperties()); 560 &m_rootPaintChunkId, rootPaintChunkProperties());
561 }
541 562
542 first.setDisplayItemsUncached(); 563 first.setDisplayItemsUncached();
543 second.setDisplayItemsUncached(); 564 second.setDisplayItemsUncached();
544 second.setVisualRect(LayoutRect(150, 150, 100, 100)); 565 second.setVisualRect(LayoutRect(150, 150, 100, 100));
545 drawRect(context, first, backgroundDrawingType, 566 drawRect(context, first, backgroundDrawingType,
546 FloatRect(100, 100, 150, 150)); 567 FloatRect(100, 100, 150, 150));
547 drawRect(context, first, foregroundDrawingType, 568 drawRect(context, first, foregroundDrawingType,
548 FloatRect(100, 100, 150, 150)); 569 FloatRect(100, 100, 150, 150));
549 drawRect(context, second, backgroundDrawingType, 570 drawRect(context, second, backgroundDrawingType,
550 FloatRect(150, 150, 100, 100)); 571 FloatRect(150, 150, 100, 100));
(...skipping 11 matching lines...) Expand all
562 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 583 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
563 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 584 EXPECT_EQ(1u, getPaintController().paintChunks().size());
564 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 585 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
565 UnorderedElementsAre( 586 UnorderedElementsAre(
566 FloatRect(100, 100, 150, 587 FloatRect(100, 100, 150,
567 150), // |first| newly appeared in the chunk. 588 150), // |first| newly appeared in the chunk.
568 FloatRect(200, 200, 50, 50), // Old bounds of |second|. 589 FloatRect(200, 200, 50, 50), // Old bounds of |second|.
569 FloatRect(150, 150, 100, 100))); // New bounds of |second|. 590 FloatRect(150, 150, 100, 100))); // New bounds of |second|.
570 591
571 getPaintController().updateCurrentPaintChunkProperties( 592 getPaintController().updateCurrentPaintChunkProperties(
572 &m_rootPaintChunkId, PaintChunkProperties()); 593 &m_rootPaintChunkId, rootPaintChunkProperties());
573 } 594 }
574 595
575 drawRect(context, second, backgroundDrawingType, 596 drawRect(context, second, backgroundDrawingType,
576 FloatRect(150, 150, 100, 100)); 597 FloatRect(150, 150, 100, 100));
577 drawRect(context, second, foregroundDrawingType, 598 drawRect(context, second, foregroundDrawingType,
578 FloatRect(150, 150, 100, 100)); 599 FloatRect(150, 150, 100, 100));
579 600
580 EXPECT_EQ(2, numCachedNewItems()); 601 EXPECT_EQ(2, numCachedNewItems());
581 #ifndef NDEBUG 602 #ifndef NDEBUG
582 EXPECT_EQ(2, numSequentialMatches()); 603 EXPECT_EQ(2, numSequentialMatches());
(...skipping 13 matching lines...) Expand all
596 getPaintController().paintChunks()[0].rasterInvalidationRects, 617 getPaintController().paintChunks()[0].rasterInvalidationRects,
597 UnorderedElementsAre(FloatRect( 618 UnorderedElementsAre(FloatRect(
598 100, 100, 150, 150))); // |first| disappeared from the chunk. 619 100, 100, 150, 150))); // |first| disappeared from the chunk.
599 } 620 }
600 } 621 }
601 622
602 TEST_P(PaintControllerTest, UpdateAddLastOverlap) { 623 TEST_P(PaintControllerTest, UpdateAddLastOverlap) {
603 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); 624 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150));
604 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); 625 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50));
605 GraphicsContext context(getPaintController()); 626 GraphicsContext context(getPaintController());
606 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 627 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
607 getPaintController().updateCurrentPaintChunkProperties( 628 getPaintController().updateCurrentPaintChunkProperties(
608 &m_rootPaintChunkId, PaintChunkProperties()); 629 &m_rootPaintChunkId, rootPaintChunkProperties());
630 }
609 631
610 drawRect(context, first, backgroundDrawingType, 632 drawRect(context, first, backgroundDrawingType,
611 FloatRect(100, 100, 150, 150)); 633 FloatRect(100, 100, 150, 150));
612 drawRect(context, first, foregroundDrawingType, 634 drawRect(context, first, foregroundDrawingType,
613 FloatRect(100, 100, 150, 150)); 635 FloatRect(100, 100, 150, 150));
614 getPaintController().commitNewDisplayItems(); 636 getPaintController().commitNewDisplayItems();
615 637
616 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 638 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
617 TestDisplayItem(first, backgroundDrawingType), 639 TestDisplayItem(first, backgroundDrawingType),
618 TestDisplayItem(first, foregroundDrawingType)); 640 TestDisplayItem(first, foregroundDrawingType));
619 641
620 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 642 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
621 getPaintController().updateCurrentPaintChunkProperties( 643 getPaintController().updateCurrentPaintChunkProperties(
622 &m_rootPaintChunkId, PaintChunkProperties()); 644 &m_rootPaintChunkId, rootPaintChunkProperties());
645 }
623 646
624 first.setDisplayItemsUncached(); 647 first.setDisplayItemsUncached();
625 first.setVisualRect(LayoutRect(150, 150, 100, 100)); 648 first.setVisualRect(LayoutRect(150, 150, 100, 100));
626 second.setDisplayItemsUncached(); 649 second.setDisplayItemsUncached();
627 drawRect(context, first, backgroundDrawingType, 650 drawRect(context, first, backgroundDrawingType,
628 FloatRect(150, 150, 100, 100)); 651 FloatRect(150, 150, 100, 100));
629 drawRect(context, first, foregroundDrawingType, 652 drawRect(context, first, foregroundDrawingType,
630 FloatRect(150, 150, 100, 100)); 653 FloatRect(150, 150, 100, 100));
631 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)); 654 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50));
632 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)); 655 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50));
633 EXPECT_EQ(0, numCachedNewItems()); 656 EXPECT_EQ(0, numCachedNewItems());
634 getPaintController().commitNewDisplayItems(); 657 getPaintController().commitNewDisplayItems();
635 658
636 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, 659 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4,
637 TestDisplayItem(first, backgroundDrawingType), 660 TestDisplayItem(first, backgroundDrawingType),
638 TestDisplayItem(first, foregroundDrawingType), 661 TestDisplayItem(first, foregroundDrawingType),
639 TestDisplayItem(second, backgroundDrawingType), 662 TestDisplayItem(second, backgroundDrawingType),
640 TestDisplayItem(second, foregroundDrawingType)); 663 TestDisplayItem(second, foregroundDrawingType));
641 664
642 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 665 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
643 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 666 EXPECT_EQ(1u, getPaintController().paintChunks().size());
644 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 667 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
645 UnorderedElementsAre( 668 UnorderedElementsAre(
646 FloatRect(100, 100, 150, 150), // Old bounds of |first|. 669 FloatRect(100, 100, 150, 150), // Old bounds of |first|.
647 FloatRect(150, 150, 100, 100), // New bounds of |first|. 670 FloatRect(150, 150, 100, 100), // New bounds of |first|.
648 FloatRect(200, 200, 50, 671 FloatRect(200, 200, 50,
649 50))); // |second| newly appeared in the chunk. 672 50))); // |second| newly appeared in the chunk.
650 673
651 getPaintController().updateCurrentPaintChunkProperties( 674 getPaintController().updateCurrentPaintChunkProperties(
652 &m_rootPaintChunkId, PaintChunkProperties()); 675 &m_rootPaintChunkId, rootPaintChunkProperties());
653 } 676 }
654 677
655 first.setDisplayItemsUncached(); 678 first.setDisplayItemsUncached();
656 first.setVisualRect(LayoutRect(100, 100, 150, 150)); 679 first.setVisualRect(LayoutRect(100, 100, 150, 150));
657 second.setDisplayItemsUncached(); 680 second.setDisplayItemsUncached();
658 drawRect(context, first, backgroundDrawingType, 681 drawRect(context, first, backgroundDrawingType,
659 FloatRect(100, 100, 150, 150)); 682 FloatRect(100, 100, 150, 150));
660 drawRect(context, first, foregroundDrawingType, 683 drawRect(context, first, foregroundDrawingType,
661 FloatRect(100, 100, 150, 150)); 684 FloatRect(100, 100, 150, 150));
662 EXPECT_EQ(0, numCachedNewItems()); 685 EXPECT_EQ(0, numCachedNewItems());
(...skipping 15 matching lines...) Expand all
678 } 701 }
679 702
680 TEST_P(PaintControllerTest, UpdateClip) { 703 TEST_P(PaintControllerTest, UpdateClip) {
681 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); 704 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150));
682 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); 705 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200));
683 GraphicsContext context(getPaintController()); 706 GraphicsContext context(getPaintController());
684 707
685 { 708 {
686 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 709 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
687 PaintChunk::Id id(first, clipType); 710 PaintChunk::Id id(first, clipType);
688 PaintChunkProperties properties; 711 PaintChunkProperties properties = rootPaintChunkProperties();
689 properties.clip = ClipPaintPropertyNode::create( 712 properties.clip = ClipPaintPropertyNode::create(
690 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); 713 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2));
691 getPaintController().updateCurrentPaintChunkProperties(&id, properties); 714 getPaintController().updateCurrentPaintChunkProperties(&id, properties);
692 } 715 }
693 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)); 716 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2));
694 drawRect(context, first, backgroundDrawingType, 717 drawRect(context, first, backgroundDrawingType,
695 FloatRect(100, 100, 150, 150)); 718 FloatRect(100, 100, 150, 150));
696 drawRect(context, second, backgroundDrawingType, 719 drawRect(context, second, backgroundDrawingType,
697 FloatRect(100, 100, 200, 200)); 720 FloatRect(100, 100, 200, 200));
698 } 721 }
699 getPaintController().commitNewDisplayItems(); 722 getPaintController().commitNewDisplayItems();
700 723
701 EXPECT_DISPLAY_LIST( 724 EXPECT_DISPLAY_LIST(
702 getPaintController().getDisplayItemList(), 4, 725 getPaintController().getDisplayItemList(), 4,
703 TestDisplayItem(first, clipType), 726 TestDisplayItem(first, clipType),
704 TestDisplayItem(first, backgroundDrawingType), 727 TestDisplayItem(first, backgroundDrawingType),
705 TestDisplayItem(second, backgroundDrawingType), 728 TestDisplayItem(second, backgroundDrawingType),
706 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); 729 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType)));
707 730
708 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 731 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
709 getPaintController().updateCurrentPaintChunkProperties( 732 getPaintController().updateCurrentPaintChunkProperties(
710 &m_rootPaintChunkId, PaintChunkProperties()); 733 &m_rootPaintChunkId, rootPaintChunkProperties());
734 }
711 735
712 first.setDisplayItemsUncached(); 736 first.setDisplayItemsUncached();
713 drawRect(context, first, backgroundDrawingType, 737 drawRect(context, first, backgroundDrawingType,
714 FloatRect(100, 100, 150, 150)); 738 FloatRect(100, 100, 150, 150));
715 drawRect(context, second, backgroundDrawingType, 739 drawRect(context, second, backgroundDrawingType,
716 FloatRect(100, 100, 200, 200)); 740 FloatRect(100, 100, 200, 200));
717 741
718 EXPECT_EQ(1, numCachedNewItems()); 742 EXPECT_EQ(1, numCachedNewItems());
719 #ifndef NDEBUG 743 #ifndef NDEBUG
720 EXPECT_EQ(1, numSequentialMatches()); 744 EXPECT_EQ(1, numSequentialMatches());
721 EXPECT_EQ(0, numOutOfOrderMatches()); 745 EXPECT_EQ(0, numOutOfOrderMatches());
722 EXPECT_EQ(1, numIndexedItems()); 746 EXPECT_EQ(1, numIndexedItems());
723 #endif 747 #endif
724 748
725 getPaintController().commitNewDisplayItems(); 749 getPaintController().commitNewDisplayItems();
726 750
727 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 751 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
728 TestDisplayItem(first, backgroundDrawingType), 752 TestDisplayItem(first, backgroundDrawingType),
729 TestDisplayItem(second, backgroundDrawingType)); 753 TestDisplayItem(second, backgroundDrawingType));
730 754
731 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 755 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
732 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 756 EXPECT_EQ(1u, getPaintController().paintChunks().size());
733 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 757 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
734 UnorderedElementsAre(FloatRect( 758 UnorderedElementsAre(FloatRect(
735 LayoutRect::infiniteIntRect()))); // This is a new chunk. 759 LayoutRect::infiniteIntRect()))); // This is a new chunk.
736 760
737 getPaintController().updateCurrentPaintChunkProperties( 761 getPaintController().updateCurrentPaintChunkProperties(
738 &m_rootPaintChunkId, PaintChunkProperties()); 762 &m_rootPaintChunkId, rootPaintChunkProperties());
739 } 763 }
740 764
741 second.setDisplayItemsUncached(); 765 second.setDisplayItemsUncached();
742 drawRect(context, first, backgroundDrawingType, 766 drawRect(context, first, backgroundDrawingType,
743 FloatRect(100, 100, 150, 150)); 767 FloatRect(100, 100, 150, 150));
744 { 768 {
745 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 769 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
746 PaintChunk::Id id(second, clipType); 770 PaintChunk::Id id(second, clipType);
747 PaintChunkProperties properties; 771 PaintChunkProperties properties = rootPaintChunkProperties();
748 properties.clip = ClipPaintPropertyNode::create( 772 properties.clip = ClipPaintPropertyNode::create(
749 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); 773 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2));
750 getPaintController().updateCurrentPaintChunkProperties(&id, properties); 774 getPaintController().updateCurrentPaintChunkProperties(&id, properties);
751 } 775 }
752 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)); 776 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2));
753 drawRect(context, second, backgroundDrawingType, 777 drawRect(context, second, backgroundDrawingType,
754 FloatRect(100, 100, 200, 200)); 778 FloatRect(100, 100, 200, 200));
755 } 779 }
756 getPaintController().commitNewDisplayItems(); 780 getPaintController().commitNewDisplayItems();
757 781
(...skipping 13 matching lines...) Expand all
771 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRects, 795 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRects,
772 UnorderedElementsAre(FloatRect( 796 UnorderedElementsAre(FloatRect(
773 LayoutRect::infiniteIntRect()))); // This is a new chunk. 797 LayoutRect::infiniteIntRect()))); // This is a new chunk.
774 } 798 }
775 } 799 }
776 800
777 TEST_P(PaintControllerTest, CachedDisplayItems) { 801 TEST_P(PaintControllerTest, CachedDisplayItems) {
778 FakeDisplayItemClient first("first"); 802 FakeDisplayItemClient first("first");
779 FakeDisplayItemClient second("second"); 803 FakeDisplayItemClient second("second");
780 GraphicsContext context(getPaintController()); 804 GraphicsContext context(getPaintController());
805 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
806 getPaintController().updateCurrentPaintChunkProperties(
807 &m_rootPaintChunkId, rootPaintChunkProperties());
808 }
781 809
782 drawRect(context, first, backgroundDrawingType, 810 drawRect(context, first, backgroundDrawingType,
783 FloatRect(100, 100, 150, 150)); 811 FloatRect(100, 100, 150, 150));
784 drawRect(context, second, backgroundDrawingType, 812 drawRect(context, second, backgroundDrawingType,
785 FloatRect(100, 100, 150, 150)); 813 FloatRect(100, 100, 150, 150));
786 getPaintController().commitNewDisplayItems(); 814 getPaintController().commitNewDisplayItems();
787 815
788 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 816 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
789 TestDisplayItem(first, backgroundDrawingType), 817 TestDisplayItem(first, backgroundDrawingType),
790 TestDisplayItem(second, backgroundDrawingType)); 818 TestDisplayItem(second, backgroundDrawingType));
791 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); 819 EXPECT_TRUE(getPaintController().clientCacheIsValid(first));
792 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); 820 EXPECT_TRUE(getPaintController().clientCacheIsValid(second));
793 const SkPicture* firstPicture = 821 const SkPicture* firstPicture =
794 static_cast<const DrawingDisplayItem&>( 822 static_cast<const DrawingDisplayItem&>(
795 getPaintController().getDisplayItemList()[0]) 823 getPaintController().getDisplayItemList()[0])
796 .picture(); 824 .picture();
797 const SkPicture* secondPicture = 825 const SkPicture* secondPicture =
798 static_cast<const DrawingDisplayItem&>( 826 static_cast<const DrawingDisplayItem&>(
799 getPaintController().getDisplayItemList()[1]) 827 getPaintController().getDisplayItemList()[1])
800 .picture(); 828 .picture();
801 829
802 first.setDisplayItemsUncached(); 830 first.setDisplayItemsUncached();
803 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); 831 EXPECT_FALSE(getPaintController().clientCacheIsValid(first));
804 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); 832 EXPECT_TRUE(getPaintController().clientCacheIsValid(second));
805 833
834 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
835 getPaintController().updateCurrentPaintChunkProperties(
836 &m_rootPaintChunkId, rootPaintChunkProperties());
837 }
806 drawRect(context, first, backgroundDrawingType, 838 drawRect(context, first, backgroundDrawingType,
807 FloatRect(100, 100, 150, 150)); 839 FloatRect(100, 100, 150, 150));
808 drawRect(context, second, backgroundDrawingType, 840 drawRect(context, second, backgroundDrawingType,
809 FloatRect(100, 100, 150, 150)); 841 FloatRect(100, 100, 150, 150));
810 getPaintController().commitNewDisplayItems(); 842 getPaintController().commitNewDisplayItems();
811 843
812 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 844 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
813 TestDisplayItem(first, backgroundDrawingType), 845 TestDisplayItem(first, backgroundDrawingType),
814 TestDisplayItem(second, backgroundDrawingType)); 846 TestDisplayItem(second, backgroundDrawingType));
815 // The first display item should be updated. 847 // The first display item should be updated.
(...skipping 14 matching lines...) Expand all
830 } 862 }
831 863
832 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) { 864 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) {
833 FakeDisplayItemClient container1("container1", 865 FakeDisplayItemClient container1("container1",
834 LayoutRect(100, 100, 100, 100)); 866 LayoutRect(100, 100, 100, 100));
835 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 867 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
836 FakeDisplayItemClient container2("container2", 868 FakeDisplayItemClient container2("container2",
837 LayoutRect(100, 200, 100, 100)); 869 LayoutRect(100, 200, 100, 100));
838 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 870 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
839 GraphicsContext context(getPaintController()); 871 GraphicsContext context(getPaintController());
840 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 872 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
841 getPaintController().updateCurrentPaintChunkProperties( 873 getPaintController().updateCurrentPaintChunkProperties(
842 &m_rootPaintChunkId, PaintChunkProperties()); 874 &m_rootPaintChunkId, rootPaintChunkProperties());
875 }
843 876
844 drawRect(context, container1, backgroundDrawingType, 877 drawRect(context, container1, backgroundDrawingType,
845 FloatRect(100, 100, 100, 100)); 878 FloatRect(100, 100, 100, 100));
846 drawRect(context, content1, backgroundDrawingType, 879 drawRect(context, content1, backgroundDrawingType,
847 FloatRect(100, 100, 50, 200)); 880 FloatRect(100, 100, 50, 200));
848 drawRect(context, content1, foregroundDrawingType, 881 drawRect(context, content1, foregroundDrawingType,
849 FloatRect(100, 100, 50, 200)); 882 FloatRect(100, 100, 50, 200));
850 drawRect(context, container1, foregroundDrawingType, 883 drawRect(context, container1, foregroundDrawingType,
851 FloatRect(100, 100, 100, 100)); 884 FloatRect(100, 100, 100, 100));
852 drawRect(context, container2, backgroundDrawingType, 885 drawRect(context, container2, backgroundDrawingType,
853 FloatRect(100, 200, 100, 100)); 886 FloatRect(100, 200, 100, 100));
854 drawRect(context, content2, backgroundDrawingType, 887 drawRect(context, content2, backgroundDrawingType,
855 FloatRect(100, 200, 50, 200)); 888 FloatRect(100, 200, 50, 200));
856 drawRect(context, content2, foregroundDrawingType, 889 drawRect(context, content2, foregroundDrawingType,
857 FloatRect(100, 200, 50, 200)); 890 FloatRect(100, 200, 50, 200));
858 drawRect(context, container2, foregroundDrawingType, 891 drawRect(context, container2, foregroundDrawingType,
859 FloatRect(100, 200, 100, 100)); 892 FloatRect(100, 200, 100, 100));
860 getPaintController().commitNewDisplayItems(); 893 getPaintController().commitNewDisplayItems();
861 894
862 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, 895 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8,
863 TestDisplayItem(container1, backgroundDrawingType), 896 TestDisplayItem(container1, backgroundDrawingType),
864 TestDisplayItem(content1, backgroundDrawingType), 897 TestDisplayItem(content1, backgroundDrawingType),
865 TestDisplayItem(content1, foregroundDrawingType), 898 TestDisplayItem(content1, foregroundDrawingType),
866 TestDisplayItem(container1, foregroundDrawingType), 899 TestDisplayItem(container1, foregroundDrawingType),
867 TestDisplayItem(container2, backgroundDrawingType), 900 TestDisplayItem(container2, backgroundDrawingType),
868 TestDisplayItem(content2, backgroundDrawingType), 901 TestDisplayItem(content2, backgroundDrawingType),
869 TestDisplayItem(content2, foregroundDrawingType), 902 TestDisplayItem(content2, foregroundDrawingType),
870 TestDisplayItem(container2, foregroundDrawingType)); 903 TestDisplayItem(container2, foregroundDrawingType));
871 904
872 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 905 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
873 getPaintController().updateCurrentPaintChunkProperties( 906 getPaintController().updateCurrentPaintChunkProperties(
874 &m_rootPaintChunkId, PaintChunkProperties()); 907 &m_rootPaintChunkId, rootPaintChunkProperties());
908 }
875 909
876 // Simulate the situation when |container1| gets a z-index that is greater 910 // Simulate the situation when |container1| gets a z-index that is greater
877 // than that of |container2|. 911 // than that of |container2|.
878 drawRect(context, container2, backgroundDrawingType, 912 drawRect(context, container2, backgroundDrawingType,
879 FloatRect(100, 200, 100, 100)); 913 FloatRect(100, 200, 100, 100));
880 drawRect(context, content2, backgroundDrawingType, 914 drawRect(context, content2, backgroundDrawingType,
881 FloatRect(100, 200, 50, 200)); 915 FloatRect(100, 200, 50, 200));
882 drawRect(context, content2, foregroundDrawingType, 916 drawRect(context, content2, foregroundDrawingType,
883 FloatRect(100, 200, 50, 200)); 917 FloatRect(100, 200, 50, 200));
884 drawRect(context, container2, foregroundDrawingType, 918 drawRect(context, container2, foregroundDrawingType,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 } 950 }
917 951
918 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) { 952 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) {
919 FakeDisplayItemClient container1("container1", 953 FakeDisplayItemClient container1("container1",
920 LayoutRect(100, 100, 100, 100)); 954 LayoutRect(100, 100, 100, 100));
921 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 955 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
922 FakeDisplayItemClient container2("container2", 956 FakeDisplayItemClient container2("container2",
923 LayoutRect(100, 200, 100, 100)); 957 LayoutRect(100, 200, 100, 100));
924 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 958 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
925 GraphicsContext context(getPaintController()); 959 GraphicsContext context(getPaintController());
926 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 960 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
927 getPaintController().updateCurrentPaintChunkProperties( 961 getPaintController().updateCurrentPaintChunkProperties(
928 &m_rootPaintChunkId, PaintChunkProperties()); 962 &m_rootPaintChunkId, rootPaintChunkProperties());
963 }
929 964
930 drawRect(context, container1, backgroundDrawingType, 965 drawRect(context, container1, backgroundDrawingType,
931 FloatRect(100, 100, 100, 100)); 966 FloatRect(100, 100, 100, 100));
932 drawRect(context, content1, backgroundDrawingType, 967 drawRect(context, content1, backgroundDrawingType,
933 FloatRect(100, 100, 50, 200)); 968 FloatRect(100, 100, 50, 200));
934 drawRect(context, content1, foregroundDrawingType, 969 drawRect(context, content1, foregroundDrawingType,
935 FloatRect(100, 100, 50, 200)); 970 FloatRect(100, 100, 50, 200));
936 drawRect(context, container1, foregroundDrawingType, 971 drawRect(context, container1, foregroundDrawingType,
937 FloatRect(100, 100, 100, 100)); 972 FloatRect(100, 100, 100, 100));
938 drawRect(context, container2, backgroundDrawingType, 973 drawRect(context, container2, backgroundDrawingType,
939 FloatRect(100, 200, 100, 100)); 974 FloatRect(100, 200, 100, 100));
940 drawRect(context, content2, backgroundDrawingType, 975 drawRect(context, content2, backgroundDrawingType,
941 FloatRect(100, 200, 50, 200)); 976 FloatRect(100, 200, 50, 200));
942 drawRect(context, content2, foregroundDrawingType, 977 drawRect(context, content2, foregroundDrawingType,
943 FloatRect(100, 200, 50, 200)); 978 FloatRect(100, 200, 50, 200));
944 drawRect(context, container2, foregroundDrawingType, 979 drawRect(context, container2, foregroundDrawingType,
945 FloatRect(100, 200, 100, 100)); 980 FloatRect(100, 200, 100, 100));
946 getPaintController().commitNewDisplayItems(); 981 getPaintController().commitNewDisplayItems();
947 982
948 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, 983 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8,
949 TestDisplayItem(container1, backgroundDrawingType), 984 TestDisplayItem(container1, backgroundDrawingType),
950 TestDisplayItem(content1, backgroundDrawingType), 985 TestDisplayItem(content1, backgroundDrawingType),
951 TestDisplayItem(content1, foregroundDrawingType), 986 TestDisplayItem(content1, foregroundDrawingType),
952 TestDisplayItem(container1, foregroundDrawingType), 987 TestDisplayItem(container1, foregroundDrawingType),
953 TestDisplayItem(container2, backgroundDrawingType), 988 TestDisplayItem(container2, backgroundDrawingType),
954 TestDisplayItem(content2, backgroundDrawingType), 989 TestDisplayItem(content2, backgroundDrawingType),
955 TestDisplayItem(content2, foregroundDrawingType), 990 TestDisplayItem(content2, foregroundDrawingType),
956 TestDisplayItem(container2, foregroundDrawingType)); 991 TestDisplayItem(container2, foregroundDrawingType));
957 992
958 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 993 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
959 getPaintController().updateCurrentPaintChunkProperties( 994 getPaintController().updateCurrentPaintChunkProperties(
960 &m_rootPaintChunkId, PaintChunkProperties()); 995 &m_rootPaintChunkId, rootPaintChunkProperties());
996 }
961 997
962 // Simulate the situation when |container1| gets a z-index that is greater 998 // Simulate the situation when |container1| gets a z-index that is greater
963 // than that of |container2|, and |container1| is invalidated. 999 // than that of |container2|, and |container1| is invalidated.
964 container1.setDisplayItemsUncached(); 1000 container1.setDisplayItemsUncached();
965 drawRect(context, container2, backgroundDrawingType, 1001 drawRect(context, container2, backgroundDrawingType,
966 FloatRect(100, 200, 100, 100)); 1002 FloatRect(100, 200, 100, 100));
967 drawRect(context, content2, backgroundDrawingType, 1003 drawRect(context, content2, backgroundDrawingType,
968 FloatRect(100, 200, 50, 200)); 1004 FloatRect(100, 200, 50, 200));
969 drawRect(context, content2, foregroundDrawingType, 1005 drawRect(context, content2, foregroundDrawingType,
970 FloatRect(100, 200, 50, 200)); 1006 FloatRect(100, 200, 50, 200));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 1042
1007 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { 1043 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) {
1008 FakeDisplayItemClient container1("container1", 1044 FakeDisplayItemClient container1("container1",
1009 LayoutRect(100, 100, 100, 100)); 1045 LayoutRect(100, 100, 100, 100));
1010 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 1046 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
1011 FakeDisplayItemClient container2("container2", 1047 FakeDisplayItemClient container2("container2",
1012 LayoutRect(100, 200, 100, 100)); 1048 LayoutRect(100, 200, 100, 100));
1013 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1049 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1014 GraphicsContext context(getPaintController()); 1050 GraphicsContext context(getPaintController());
1015 1051
1016 PaintChunkProperties container1Properties; 1052 PaintChunkProperties container1Properties = rootPaintChunkProperties();
1017 PaintChunkProperties container2Properties; 1053 PaintChunkProperties container2Properties = rootPaintChunkProperties();
1018 1054
1019 { 1055 {
1020 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1056 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1021 PaintChunk::Id id(container1, backgroundDrawingType); 1057 PaintChunk::Id id(container1, backgroundDrawingType);
1022 container1Properties.effect = EffectPaintPropertyNode::create( 1058 container1Properties.effect = EffectPaintPropertyNode::create(
1023 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 1059 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
1024 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); 1060 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
1025 getPaintController().updateCurrentPaintChunkProperties( 1061 getPaintController().updateCurrentPaintChunkProperties(
1026 &id, container1Properties); 1062 &id, container1Properties);
1027 } 1063 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1214
1179 TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { 1215 TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) {
1180 FakeDisplayItemClient container1("container1", 1216 FakeDisplayItemClient container1("container1",
1181 LayoutRect(100, 100, 100, 100)); 1217 LayoutRect(100, 100, 100, 100));
1182 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 1218 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
1183 FakeDisplayItemClient container2("container2", 1219 FakeDisplayItemClient container2("container2",
1184 LayoutRect(100, 200, 100, 100)); 1220 LayoutRect(100, 200, 100, 100));
1185 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1221 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1186 GraphicsContext context(getPaintController()); 1222 GraphicsContext context(getPaintController());
1187 1223
1188 PaintChunkProperties container1Properties; 1224 PaintChunkProperties container1Properties = rootPaintChunkProperties();
1189 PaintChunkProperties container2Properties; 1225 PaintChunkProperties container2Properties = rootPaintChunkProperties();
1190 1226
1191 { 1227 {
1192 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1228 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1193 PaintChunk::Id id(container1, backgroundDrawingType); 1229 PaintChunk::Id id(container1, backgroundDrawingType);
1194 container1Properties.effect = EffectPaintPropertyNode::create( 1230 container1Properties.effect = EffectPaintPropertyNode::create(
1195 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 1231 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
1196 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); 1232 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
1197 getPaintController().updateCurrentPaintChunkProperties( 1233 getPaintController().updateCurrentPaintChunkProperties(
1198 &id, container1Properties); 1234 &id, container1Properties);
1199 } 1235 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 GraphicsContext context(getPaintController()); 1326 GraphicsContext context(getPaintController());
1291 1327
1292 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst; 1328 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst;
1293 const DisplayItem::Type type2 = 1329 const DisplayItem::Type type2 =
1294 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 1); 1330 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 1);
1295 const DisplayItem::Type type3 = 1331 const DisplayItem::Type type3 =
1296 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 2); 1332 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 2);
1297 const DisplayItem::Type type4 = 1333 const DisplayItem::Type type4 =
1298 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 3); 1334 static_cast<DisplayItem::Type>(DisplayItem::kDrawingFirst + 3);
1299 1335
1336 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1337 getPaintController().updateCurrentPaintChunkProperties(
1338 &m_rootPaintChunkId, rootPaintChunkProperties());
1339 }
1300 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 1340 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
1301 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 1341 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
1302 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 1342 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
1303 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 1343 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
1304 1344
1305 getPaintController().commitNewDisplayItems(); 1345 getPaintController().commitNewDisplayItems();
1306 1346
1347 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1348 getPaintController().updateCurrentPaintChunkProperties(
1349 &m_rootPaintChunkId, rootPaintChunkProperties());
1350 }
1307 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 1351 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
1308 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 1352 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
1309 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 1353 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
1310 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 1354 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
1311 1355
1312 getPaintController().commitNewDisplayItems(); 1356 getPaintController().commitNewDisplayItems();
1313 } 1357 }
1314 1358
1315 TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { 1359 TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
1316 FakeDisplayItemClient container1("container1", 1360 FakeDisplayItemClient container1("container1",
1317 LayoutRect(100, 100, 100, 100)); 1361 LayoutRect(100, 100, 100, 100));
1318 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 1362 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
1319 FakeDisplayItemClient container2("container2", 1363 FakeDisplayItemClient container2("container2",
1320 LayoutRect(100, 200, 100, 100)); 1364 LayoutRect(100, 200, 100, 100));
1321 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1365 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1322 GraphicsContext context(getPaintController()); 1366 GraphicsContext context(getPaintController());
1323 1367
1324 PaintChunkProperties container1BackgroundProperties; 1368 PaintChunkProperties container1BackgroundProperties =
1325 PaintChunkProperties content1Properties; 1369 rootPaintChunkProperties();
1326 PaintChunkProperties container1ForegroundProperties; 1370 PaintChunkProperties content1Properties = rootPaintChunkProperties();
1327 PaintChunkProperties container2BackgroundProperties; 1371 PaintChunkProperties container1ForegroundProperties =
1328 PaintChunkProperties content2Properties; 1372 rootPaintChunkProperties();
1373 PaintChunkProperties container2BackgroundProperties =
1374 rootPaintChunkProperties();
1375 PaintChunkProperties content2Properties = rootPaintChunkProperties();
1329 1376
1330 { 1377 {
1331 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1378 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1332 PaintChunk::Id id(container1, backgroundDrawingType); 1379 PaintChunk::Id id(container1, backgroundDrawingType);
1333 container1BackgroundProperties.effect = EffectPaintPropertyNode::create( 1380 container1BackgroundProperties.effect = EffectPaintPropertyNode::create(
1334 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 1381 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
1335 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); 1382 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
1336 getPaintController().updateCurrentPaintChunkProperties( 1383 getPaintController().updateCurrentPaintChunkProperties(
1337 &id, container1BackgroundProperties); 1384 &id, container1BackgroundProperties);
1338 } 1385 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 1587
1541 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 1588 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
1542 DisplayItemClient::endShouldKeepAliveAllClients(); 1589 DisplayItemClient::endShouldKeepAliveAllClients();
1543 #endif 1590 #endif
1544 } 1591 }
1545 1592
1546 TEST_P(PaintControllerTest, SkipCache) { 1593 TEST_P(PaintControllerTest, SkipCache) {
1547 FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200)); 1594 FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200));
1548 FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100)); 1595 FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100));
1549 GraphicsContext context(getPaintController()); 1596 GraphicsContext context(getPaintController());
1550 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 1597 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1551 getPaintController().updateCurrentPaintChunkProperties( 1598 getPaintController().updateCurrentPaintChunkProperties(
1552 &m_rootPaintChunkId, PaintChunkProperties()); 1599 &m_rootPaintChunkId, rootPaintChunkProperties());
1600 }
1553 1601
1554 FloatRect rect1(100, 100, 50, 50); 1602 FloatRect rect1(100, 100, 50, 50);
1555 FloatRect rect2(150, 100, 50, 50); 1603 FloatRect rect2(150, 100, 50, 50);
1556 FloatRect rect3(200, 100, 50, 50); 1604 FloatRect rect3(200, 100, 50, 50);
1557 1605
1558 drawRect(context, multicol, backgroundDrawingType, 1606 drawRect(context, multicol, backgroundDrawingType,
1559 FloatRect(100, 200, 100, 100)); 1607 FloatRect(100, 200, 100, 100));
1560 1608
1561 getPaintController().beginSkippingCache(); 1609 getPaintController().beginSkippingCache();
1562 drawRect(context, content, foregroundDrawingType, rect1); 1610 drawRect(context, content, foregroundDrawingType, rect1);
(...skipping 15 matching lines...) Expand all
1578 getPaintController().getDisplayItemList()[2]) 1626 getPaintController().getDisplayItemList()[2])
1579 .picture()); 1627 .picture());
1580 EXPECT_NE(picture1, picture2); 1628 EXPECT_NE(picture1, picture2);
1581 1629
1582 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1630 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1583 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1631 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1584 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 1632 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
1585 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 1633 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
1586 1634
1587 getPaintController().updateCurrentPaintChunkProperties( 1635 getPaintController().updateCurrentPaintChunkProperties(
1588 &m_rootPaintChunkId, PaintChunkProperties()); 1636 &m_rootPaintChunkId, rootPaintChunkProperties());
1589 } 1637 }
1590 1638
1591 // Draw again with nothing invalidated. 1639 // Draw again with nothing invalidated.
1592 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); 1640 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol));
1593 drawRect(context, multicol, backgroundDrawingType, 1641 drawRect(context, multicol, backgroundDrawingType,
1594 FloatRect(100, 200, 100, 100)); 1642 FloatRect(100, 200, 100, 100));
1595 1643
1596 getPaintController().beginSkippingCache(); 1644 getPaintController().beginSkippingCache();
1597 drawRect(context, content, foregroundDrawingType, rect1); 1645 drawRect(context, content, foregroundDrawingType, rect1);
1598 drawRect(context, content, foregroundDrawingType, rect2); 1646 drawRect(context, content, foregroundDrawingType, rect2);
(...skipping 21 matching lines...) Expand all
1620 1668
1621 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1669 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1622 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1670 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1623 EXPECT_THAT( 1671 EXPECT_THAT(
1624 getPaintController().paintChunks()[0].rasterInvalidationRects, 1672 getPaintController().paintChunks()[0].rasterInvalidationRects,
1625 UnorderedElementsAre( 1673 UnorderedElementsAre(
1626 FloatRect(100, 100, 100, 100), // Old bounds of |content|. 1674 FloatRect(100, 100, 100, 100), // Old bounds of |content|.
1627 FloatRect(100, 100, 100, 100))); // New bounds of |content|. 1675 FloatRect(100, 100, 100, 100))); // New bounds of |content|.
1628 1676
1629 getPaintController().updateCurrentPaintChunkProperties( 1677 getPaintController().updateCurrentPaintChunkProperties(
1630 &m_rootPaintChunkId, PaintChunkProperties()); 1678 &m_rootPaintChunkId, rootPaintChunkProperties());
1631 } 1679 }
1632 1680
1633 // Now the multicol becomes 3 columns and repaints. 1681 // Now the multicol becomes 3 columns and repaints.
1634 multicol.setDisplayItemsUncached(); 1682 multicol.setDisplayItemsUncached();
1635 drawRect(context, multicol, backgroundDrawingType, 1683 drawRect(context, multicol, backgroundDrawingType,
1636 FloatRect(100, 100, 100, 100)); 1684 FloatRect(100, 100, 100, 100));
1637 1685
1638 getPaintController().beginSkippingCache(); 1686 getPaintController().beginSkippingCache();
1639 drawRect(context, content, foregroundDrawingType, rect1); 1687 drawRect(context, content, foregroundDrawingType, rect1);
1640 drawRect(context, content, foregroundDrawingType, rect2); 1688 drawRect(context, content, foregroundDrawingType, rect2);
(...skipping 28 matching lines...) Expand all
1669 } 1717 }
1670 1718
1671 TEST_P(PaintControllerTest, PartialSkipCache) { 1719 TEST_P(PaintControllerTest, PartialSkipCache) {
1672 FakeDisplayItemClient content("content"); 1720 FakeDisplayItemClient content("content");
1673 GraphicsContext context(getPaintController()); 1721 GraphicsContext context(getPaintController());
1674 1722
1675 FloatRect rect1(100, 100, 50, 50); 1723 FloatRect rect1(100, 100, 50, 50);
1676 FloatRect rect2(150, 100, 50, 50); 1724 FloatRect rect2(150, 100, 50, 50);
1677 FloatRect rect3(200, 100, 50, 50); 1725 FloatRect rect3(200, 100, 50, 50);
1678 1726
1727 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1728 getPaintController().updateCurrentPaintChunkProperties(
1729 &m_rootPaintChunkId, rootPaintChunkProperties());
1730 }
1679 drawRect(context, content, backgroundDrawingType, rect1); 1731 drawRect(context, content, backgroundDrawingType, rect1);
1680 getPaintController().beginSkippingCache(); 1732 getPaintController().beginSkippingCache();
1681 drawRect(context, content, foregroundDrawingType, rect2); 1733 drawRect(context, content, foregroundDrawingType, rect2);
1682 getPaintController().endSkippingCache(); 1734 getPaintController().endSkippingCache();
1683 drawRect(context, content, foregroundDrawingType, rect3); 1735 drawRect(context, content, foregroundDrawingType, rect3);
1684 1736
1685 getPaintController().commitNewDisplayItems(); 1737 getPaintController().commitNewDisplayItems();
1686 1738
1687 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1739 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1688 TestDisplayItem(content, backgroundDrawingType), 1740 TestDisplayItem(content, backgroundDrawingType),
(...skipping 10 matching lines...) Expand all
1699 sk_sp<const SkPicture> picture2 = 1751 sk_sp<const SkPicture> picture2 =
1700 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1752 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1701 getPaintController().getDisplayItemList()[2]) 1753 getPaintController().getDisplayItemList()[2])
1702 .picture()); 1754 .picture());
1703 EXPECT_NE(picture1, picture2); 1755 EXPECT_NE(picture1, picture2);
1704 1756
1705 // Content's cache is invalid because it has display items skipped cache. 1757 // Content's cache is invalid because it has display items skipped cache.
1706 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); 1758 EXPECT_FALSE(getPaintController().clientCacheIsValid(content));
1707 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); 1759 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
1708 1760
1761 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1762 getPaintController().updateCurrentPaintChunkProperties(
1763 &m_rootPaintChunkId, rootPaintChunkProperties());
1764 }
1709 // Draw again with nothing invalidated. 1765 // Draw again with nothing invalidated.
1710 drawRect(context, content, backgroundDrawingType, rect1); 1766 drawRect(context, content, backgroundDrawingType, rect1);
1711 getPaintController().beginSkippingCache(); 1767 getPaintController().beginSkippingCache();
1712 drawRect(context, content, foregroundDrawingType, rect2); 1768 drawRect(context, content, foregroundDrawingType, rect2);
1713 getPaintController().endSkippingCache(); 1769 getPaintController().endSkippingCache();
1714 drawRect(context, content, foregroundDrawingType, rect3); 1770 drawRect(context, content, foregroundDrawingType, rect3);
1715 1771
1716 EXPECT_EQ(0, numCachedNewItems()); 1772 EXPECT_EQ(0, numCachedNewItems());
1717 #ifndef NDEBUG 1773 #ifndef NDEBUG
1718 EXPECT_EQ(0, numSequentialMatches()); 1774 EXPECT_EQ(0, numSequentialMatches());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // Empty clips should have been optimized out. 1842 // Empty clips should have been optimized out.
1787 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 1843 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
1788 TestDisplayItem(first, backgroundDrawingType), 1844 TestDisplayItem(first, backgroundDrawingType),
1789 TestDisplayItem(third, backgroundDrawingType)); 1845 TestDisplayItem(third, backgroundDrawingType));
1790 } 1846 }
1791 1847
1792 TEST_F(PaintControllerTestBase, SmallPaintControllerHasOnePaintChunk) { 1848 TEST_F(PaintControllerTestBase, SmallPaintControllerHasOnePaintChunk) {
1793 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 1849 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
1794 FakeDisplayItemClient client("test client"); 1850 FakeDisplayItemClient client("test client");
1795 1851
1852 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1853 getPaintController().updateCurrentPaintChunkProperties(
1854 nullptr, rootPaintChunkProperties());
1855 }
1796 GraphicsContext context(getPaintController()); 1856 GraphicsContext context(getPaintController());
1797 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 1857 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
1798 1858
1799 getPaintController().commitNewDisplayItems(); 1859 getPaintController().commitNewDisplayItems();
1800 const auto& paintChunks = getPaintController().paintChunks(); 1860 const auto& paintChunks = getPaintController().paintChunks();
1801 ASSERT_EQ(1u, paintChunks.size()); 1861 ASSERT_EQ(1u, paintChunks.size());
1802 EXPECT_EQ(0u, paintChunks[0].beginIndex); 1862 EXPECT_EQ(0u, paintChunks[0].beginIndex);
1803 EXPECT_EQ(1u, paintChunks[0].endIndex); 1863 EXPECT_EQ(1u, paintChunks[0].endIndex);
1804 } 1864 }
1805 1865
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 } 2327 }
2268 2328
2269 TEST_F(PaintControllerUnderInvalidationTest, 2329 TEST_F(PaintControllerUnderInvalidationTest,
2270 FoldCompositingDrawingInSubsequence) { 2330 FoldCompositingDrawingInSubsequence) {
2271 testFoldCompositingDrawingInSubsequence(); 2331 testFoldCompositingDrawingInSubsequence();
2272 } 2332 }
2273 2333
2274 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2334 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2275 2335
2276 } // namespace blink 2336 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698