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

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

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

Powered by Google App Engine
This is Rietveld 408576698