| OLD | NEW |
| 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
| 7 | 7 |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/paint/CachedDisplayItem.h" | 10 #include "platform/graphics/paint/CachedDisplayItem.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 TestDisplayItemClient container1("container1"); | 456 TestDisplayItemClient container1("container1"); |
| 457 TestDisplayItemClient content1("content1"); | 457 TestDisplayItemClient content1("content1"); |
| 458 TestDisplayItemClient container2("container2"); | 458 TestDisplayItemClient container2("container2"); |
| 459 TestDisplayItemClient content2("content2"); | 459 TestDisplayItemClient content2("content2"); |
| 460 GraphicsContext context(&displayItemList()); | 460 GraphicsContext context(&displayItemList()); |
| 461 const int backgroundPaintPhase = backgroundDrawingType - DisplayItem::Drawin
gPaintPhaseFirst; | 461 const int backgroundPaintPhase = backgroundDrawingType - DisplayItem::Drawin
gPaintPhaseFirst; |
| 462 const int foregroundPaintPhase = foregroundDrawingType - DisplayItem::Drawin
gPaintPhaseFirst; | 462 const int foregroundPaintPhase = foregroundDrawingType - DisplayItem::Drawin
gPaintPhaseFirst; |
| 463 | 463 |
| 464 { | 464 { |
| 465 SubtreeRecorder r(context, container1, backgroundPaintPhase); | 465 SubtreeRecorder r(context, container1, backgroundPaintPhase); |
| 466 EXPECT_FALSE(r.canUseCache()); | |
| 467 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); | 466 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 468 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5
0, 200)); | 467 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5
0, 200)); |
| 469 } | 468 } |
| 470 { | 469 { |
| 471 SubtreeRecorder r(context, container1, foregroundPaintPhase); | 470 SubtreeRecorder r(context, container1, foregroundPaintPhase); |
| 472 EXPECT_FALSE(r.canUseCache()); | |
| 473 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5
0, 200)); | 471 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5
0, 200)); |
| 474 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); | 472 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 475 } | 473 } |
| 476 { | 474 { |
| 477 SubtreeRecorder r(context, container2, backgroundPaintPhase); | 475 SubtreeRecorder r(context, container2, backgroundPaintPhase); |
| 478 EXPECT_FALSE(r.canUseCache()); | |
| 479 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); | 476 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 480 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 477 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 481 } | 478 } |
| 482 { | 479 { |
| 483 SubtreeRecorder r(context, container2, foregroundPaintPhase); | 480 SubtreeRecorder r(context, container2, foregroundPaintPhase); |
| 484 EXPECT_FALSE(r.canUseCache()); | |
| 485 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 481 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 486 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200,
100, 100)); | 482 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 487 } | 483 } |
| 488 displayItemList().commitNewDisplayItems(); | 484 displayItemList().commitNewDisplayItems(); |
| 489 | 485 |
| 490 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 16, | 486 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 16, |
| 491 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundPaintPhase)), | 487 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundPaintPhase)), |
| 492 TestDisplayItem(container1, backgroundDrawingType), | 488 TestDisplayItem(container1, backgroundDrawingType), |
| 493 TestDisplayItem(content1, backgroundDrawingType), | 489 TestDisplayItem(content1, backgroundDrawingType), |
| 494 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(back
groundPaintPhase)), | 490 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(back
groundPaintPhase)), |
| 495 | 491 |
| 496 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(fo
regroundPaintPhase)), | 492 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(fo
regroundPaintPhase)), |
| 497 TestDisplayItem(content1, foregroundDrawingType), | 493 TestDisplayItem(content1, foregroundDrawingType), |
| 498 TestDisplayItem(container1, foregroundDrawingType), | 494 TestDisplayItem(container1, foregroundDrawingType), |
| 499 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(fore
groundPaintPhase)), | 495 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(fore
groundPaintPhase)), |
| 500 | 496 |
| 501 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundPaintPhase)), | 497 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundPaintPhase)), |
| 502 TestDisplayItem(container2, backgroundDrawingType), | 498 TestDisplayItem(container2, backgroundDrawingType), |
| 503 TestDisplayItem(content2, backgroundDrawingType), | 499 TestDisplayItem(content2, backgroundDrawingType), |
| 504 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(back
groundPaintPhase)), | 500 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(back
groundPaintPhase)), |
| 505 | 501 |
| 506 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(fo
regroundPaintPhase)), | 502 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(fo
regroundPaintPhase)), |
| 507 TestDisplayItem(content2, foregroundDrawingType), | 503 TestDisplayItem(content2, foregroundDrawingType), |
| 508 TestDisplayItem(container2, foregroundDrawingType), | 504 TestDisplayItem(container2, foregroundDrawingType), |
| 509 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(fore
groundPaintPhase))); | 505 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(fore
groundPaintPhase))); |
| 510 | 506 |
| 511 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. | 507 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
| 512 displayItemList().createAndAppend<CachedDisplayItem>(container2, DisplayItem
::paintPhaseToCachedSubtreeType(backgroundPaintPhase)); | 508 EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container2,
backgroundPaintPhase)); |
| 513 EXPECT_EQ((size_t)1, newPaintListBeforeUpdate().size()); | 509 EXPECT_EQ((size_t)1, newPaintListBeforeUpdate().size()); |
| 514 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); | 510 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
| 515 displayItemList().createAndAppend<CachedDisplayItem>(container2, DisplayItem
::paintPhaseToCachedSubtreeType(foregroundPaintPhase)); | 511 EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container2,
foregroundPaintPhase)); |
| 516 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); | 512 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); |
| 517 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); | 513 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
| 518 | 514 |
| 519 displayItemList().createAndAppend<CachedDisplayItem>(container1, DisplayItem
::paintPhaseToCachedSubtreeType(backgroundPaintPhase)); | 515 EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container1,
backgroundPaintPhase)); |
| 520 EXPECT_EQ((size_t)3, newPaintListBeforeUpdate().size()); | 516 EXPECT_EQ((size_t)3, newPaintListBeforeUpdate().size()); |
| 521 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); | 517 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
| 522 displayItemList().createAndAppend<CachedDisplayItem>(container1, DisplayItem
::paintPhaseToCachedSubtreeType(foregroundPaintPhase)); | 518 EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container1,
foregroundPaintPhase)); |
| 523 EXPECT_EQ((size_t)4, newPaintListBeforeUpdate().size()); | 519 EXPECT_EQ((size_t)4, newPaintListBeforeUpdate().size()); |
| 524 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); | 520 EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
| 525 displayItemList().commitNewDisplayItems(); | 521 displayItemList().commitNewDisplayItems(); |
| 526 | 522 |
| 527 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 16, | 523 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 16, |
| 528 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundDrawingType)), | 524 TestDisplayItem(container2, DisplayItem::paintPhaseToBeginSubtreeType(ba
ckgroundDrawingType)), |
| 529 TestDisplayItem(container2, backgroundDrawingType), | 525 TestDisplayItem(container2, backgroundDrawingType), |
| 530 TestDisplayItem(content2, backgroundDrawingType), | 526 TestDisplayItem(content2, backgroundDrawingType), |
| 531 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(back
groundDrawingType)), | 527 TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(back
groundDrawingType)), |
| 532 | 528 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 674 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 679 displayItemList().commitNewDisplayItems(); | 675 displayItemList().commitNewDisplayItems(); |
| 680 | 676 |
| 681 // Empty clips should have been optimized out. | 677 // Empty clips should have been optimized out. |
| 682 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, | 678 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, |
| 683 TestDisplayItem(first, backgroundDrawingType), | 679 TestDisplayItem(first, backgroundDrawingType), |
| 684 TestDisplayItem(third, backgroundDrawingType)); | 680 TestDisplayItem(third, backgroundDrawingType)); |
| 685 } | 681 } |
| 686 | 682 |
| 687 } // namespace blink | 683 } // namespace blink |
| OLD | NEW |