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

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

Issue 2299223002: Compile under-invalidation checking in all builds (Closed)
Patch Set: Resolve conflict Created 4 years, 3 months 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 19 matching lines...) Expand all
30 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) 30 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index)
31 { 31 {
32 return paintArtifact.getDisplayItemList().visualRect(index); 32 return paintArtifact.getDisplayItemList().visualRect(index);
33 } 33 }
34 34
35 protected: 35 protected:
36 PaintController& getPaintController() { return *m_paintController; } 36 PaintController& getPaintController() { return *m_paintController; }
37 37
38 int numCachedNewItems() const { return m_paintController->m_numCachedNewItem s; } 38 int numCachedNewItems() const { return m_paintController->m_numCachedNewItem s; }
39 39
40 #if DCHECK_IS_ON() 40 #ifndef NDEBUG
41 int numSequentialMatches() const { return m_paintController->m_numSequential Matches; } 41 int numSequentialMatches() const { return m_paintController->m_numSequential Matches; }
42 int numOutOfOrderMatches() const { return m_paintController->m_numOutOfOrder Matches; } 42 int numOutOfOrderMatches() const { return m_paintController->m_numOutOfOrder Matches; }
43 int numIndexedItems() const { return m_paintController->m_numIndexedItems; } 43 int numIndexedItems() const { return m_paintController->m_numIndexedItems; }
44 #endif 44 #endif
45 45
46 void TearDown() override 46 void TearDown() override
47 { 47 {
48 m_featuresBackup.restore(); 48 m_featuresBackup.restore();
49 } 49 }
50 50
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound) 98 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound)
99 { 99 {
100 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9)); 100 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9));
101 drawRect(context, client, drawingType, bound); 101 drawRect(context, client, drawingType, bound);
102 } 102 }
103 103
104 enum TestConfigurations { 104 enum TestConfigurations {
105 SPv1, 105 SPv1,
106 SPv2, 106 SPv2,
107 #if DCHECK_IS_ON()
108 UnderInvalidationCheckingSPv1, 107 UnderInvalidationCheckingSPv1,
109 UnderInvalidationCheckingSPv2, 108 UnderInvalidationCheckingSPv2,
110 #endif
111 }; 109 };
112 110
113 // Tests using this class will be tested with under-invalidation-checking enable d and disabled. 111 // Tests using this class will be tested with under-invalidation-checking enable d and disabled.
114 class PaintControllerTest : public PaintControllerTestBase, public testing::With ParamInterface<TestConfigurations> { 112 class PaintControllerTest : public PaintControllerTestBase, public testing::With ParamInterface<TestConfigurations> {
115 public: 113 public:
116 PaintControllerTest() 114 PaintControllerTest()
117 : m_rootPaintPropertyClient("root") 115 : m_rootPaintPropertyClient("root")
118 , m_rootPaintChunkId(m_rootPaintPropertyClient, DisplayItem::kUninitiali zedType) 116 , m_rootPaintChunkId(m_rootPaintPropertyClient, DisplayItem::kUninitiali zedType)
119 { } 117 { }
120 118
121 protected: 119 protected:
122 void SetUp() override 120 void SetUp() override
123 { 121 {
124 switch (GetParam()) { 122 switch (GetParam()) {
125 case SPv1: 123 case SPv1:
126 break; 124 break;
127 case SPv2: 125 case SPv2:
128 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 126 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
129 break; 127 break;
130 #if DCHECK_IS_ON()
131 case UnderInvalidationCheckingSPv1: 128 case UnderInvalidationCheckingSPv1:
132 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true); 129 RuntimeEnabledFeatures::setPaintUnderInvalidationCheckingEnabled(tru e);
133 break; 130 break;
134 case UnderInvalidationCheckingSPv2: 131 case UnderInvalidationCheckingSPv2:
135 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 132 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
136 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true); 133 RuntimeEnabledFeatures::setPaintUnderInvalidationCheckingEnabled(tru e);
137 break; 134 break;
138 #endif
139 } 135 }
140 } 136 }
141 137
142 FakeDisplayItemClient m_rootPaintPropertyClient; 138 FakeDisplayItemClient m_rootPaintPropertyClient;
143 PaintChunk::Id m_rootPaintChunkId; 139 PaintChunk::Id m_rootPaintChunkId;
144 }; 140 };
145 141
146 #if DCHECK_IS_ON()
147 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Values(SPv1, SPv2, UnderInvalidationCheckingSPv1, UnderInvalidationCheckingSPv2)); 142 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Values(SPv1, SPv2, UnderInvalidationCheckingSPv1, UnderInvalidationCheckingSPv2));
148 #else
149 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Values(SPv1, SPv2)) ;
150 #endif
151 143
152 TEST_P(PaintControllerTest, NestedRecorders) 144 TEST_P(PaintControllerTest, NestedRecorders)
153 { 145 {
154 GraphicsContext context(getPaintController()); 146 GraphicsContext context(getPaintController());
155 FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200)); 147 FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200));
156 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 148 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
157 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 149 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
158 150
159 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200)); 151 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200));
160 getPaintController().commitNewDisplayItems(); 152 getPaintController().commitNewDisplayItems();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 189 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
198 FloatRect(LayoutRect::infiniteIntRect()))); 190 FloatRect(LayoutRect::infiniteIntRect())));
199 191
200 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 192 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
201 } 193 }
202 194
203 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); 195 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 ));
204 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); 196 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 ));
205 197
206 EXPECT_EQ(2, numCachedNewItems()); 198 EXPECT_EQ(2, numCachedNewItems());
207 #if DCHECK_IS_ON() 199 #ifndef NDEBUG
208 EXPECT_EQ(2, numSequentialMatches()); 200 EXPECT_EQ(2, numSequentialMatches());
209 EXPECT_EQ(0, numOutOfOrderMatches()); 201 EXPECT_EQ(0, numOutOfOrderMatches());
210 EXPECT_EQ(1, numIndexedItems()); 202 EXPECT_EQ(1, numIndexedItems());
211 #endif 203 #endif
212 204
213 getPaintController().commitNewDisplayItems(); 205 getPaintController().commitNewDisplayItems();
214 206
215 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 207 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
216 TestDisplayItem(first, backgroundDrawingType), 208 TestDisplayItem(first, backgroundDrawingType),
217 TestDisplayItem(first, foregroundDrawingType)); 209 TestDisplayItem(first, foregroundDrawingType));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 TestDisplayItem(unaffected, foregroundDrawingType)); 243 TestDisplayItem(unaffected, foregroundDrawingType));
252 244
253 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 245 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
254 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 246 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
255 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 247 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
256 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 248 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
257 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); 249 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10));
258 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); 250 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10));
259 251
260 EXPECT_EQ(6, numCachedNewItems()); 252 EXPECT_EQ(6, numCachedNewItems());
261 #if DCHECK_IS_ON() 253 #ifndef NDEBUG
262 EXPECT_EQ(5, numSequentialMatches()); // second, first foreground, unaffecte d 254 EXPECT_EQ(5, numSequentialMatches()); // second, first foreground, unaffecte d
263 EXPECT_EQ(1, numOutOfOrderMatches()); // first 255 EXPECT_EQ(1, numOutOfOrderMatches()); // first
264 EXPECT_EQ(2, numIndexedItems()); // first 256 EXPECT_EQ(2, numIndexedItems()); // first
265 #endif 257 #endif
266 258
267 getPaintController().commitNewDisplayItems(); 259 getPaintController().commitNewDisplayItems();
268 260
269 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 261 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
270 TestDisplayItem(second, backgroundDrawingType), 262 TestDisplayItem(second, backgroundDrawingType),
271 TestDisplayItem(second, foregroundDrawingType), 263 TestDisplayItem(second, foregroundDrawingType),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 304
313 first.setDisplayItemsUncached(); 305 first.setDisplayItemsUncached();
314 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 306 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
315 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 307 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
316 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 308 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
317 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 309 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
318 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); 310 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10));
319 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); 311 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10));
320 312
321 EXPECT_EQ(4, numCachedNewItems()); 313 EXPECT_EQ(4, numCachedNewItems());
322 #if DCHECK_IS_ON() 314 #ifndef NDEBUG
323 EXPECT_EQ(4, numSequentialMatches()); // second, unaffected 315 EXPECT_EQ(4, numSequentialMatches()); // second, unaffected
324 EXPECT_EQ(0, numOutOfOrderMatches()); 316 EXPECT_EQ(0, numOutOfOrderMatches());
325 EXPECT_EQ(2, numIndexedItems()); 317 EXPECT_EQ(2, numIndexedItems());
326 #endif 318 #endif
327 319
328 getPaintController().commitNewDisplayItems(); 320 getPaintController().commitNewDisplayItems();
329 321
330 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 322 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
331 TestDisplayItem(second, backgroundDrawingType), 323 TestDisplayItem(second, backgroundDrawingType),
332 TestDisplayItem(second, foregroundDrawingType), 324 TestDisplayItem(second, foregroundDrawingType),
(...skipping 28 matching lines...) Expand all
361 TestDisplayItem(second, backgroundDrawingType)); 353 TestDisplayItem(second, backgroundDrawingType));
362 354
363 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 355 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
364 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 356 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
365 357
366 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 358 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
367 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) ); 359 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) );
368 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 360 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
369 361
370 EXPECT_EQ(2, numCachedNewItems()); 362 EXPECT_EQ(2, numCachedNewItems());
371 #if DCHECK_IS_ON() 363 #ifndef NDEBUG
372 EXPECT_EQ(2, numSequentialMatches()); // first, second 364 EXPECT_EQ(2, numSequentialMatches()); // first, second
373 EXPECT_EQ(0, numOutOfOrderMatches()); 365 EXPECT_EQ(0, numOutOfOrderMatches());
374 EXPECT_EQ(0, numIndexedItems()); 366 EXPECT_EQ(0, numIndexedItems());
375 #endif 367 #endif
376 368
377 getPaintController().commitNewDisplayItems(); 369 getPaintController().commitNewDisplayItems();
378 370
379 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 371 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
380 TestDisplayItem(first, backgroundDrawingType), 372 TestDisplayItem(first, backgroundDrawingType),
381 TestDisplayItem(third, backgroundDrawingType), 373 TestDisplayItem(third, backgroundDrawingType),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 410
419 second.setDisplayItemsUncached(); 411 second.setDisplayItemsUncached();
420 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 412 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
421 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 413 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
422 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; 414 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ;
423 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 415 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
424 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 416 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
425 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; 417 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ;
426 418
427 EXPECT_EQ(4, numCachedNewItems()); 419 EXPECT_EQ(4, numCachedNewItems());
428 #if DCHECK_IS_ON() 420 #ifndef NDEBUG
429 EXPECT_EQ(4, numSequentialMatches()); 421 EXPECT_EQ(4, numSequentialMatches());
430 EXPECT_EQ(0, numOutOfOrderMatches()); 422 EXPECT_EQ(0, numOutOfOrderMatches());
431 EXPECT_EQ(2, numIndexedItems()); 423 EXPECT_EQ(2, numIndexedItems());
432 #endif 424 #endif
433 425
434 getPaintController().commitNewDisplayItems(); 426 getPaintController().commitNewDisplayItems();
435 427
436 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 428 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
437 TestDisplayItem(first, backgroundDrawingType), 429 TestDisplayItem(first, backgroundDrawingType),
438 TestDisplayItem(second, backgroundDrawingType), 430 TestDisplayItem(second, backgroundDrawingType),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 FloatRect(200, 200, 50, 50), // Old bounds of |second|. 483 FloatRect(200, 200, 50, 50), // Old bounds of |second|.
492 FloatRect(150, 150, 100, 100))); // New bounds of |second|. 484 FloatRect(150, 150, 100, 100))); // New bounds of |second|.
493 485
494 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 486 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
495 } 487 }
496 488
497 drawRect(context, second, backgroundDrawingType, FloatRect(150, 150, 100, 10 0)); 489 drawRect(context, second, backgroundDrawingType, FloatRect(150, 150, 100, 10 0));
498 drawRect(context, second, foregroundDrawingType, FloatRect(150, 150, 100, 10 0)); 490 drawRect(context, second, foregroundDrawingType, FloatRect(150, 150, 100, 10 0));
499 491
500 EXPECT_EQ(2, numCachedNewItems()); 492 EXPECT_EQ(2, numCachedNewItems());
501 #if DCHECK_IS_ON() 493 #ifndef NDEBUG
502 EXPECT_EQ(2, numSequentialMatches()); 494 EXPECT_EQ(2, numSequentialMatches());
503 EXPECT_EQ(0, numOutOfOrderMatches()); 495 EXPECT_EQ(0, numOutOfOrderMatches());
504 EXPECT_EQ(2, numIndexedItems()); 496 EXPECT_EQ(2, numIndexedItems());
505 #endif 497 #endif
506 498
507 getPaintController().commitNewDisplayItems(); 499 getPaintController().commitNewDisplayItems();
508 500
509 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 501 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
510 TestDisplayItem(second, backgroundDrawingType), 502 TestDisplayItem(second, backgroundDrawingType),
511 TestDisplayItem(second, foregroundDrawingType)); 503 TestDisplayItem(second, foregroundDrawingType));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); 601 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType)));
610 602
611 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 603 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
612 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 604 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
613 605
614 first.setDisplayItemsUncached(); 606 first.setDisplayItemsUncached();
615 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 607 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
616 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); 608 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0));
617 609
618 EXPECT_EQ(1, numCachedNewItems()); 610 EXPECT_EQ(1, numCachedNewItems());
619 #if DCHECK_IS_ON() 611 #ifndef NDEBUG
620 EXPECT_EQ(1, numSequentialMatches()); 612 EXPECT_EQ(1, numSequentialMatches());
621 EXPECT_EQ(0, numOutOfOrderMatches()); 613 EXPECT_EQ(0, numOutOfOrderMatches());
622 EXPECT_EQ(1, numIndexedItems()); 614 EXPECT_EQ(1, numIndexedItems());
623 #endif 615 #endif
624 616
625 getPaintController().commitNewDisplayItems(); 617 getPaintController().commitNewDisplayItems();
626 618
627 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 619 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
628 TestDisplayItem(first, backgroundDrawingType), 620 TestDisplayItem(first, backgroundDrawingType),
629 TestDisplayItem(second, backgroundDrawingType)); 621 TestDisplayItem(second, backgroundDrawingType));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 682 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
691 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 683 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
692 getPaintController().commitNewDisplayItems(); 684 getPaintController().commitNewDisplayItems();
693 685
694 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 686 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
695 TestDisplayItem(first, backgroundDrawingType), 687 TestDisplayItem(first, backgroundDrawingType),
696 TestDisplayItem(second, backgroundDrawingType)); 688 TestDisplayItem(second, backgroundDrawingType));
697 // The first display item should be updated. 689 // The first display item should be updated.
698 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(getPaintContr oller().getDisplayItemList()[0]).picture()); 690 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(getPaintContr oller().getDisplayItemList()[0]).picture());
699 // The second display item should be cached. 691 // The second display item should be cached.
700 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled() ) 692 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled())
701 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture()); 693 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture());
702 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); 694 EXPECT_TRUE(getPaintController().clientCacheIsValid(first));
703 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); 695 EXPECT_TRUE(getPaintController().clientCacheIsValid(second));
704 696
705 getPaintController().invalidateAll(); 697 getPaintController().invalidateAll();
706 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); 698 EXPECT_FALSE(getPaintController().clientCacheIsValid(first));
707 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); 699 EXPECT_FALSE(getPaintController().clientCacheIsValid(second));
708 } 700 }
709 701
710 TEST_P(PaintControllerTest, ComplexUpdateSwapOrder) 702 TEST_P(PaintControllerTest, ComplexUpdateSwapOrder)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 EXPECT_EQ(2u, getPaintController().paintChunks().size()); 820 EXPECT_EQ(2u, getPaintController().paintChunks().size());
829 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id); 821 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id);
830 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id); 822 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id);
831 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 823 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
832 FloatRect(LayoutRect::infiniteIntRect()))); 824 FloatRect(LayoutRect::infiniteIntRect())));
833 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre( 825 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre(
834 FloatRect(LayoutRect::infiniteIntRect()))); 826 FloatRect(LayoutRect::infiniteIntRect())));
835 } 827 }
836 828
837 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. 829 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
838 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { 830 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
839 // When under-invalidation-checking is enabled, useCachedSubsequenceIfPo ssible is forced off, 831 // When under-invalidation-checking is enabled, useCachedSubsequenceIfPo ssible is forced off,
840 // and the client is expected to create the same painting as in the prev ious paint. 832 // and the client is expected to create the same painting as in the prev ious paint.
841 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2)); 833 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2));
842 { 834 {
843 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 835 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
844 PaintChunk::Id id(container2, backgroundDrawingType); 836 PaintChunk::Id id(container2, backgroundDrawingType);
845 getPaintController().updateCurrentPaintChunkProperties(&id, cont ainer2Properties); 837 getPaintController().updateCurrentPaintChunkProperties(&id, cont ainer2Properties);
846 } 838 }
847 SubsequenceRecorder r(context, container2); 839 SubsequenceRecorder r(context, container2);
848 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 840 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
(...skipping 12 matching lines...) Expand all
861 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); 853 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
862 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); 854 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
863 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 855 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
864 } 856 }
865 } else { 857 } else {
866 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2)); 858 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2));
867 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1)); 859 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1));
868 } 860 }
869 861
870 EXPECT_EQ(12, numCachedNewItems()); 862 EXPECT_EQ(12, numCachedNewItems());
871 #if DCHECK_IS_ON() 863 #ifndef NDEBUG
872 EXPECT_EQ(1, numSequentialMatches()); 864 EXPECT_EQ(1, numSequentialMatches());
873 EXPECT_EQ(1, numOutOfOrderMatches()); 865 EXPECT_EQ(1, numOutOfOrderMatches());
874 EXPECT_EQ(5, numIndexedItems()); 866 EXPECT_EQ(5, numIndexedItems());
875 #endif 867 #endif
876 868
877 getPaintController().commitNewDisplayItems(); 869 getPaintController().commitNewDisplayItems();
878 870
879 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, 871 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12,
880 TestDisplayItem(container2, DisplayItem::kSubsequence), 872 TestDisplayItem(container2, DisplayItem::kSubsequence),
881 TestDisplayItem(container2, backgroundDrawingType), 873 TestDisplayItem(container2, backgroundDrawingType),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 getPaintController().updateCurrentPaintChunkProperties(&id, content2 Properties); 1029 getPaintController().updateCurrentPaintChunkProperties(&id, content2 Properties);
1038 } 1030 }
1039 SubsequenceRecorder r(context, content2); 1031 SubsequenceRecorder r(context, content2);
1040 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); 1032 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200));
1041 } 1033 }
1042 // Repaint container1 with foreground only. 1034 // Repaint container1 with foreground only.
1043 { 1035 {
1044 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); 1036 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1));
1045 SubsequenceRecorder r(context, container1); 1037 SubsequenceRecorder r(context, container1);
1046 // Use cached subsequence of content1. 1038 // Use cached subsequence of content1.
1047 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) { 1039 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
1048 // When under-invalidation-checking is enabled, useCachedSubsequence IfPossible is forced off, 1040 // When under-invalidation-checking is enabled, useCachedSubsequence IfPossible is forced off,
1049 // and the client is expected to create the same painting as in the previous paint. 1041 // and the client is expected to create the same painting as in the previous paint.
1050 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1)); 1042 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1));
1051 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1043 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1052 PaintChunk::Id id(content1, backgroundDrawingType); 1044 PaintChunk::Id id(content1, backgroundDrawingType);
1053 getPaintController().updateCurrentPaintChunkProperties(&id, cont ent1Properties); 1045 getPaintController().updateCurrentPaintChunkProperties(&id, cont ent1Properties);
1054 } 1046 }
1055 SubsequenceRecorder r(context, content1); 1047 SubsequenceRecorder r(context, content1);
1056 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); 1048 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
1057 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); 1049 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
1058 } else { 1050 } else {
1059 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1)); 1051 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1));
1060 } 1052 }
1061 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1053 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1062 PaintChunk::Id id(container1, foregroundDrawingType); 1054 PaintChunk::Id id(container1, foregroundDrawingType);
1063 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1ForegroundProperties); 1055 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1ForegroundProperties);
1064 } 1056 }
1065 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 1057 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
1066 } 1058 }
1067 1059
1068 EXPECT_EQ(4, numCachedNewItems()); 1060 EXPECT_EQ(4, numCachedNewItems());
1069 #if DCHECK_IS_ON() 1061 #ifndef NDEBUG
1070 EXPECT_EQ(1, numSequentialMatches()); 1062 EXPECT_EQ(1, numSequentialMatches());
1071 EXPECT_EQ(0, numOutOfOrderMatches()); 1063 EXPECT_EQ(0, numOutOfOrderMatches());
1072 EXPECT_EQ(2, numIndexedItems()); 1064 EXPECT_EQ(2, numIndexedItems());
1073 #endif 1065 #endif
1074 1066
1075 getPaintController().commitNewDisplayItems(); 1067 getPaintController().commitNewDisplayItems();
1076 1068
1077 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, 1069 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10,
1078 TestDisplayItem(content2, DisplayItem::kSubsequence), 1070 TestDisplayItem(content2, DisplayItem::kSubsequence),
1079 TestDisplayItem(content2, foregroundDrawingType), 1071 TestDisplayItem(content2, foregroundDrawingType),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 // Draw again with nothing invalidated. 1139 // Draw again with nothing invalidated.
1148 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); 1140 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol));
1149 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 1141 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
1150 1142
1151 getPaintController().beginSkippingCache(); 1143 getPaintController().beginSkippingCache();
1152 drawRect(context, content, foregroundDrawingType, rect1); 1144 drawRect(context, content, foregroundDrawingType, rect1);
1153 drawRect(context, content, foregroundDrawingType, rect2); 1145 drawRect(context, content, foregroundDrawingType, rect2);
1154 getPaintController().endSkippingCache(); 1146 getPaintController().endSkippingCache();
1155 1147
1156 EXPECT_EQ(1, numCachedNewItems()); 1148 EXPECT_EQ(1, numCachedNewItems());
1157 #if DCHECK_IS_ON() 1149 #ifndef NDEBUG
1158 EXPECT_EQ(1, numSequentialMatches()); 1150 EXPECT_EQ(1, numSequentialMatches());
1159 EXPECT_EQ(0, numOutOfOrderMatches()); 1151 EXPECT_EQ(0, numOutOfOrderMatches());
1160 EXPECT_EQ(0, numIndexedItems()); 1152 EXPECT_EQ(0, numIndexedItems());
1161 #endif 1153 #endif
1162 1154
1163 getPaintController().commitNewDisplayItems(); 1155 getPaintController().commitNewDisplayItems();
1164 1156
1165 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1157 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1166 TestDisplayItem(multicol, backgroundDrawingType), 1158 TestDisplayItem(multicol, backgroundDrawingType),
1167 TestDisplayItem(content, foregroundDrawingType), 1159 TestDisplayItem(content, foregroundDrawingType),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); 1232 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
1241 1233
1242 // Draw again with nothing invalidated. 1234 // Draw again with nothing invalidated.
1243 drawRect(context, content, backgroundDrawingType, rect1); 1235 drawRect(context, content, backgroundDrawingType, rect1);
1244 getPaintController().beginSkippingCache(); 1236 getPaintController().beginSkippingCache();
1245 drawRect(context, content, foregroundDrawingType, rect2); 1237 drawRect(context, content, foregroundDrawingType, rect2);
1246 getPaintController().endSkippingCache(); 1238 getPaintController().endSkippingCache();
1247 drawRect(context, content, foregroundDrawingType, rect3); 1239 drawRect(context, content, foregroundDrawingType, rect3);
1248 1240
1249 EXPECT_EQ(0, numCachedNewItems()); 1241 EXPECT_EQ(0, numCachedNewItems());
1250 #if DCHECK_IS_ON() 1242 #ifndef NDEBUG
1251 EXPECT_EQ(0, numSequentialMatches()); 1243 EXPECT_EQ(0, numSequentialMatches());
1252 EXPECT_EQ(0, numOutOfOrderMatches()); 1244 EXPECT_EQ(0, numOutOfOrderMatches());
1253 EXPECT_EQ(0, numIndexedItems()); 1245 EXPECT_EQ(0, numIndexedItems());
1254 #endif 1246 #endif
1255 1247
1256 getPaintController().commitNewDisplayItems(); 1248 getPaintController().commitNewDisplayItems();
1257 1249
1258 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1250 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1259 TestDisplayItem(content, backgroundDrawingType), 1251 TestDisplayItem(content, backgroundDrawingType),
1260 TestDisplayItem(content, foregroundDrawingType), 1252 TestDisplayItem(content, foregroundDrawingType),
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 for (int j = 0; j < 50; ++j) 1468 for (int j = 0; j < 50; ++j)
1477 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); 1469 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path);
1478 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 1470 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
1479 for (int j = 0; j < 50; ++j) 1471 for (int j = 0; j < 50; ++j)
1480 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; 1472 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ;
1481 getPaintController().commitNewDisplayItems(LayoutSize()); 1473 getPaintController().commitNewDisplayItems(LayoutSize());
1482 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1474 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1483 } 1475 }
1484 } 1476 }
1485 1477
1486 // Under-invalidation checking is only available when DCHECK_IS_ON().
1487 // Death tests don't work properly on Android. 1478 // Death tests don't work properly on Android.
1488 #if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 1479 #if defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1489 1480
1490 class PaintControllerUnderInvalidationTest : public PaintControllerTestBase { 1481 class PaintControllerUnderInvalidationTest : public PaintControllerTestBase {
1491 protected: 1482 protected:
1492 void SetUp() override 1483 void SetUp() override
1493 { 1484 {
1494 PaintControllerTestBase::SetUp(); 1485 PaintControllerTestBase::SetUp();
1495 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEnabled (true); 1486 RuntimeEnabledFeatures::setPaintUnderInvalidationCheckingEnabled(true);
1496 } 1487 }
1497 1488
1498 void testChangeDrawing() 1489 void testChangeDrawing()
1499 { 1490 {
1500 FakeDisplayItemClient first("first"); 1491 FakeDisplayItemClient first("first");
1501 GraphicsContext context(getPaintController()); 1492 GraphicsContext context(getPaintController());
1502 1493
1503 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300)); 1494 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1504 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300)); 1495 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1505 getPaintController().commitNewDisplayItems(); 1496 getPaintController().commitNewDisplayItems();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 // We allow invalidated display item clients as long as they would produce t he same display items. 1745 // We allow invalidated display item clients as long as they would produce t he same display items.
1755 // The cases of changed display items are tested by other test cases. 1746 // The cases of changed display items are tested by other test cases.
1756 testInvalidationInSubsequence(); 1747 testInvalidationInSubsequence();
1757 } 1748 }
1758 1749
1759 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) 1750 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence )
1760 { 1751 {
1761 testFoldCompositingDrawingInSubsequence(); 1752 testFoldCompositingDrawingInSubsequence();
1762 } 1753 }
1763 1754
1764 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 1755 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1765 1756
1766 } // namespace blink 1757 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698