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

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: - 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 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2));
chrishtr 2016/07/28 18:14:42 Add a note that useCachedSubsequenceIfPossible is
Xianzhu 2016/07/28 18:40:09 Done.
624 {
625 SubsequenceRecorder r(context, container2);
626 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
627 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200));
628 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 20 0, 50, 200));
629 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100));
630 }
631 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1));
632 {
633 SubsequenceRecorder r(context, container1);
634 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
635 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
636 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
637 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
638 }
639 } else {
640 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2));
641 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1));
642 }
606 643
607 EXPECT_EQ(12, numCachedNewItems()); 644 EXPECT_EQ(12, numCachedNewItems());
608 #if DCHECK_IS_ON() 645 #if DCHECK_IS_ON()
609 EXPECT_EQ(1, numSequentialMatches()); 646 EXPECT_EQ(1, numSequentialMatches());
610 EXPECT_EQ(1, numOutOfOrderMatches()); 647 EXPECT_EQ(1, numOutOfOrderMatches());
611 EXPECT_EQ(5, numIndexedItems()); 648 EXPECT_EQ(5, numIndexedItems());
612 #endif 649 #endif
613 650
614 getPaintController().commitNewDisplayItems(); 651 getPaintController().commitNewDisplayItems();
615 652
(...skipping 10 matching lines...) Expand all
626 TestDisplayItem(content1, backgroundDrawingType), 663 TestDisplayItem(content1, backgroundDrawingType),
627 TestDisplayItem(content1, foregroundDrawingType), 664 TestDisplayItem(content1, foregroundDrawingType),
628 TestDisplayItem(container1, foregroundDrawingType), 665 TestDisplayItem(container1, foregroundDrawingType),
629 TestDisplayItem(container1, DisplayItem::EndSubsequence)); 666 TestDisplayItem(container1, DisplayItem::EndSubsequence));
630 667
631 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 668 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
632 DisplayItemClient::endShouldKeepAliveAllClients(); 669 DisplayItemClient::endShouldKeepAliveAllClients();
633 #endif 670 #endif
634 } 671 }
635 672
636 TEST_F(PaintControllerTest, OutOfOrderNoCrash) 673 TEST_F_OR_P(PaintControllerTest, OutOfOrderNoCrash)
637 { 674 {
638 FakeDisplayItemClient client("client"); 675 FakeDisplayItemClient client("client");
639 GraphicsContext context(getPaintController()); 676 GraphicsContext context(getPaintController());
640 677
641 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; 678 const DisplayItem::Type type1 = DisplayItem::DrawingFirst;
642 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1); 679 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1);
643 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2); 680 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2);
644 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3); 681 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3);
645 682
646 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 683 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
647 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 684 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
648 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 685 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
649 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 686 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
650 687
651 getPaintController().commitNewDisplayItems(); 688 getPaintController().commitNewDisplayItems();
652 689
653 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 690 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
654 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 691 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
655 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 692 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
656 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 693 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
657 694
658 getPaintController().commitNewDisplayItems(); 695 getPaintController().commitNewDisplayItems();
659 } 696 }
660 697
661 TEST_F(PaintControllerTest, CachedNestedSubsequenceUpdate) 698 TEST_F_OR_P(PaintControllerTest, CachedNestedSubsequenceUpdate)
662 { 699 {
663 FakeDisplayItemClient container1("container1"); 700 FakeDisplayItemClient container1("container1");
664 FakeDisplayItemClient content1("content1"); 701 FakeDisplayItemClient content1("content1");
665 FakeDisplayItemClient container2("container2"); 702 FakeDisplayItemClient container2("container2");
666 FakeDisplayItemClient content2("content2"); 703 FakeDisplayItemClient content2("content2");
667 GraphicsContext context(getPaintController()); 704 GraphicsContext context(getPaintController());
668 705
669 { 706 {
670 SubsequenceRecorder r(context, container1); 707 SubsequenceRecorder r(context, container1);
671 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 708 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. 753 // Content2 now outputs foreground only.
717 { 754 {
718 SubsequenceRecorder r(context, content2); 755 SubsequenceRecorder r(context, content2);
719 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); 756 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200));
720 } 757 }
721 // Repaint container1 with foreground only. 758 // Repaint container1 with foreground only.
722 { 759 {
723 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); 760 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1));
724 SubsequenceRecorder r(context, container1); 761 SubsequenceRecorder r(context, container1);
725 // Use cached subsequence of content1. 762 // Use cached subsequence of content1.
726 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, content1)); 763 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) {
764 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1));
chrishtr 2016/07/28 18:14:42 Ditto.
Xianzhu 2016/07/28 18:40:09 Done.
765 SubsequenceRecorder r(context, content1);
766 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
767 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
768 } else {
769 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1));
770 }
727 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 771 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
728 } 772 }
729 773
730 EXPECT_EQ(4, numCachedNewItems()); 774 EXPECT_EQ(4, numCachedNewItems());
731 #if DCHECK_IS_ON() 775 #if DCHECK_IS_ON()
732 EXPECT_EQ(1, numSequentialMatches()); 776 EXPECT_EQ(1, numSequentialMatches());
733 EXPECT_EQ(0, numOutOfOrderMatches()); 777 EXPECT_EQ(0, numOutOfOrderMatches());
734 EXPECT_EQ(2, numIndexedItems()); 778 EXPECT_EQ(2, numIndexedItems());
735 #endif 779 #endif
736 780
(...skipping 10 matching lines...) Expand all
747 TestDisplayItem(content1, foregroundDrawingType), 791 TestDisplayItem(content1, foregroundDrawingType),
748 TestDisplayItem(content1, DisplayItem::EndSubsequence), 792 TestDisplayItem(content1, DisplayItem::EndSubsequence),
749 TestDisplayItem(container1, foregroundDrawingType), 793 TestDisplayItem(container1, foregroundDrawingType),
750 TestDisplayItem(container1, DisplayItem::EndSubsequence)); 794 TestDisplayItem(container1, DisplayItem::EndSubsequence));
751 795
752 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 796 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
753 DisplayItemClient::endShouldKeepAliveAllClients(); 797 DisplayItemClient::endShouldKeepAliveAllClients();
754 #endif 798 #endif
755 } 799 }
756 800
757 TEST_F(PaintControllerTest, SkipCache) 801 TEST_F_OR_P(PaintControllerTest, SkipCache)
758 { 802 {
759 FakeDisplayItemClient multicol("multicol"); 803 FakeDisplayItemClient multicol("multicol");
760 FakeDisplayItemClient content("content"); 804 FakeDisplayItemClient content("content");
761 GraphicsContext context(getPaintController()); 805 GraphicsContext context(getPaintController());
762 806
763 FloatRect rect1(100, 100, 50, 50); 807 FloatRect rect1(100, 100, 50, 50);
764 FloatRect rect2(150, 100, 50, 50); 808 FloatRect rect2(150, 100, 50, 50);
765 FloatRect rect3(200, 100, 50, 50); 809 FloatRect rect3(200, 100, 50, 50);
766 810
767 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 811 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), 865 TestDisplayItem(multicol, backgroundDrawingType),
822 TestDisplayItem(content, foregroundDrawingType), 866 TestDisplayItem(content, foregroundDrawingType),
823 TestDisplayItem(content, foregroundDrawingType), 867 TestDisplayItem(content, foregroundDrawingType),
824 TestDisplayItem(content, foregroundDrawingType)); 868 TestDisplayItem(content, foregroundDrawingType));
825 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); 869 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()); 870 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture());
827 871
828 getPaintController().commitNewDisplayItems(); 872 getPaintController().commitNewDisplayItems();
829 } 873 }
830 874
831 TEST_F(PaintControllerTest, PartialSkipCache) 875 TEST_F_OR_P(PaintControllerTest, PartialSkipCache)
832 { 876 {
833 FakeDisplayItemClient content("content"); 877 FakeDisplayItemClient content("content");
834 GraphicsContext context(getPaintController()); 878 GraphicsContext context(getPaintController());
835 879
836 FloatRect rect1(100, 100, 50, 50); 880 FloatRect rect1(100, 100, 50, 50);
837 FloatRect rect2(150, 100, 50, 50); 881 FloatRect rect2(150, 100, 50, 50);
838 FloatRect rect3(200, 100, 50, 50); 882 FloatRect rect3(200, 100, 50, 50);
839 883
840 drawRect(context, content, backgroundDrawingType, rect1); 884 drawRect(context, content, backgroundDrawingType, rect1);
841 getPaintController().beginSkippingCache(); 885 getPaintController().beginSkippingCache();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 920
877 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 921 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
878 TestDisplayItem(content, backgroundDrawingType), 922 TestDisplayItem(content, backgroundDrawingType),
879 TestDisplayItem(content, foregroundDrawingType), 923 TestDisplayItem(content, foregroundDrawingType),
880 TestDisplayItem(content, foregroundDrawingType)); 924 TestDisplayItem(content, foregroundDrawingType));
881 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); 925 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()); 926 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()); 927 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture());
884 } 928 }
885 929
886 TEST_F(PaintControllerTest, OptimizeNoopPairs) 930 TEST_F_OR_P(PaintControllerTest, OptimizeNoopPairs)
887 { 931 {
888 FakeDisplayItemClient first("first"); 932 FakeDisplayItemClient first("first");
889 FakeDisplayItemClient second("second"); 933 FakeDisplayItemClient second("second");
890 FakeDisplayItemClient third("third"); 934 FakeDisplayItemClient third("third");
891 935
892 GraphicsContext context(getPaintController()); 936 GraphicsContext context(getPaintController());
893 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 937 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
894 { 938 {
895 ClipPathRecorder clipRecorder(context, second, Path()); 939 ClipPathRecorder clipRecorder(context, second, Path());
896 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 940 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
897 } 941 }
898 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 942 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
899 943
900 getPaintController().commitNewDisplayItems(); 944 getPaintController().commitNewDisplayItems();
901 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 5, 945 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 5,
902 TestDisplayItem(first, backgroundDrawingType), 946 TestDisplayItem(first, backgroundDrawingType),
903 TestDisplayItem(second, DisplayItem::BeginClipPath), 947 TestDisplayItem(second, DisplayItem::BeginClipPath),
904 TestDisplayItem(second, backgroundDrawingType), 948 TestDisplayItem(second, backgroundDrawingType),
905 TestDisplayItem(second, DisplayItem::EndClipPath), 949 TestDisplayItem(second, DisplayItem::EndClipPath),
906 TestDisplayItem(third, backgroundDrawingType)); 950 TestDisplayItem(third, backgroundDrawingType));
907 951
908 second.setDisplayItemsUncached();
chrishtr 2016/07/28 18:14:42 These few lines you removed were incorrect?
Xianzhu 2016/07/28 18:40:09 This invalidation is not needed. Removing it can e
909 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 952 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
910 { 953 {
911 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) ); 954 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) );
912 // Do not draw anything for second. 955 // Do not draw anything for second.
913 } 956 }
914 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 957 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
915 getPaintController().commitNewDisplayItems(); 958 getPaintController().commitNewDisplayItems();
916 959
917 // Empty clips should have been optimized out. 960 // Empty clips should have been optimized out.
918 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 961 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
(...skipping 11 matching lines...) Expand all
930 } 973 }
931 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 974 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
932 getPaintController().commitNewDisplayItems(); 975 getPaintController().commitNewDisplayItems();
933 976
934 // Empty clips should have been optimized out. 977 // Empty clips should have been optimized out.
935 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, 978 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2,
936 TestDisplayItem(first, backgroundDrawingType), 979 TestDisplayItem(first, backgroundDrawingType),
937 TestDisplayItem(third, backgroundDrawingType)); 980 TestDisplayItem(third, backgroundDrawingType));
938 } 981 }
939 982
940 TEST_F(PaintControllerTest, SmallPaintControllerHasOnePaintChunk) 983 TEST_F_OR_P(PaintControllerTest, SmallPaintControllerHasOnePaintChunk)
941 { 984 {
942 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 985 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
943 FakeDisplayItemClient client("test client"); 986 FakeDisplayItemClient client("test client");
944 987
945 GraphicsContext context(getPaintController()); 988 GraphicsContext context(getPaintController());
946 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 989 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
947 990
948 getPaintController().commitNewDisplayItems(); 991 getPaintController().commitNewDisplayItems();
949 const auto& paintChunks = getPaintController().paintChunks(); 992 const auto& paintChunks = getPaintController().paintChunks();
950 ASSERT_EQ(1u, paintChunks.size()); 993 ASSERT_EQ(1u, paintChunks.size());
951 EXPECT_EQ(0u, paintChunks[0].beginIndex); 994 EXPECT_EQ(0u, paintChunks[0].beginIndex);
952 EXPECT_EQ(1u, paintChunks[0].endIndex); 995 EXPECT_EQ(1u, paintChunks[0].endIndex);
953 } 996 }
954 997
955 #define EXPECT_RECT_EQ(expected, actual) \ 998 #define EXPECT_RECT_EQ(expected, actual) \
956 do { \ 999 do { \
957 const IntRect& actualRect = actual; \ 1000 const IntRect& actualRect = actual; \
958 EXPECT_EQ(expected.x(), actualRect.x()); \ 1001 EXPECT_EQ(expected.x(), actualRect.x()); \
959 EXPECT_EQ(expected.y(), actualRect.y()); \ 1002 EXPECT_EQ(expected.y(), actualRect.y()); \
960 EXPECT_EQ(expected.width(), actualRect.width()); \ 1003 EXPECT_EQ(expected.width(), actualRect.width()); \
961 EXPECT_EQ(expected.height(), actualRect.height()); \ 1004 EXPECT_EQ(expected.height(), actualRect.height()); \
962 } while (false) 1005 } while (false)
963 1006
964 TEST_F(PaintControllerTest, PaintArtifactWithVisualRects) 1007 TEST_F_OR_P(PaintControllerTest, PaintArtifactWithVisualRects)
965 { 1008 {
966 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1009 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
967 1010
968 GraphicsContext context(getPaintController()); 1011 GraphicsContext context(getPaintController());
969 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 1012 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
970 1013
971 getPaintController().commitNewDisplayItems(LayoutSize(20, 30)); 1014 getPaintController().commitNewDisplayItems(LayoutSize(20, 30));
972 const auto& paintArtifact = getPaintController().paintArtifact(); 1015 const auto& paintArtifact = getPaintController().paintArtifact();
973 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size()); 1016 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size());
974 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); 1017 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0));
(...skipping 11 matching lines...) Expand all
986 path.lineTo(50, 50); 1029 path.lineTo(50, 50);
987 path.lineTo(100, 100); 1030 path.lineTo(100, 100);
988 path.lineTo(100, 0); 1031 path.lineTo(100, 0);
989 path.close(); 1032 path.close();
990 SkPaint paint; 1033 SkPaint paint;
991 paint.setAntiAlias(true); 1034 paint.setAntiAlias(true);
992 for (unsigned i = 0; i < count; i++) 1035 for (unsigned i = 0; i < count; i++)
993 context.drawPath(path, paint); 1036 context.drawPath(path, paint);
994 } 1037 }
995 1038
996 TEST_F(PaintControllerTest, IsSuitableForGpuRasterizationSinglePath) 1039 TEST_F_OR_P(PaintControllerTest, IsSuitableForGpuRasterizationSinglePath)
997 { 1040 {
998 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1041 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
999 GraphicsContext context(getPaintController()); 1042 GraphicsContext context(getPaintController());
1000 drawPath(context, client, backgroundDrawingType, 1); 1043 drawPath(context, client, backgroundDrawingType, 1);
1001 getPaintController().commitNewDisplayItems(LayoutSize()); 1044 getPaintController().commitNewDisplayItems(LayoutSize());
1002 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on()); 1045 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on());
1003 } 1046 }
1004 1047
1005 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hs) 1048 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPaths)
1006 { 1049 {
1007 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1050 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1008 GraphicsContext context(getPaintController()); 1051 GraphicsContext context(getPaintController());
1009 1052
1010 drawPath(context, client, backgroundDrawingType, 50); 1053 drawPath(context, client, backgroundDrawingType, 50);
1011 getPaintController().commitNewDisplayItems(LayoutSize()); 1054 getPaintController().commitNewDisplayItems(LayoutSize());
1012 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1055 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1013 } 1056 }
1014 1057
1015 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicturesSing lePathEach) 1058 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicture sSinglePathEach)
1016 { 1059 {
1017 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1060 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1018 GraphicsContext context(getPaintController()); 1061 GraphicsContext context(getPaintController());
1019 getPaintController().beginSkippingCache(); 1062 getPaintController().beginSkippingCache();
1020 1063
1021 for (int i = 0; i < 50; ++i) 1064 for (int i = 0; i < 50; ++i)
1022 drawPath(context, client, backgroundDrawingType, 50); 1065 drawPath(context, client, backgroundDrawingType, 50);
1023 1066
1024 getPaintController().endSkippingCache(); 1067 getPaintController().endSkippingCache();
1025 getPaintController().commitNewDisplayItems(LayoutSize()); 1068 getPaintController().commitNewDisplayItems(LayoutSize());
1026 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1069 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1027 } 1070 }
1028 1071
1029 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsTwoPaints) 1072 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsTwoPaints)
1030 { 1073 {
1031 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1074 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1032 1075
1033 { 1076 {
1034 GraphicsContext context(getPaintController()); 1077 GraphicsContext context(getPaintController());
1035 drawPath(context, client, backgroundDrawingType, 50); 1078 drawPath(context, client, backgroundDrawingType, 50);
1036 getPaintController().commitNewDisplayItems(LayoutSize()); 1079 getPaintController().commitNewDisplayItems(LayoutSize());
1037 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1080 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1038 } 1081 }
1039 1082
1040 client.setDisplayItemsUncached(); 1083 client.setDisplayItemsUncached();
1041 1084
1042 { 1085 {
1043 GraphicsContext context(getPaintController()); 1086 GraphicsContext context(getPaintController());
1044 drawPath(context, client, backgroundDrawingType, 50); 1087 drawPath(context, client, backgroundDrawingType, 50);
1045 getPaintController().commitNewDisplayItems(LayoutSize()); 1088 getPaintController().commitNewDisplayItems(LayoutSize());
1046 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1089 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1047 } 1090 }
1048 } 1091 }
1049 1092
1050 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsCached) 1093 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsCached)
1051 { 1094 {
1052 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1095 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1053 1096
1054 { 1097 {
1055 GraphicsContext context(getPaintController()); 1098 GraphicsContext context(getPaintController());
1056 drawPath(context, client, backgroundDrawingType, 50); 1099 drawPath(context, client, backgroundDrawingType, 50);
1057 getPaintController().commitNewDisplayItems(LayoutSize()); 1100 getPaintController().commitNewDisplayItems(LayoutSize());
1058 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1101 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1059 } 1102 }
1060 1103
1061 { 1104 {
1062 GraphicsContext context(getPaintController()); 1105 GraphicsContext context(getPaintController());
1063 drawPath(context, client, backgroundDrawingType, 50); 1106 drawPath(context, client, backgroundDrawingType, 50);
1064 getPaintController().commitNewDisplayItems(LayoutSize()); 1107 getPaintController().commitNewDisplayItems(LayoutSize());
1065 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1108 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1066 } 1109 }
1067 } 1110 }
1068 1111
1069 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsCachedSubsequence) 1112 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationSinglePictureMan yPathsCachedSubsequence)
1070 { 1113 {
1071 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1114 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1072 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100)); 1115 FakeDisplayItemClient container("container", LayoutRect(0, 0, 200, 100));
1073 1116
1074 GraphicsContext context(getPaintController()); 1117 GraphicsContext context(getPaintController());
1075 { 1118 {
1076 SubsequenceRecorder subsequenceRecorder(context, container); 1119 SubsequenceRecorder subsequenceRecorder(context, container);
1077 drawPath(context, client, backgroundDrawingType, 50); 1120 drawPath(context, client, backgroundDrawingType, 50);
1078 } 1121 }
1079 getPaintController().commitNewDisplayItems(LayoutSize()); 1122 getPaintController().commitNewDisplayItems(LayoutSize());
1080 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1123 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1081 1124
1082 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer)); 1125 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer));
1083 getPaintController().commitNewDisplayItems(LayoutSize()); 1126 getPaintController().commitNewDisplayItems(LayoutSize());
1084 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 1127 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
1085 1128
1086 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 1129 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
1087 DisplayItemClient::endShouldKeepAliveAllClients(); 1130 DisplayItemClient::endShouldKeepAliveAllClients();
1088 #endif 1131 #endif
1089 } 1132 }
1090 1133
1091 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969). 1134 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969).
1092 TEST_F(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcaveClip Path) 1135 TEST_F_OR_P(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcav eClipPath)
1093 { 1136 {
1094 Path path; 1137 Path path;
1095 path.addLineTo(FloatPoint(50, 50)); 1138 path.addLineTo(FloatPoint(50, 50));
1096 path.addLineTo(FloatPoint(100, 0)); 1139 path.addLineTo(FloatPoint(100, 0));
1097 path.addLineTo(FloatPoint(50, 100)); 1140 path.addLineTo(FloatPoint(50, 100));
1098 path.closeSubpath(); 1141 path.closeSubpath();
1099 1142
1100 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1143 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1101 GraphicsContext context(getPaintController()); 1144 GraphicsContext context(getPaintController());
1102 1145
1103 // Run twice for empty/non-empty m_currentPaintArtifact coverage. 1146 // Run twice for empty/non-empty m_currentPaintArtifact coverage.
1104 for (int i = 0; i < 2; ++i) { 1147 for (int i = 0; i < 2; ++i) {
1105 for (int j = 0; j < 50; ++j) 1148 for (int j = 0; j < 50; ++j)
1106 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); 1149 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path);
1107 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 1150 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
1108 for (int j = 0; j < 50; ++j) 1151 for (int j = 0; j < 50; ++j)
1109 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; 1152 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ;
1110 getPaintController().commitNewDisplayItems(LayoutSize()); 1153 getPaintController().commitNewDisplayItems(LayoutSize());
1111 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 1154 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
1112 } 1155 }
1113 } 1156 }
1114 1157
1158 #if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
chrishtr 2016/07/28 18:14:42 Why the if for android? Please add a commment.
Xianzhu 2016/07/28 18:40:09 Done.
1159
1160 class PaintControllerUnderInvalidationTest : public PaintControllerTestBase {
1161 protected:
1162 void SetUp() override
1163 {
1164 PaintControllerTestBase::SetUp();
1165 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEnabled (true);
1166 }
1167
1168 void testChangeDrawing()
1169 {
1170 FakeDisplayItemClient first("first");
1171 GraphicsContext context(getPaintController());
1172
1173 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1174 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1175 getPaintController().commitNewDisplayItems();
1176 drawRect(context, first, backgroundDrawingType, FloatRect(200, 200, 300, 300));
1177 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1178 getPaintController().commitNewDisplayItems();
1179 }
1180
1181 void testMoreDrawing()
1182 {
1183 FakeDisplayItemClient first("first");
1184 GraphicsContext context(getPaintController());
1185
1186 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1187 getPaintController().commitNewDisplayItems();
1188 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1189 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1190 getPaintController().commitNewDisplayItems();
1191 }
1192
1193 void testLessDrawing()
1194 {
1195 FakeDisplayItemClient first("first");
1196 GraphicsContext context(getPaintController());
1197
1198 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1199 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1200 getPaintController().commitNewDisplayItems();
1201 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1202 getPaintController().commitNewDisplayItems();
1203 }
1204
1205 void testNoopPairsInSubsequence()
1206 {
1207 FakeDisplayItemClient container("container");
1208 GraphicsContext context(getPaintController());
1209
1210 {
1211 SubsequenceRecorder r(context, container);
1212 drawRect(context, container, backgroundDrawingType, FloatRect(100, 1 00, 100, 100));
1213 }
1214 getPaintController().commitNewDisplayItems();
1215
1216 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container));
1217 {
1218 // Generate some no-op pairs which should not affect under-invalidat ion checking.
1219 ClipRecorder r1(context, container, clipType, IntRect(1, 1, 9, 9));
1220 ClipRecorder r2(context, container, clipType, IntRect(1, 1, 2, 2));
1221 ClipRecorder r3(context, container, clipType, IntRect(1, 1, 3, 3));
1222 ClipPathRecorder r4(context, container, Path());
1223 }
1224 {
1225 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1226 SubsequenceRecorder r(context, container);
1227 drawRect(context, container, backgroundDrawingType, FloatRect(100, 1 00, 100, 100));
1228 }
1229 getPaintController().commitNewDisplayItems();
1230
1231 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
1232 DisplayItemClient::endShouldKeepAliveAllClients();
1233 #endif
1234 }
1235
1236 void testChangeDrawingInSubsequence()
1237 {
1238 FakeDisplayItemClient first("first");
1239 GraphicsContext context(getPaintController());
1240 {
1241 SubsequenceRecorder r(context, first);
1242 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1243 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1244 }
1245 getPaintController().commitNewDisplayItems();
1246 {
1247 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1248 SubsequenceRecorder r(context, first);
1249 drawRect(context, first, backgroundDrawingType, FloatRect(200, 200, 300, 300));
1250 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1251 }
1252 getPaintController().commitNewDisplayItems();
1253 }
1254
1255 void testMoreDrawingInSubsequence()
1256 {
1257 FakeDisplayItemClient first("first");
1258 GraphicsContext context(getPaintController());
1259
1260 {
1261 SubsequenceRecorder r(context, first);
1262 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1263 }
1264 getPaintController().commitNewDisplayItems();
1265
1266 {
1267 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1268 SubsequenceRecorder r(context, first);
1269 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1270 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1271 }
1272 getPaintController().commitNewDisplayItems();
1273 }
1274
1275 void testLessDrawingInSubsequence()
1276 {
1277 FakeDisplayItemClient first("first");
1278 GraphicsContext context(getPaintController());
1279
1280 {
1281 SubsequenceRecorder r(context, first);
1282 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1283 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300));
1284 }
1285 getPaintController().commitNewDisplayItems();
1286
1287 {
1288 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, first));
1289 SubsequenceRecorder r(context, first);
1290 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300));
1291 }
1292 getPaintController().commitNewDisplayItems();
1293 }
1294
1295 void testChangeNonCacheableInSubsequence()
1296 {
1297 FakeDisplayItemClient container("container");
1298 FakeDisplayItemClient content("content");
1299 GraphicsContext context(getPaintController());
1300
1301 {
1302 SubsequenceRecorder r(context, container);
1303 {
1304 ClipPathRecorder clipPathRecorder(context, container, Path());
1305 }
1306 ClipRecorder clip(context, container, clipType, IntRect(1, 1, 9, 9)) ;
1307 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1308 }
1309 getPaintController().commitNewDisplayItems();
1310
1311 {
1312 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1313 SubsequenceRecorder r(context, container);
1314 {
1315 ClipPathRecorder clipPathRecorder(context, container, Path());
1316 }
1317 ClipRecorder clip(context, container, clipType, IntRect(1, 1, 30, 30 ));
1318 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1319 }
1320 getPaintController().commitNewDisplayItems();
1321 }
1322
1323 void testInvalidationInSubsequence()
1324 {
1325 FakeDisplayItemClient container("container");
1326 FakeDisplayItemClient content("content");
1327 GraphicsContext context(getPaintController());
1328
1329 {
1330 SubsequenceRecorder r(context, container);
1331 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1332 }
1333 getPaintController().commitNewDisplayItems();
1334
1335 content.setDisplayItemsUncached();
1336 // Leave container not invalidated.
1337 {
1338 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, container));
1339 SubsequenceRecorder r(context, content);
1340 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100 , 300, 300));
1341 }
1342 getPaintController().commitNewDisplayItems();
1343 }
1344
1345 // TODO(wangxianzhu): Add under-invalidation checking test in case of compos iting item folding.
1346 };
1347
1348 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawing)
1349 {
1350 EXPECT_DEATH(testChangeDrawing(), "under-invalidation: display item changed\ \n.*first.*DrawingPaintPhaseBlockBackground");
1351 }
1352
1353 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawing)
1354 {
1355 EXPECT_DEATH(testMoreDrawing(), "\"first\":\"DrawingPaintPhaseForeground\" n ot found in current display item list");
1356 }
1357
1358 TEST_F(PaintControllerUnderInvalidationTest, LessDrawing)
1359 {
1360 // This should not die.
chrishtr 2016/07/28 18:14:42 Shouldn't less drawing for the same client ideally
Xianzhu 2016/07/28 18:40:09 Added comments: // We don't detect under-inva
1361 testLessDrawing();
1362 }
1363
1364 TEST_F(PaintControllerUnderInvalidationTest, NoopPairsInSubsequence)
1365 {
1366 // This should not die.
1367 testNoopPairsInSubsequence();
1368 }
1369
1370 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawingInSubsequence)
1371 {
1372 EXPECT_DEATH(testChangeDrawingInSubsequence(), "\"\\(In CachedSubsequence of first\\)\" under-invalidation: display item changed\\n.*first.*DrawingPaintPhas eBlockBackground");
1373 }
1374
1375 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawingInSubsequence)
1376 {
1377 EXPECT_DEATH(testMoreDrawingInSubsequence(), "\"\\(In CachedSubsequence of f irst\\)\" under-invalidation: display item changed\\n.*first.*DrawingPaintPhaseF oreground.*\\n.*first.*EndSubsequence");
1378 }
1379
1380 TEST_F(PaintControllerUnderInvalidationTest, LessDrawingInSubsequence)
1381 {
1382 EXPECT_DEATH(testLessDrawingInSubsequence(), "\"\\(In CachedSubsequence of f irst\\)\" under-invalidation: display item changed\\n.*first.*EndSubsequence.*\\ n.*first.*DrawingPaintPhaseForeground");
1383 }
1384
1385 TEST_F(PaintControllerUnderInvalidationTest, ChangeNonCacheableInSubsequence)
1386 {
1387 EXPECT_DEATH(testChangeNonCacheableInSubsequence(), "\"\\(In CachedSubsequen ce of container\\)\" under-invalidation: display item changed\\n.*container.*Cli pBoxPaintPhaseBlockBackground");
1388 }
1389
1390 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence)
1391 {
1392 EXPECT_DEATH(testInvalidationInSubsequence(), "\"\\(In CachedSubsequence of container\\)\" under-invalidation of PaintLayer: invalidated in cached subsequen ce");
1393 }
1394
1395 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1396
1115 } // namespace blink 1397 } // 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