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 | 6 |
7 #include "core/paint/LayerClipRecorder.h" | 7 #include "core/paint/LayerClipRecorder.h" |
8 #include "core/paint/LayerPainter.h" | 8 #include "core/paint/LayerPainter.h" |
9 #include "core/paint/RenderDrawingRecorder.h" | 9 #include "core/paint/RenderDrawingRecorder.h" |
10 #include "core/rendering/RenderView.h" | 10 #include "core/rendering/RenderView.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 RenderingTest::SetUp(); | 34 RenderingTest::SetUp(); |
35 enableCompositing(); | 35 enableCompositing(); |
36 | 36 |
37 m_renderView = document().view()->renderView(); | 37 m_renderView = document().view()->renderView(); |
38 ASSERT_TRUE(m_renderView); | 38 ASSERT_TRUE(m_renderView); |
39 } | 39 } |
40 | 40 |
41 virtual void TearDown() override | 41 virtual void TearDown() override |
42 { | 42 { |
43 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); | 43 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); |
44 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false); | |
45 } | 44 } |
46 | 45 |
47 RenderView* m_renderView; | 46 RenderView* m_renderView; |
48 }; | 47 }; |
49 | 48 |
50 class TestDisplayItem : public DisplayItem { | 49 class TestDisplayItem : public DisplayItem { |
51 public: | 50 public: |
52 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } | 51 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } |
53 | 52 |
54 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } | 53 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 | 438 |
440 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 439 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
441 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), | 440 TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackgr ound), |
442 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), | 441 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), |
443 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), | 442 TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackg round), |
444 TestDisplayItem(secondRenderer, DisplayItem::EndClip)); | 443 TestDisplayItem(secondRenderer, DisplayItem::EndClip)); |
445 } | 444 } |
446 | 445 |
447 TEST_F(ViewDisplayListTest, CachedDisplayItems) | 446 TEST_F(ViewDisplayListTest, CachedDisplayItems) |
448 { | 447 { |
449 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); | |
450 | |
451 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 448 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
452 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); | 449 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer()); |
453 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); | 450 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer()); |
454 GraphicsContext context(nullptr, &rootDisplayItemList()); | 451 GraphicsContext context(nullptr, &rootDisplayItemList()); |
455 | 452 |
456 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 453 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
457 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); | 454 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); |
458 rootDisplayItemList().endNewPaints(); | 455 rootDisplayItemList().endNewPaints(); |
459 | 456 |
460 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 457 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 document().view()->updateLayoutAndStyleForPainting(); | 509 document().view()->updateLayoutAndStyleForPainting(); |
513 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); | 510 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases); |
514 rootDisplayItemList().endNewPaints(); | 511 rootDisplayItemList().endNewPaints(); |
515 | 512 |
516 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 513 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
517 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), | 514 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und), |
518 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground), | 515 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground), |
519 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret)); | 516 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret)); |
520 } | 517 } |
521 | 518 |
519 TEST_F(ViewDisplayListTest, ComplexUpdateSwapOrder) | |
520 { | |
521 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>" | |
522 "<div id='container2'><div id='content2'></div></div>"); | |
523 RenderObject* container1 = document().body()->firstChild()->renderer(); | |
524 RenderObject* content1 = document().body()->firstChild()->firstChild()->rend erer(); | |
525 RenderObject* container2 = document().body()->firstChild()->nextSibling()->r enderer(); | |
526 RenderObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->renderer(); | |
527 GraphicsContext context(nullptr, &rootDisplayItemList()); | |
528 | |
529 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100)); | |
530 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | |
531 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00)); | |
532 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100)); | |
533 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100)); | |
534 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200)); | |
535 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00)); | |
536 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100)); | |
537 rootDisplayItemList().endNewPaints(); | |
538 | |
539 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8, | |
540 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), | |
541 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) , | |
542 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground), | |
543 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground), | |
544 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), | |
545 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) , | |
546 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground), | |
547 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground)); | |
548 | |
549 rootDisplayItemList().invalidate(container1->displayItemClient()); | |
chrishtr
2015/01/22 22:17:21
Add a comment that this is simulating the situatio
Xianzhu
2015/01/22 23:50:59
Done.
| |
550 drawRect(&context, container2, PaintPhaseBlockBackground, FloatRect(100, 200 , 100, 100)); | |
551 drawRect(&context, content2, PaintPhaseBlockBackground, FloatRect(100, 200, 50, 200)); | |
552 drawRect(&context, content2, PaintPhaseForeground, FloatRect(100, 200, 50, 2 00)); | |
553 drawRect(&context, container2, PaintPhaseForeground, FloatRect(100, 200, 100 , 100)); | |
554 drawRect(&context, container1, PaintPhaseBlockBackground, FloatRect(100, 100 , 100, 100)); | |
555 drawRect(&context, content1, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); | |
556 drawRect(&context, content1, PaintPhaseForeground, FloatRect(100, 100, 50, 2 00)); | |
557 drawRect(&context, container1, PaintPhaseForeground, FloatRect(100, 100, 100 , 100)); | |
558 rootDisplayItemList().endNewPaints(); | |
559 | |
560 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 8, | |
561 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseBlockBackgroun d), | |
562 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseBlockBackground) , | |
563 TestDisplayItem(content2, DisplayItem::DrawingPaintPhaseForeground), | |
564 TestDisplayItem(container2, DisplayItem::DrawingPaintPhaseForeground), | |
565 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseBlockBackgroun d), | |
566 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseBlockBackground) , | |
567 TestDisplayItem(content1, DisplayItem::DrawingPaintPhaseForeground), | |
568 TestDisplayItem(container1, DisplayItem::DrawingPaintPhaseForeground)); | |
569 } | |
570 | |
522 } // anonymous namespace | 571 } // anonymous namespace |
523 } // namespace blink | 572 } // namespace blink |
OLD | NEW |