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

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

Issue 2184363002: Handle removed display items in under-invalidation checking in cached subsequences (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make test expectations suitable for both debug and release+dcheck Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "platform/graphics/paint/ClipRecorder.h" 11 #include "platform/graphics/paint/ClipRecorder.h"
12 #include "platform/graphics/paint/DrawingDisplayItem.h" 12 #include "platform/graphics/paint/DrawingDisplayItem.h"
13 #include "platform/graphics/paint/DrawingRecorder.h" 13 #include "platform/graphics/paint/DrawingRecorder.h"
14 #include "platform/graphics/paint/SubsequenceRecorder.h" 14 #include "platform/graphics/paint/SubsequenceRecorder.h"
15 #include "platform/testing/FakeDisplayItemClient.h" 15 #include "platform/testing/FakeDisplayItemClient.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include <memory> 17 #include <memory>
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class PaintControllerTest : public ::testing::Test { 21 class PaintControllerTestBase : public testing::Test {
22 public: 22 public:
23 PaintControllerTest() 23 PaintControllerTestBase()
24 : m_paintController(PaintController::create()) 24 : m_paintController(PaintController::create()) { }
25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
26 25
27 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) 26 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index)
28 { 27 {
29 return paintArtifact.getDisplayItemList().visualRect(index); 28 return paintArtifact.getDisplayItemList().visualRect(index);
30 } 29 }
31 30
32 protected: 31 protected:
33 PaintController& getPaintController() { return *m_paintController; } 32 PaintController& getPaintController() { return *m_paintController; }
34 33
35 int numCachedNewItems() const { return m_paintController->m_numCachedNewItem s; } 34 int numCachedNewItems() const { return m_paintController->m_numCachedNewItem s; }
36 35
37 #if DCHECK_IS_ON() 36 #if DCHECK_IS_ON()
38 int numSequentialMatches() const { return m_paintController->m_numSequential Matches; } 37 int numSequentialMatches() const { return m_paintController->m_numSequential Matches; }
39 int numOutOfOrderMatches() const { return m_paintController->m_numOutOfOrder Matches; } 38 int numOutOfOrderMatches() const { return m_paintController->m_numOutOfOrder Matches; }
40 int numIndexedItems() const { return m_paintController->m_numIndexedItems; } 39 int numIndexedItems() const { return m_paintController->m_numIndexedItems; }
41 #endif 40 #endif
42 41
43 private:
44 void TearDown() override 42 void TearDown() override
45 { 43 {
46 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); 44 m_featuresBackup.restore();
47 } 45 }
48 46
47 private:
49 std::unique_ptr<PaintController> m_paintController; 48 std::unique_ptr<PaintController> m_paintController;
50 bool m_originalSlimmingPaintV2Enabled; 49 RuntimeEnabledFeatures::Backup m_featuresBackup;
51 }; 50 };
52 51
53 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D isplayItem::DrawingPaintPhaseFirst + 4); 52 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D isplayItem::DrawingPaintPhaseFirst + 4);
54 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi rst; 53 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi rst;
55 const DisplayItem::Type clipType = DisplayItem::ClipFirst; 54 const DisplayItem::Type clipType = DisplayItem::ClipFirst;
56 55
57 class TestDisplayItem final : public DisplayItem { 56 class TestDisplayItem final : public DisplayItem {
58 public: 57 public:
59 TestDisplayItem(const FakeDisplayItemClient& client, Type type) : DisplayIte m(client, type, sizeof(*this)) { } 58 TestDisplayItem(const FakeDisplayItemClient& client, Type type) : DisplayIte m(client, type, sizeof(*this)) { }
60 59
(...skipping 30 matching lines...) Expand all
91 IntRect rect(0, 0, 10, 10); 90 IntRect rect(0, 0, 10, 10);
92 context.drawRect(rect); 91 context.drawRect(rect);
93 } 92 }
94 93
95 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound) 94 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound)
96 { 95 {
97 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9)); 96 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9));
98 drawRect(context, client, drawingType, bound); 97 drawRect(context, client, drawingType, bound);
99 } 98 }
100 99
101 TEST_F(PaintControllerTest, NestedRecorders) 100 #if DCHECK_IS_ON()
101 // Tests using this class will be tested with under-invalidation-checking enable d and disabled.
102 class PaintControllerTest : public PaintControllerTestBase, public testing::With ParamInterface<bool> {
103 protected:
104 void SetUp() override
105 {
106 if (GetParam())
107 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true);
108 }
109 };
110
111 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Bool());
112 #define TEST_F_OR_P TEST_P
113 #else
114 // Under-invalidation checking is only available when DCHECK_IS_ON().
115 using PaintControllerTest = PaintControllerTestBase;
116 #define TEST_F_OR_P TEST_F
117 #endif
118
119 TEST_F_OR_P(PaintControllerTest, NestedRecorders)
102 { 120 {
103 GraphicsContext context(getPaintController()); 121 GraphicsContext context(getPaintController());
104 122
105 FakeDisplayItemClient client("client"); 123 FakeDisplayItemClient client("client");
106 124
107 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200)); 125 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200));
108 getPaintController().commitNewDisplayItems(); 126 getPaintController().commitNewDisplayItems();
109 127
110 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 128 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
111 TestDisplayItem(client, clipType), 129 TestDisplayItem(client, clipType),
112 TestDisplayItem(client, backgroundDrawingType), 130 TestDisplayItem(client, backgroundDrawingType),
113 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); 131 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType)));
114 } 132 }
115 133
116 TEST_F(PaintControllerTest, UpdateBasic) 134 TEST_F_OR_P(PaintControllerTest, UpdateBasic)
117 { 135 {
118 FakeDisplayItemClient first("first"); 136 FakeDisplayItemClient first("first");
119 FakeDisplayItemClient second("second"); 137 FakeDisplayItemClient second("second");
120 GraphicsContext context(getPaintController()); 138 GraphicsContext context(getPaintController());
121 139
122 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); 140 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 ));
123 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); 141 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0));
124 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); 142 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 ));
125 143
126 EXPECT_EQ(0, numCachedNewItems()); 144 EXPECT_EQ(0, numCachedNewItems());
127 145
128 getPaintController().commitNewDisplayItems(); 146 getPaintController().commitNewDisplayItems();
129 147
130 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 148 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
131 TestDisplayItem(first, backgroundDrawingType), 149 TestDisplayItem(first, backgroundDrawingType),
132 TestDisplayItem(second, backgroundDrawingType), 150 TestDisplayItem(second, backgroundDrawingType),
133 TestDisplayItem(first, foregroundDrawingType)); 151 TestDisplayItem(first, foregroundDrawingType));
134 152
135 second.setDisplayItemsUncached();
136 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); 153 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 ));
137 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); 154 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 ));
138 155
139 EXPECT_EQ(2, numCachedNewItems()); 156 EXPECT_EQ(2, numCachedNewItems());
140 #if DCHECK_IS_ON() 157 #if DCHECK_IS_ON()
141 EXPECT_EQ(2, numSequentialMatches()); 158 EXPECT_EQ(2, numSequentialMatches());
142 EXPECT_EQ(0, numOutOfOrderMatches()); 159 EXPECT_EQ(0, numOutOfOrderMatches());
143 EXPECT_EQ(1, numIndexedItems()); 160 EXPECT_EQ(1, numIndexedItems());
144 #endif 161 #endif
145 162
146 getPaintController().commitNewDisplayItems(); 163 getPaintController().commitNewDisplayItems();
147 164
148 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 165 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
149 TestDisplayItem(first, backgroundDrawingType), 166 TestDisplayItem(first, backgroundDrawingType),
150 TestDisplayItem(first, foregroundDrawingType)); 167 TestDisplayItem(first, foregroundDrawingType));
151 } 168 }
152 169
153 TEST_F(PaintControllerTest, UpdateSwapOrder) 170 TEST_F_OR_P(PaintControllerTest, UpdateSwapOrder)
154 { 171 {
155 FakeDisplayItemClient first("first"); 172 FakeDisplayItemClient first("first");
156 FakeDisplayItemClient second("second"); 173 FakeDisplayItemClient second("second");
157 FakeDisplayItemClient unaffected("unaffected"); 174 FakeDisplayItemClient unaffected("unaffected");
158 GraphicsContext context(getPaintController()); 175 GraphicsContext context(getPaintController());
159 176
160 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 177 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
161 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 178 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
162 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 179 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
163 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 180 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
(...skipping 27 matching lines...) Expand all
191 208
192 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 209 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
193 TestDisplayItem(second, backgroundDrawingType), 210 TestDisplayItem(second, backgroundDrawingType),
194 TestDisplayItem(second, foregroundDrawingType), 211 TestDisplayItem(second, foregroundDrawingType),
195 TestDisplayItem(first, backgroundDrawingType), 212 TestDisplayItem(first, backgroundDrawingType),
196 TestDisplayItem(first, foregroundDrawingType), 213 TestDisplayItem(first, foregroundDrawingType),
197 TestDisplayItem(unaffected, backgroundDrawingType), 214 TestDisplayItem(unaffected, backgroundDrawingType),
198 TestDisplayItem(unaffected, foregroundDrawingType)); 215 TestDisplayItem(unaffected, foregroundDrawingType));
199 } 216 }
200 217
201 TEST_F(PaintControllerTest, UpdateSwapOrderWithInvalidation) 218 TEST_F_OR_P(PaintControllerTest, UpdateSwapOrderWithInvalidation)
202 { 219 {
203 FakeDisplayItemClient first("first"); 220 FakeDisplayItemClient first("first");
204 FakeDisplayItemClient second("second"); 221 FakeDisplayItemClient second("second");
205 FakeDisplayItemClient unaffected("unaffected"); 222 FakeDisplayItemClient unaffected("unaffected");
206 GraphicsContext context(getPaintController()); 223 GraphicsContext context(getPaintController());
207 224
208 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 225 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
209 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 226 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
210 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 227 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
211 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 228 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
(...skipping 28 matching lines...) Expand all
240 257
241 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 258 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
242 TestDisplayItem(second, backgroundDrawingType), 259 TestDisplayItem(second, backgroundDrawingType),
243 TestDisplayItem(second, foregroundDrawingType), 260 TestDisplayItem(second, foregroundDrawingType),
244 TestDisplayItem(first, backgroundDrawingType), 261 TestDisplayItem(first, backgroundDrawingType),
245 TestDisplayItem(first, foregroundDrawingType), 262 TestDisplayItem(first, foregroundDrawingType),
246 TestDisplayItem(unaffected, backgroundDrawingType), 263 TestDisplayItem(unaffected, backgroundDrawingType),
247 TestDisplayItem(unaffected, foregroundDrawingType)); 264 TestDisplayItem(unaffected, foregroundDrawingType));
248 } 265 }
249 266
250 TEST_F(PaintControllerTest, UpdateNewItemInMiddle) 267 TEST_F_OR_P(PaintControllerTest, UpdateNewItemInMiddle)
251 { 268 {
252 FakeDisplayItemClient first("first"); 269 FakeDisplayItemClient first("first");
253 FakeDisplayItemClient second("second"); 270 FakeDisplayItemClient second("second");
254 FakeDisplayItemClient third("third"); 271 FakeDisplayItemClient third("third");
255 GraphicsContext context(getPaintController()); 272 GraphicsContext context(getPaintController());
256 273
257 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 274 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
258 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 275 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
259 getPaintController().commitNewDisplayItems(); 276 getPaintController().commitNewDisplayItems();
260 277
(...skipping 13 matching lines...) Expand all
274 #endif 291 #endif
275 292
276 getPaintController().commitNewDisplayItems(); 293 getPaintController().commitNewDisplayItems();
277 294
278 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 295 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
279 TestDisplayItem(first, backgroundDrawingType), 296 TestDisplayItem(first, backgroundDrawingType),
280 TestDisplayItem(third, backgroundDrawingType), 297 TestDisplayItem(third, backgroundDrawingType),
281 TestDisplayItem(second, backgroundDrawingType)); 298 TestDisplayItem(second, backgroundDrawingType));
282 } 299 }
283 300
284 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases) 301 TEST_F_OR_P(PaintControllerTest, UpdateInvalidationWithPhases)
285 { 302 {
286 FakeDisplayItemClient first("first"); 303 FakeDisplayItemClient first("first");
287 FakeDisplayItemClient second("second"); 304 FakeDisplayItemClient second("second");
288 FakeDisplayItemClient third("third"); 305 FakeDisplayItemClient third("third");
289 GraphicsContext context(getPaintController()); 306 GraphicsContext context(getPaintController());
290 307
291 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 308 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
292 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 309 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
293 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; 310 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ;
294 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 311 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
(...skipping 28 matching lines...) Expand all
323 340
324 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 341 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
325 TestDisplayItem(first, backgroundDrawingType), 342 TestDisplayItem(first, backgroundDrawingType),
326 TestDisplayItem(second, backgroundDrawingType), 343 TestDisplayItem(second, backgroundDrawingType),
327 TestDisplayItem(third, backgroundDrawingType), 344 TestDisplayItem(third, backgroundDrawingType),
328 TestDisplayItem(first, foregroundDrawingType), 345 TestDisplayItem(first, foregroundDrawingType),
329 TestDisplayItem(second, foregroundDrawingType), 346 TestDisplayItem(second, foregroundDrawingType),
330 TestDisplayItem(third, foregroundDrawingType)); 347 TestDisplayItem(third, foregroundDrawingType));
331 } 348 }
332 349
333 TEST_F(PaintControllerTest, UpdateAddFirstOverlap) 350 TEST_F_OR_P(PaintControllerTest, UpdateAddFirstOverlap)
334 { 351 {
335 FakeDisplayItemClient first("first"); 352 FakeDisplayItemClient first("first");
336 FakeDisplayItemClient second("second"); 353 FakeDisplayItemClient second("second");
337 GraphicsContext context(getPaintController()); 354 GraphicsContext context(getPaintController());
338 355
339 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); 356 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) );
340 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); 357 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) );
341 getPaintController().commitNewDisplayItems(); 358 getPaintController().commitNewDisplayItems();
342 359
343 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 360 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
(...skipping 26 matching lines...) Expand all
370 EXPECT_EQ(2, numIndexedItems()); 387 EXPECT_EQ(2, numIndexedItems());
371 #endif 388 #endif
372 389
373 getPaintController().commitNewDisplayItems(); 390 getPaintController().commitNewDisplayItems();
374 391
375 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 392 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
376 TestDisplayItem(second, backgroundDrawingType), 393 TestDisplayItem(second, backgroundDrawingType),
377 TestDisplayItem(second, foregroundDrawingType)); 394 TestDisplayItem(second, foregroundDrawingType));
378 } 395 }
379 396
380 TEST_F(PaintControllerTest, UpdateAddLastOverlap) 397 TEST_F_OR_P(PaintControllerTest, UpdateAddLastOverlap)
381 { 398 {
382 FakeDisplayItemClient first("first"); 399 FakeDisplayItemClient first("first");
383 FakeDisplayItemClient second("second"); 400 FakeDisplayItemClient second("second");
384 GraphicsContext context(getPaintController()); 401 GraphicsContext context(getPaintController());
385 402
386 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 403 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
387 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 404 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
388 getPaintController().commitNewDisplayItems(); 405 getPaintController().commitNewDisplayItems();
389 406
390 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 407 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
(...skipping 20 matching lines...) Expand all
411 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 428 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
412 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 429 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
413 EXPECT_EQ(0, numCachedNewItems()); 430 EXPECT_EQ(0, numCachedNewItems());
414 getPaintController().commitNewDisplayItems(); 431 getPaintController().commitNewDisplayItems();
415 432
416 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 433 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
417 TestDisplayItem(first, backgroundDrawingType), 434 TestDisplayItem(first, backgroundDrawingType),
418 TestDisplayItem(first, foregroundDrawingType)); 435 TestDisplayItem(first, foregroundDrawingType));
419 } 436 }
420 437
421 TEST_F(PaintControllerTest, UpdateClip) 438 TEST_F_OR_P(PaintControllerTest, UpdateClip)
422 { 439 {
423 FakeDisplayItemClient first("first"); 440 FakeDisplayItemClient first("first");
424 FakeDisplayItemClient second("second"); 441 FakeDisplayItemClient second("second");
425 GraphicsContext context(getPaintController()); 442 GraphicsContext context(getPaintController());
426 443
427 { 444 {
428 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)) ; 445 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)) ;
429 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150)); 446 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150));
430 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150)); 447 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150));
431 } 448 }
(...skipping 30 matching lines...) Expand all
462 } 479 }
463 getPaintController().commitNewDisplayItems(); 480 getPaintController().commitNewDisplayItems();
464 481
465 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, 482 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4,
466 TestDisplayItem(first, backgroundDrawingType), 483 TestDisplayItem(first, backgroundDrawingType),
467 TestDisplayItem(second, clipType), 484 TestDisplayItem(second, clipType),
468 TestDisplayItem(second, backgroundDrawingType), 485 TestDisplayItem(second, backgroundDrawingType),
469 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); 486 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType)));
470 } 487 }
471 488
472 TEST_F(PaintControllerTest, CachedDisplayItems) 489 TEST_F_OR_P(PaintControllerTest, CachedDisplayItems)
473 { 490 {
474 FakeDisplayItemClient first("first"); 491 FakeDisplayItemClient first("first");
475 FakeDisplayItemClient second("second"); 492 FakeDisplayItemClient second("second");
476 GraphicsContext context(getPaintController()); 493 GraphicsContext context(getPaintController());
477 494
478 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 495 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
479 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 496 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
480 getPaintController().commitNewDisplayItems(); 497 getPaintController().commitNewDisplayItems();
481 498
482 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 499 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
(...skipping 11 matching lines...) Expand all
494 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 511 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
495 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 512 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
496 getPaintController().commitNewDisplayItems(); 513 getPaintController().commitNewDisplayItems();
497 514
498 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 515 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
499 TestDisplayItem(first, backgroundDrawingType), 516 TestDisplayItem(first, backgroundDrawingType),
500 TestDisplayItem(second, backgroundDrawingType)); 517 TestDisplayItem(second, backgroundDrawingType));
501 // The first display item should be updated. 518 // The first display item should be updated.
502 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(getPaintContr oller().getDisplayItemList()[0]).picture()); 519 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(getPaintContr oller().getDisplayItemList()[0]).picture());
503 // The second display item should be cached. 520 // The second display item should be cached.
504 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaintCont roller().getDisplayItemList()[1]).picture()); 521 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled() )
522 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture());
505 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); 523 EXPECT_TRUE(getPaintController().clientCacheIsValid(first));
506 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); 524 EXPECT_TRUE(getPaintController().clientCacheIsValid(second));
507 525
508 getPaintController().invalidateAll(); 526 getPaintController().invalidateAll();
509 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); 527 EXPECT_FALSE(getPaintController().clientCacheIsValid(first));
510 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); 528 EXPECT_FALSE(getPaintController().clientCacheIsValid(second));
511 } 529 }
512 530
513 TEST_F(PaintControllerTest, ComplexUpdateSwapOrder) 531 TEST_F_OR_P(PaintControllerTest, ComplexUpdateSwapOrder)
514 { 532 {
515 FakeDisplayItemClient container1("container1"); 533 FakeDisplayItemClient container1("container1");
516 FakeDisplayItemClient content1("content1"); 534 FakeDisplayItemClient content1("content1");
517 FakeDisplayItemClient container2("container2"); 535 FakeDisplayItemClient container2("container2");
518 FakeDisplayItemClient content2("content2"); 536 FakeDisplayItemClient content2("content2");
519 GraphicsContext context(getPaintController()); 537 GraphicsContext context(getPaintController());
520 538
521 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); 539 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
522 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); 540 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
523 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); 541 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
(...skipping 30 matching lines...) Expand all
554 TestDisplayItem(container2, backgroundDrawingType), 572 TestDisplayItem(container2, backgroundDrawingType),
555 TestDisplayItem(content2, backgroundDrawingType), 573 TestDisplayItem(content2, backgroundDrawingType),
556 TestDisplayItem(content2, foregroundDrawingType), 574 TestDisplayItem(content2, foregroundDrawingType),
557 TestDisplayItem(container2, foregroundDrawingType), 575 TestDisplayItem(container2, foregroundDrawingType),
558 TestDisplayItem(container1, backgroundDrawingType), 576 TestDisplayItem(container1, backgroundDrawingType),
559 TestDisplayItem(content1, backgroundDrawingType), 577 TestDisplayItem(content1, backgroundDrawingType),
560 TestDisplayItem(content1, foregroundDrawingType), 578 TestDisplayItem(content1, foregroundDrawingType),
561 TestDisplayItem(container1, foregroundDrawingType)); 579 TestDisplayItem(container1, foregroundDrawingType));
562 } 580 }
563 581
564 TEST_F(PaintControllerTest, CachedSubsequenceSwapOrder) 582 TEST_F_OR_P(PaintControllerTest, CachedSubsequenceSwapOrder)
565 { 583 {
566 FakeDisplayItemClient container1("container1"); 584 FakeDisplayItemClient container1("container1");
567 FakeDisplayItemClient content1("content1"); 585 FakeDisplayItemClient content1("content1");
568 FakeDisplayItemClient container2("container2"); 586 FakeDisplayItemClient container2("container2");
569 FakeDisplayItemClient content2("content2"); 587 FakeDisplayItemClient content2("content2");
570 GraphicsContext context(getPaintController()); 588 GraphicsContext context(getPaintController());
571 589
572 { 590 {
573 SubsequenceRecorder r(context, container1); 591 SubsequenceRecorder r(context, container1);
574 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 592 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
(...skipping 19 matching lines...) Expand all
594 TestDisplayItem(container1, DisplayItem::EndSubsequence), 612 TestDisplayItem(container1, DisplayItem::EndSubsequence),
595 613
596 TestDisplayItem(container2, DisplayItem::Subsequence), 614 TestDisplayItem(container2, DisplayItem::Subsequence),
597 TestDisplayItem(container2, backgroundDrawingType), 615 TestDisplayItem(container2, backgroundDrawingType),
598 TestDisplayItem(content2, backgroundDrawingType), 616 TestDisplayItem(content2, backgroundDrawingType),
599 TestDisplayItem(content2, foregroundDrawingType), 617 TestDisplayItem(content2, foregroundDrawingType),
600 TestDisplayItem(container2, foregroundDrawingType), 618 TestDisplayItem(container2, foregroundDrawingType),
601 TestDisplayItem(container2, DisplayItem::EndSubsequence)); 619 TestDisplayItem(container2, DisplayItem::EndSubsequence));
602 620
603 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. 621 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
604 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer2)); 622 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) {
605 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer1)); 623 // When under-invalidation-checking is enabled, useCachedSubsequenceIfPo ssible is forced off,
624 // and the client is expected to create the same painting as in the prev ious paint.
625 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2));
626 {
627 SubsequenceRecorder r(context, container2);
628 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
629 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200));
630 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 20 0, 50, 200));
631 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100));
632 }
633 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1));
634 {
635 SubsequenceRecorder r(context, container1);
636 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
637 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
638 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
639 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
640 }
641 } else {
642 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2));
643 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1));
644 }
606 645
607 EXPECT_EQ(12, numCachedNewItems()); 646 EXPECT_EQ(12, numCachedNewItems());
608 #if DCHECK_IS_ON() 647 #if DCHECK_IS_ON()
609 EXPECT_EQ(1, numSequentialMatches()); 648 EXPECT_EQ(1, numSequentialMatches());
610 EXPECT_EQ(1, numOutOfOrderMatches()); 649 EXPECT_EQ(1, numOutOfOrderMatches());
611 EXPECT_EQ(5, numIndexedItems()); 650 EXPECT_EQ(5, numIndexedItems());
612 #endif 651 #endif
613 652
614 getPaintController().commitNewDisplayItems(); 653 getPaintController().commitNewDisplayItems();
615 654
(...skipping 10 matching lines...) Expand all
626 TestDisplayItem(content1, backgroundDrawingType), 665 TestDisplayItem(content1, backgroundDrawingType),
627 TestDisplayItem(content1, foregroundDrawingType), 666 TestDisplayItem(content1, foregroundDrawingType),
628 TestDisplayItem(container1, foregroundDrawingType), 667 TestDisplayItem(container1, foregroundDrawingType),
629 TestDisplayItem(container1, DisplayItem::EndSubsequence)); 668 TestDisplayItem(container1, DisplayItem::EndSubsequence));
630 669
631 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 670 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
632 DisplayItemClient::endShouldKeepAliveAllClients(); 671 DisplayItemClient::endShouldKeepAliveAllClients();
633 #endif 672 #endif
634 } 673 }
635 674
636 TEST_F(PaintControllerTest, OutOfOrderNoCrash) 675 TEST_F_OR_P(PaintControllerTest, OutOfOrderNoCrash)
637 { 676 {
638 FakeDisplayItemClient client("client"); 677 FakeDisplayItemClient client("client");
639 GraphicsContext context(getPaintController()); 678 GraphicsContext context(getPaintController());
640 679
641 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; 680 const DisplayItem::Type type1 = DisplayItem::DrawingFirst;
642 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1); 681 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1);
643 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2); 682 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2);
644 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3); 683 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3);
645 684
646 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 685 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
647 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 686 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
648 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 687 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
649 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 688 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
650 689
651 getPaintController().commitNewDisplayItems(); 690 getPaintController().commitNewDisplayItems();
652 691
653 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 692 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
654 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 693 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
655 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 694 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
656 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 695 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
657 696
658 getPaintController().commitNewDisplayItems(); 697 getPaintController().commitNewDisplayItems();
659 } 698 }
660 699
661 TEST_F(PaintControllerTest, CachedNestedSubsequenceUpdate) 700 TEST_F_OR_P(PaintControllerTest, CachedNestedSubsequenceUpdate)
662 { 701 {
663 FakeDisplayItemClient container1("container1"); 702 FakeDisplayItemClient container1("container1");
664 FakeDisplayItemClient content1("content1"); 703 FakeDisplayItemClient content1("content1");
665 FakeDisplayItemClient container2("container2"); 704 FakeDisplayItemClient container2("container2");
666 FakeDisplayItemClient content2("content2"); 705 FakeDisplayItemClient content2("content2");
667 GraphicsContext context(getPaintController()); 706 GraphicsContext context(getPaintController());
668 707
669 { 708 {
670 SubsequenceRecorder r(context, container1); 709 SubsequenceRecorder r(context, container1);
671 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 710 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // Content2 now outputs foreground only. 755 // Content2 now outputs foreground only.
717 { 756 {
718 SubsequenceRecorder r(context, content2); 757 SubsequenceRecorder r(context, content2);
719 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); 758 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200));
720 } 759 }
721 // Repaint container1 with foreground only. 760 // Repaint container1 with foreground only.
722 { 761 {
723 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); 762 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1));
724 SubsequenceRecorder r(context, container1); 763 SubsequenceRecorder r(context, container1);
725 // Use cached subsequence of content1. 764 // Use cached subsequence of content1.
726 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, content1)); 765 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) {
766 // When under-invalidation-checking is enabled, useCachedSubsequence IfPossible is forced off,
767 // and the client is expected to create the same painting as in the previous paint.
768 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1));
769 SubsequenceRecorder r(context, content1);
770 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
771 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
772 } else {
773 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1));
774 }
727 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 775 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
728 } 776 }
729 777
730 EXPECT_EQ(4, numCachedNewItems()); 778 EXPECT_EQ(4, numCachedNewItems());
731 #if DCHECK_IS_ON() 779 #if DCHECK_IS_ON()
732 EXPECT_EQ(1, numSequentialMatches()); 780 EXPECT_EQ(1, numSequentialMatches());
733 EXPECT_EQ(0, numOutOfOrderMatches()); 781 EXPECT_EQ(0, numOutOfOrderMatches());
734 EXPECT_EQ(2, numIndexedItems()); 782 EXPECT_EQ(2, numIndexedItems());
735 #endif 783 #endif
736 784
(...skipping 10 matching lines...) Expand all
747 TestDisplayItem(content1, foregroundDrawingType), 795 TestDisplayItem(content1, foregroundDrawingType),
748 TestDisplayItem(content1, DisplayItem::EndSubsequence), 796 TestDisplayItem(content1, DisplayItem::EndSubsequence),
749 TestDisplayItem(container1, foregroundDrawingType), 797 TestDisplayItem(container1, foregroundDrawingType),
750 TestDisplayItem(container1, DisplayItem::EndSubsequence)); 798 TestDisplayItem(container1, DisplayItem::EndSubsequence));
751 799
752 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 800 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
753 DisplayItemClient::endShouldKeepAliveAllClients(); 801 DisplayItemClient::endShouldKeepAliveAllClients();
754 #endif 802 #endif
755 } 803 }
756 804
757 TEST_F(PaintControllerTest, SkipCache) 805 TEST_F_OR_P(PaintControllerTest, SkipCache)
758 { 806 {
759 FakeDisplayItemClient multicol("multicol"); 807 FakeDisplayItemClient multicol("multicol");
760 FakeDisplayItemClient content("content"); 808 FakeDisplayItemClient content("content");
761 GraphicsContext context(getPaintController()); 809 GraphicsContext context(getPaintController());
762 810
763 FloatRect rect1(100, 100, 50, 50); 811 FloatRect rect1(100, 100, 50, 50);
764 FloatRect rect2(150, 100, 50, 50); 812 FloatRect rect2(150, 100, 50, 50);
765 FloatRect rect3(200, 100, 50, 50); 813 FloatRect rect3(200, 100, 50, 50);
766 814
767 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 815 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 TestDisplayItem(multicol, backgroundDrawingType), 869 TestDisplayItem(multicol, backgroundDrawingType),
822 TestDisplayItem(content, foregroundDrawingType), 870 TestDisplayItem(content, foregroundDrawingType),
823 TestDisplayItem(content, foregroundDrawingType), 871 TestDisplayItem(content, foregroundDrawingType),
824 TestDisplayItem(content, foregroundDrawingType)); 872 TestDisplayItem(content, foregroundDrawingType));
825 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); 873 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture());
826 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); 874 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture());
827 875
828 getPaintController().commitNewDisplayItems(); 876 getPaintController().commitNewDisplayItems();
829 } 877 }
830 878
831 TEST_F(PaintControllerTest, PartialSkipCache) 879 TEST_F_OR_P(PaintControllerTest, PartialSkipCache)
832 { 880 {
833 FakeDisplayItemClient content("content"); 881 FakeDisplayItemClient content("content");
834 GraphicsContext context(getPaintController()); 882 GraphicsContext context(getPaintController());
835 883
836 FloatRect rect1(100, 100, 50, 50); 884 FloatRect rect1(100, 100, 50, 50);
837 FloatRect rect2(150, 100, 50, 50); 885 FloatRect rect2(150, 100, 50, 50);
838 FloatRect rect3(200, 100, 50, 50); 886 FloatRect rect3(200, 100, 50, 50);
839 887
840 drawRect(context, content, backgroundDrawingType, rect1); 888 drawRect(context, content, backgroundDrawingType, rect1);
841 getPaintController().beginSkippingCache(); 889 getPaintController().beginSkippingCache();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 924
877 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 925 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
878 TestDisplayItem(content, backgroundDrawingType), 926 TestDisplayItem(content, backgroundDrawingType),
879 TestDisplayItem(content, foregroundDrawingType), 927 TestDisplayItem(content, foregroundDrawingType),
880 TestDisplayItem(content, foregroundDrawingType)); 928 TestDisplayItem(content, foregroundDrawingType));
881 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); 929 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture());
882 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 930 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture());
883 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 931 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture());
884 } 932 }
885 933
886 TEST_F(PaintControllerTest, OptimizeNoopPairs) 934 TEST_F_OR_P(PaintControllerTest, OptimizeNoopPairs)
887 { 935 {
888 FakeDisplayItemClient first("first"); 936 FakeDisplayItemClient first("first");
889 FakeDisplayItemClient second("second"); 937 FakeDisplayItemClient second("second");
890 FakeDisplayItemClient third("third"); 938 FakeDisplayItemClient third("third");
891 939
892 GraphicsContext context(getPaintController()); 940 GraphicsContext context(getPaintController());
893 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 941 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
894 { 942 {
895 ClipPathRecorder clipRecorder(context, second, Path()); 943 ClipPathRecorder clipRecorder(context, second, Path());
896 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 944 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
897 } 945 }
898 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 946 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
899 947
900 getPaintController().commitNewDisplayItems(); 948 getPaintController().commitNewDisplayItems();
901 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 5, 949 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 5,
902 TestDisplayItem(first, backgroundDrawingType), 950 TestDisplayItem(first, backgroundDrawingType),
903 TestDisplayItem(second, DisplayItem::BeginClipPath), 951 TestDisplayItem(second, DisplayItem::BeginClipPath),
904 TestDisplayItem(second, backgroundDrawingType), 952 TestDisplayItem(second, backgroundDrawingType),
905 TestDisplayItem(second, DisplayItem::EndClipPath), 953 TestDisplayItem(second, DisplayItem::EndClipPath),
906 TestDisplayItem(third, backgroundDrawingType)); 954 TestDisplayItem(third, backgroundDrawingType));
907 955
908 second.setDisplayItemsUncached();
909 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 956 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
910 { 957 {
911 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) ); 958 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) );
912 // Do not draw anything for second. 959 // Do not draw anything for second.
913 } 960 }
914 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 961 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
915 getPaintController().commitNewDisplayItems(); 962 getPaintController().commitNewDisplayItems();
916 963
917 // Empty clips should have been optimized out. 964 // Empty clips should have been optimized out.
918 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 965 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
(...skipping 11 matching lines...) Expand all
930 } 977 }
931 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 978 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
932 getPaintController().commitNewDisplayItems(); 979 getPaintController().commitNewDisplayItems();
933 980
934 // Empty clips should have been optimized out. 981 // Empty clips should have been optimized out.
935 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 982 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
936 TestDisplayItem(first, backgroundDrawingType), 983 TestDisplayItem(first, backgroundDrawingType),
937 TestDisplayItem(third, backgroundDrawingType)); 984 TestDisplayItem(third, backgroundDrawingType));
938 } 985 }
939 986
940 TEST_F(PaintControllerTest, SmallPaintControllerHasOnePaintChunk) 987 TEST_F_OR_P(PaintControllerTest, SmallPaintControllerHasOnePaintChunk)
941 { 988 {
942 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 989 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
943 FakeDisplayItemClient client("test client"); 990 FakeDisplayItemClient client("test client");
944 991
945 GraphicsContext context(getPaintController()); 992 GraphicsContext context(getPaintController());
946 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 993 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
947 994
948 getPaintController().commitNewDisplayItems(); 995 getPaintController().commitNewDisplayItems();
949 const auto& paintChunks = getPaintController().paintChunks(); 996 const auto& paintChunks = getPaintController().paintChunks();
950 ASSERT_EQ(1u, paintChunks.size()); 997 ASSERT_EQ(1u, paintChunks.size());
951 EXPECT_EQ(0u, paintChunks[0].beginIndex); 998 EXPECT_EQ(0u, paintChunks[0].beginIndex);
952 EXPECT_EQ(1u, paintChunks[0].endIndex); 999 EXPECT_EQ(1u, paintChunks[0].endIndex);
953 } 1000 }
954 1001
955 #define EXPECT_RECT_EQ(expected, actual) \ 1002 #define EXPECT_RECT_EQ(expected, actual) \
956 do { \ 1003 do { \
957 const IntRect& actualRect = actual; \ 1004 const IntRect& actualRect = actual; \
958 EXPECT_EQ(expected.x(), actualRect.x()); \ 1005 EXPECT_EQ(expected.x(), actualRect.x()); \
959 EXPECT_EQ(expected.y(), actualRect.y()); \ 1006 EXPECT_EQ(expected.y(), actualRect.y()); \
960 EXPECT_EQ(expected.width(), actualRect.width()); \ 1007 EXPECT_EQ(expected.width(), actualRect.width()); \
961 EXPECT_EQ(expected.height(), actualRect.height()); \ 1008 EXPECT_EQ(expected.height(), actualRect.height()); \
962 } while (false) 1009 } while (false)
963 1010
964 TEST_F(PaintControllerTest, PaintArtifactWithVisualRects) 1011 TEST_F_OR_P(PaintControllerTest, PaintArtifactWithVisualRects)
965 { 1012 {
966 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1013 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
967 1014
968 GraphicsContext context(getPaintController()); 1015 GraphicsContext context(getPaintController());
969 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 1016 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
970 1017
971 getPaintController().commitNewDisplayItems(LayoutSize(20, 30)); 1018 getPaintController().commitNewDisplayItems(LayoutSize(20, 30));
972 const auto& paintArtifact = getPaintController().paintArtifact(); 1019 const auto& paintArtifact = getPaintController().paintArtifact();
973 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size()); 1020 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size());
974 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); 1021 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0));
(...skipping 11 matching lines...) Expand all
986 path.lineTo(50, 50); 1033 path.lineTo(50, 50);
987 path.lineTo(100, 100); 1034 path.lineTo(100, 100);
988 path.lineTo(100, 0); 1035 path.lineTo(100, 0);
989 path.close(); 1036 path.close();
990 SkPaint paint; 1037 SkPaint paint;
991 paint.setAntiAlias(true); 1038 paint.setAntiAlias(true);
992 for (unsigned i = 0; i < count; i++) 1039 for (unsigned i = 0; i < count; i++)
993 context.drawPath(path, paint); 1040 context.drawPath(path, paint);
994 } 1041 }
995 1042
996 TEST_F(PaintControllerTest, IsSuitableForGpuRasterizationSinglePath) 1043 TEST_F_OR_P(PaintControllerTest, IsSuitableForGpuRasterizationSinglePath)
997 { 1044 {
998 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1045 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
999 GraphicsContext context(getPaintController()); 1046 GraphicsContext context(getPaintController());
1000 drawPath(context, client, backgroundDrawingType, 1); 1047 drawPath(context, client, backgroundDrawingType, 1);
1001 getPaintController().commitNewDisplayItems(LayoutSize()); 1048 getPaintController().commitNewDisplayItems(LayoutSize());
1002 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on()); 1049 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on());
1003 } 1050 }
1004 1051
1005 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hs) 1052 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPaths)
1006 { 1053 {
1007 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1054 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1008 GraphicsContext context(getPaintController()); 1055 GraphicsContext context(getPaintController());
1009 1056
1010 drawPath(context, client, backgroundDrawingType, 50); 1057 drawPath(context, client, backgroundDrawingType, 50);
1011 getPaintController().commitNewDisplayItems(LayoutSize()); 1058 getPaintController().commitNewDisplayItems(LayoutSize());
1012 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1059 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1013 } 1060 }
1014 1061
1015 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicturesSing lePathEach) 1062 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicture sSinglePathEach)
1016 { 1063 {
1017 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1064 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1018 GraphicsContext context(getPaintController()); 1065 GraphicsContext context(getPaintController());
1019 getPaintController().beginSkippingCache(); 1066 getPaintController().beginSkippingCache();
1020 1067
1021 for (int i = 0; i < 50; ++i) 1068 for (int i = 0; i < 50; ++i)
1022 drawPath(context, client, backgroundDrawingType, 50); 1069 drawPath(context, client, backgroundDrawingType, 50);
1023 1070
1024 getPaintController().endSkippingCache(); 1071 getPaintController().endSkippingCache();
1025 getPaintController().commitNewDisplayItems(LayoutSize()); 1072 getPaintController().commitNewDisplayItems(LayoutSize());
1026 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1073 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1027 } 1074 }
1028 1075
1029 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsTwoPaints) 1076 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsTwoPaints)
1030 { 1077 {
1031 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1078 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1032 1079
1033 { 1080 {
1034 GraphicsContext context(getPaintController()); 1081 GraphicsContext context(getPaintController());
1035 drawPath(context, client, backgroundDrawingType, 50); 1082 drawPath(context, client, backgroundDrawingType, 50);
1036 getPaintController().commitNewDisplayItems(LayoutSize()); 1083 getPaintController().commitNewDisplayItems(LayoutSize());
1037 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1084 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1038 } 1085 }
1039 1086
1040 client.setDisplayItemsUncached(); 1087 client.setDisplayItemsUncached();
1041 1088
1042 { 1089 {
1043 GraphicsContext context(getPaintController()); 1090 GraphicsContext context(getPaintController());
1044 drawPath(context, client, backgroundDrawingType, 50); 1091 drawPath(context, client, backgroundDrawingType, 50);
1045 getPaintController().commitNewDisplayItems(LayoutSize()); 1092 getPaintController().commitNewDisplayItems(LayoutSize());
1046 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1093 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1047 } 1094 }
1048 } 1095 }
1049 1096
1050 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsCached) 1097 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsCached)
1051 { 1098 {
1052 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1099 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1053 1100
1054 { 1101 {
1055 GraphicsContext context(getPaintController()); 1102 GraphicsContext context(getPaintController());
1056 drawPath(context, client, backgroundDrawingType, 50); 1103 drawPath(context, client, backgroundDrawingType, 50);
1057 getPaintController().commitNewDisplayItems(LayoutSize()); 1104 getPaintController().commitNewDisplayItems(LayoutSize());
1058 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1105 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1059 } 1106 }
1060 1107
1061 { 1108 {
1062 GraphicsContext context(getPaintController()); 1109 GraphicsContext context(getPaintController());
1063 drawPath(context, client, backgroundDrawingType, 50); 1110 drawPath(context, client, backgroundDrawingType, 50);
1064 getPaintController().commitNewDisplayItems(LayoutSize()); 1111 getPaintController().commitNewDisplayItems(LayoutSize());
1065 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1112 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1066 } 1113 }
1067 } 1114 }
1068 1115
1069 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsCachedSubsequence) 1116 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationSinglePictureMan yPathsCachedSubsequence)
1070 { 1117 {
1071 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1118 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1072 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); 1119 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100));
1073 1120
1074 GraphicsContext context(getPaintController()); 1121 GraphicsContext context(getPaintController());
1075 { 1122 {
1076 SubsequenceRecorder subsequenceRecorder(context, container); 1123 SubsequenceRecorder subsequenceRecorder(context, container);
1077 drawPath(context, client, backgroundDrawingType, 50); 1124 drawPath(context, client, backgroundDrawingType, 50);
1078 } 1125 }
1079 getPaintController().commitNewDisplayItems(LayoutSize()); 1126 getPaintController().commitNewDisplayItems(LayoutSize());
1080 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1127 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1081 1128
1082 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer)); 1129 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer));
1083 getPaintController().commitNewDisplayItems(LayoutSize()); 1130 getPaintController().commitNewDisplayItems(LayoutSize());
1084 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1131 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1085 1132
1086 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 1133 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
1087 DisplayItemClient::endShouldKeepAliveAllClients(); 1134 DisplayItemClient::endShouldKeepAliveAllClients();
1088 #endif 1135 #endif
1089 } 1136 }
1090 1137
1091 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969). 1138 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969).
1092 TEST_F(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcaveClip Path) 1139 TEST_F_OR_P(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcav eClipPath)
1093 { 1140 {
1094 Path path; 1141 Path path;
1095 path.addLineTo(FloatPoint(50, 50)); 1142 path.addLineTo(FloatPoint(50, 50));
1096 path.addLineTo(FloatPoint(100, 0)); 1143 path.addLineTo(FloatPoint(100, 0));
1097 path.addLineTo(FloatPoint(50, 100)); 1144 path.addLineTo(FloatPoint(50, 100));
1098 path.closeSubpath(); 1145 path.closeSubpath();
1099 1146
1100 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1147 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1101 GraphicsContext context(getPaintController()); 1148 GraphicsContext context(getPaintController());
1102 1149
1103 // Run twice for empty/non-empty m_currentPaintArtifact coverage. 1150 // Run twice for empty/non-empty m_currentPaintArtifact coverage.
1104 for (int i = 0; i < 2; ++i) { 1151 for (int i = 0; i < 2; ++i) {
1105 for (int j = 0; j < 50; ++j) 1152 for (int j = 0; j < 50; ++j)
1106 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); 1153 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path);
1107 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 1154 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
1108 for (int j = 0; j < 50; ++j) 1155 for (int j = 0; j < 50; ++j)
1109 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; 1156 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ;
1110 getPaintController().commitNewDisplayItems(LayoutSize()); 1157 getPaintController().commitNewDisplayItems(LayoutSize());
1111 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1158 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1112 } 1159 }
1113 } 1160 }
1114 1161
1162 // Under-invalidation checking is only available when DCHECK_IS_ON().
1163 // Death tests don't work properly on Android.
1164 #if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1165
1166 class PaintControllerUnderInvalidationTest : public PaintControllerTestBase {
1167 protected:
1168 void SetUp() override
1169 {
1170 PaintControllerTestBase::SetUp();
1171 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEnabled (true);
1172 }
1173
1174 void testChangeDrawing()
1175 {
1176 FakeDisplayItemClient first("first");
1177 GraphicsContext context(getPaintController());
1178
1179 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1180 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1181 getPaintController().commitNewDisplayItems();
1182 drawRect(context, first, backgroundDrawingType, FloatRect(200, 200, 300, 300));
1183 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1184 getPaintController().commitNewDisplayItems();
1185 }
1186
1187 void testMoreDrawing()
1188 {
1189 FakeDisplayItemClient first("first");
1190 GraphicsContext context(getPaintController());
1191
1192 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1193 getPaintController().commitNewDisplayItems();
1194 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1195 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1196 getPaintController().commitNewDisplayItems();
1197 }
1198
1199 void testLessDrawing()
1200 {
1201 FakeDisplayItemClient first("first");
1202 GraphicsContext context(getPaintController());
1203
1204 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1205 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1206 getPaintController().commitNewDisplayItems();
1207 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1208 getPaintController().commitNewDisplayItems();
1209 }
1210
1211 void testNoopPairsInSubsequence()
1212 {
1213 FakeDisplayItemClient container("container");
1214 GraphicsContext context(getPaintController());
1215
1216 {
1217 SubsequenceRecorder r(context, container);
1218 drawRect(context, container, backgroundDrawingType, FloatRect(100, 1 00, 100, 100));
1219 }
1220 getPaintController().commitNewDisplayItems();
1221
1222 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container));
1223 {
1224 // Generate some no-op pairs which should not affect under-invalidat ion checking.
1225 ClipRecorder r1(context, container, clipType, IntRect(1, 1, 9, 9));
1226 ClipRecorder r2(context, container, clipType, IntRect(1, 1, 2, 2));
1227 ClipRecorder r3(context, container, clipType, IntRect(1, 1, 3, 3));
1228 ClipPathRecorder r4(context, container, Path());
1229 }
1230 {
1231 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1232 SubsequenceRecorder r(context, container);
1233 drawRect(context, container, backgroundDrawingType, FloatRect(100, 1 00, 100, 100));
1234 }
1235 getPaintController().commitNewDisplayItems();
1236
1237 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
1238 DisplayItemClient::endShouldKeepAliveAllClients();
1239 #endif
1240 }
1241
1242 void testChangeDrawingInSubsequence()
1243 {
1244 FakeDisplayItemClient first("first");
1245 GraphicsContext context(getPaintController());
1246 {
1247 SubsequenceRecorder r(context, first);
1248 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1249 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1250 }
1251 getPaintController().commitNewDisplayItems();
1252 {
1253 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1254 SubsequenceRecorder r(context, first);
1255 drawRect(context, first, backgroundDrawingType, FloatRect(200, 200, 300, 300));
1256 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1257 }
1258 getPaintController().commitNewDisplayItems();
1259 }
1260
1261 void testMoreDrawingInSubsequence()
1262 {
1263 FakeDisplayItemClient first("first");
1264 GraphicsContext context(getPaintController());
1265
1266 {
1267 SubsequenceRecorder r(context, first);
1268 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1269 }
1270 getPaintController().commitNewDisplayItems();
1271
1272 {
1273 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1274 SubsequenceRecorder r(context, first);
1275 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1276 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1277 }
1278 getPaintController().commitNewDisplayItems();
1279 }
1280
1281 void testLessDrawingInSubsequence()
1282 {
1283 FakeDisplayItemClient first("first");
1284 GraphicsContext context(getPaintController());
1285
1286 {
1287 SubsequenceRecorder r(context, first);
1288 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1289 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1290 }
1291 getPaintController().commitNewDisplayItems();
1292
1293 {
1294 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1295 SubsequenceRecorder r(context, first);
1296 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1297 }
1298 getPaintController().commitNewDisplayItems();
1299 }
1300
1301 void testChangeNonCacheableInSubsequence()
1302 {
1303 FakeDisplayItemClient container("container");
1304 FakeDisplayItemClient content("content");
1305 GraphicsContext context(getPaintController());
1306
1307 {
1308 SubsequenceRecorder r(context, container);
1309 {
1310 ClipPathRecorder clipPathRecorder(context, container, Path());
1311 }
1312 ClipRecorder clip(context, container, clipType, IntRect(1, 1, 9, 9)) ;
1313 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1314 }
1315 getPaintController().commitNewDisplayItems();
1316
1317 {
1318 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1319 SubsequenceRecorder r(context, container);
1320 {
1321 ClipPathRecorder clipPathRecorder(context, container, Path());
1322 }
1323 ClipRecorder clip(context, container, clipType, IntRect(1, 1, 30, 30 ));
1324 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1325 }
1326 getPaintController().commitNewDisplayItems();
1327 }
1328
1329 void testInvalidationInSubsequence()
1330 {
1331 FakeDisplayItemClient container("container");
1332 FakeDisplayItemClient content("content");
1333 GraphicsContext context(getPaintController());
1334
1335 {
1336 SubsequenceRecorder r(context, container);
1337 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1338 }
1339 getPaintController().commitNewDisplayItems();
1340
1341 content.setDisplayItemsUncached();
1342 // Leave container not invalidated.
1343 {
1344 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1345 SubsequenceRecorder r(context, content);
1346 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1347 }
1348 getPaintController().commitNewDisplayItems();
1349 }
1350
1351 // TODO(wangxianzhu): Add under-invalidation checking test in case of compos iting item folding.
1352 };
1353
1354 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawing)
1355 {
1356 EXPECT_DEATH(testChangeDrawing(), "under-invalidation: display item changed" );
1357 }
1358
1359 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawing)
1360 {
1361 EXPECT_DEATH(testMoreDrawing(), "Can't find cached display item");
1362 }
1363
1364 TEST_F(PaintControllerUnderInvalidationTest, LessDrawing)
1365 {
1366 // We don't detect under-invalidation in this case, and PaintController can also handle the case gracefully.
1367 // However, less-drawing at a time often means more-drawing at another time so eventually we'll detect
1368 // such under-invalidations.
1369 testLessDrawing();
1370 }
1371
1372 TEST_F(PaintControllerUnderInvalidationTest, NoopPairsInSubsequence)
1373 {
1374 // This should not die.
1375 testNoopPairsInSubsequence();
1376 }
1377
1378 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawingInSubsequence)
1379 {
1380 EXPECT_DEATH(testChangeDrawingInSubsequence(), "\"\\(In cached subsequence o f first\\)\" under-invalidation: display item changed");
1381 }
1382
1383 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawingInSubsequence)
1384 {
1385 EXPECT_DEATH(testMoreDrawingInSubsequence(), "\"\\(In cached subsequence of first\\)\" under-invalidation: display item changed");
1386 }
1387
1388 TEST_F(PaintControllerUnderInvalidationTest, LessDrawingInSubsequence)
1389 {
1390 EXPECT_DEATH(testLessDrawingInSubsequence(), "\"\\(In cached subsequence of first\\)\" under-invalidation: display item changed");
1391 }
1392
1393 TEST_F(PaintControllerUnderInvalidationTest, ChangeNonCacheableInSubsequence)
1394 {
1395 EXPECT_DEATH(testChangeNonCacheableInSubsequence(), "\"\\(In cached subseque nce of container\\)\" under-invalidation: display item changed");
1396 }
1397
1398 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence)
1399 {
1400 EXPECT_DEATH(testInvalidationInSubsequence(), "\"\\(In cached subsequence of container\\)\" under-invalidation of PaintLayer: invalidated in cached subseque nce");
1401 }
1402
1403 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1404
1115 } // namespace blink 1405 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698