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

Side by Side Diff: ui/views/view_unittest.cc

Issue 2225563002: Reland "Raster display item lists via a visual rect RTree." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head. 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 | « ui/compositor/layer.cc ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/view.h" 5 #include "ui/views/view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 v1->AddChildView(v11); 519 v1->AddChildView(v11);
520 520
521 // |v2| is not. 521 // |v2| is not.
522 TestView* v2 = new TestView; 522 TestView* v2 = new TestView;
523 v2->SetBounds(3, 4, 6, 5); 523 v2->SetBounds(3, 4, 6, 5);
524 root_view->AddChildView(v2); 524 root_view->AddChildView(v2);
525 525
526 // Paint "everything". 526 // Paint "everything".
527 gfx::Rect first_paint(1, 1); 527 gfx::Rect first_paint(1, 1);
528 scoped_refptr<cc::DisplayItemList> list = 528 scoped_refptr<cc::DisplayItemList> list =
529 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 529 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
530 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 530 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
531 531
532 // The empty view has nothing to paint so it doesn't try build a cache, nor do 532 // The empty view has nothing to paint so it doesn't try build a cache, nor do
533 // its children which would be clipped by its (empty) self. 533 // its children which would be clipped by its (empty) self.
534 EXPECT_FALSE(v1->did_paint_); 534 EXPECT_FALSE(v1->did_paint_);
535 EXPECT_FALSE(v11->did_paint_); 535 EXPECT_FALSE(v11->did_paint_);
536 EXPECT_TRUE(v2->did_paint_); 536 EXPECT_TRUE(v2->did_paint_);
537 } 537 }
538 538
539 TEST_F(ViewTest, PaintWithMovedViewUsesCache) { 539 TEST_F(ViewTest, PaintWithMovedViewUsesCache) {
540 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 540 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
541 View* root_view = widget->GetRootView(); 541 View* root_view = widget->GetRootView();
542 TestView* v1 = new TestView; 542 TestView* v1 = new TestView;
543 v1->SetBounds(10, 11, 12, 13); 543 v1->SetBounds(10, 11, 12, 13);
544 root_view->AddChildView(v1); 544 root_view->AddChildView(v1);
545 545
546 // Paint everything once, since it has to build its cache. Then we can test 546 // Paint everything once, since it has to build its cache. Then we can test
547 // invalidation. 547 // invalidation.
548 gfx::Rect pixel_rect = gfx::Rect(1, 1); 548 gfx::Rect pixel_rect = gfx::Rect(1, 1);
549 float device_scale_factor = 1.f; 549 float device_scale_factor = 1.f;
550 scoped_refptr<cc::DisplayItemList> list = 550 scoped_refptr<cc::DisplayItemList> list =
551 cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 551 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
552 root_view->Paint( 552 root_view->Paint(
553 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 553 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
554 EXPECT_TRUE(v1->did_paint_); 554 EXPECT_TRUE(v1->did_paint_);
555 v1->Reset(); 555 v1->Reset();
556 // The visual rects for (clip, drawing, transform) should be in layer space. 556 // The visual rects for (clip, drawing, transform) should be in layer space.
557 gfx::Rect expected_visual_rect_in_layer_space(10, 11, 12, 13); 557 gfx::Rect expected_visual_rect_in_layer_space(10, 11, 12, 13);
558 int item_index = 3; 558 int item_index = 3;
559 EXPECT_EQ(expected_visual_rect_in_layer_space, 559 EXPECT_EQ(expected_visual_rect_in_layer_space,
560 list->VisualRectForTesting(item_index++)); 560 list->VisualRectForTesting(item_index++));
561 EXPECT_EQ(expected_visual_rect_in_layer_space, 561 EXPECT_EQ(expected_visual_rect_in_layer_space,
562 list->VisualRectForTesting(item_index++)); 562 list->VisualRectForTesting(item_index++));
563 EXPECT_EQ(expected_visual_rect_in_layer_space, 563 EXPECT_EQ(expected_visual_rect_in_layer_space,
564 list->VisualRectForTesting(item_index)); 564 list->VisualRectForTesting(item_index));
565 565
566 // If invalidation doesn't intersect v1, we paint with the cache. 566 // If invalidation doesn't intersect v1, we paint with the cache.
567 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 567 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
568 root_view->Paint( 568 root_view->Paint(
569 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 569 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
570 EXPECT_FALSE(v1->did_paint_); 570 EXPECT_FALSE(v1->did_paint_);
571 v1->Reset(); 571 v1->Reset();
572 572
573 // If invalidation does intersect v1, we don't paint with the cache. 573 // If invalidation does intersect v1, we don't paint with the cache.
574 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 574 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
575 root_view->Paint( 575 root_view->Paint(
576 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); 576 ui::PaintContext(list.get(), device_scale_factor, v1->bounds()));
577 EXPECT_TRUE(v1->did_paint_); 577 EXPECT_TRUE(v1->did_paint_);
578 v1->Reset(); 578 v1->Reset();
579 579
580 // Moving the view should still use the cache when the invalidation doesn't 580 // Moving the view should still use the cache when the invalidation doesn't
581 // intersect v1. 581 // intersect v1.
582 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 582 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
583 v1->SetX(9); 583 v1->SetX(9);
584 root_view->Paint( 584 root_view->Paint(
585 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 585 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
586 EXPECT_FALSE(v1->did_paint_); 586 EXPECT_FALSE(v1->did_paint_);
587 v1->Reset(); 587 v1->Reset();
588 item_index = 3; 588 item_index = 3;
589 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13); 589 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13);
590 EXPECT_EQ(expected_visual_rect_in_layer_space, 590 EXPECT_EQ(expected_visual_rect_in_layer_space,
591 list->VisualRectForTesting(item_index++)); 591 list->VisualRectForTesting(item_index++));
592 EXPECT_EQ(expected_visual_rect_in_layer_space, 592 EXPECT_EQ(expected_visual_rect_in_layer_space,
593 list->VisualRectForTesting(item_index++)); 593 list->VisualRectForTesting(item_index++));
594 EXPECT_EQ(expected_visual_rect_in_layer_space, 594 EXPECT_EQ(expected_visual_rect_in_layer_space,
595 list->VisualRectForTesting(item_index)); 595 list->VisualRectForTesting(item_index));
596 596
597 // Moving the view should not use the cache when painting without 597 // Moving the view should not use the cache when painting without
598 // invalidation. 598 // invalidation.
599 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 599 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
600 v1->SetX(8); 600 v1->SetX(8);
601 root_view->Paint(ui::PaintContext( 601 root_view->Paint(ui::PaintContext(
602 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), 602 ui::PaintContext(list.get(), device_scale_factor, pixel_rect),
603 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); 603 ui::PaintContext::CLONE_WITHOUT_INVALIDATION));
604 EXPECT_TRUE(v1->did_paint_); 604 EXPECT_TRUE(v1->did_paint_);
605 v1->Reset(); 605 v1->Reset();
606 item_index = 3; 606 item_index = 3;
607 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13); 607 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13);
608 EXPECT_EQ(expected_visual_rect_in_layer_space, 608 EXPECT_EQ(expected_visual_rect_in_layer_space,
609 list->VisualRectForTesting(item_index++)); 609 list->VisualRectForTesting(item_index++));
610 EXPECT_EQ(expected_visual_rect_in_layer_space, 610 EXPECT_EQ(expected_visual_rect_in_layer_space,
611 list->VisualRectForTesting(item_index++)); 611 list->VisualRectForTesting(item_index++));
612 EXPECT_EQ(expected_visual_rect_in_layer_space, 612 EXPECT_EQ(expected_visual_rect_in_layer_space,
613 list->VisualRectForTesting(item_index)); 613 list->VisualRectForTesting(item_index));
614 } 614 }
615 615
616 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { 616 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) {
617 ScopedRTL rtl; 617 ScopedRTL rtl;
618 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 618 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
619 View* root_view = widget->GetRootView(); 619 View* root_view = widget->GetRootView();
620 TestView* v1 = new TestView; 620 TestView* v1 = new TestView;
621 v1->SetBounds(10, 11, 12, 13); 621 v1->SetBounds(10, 11, 12, 13);
622 root_view->AddChildView(v1); 622 root_view->AddChildView(v1);
623 623
624 // Paint everything once, since it has to build its cache. Then we can test 624 // Paint everything once, since it has to build its cache. Then we can test
625 // invalidation. 625 // invalidation.
626 gfx::Rect pixel_rect = gfx::Rect(1, 1); 626 gfx::Rect pixel_rect = gfx::Rect(1, 1);
627 float device_scale_factor = 1.f; 627 float device_scale_factor = 1.f;
628 scoped_refptr<cc::DisplayItemList> list = 628 scoped_refptr<cc::DisplayItemList> list =
629 cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 629 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
630 root_view->Paint( 630 root_view->Paint(
631 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 631 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
632 EXPECT_TRUE(v1->did_paint_); 632 EXPECT_TRUE(v1->did_paint_);
633 v1->Reset(); 633 v1->Reset();
634 // The visual rects for (clip, drawing, transform) should be in layer space. 634 // The visual rects for (clip, drawing, transform) should be in layer space.
635 // x: 25 - 10(x) - 12(width) = 3 635 // x: 25 - 10(x) - 12(width) = 3
636 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13); 636 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13);
637 int item_index = 3; 637 int item_index = 3;
638 EXPECT_EQ(expected_visual_rect_in_layer_space, 638 EXPECT_EQ(expected_visual_rect_in_layer_space,
639 list->VisualRectForTesting(item_index++)); 639 list->VisualRectForTesting(item_index++));
640 EXPECT_EQ(expected_visual_rect_in_layer_space, 640 EXPECT_EQ(expected_visual_rect_in_layer_space,
641 list->VisualRectForTesting(item_index++)); 641 list->VisualRectForTesting(item_index++));
642 EXPECT_EQ(expected_visual_rect_in_layer_space, 642 EXPECT_EQ(expected_visual_rect_in_layer_space,
643 list->VisualRectForTesting(item_index)); 643 list->VisualRectForTesting(item_index));
644 644
645 // If invalidation doesn't intersect v1, we paint with the cache. 645 // If invalidation doesn't intersect v1, we paint with the cache.
646 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 646 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
647 root_view->Paint( 647 root_view->Paint(
648 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 648 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
649 EXPECT_FALSE(v1->did_paint_); 649 EXPECT_FALSE(v1->did_paint_);
650 v1->Reset(); 650 v1->Reset();
651 651
652 // If invalidation does intersect v1, we don't paint with the cache. 652 // If invalidation does intersect v1, we don't paint with the cache.
653 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 653 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
654 root_view->Paint( 654 root_view->Paint(
655 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); 655 ui::PaintContext(list.get(), device_scale_factor, v1->bounds()));
656 EXPECT_TRUE(v1->did_paint_); 656 EXPECT_TRUE(v1->did_paint_);
657 v1->Reset(); 657 v1->Reset();
658 658
659 // Moving the view should still use the cache when the invalidation doesn't 659 // Moving the view should still use the cache when the invalidation doesn't
660 // intersect v1. 660 // intersect v1.
661 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 661 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
662 v1->SetX(9); 662 v1->SetX(9);
663 root_view->Paint( 663 root_view->Paint(
664 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 664 ui::PaintContext(list.get(), device_scale_factor, pixel_rect));
665 EXPECT_FALSE(v1->did_paint_); 665 EXPECT_FALSE(v1->did_paint_);
666 v1->Reset(); 666 v1->Reset();
667 item_index = 3; 667 item_index = 3;
668 // x: 25 - 9(x) - 12(width) = 4 668 // x: 25 - 9(x) - 12(width) = 4
669 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13); 669 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13);
670 EXPECT_EQ(expected_visual_rect_in_layer_space, 670 EXPECT_EQ(expected_visual_rect_in_layer_space,
671 list->VisualRectForTesting(item_index++)); 671 list->VisualRectForTesting(item_index++));
672 EXPECT_EQ(expected_visual_rect_in_layer_space, 672 EXPECT_EQ(expected_visual_rect_in_layer_space,
673 list->VisualRectForTesting(item_index++)); 673 list->VisualRectForTesting(item_index++));
674 EXPECT_EQ(expected_visual_rect_in_layer_space, 674 EXPECT_EQ(expected_visual_rect_in_layer_space,
675 list->VisualRectForTesting(item_index)); 675 list->VisualRectForTesting(item_index));
676 676
677 // Moving the view should not use the cache when painting without 677 // Moving the view should not use the cache when painting without
678 // invalidation. 678 // invalidation.
679 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); 679 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
680 v1->SetX(8); 680 v1->SetX(8);
681 root_view->Paint(ui::PaintContext( 681 root_view->Paint(ui::PaintContext(
682 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), 682 ui::PaintContext(list.get(), device_scale_factor, pixel_rect),
683 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); 683 ui::PaintContext::CLONE_WITHOUT_INVALIDATION));
684 EXPECT_TRUE(v1->did_paint_); 684 EXPECT_TRUE(v1->did_paint_);
685 v1->Reset(); 685 v1->Reset();
686 item_index = 3; 686 item_index = 3;
687 // x: 25 - 8(x) - 12(width) = 5 687 // x: 25 - 8(x) - 12(width) = 5
688 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13); 688 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13);
689 EXPECT_EQ(expected_visual_rect_in_layer_space, 689 EXPECT_EQ(expected_visual_rect_in_layer_space,
(...skipping 13 matching lines...) Expand all
703 root_view->AddChildView(v1); 703 root_view->AddChildView(v1);
704 704
705 TestView* v2 = new TestView; 705 TestView* v2 = new TestView;
706 v2->SetBounds(3, 4, 6, 5); 706 v2->SetBounds(3, 4, 6, 5);
707 v1->AddChildView(v2); 707 v1->AddChildView(v2);
708 708
709 // Paint everything once, since it has to build its cache. Then we can test 709 // Paint everything once, since it has to build its cache. Then we can test
710 // invalidation. 710 // invalidation.
711 gfx::Rect first_paint(1, 1); 711 gfx::Rect first_paint(1, 1);
712 scoped_refptr<cc::DisplayItemList> list = 712 scoped_refptr<cc::DisplayItemList> list =
713 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 713 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
714 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 714 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
715 v1->Reset(); 715 v1->Reset();
716 v2->Reset(); 716 v2->Reset();
717 717
718 gfx::Rect paint_area(1, 1); 718 gfx::Rect paint_area(1, 1);
719 gfx::Rect root_area(root_view->size()); 719 gfx::Rect root_area(root_view->size());
720 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 720 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
721 721
722 // With a known invalidation, v1 and v2 are not painted. 722 // With a known invalidation, v1 and v2 are not painted.
723 EXPECT_FALSE(v1->did_paint_); 723 EXPECT_FALSE(v1->did_paint_);
724 EXPECT_FALSE(v2->did_paint_); 724 EXPECT_FALSE(v2->did_paint_);
725 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 725 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
726 EXPECT_FALSE(v1->did_paint_); 726 EXPECT_FALSE(v1->did_paint_);
727 EXPECT_FALSE(v2->did_paint_); 727 EXPECT_FALSE(v2->did_paint_);
728 728
729 // With unknown invalidation, v1 and v2 are painted. 729 // With unknown invalidation, v1 and v2 are painted.
730 root_view->Paint( 730 root_view->Paint(
(...skipping 12 matching lines...) Expand all
743 root_view->AddChildView(v1); 743 root_view->AddChildView(v1);
744 744
745 TestView* v2 = new TestView; 745 TestView* v2 = new TestView;
746 v2->SetBounds(3, 4, 6, 5); 746 v2->SetBounds(3, 4, 6, 5);
747 v1->AddChildView(v2); 747 v1->AddChildView(v2);
748 748
749 // Paint everything once, since it has to build its cache. Then we can test 749 // Paint everything once, since it has to build its cache. Then we can test
750 // invalidation. 750 // invalidation.
751 gfx::Rect first_paint(1, 1); 751 gfx::Rect first_paint(1, 1);
752 scoped_refptr<cc::DisplayItemList> list = 752 scoped_refptr<cc::DisplayItemList> list =
753 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 753 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
754 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 754 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
755 v1->Reset(); 755 v1->Reset();
756 v2->Reset(); 756 v2->Reset();
757 757
758 gfx::Rect paint_area(25, 26); 758 gfx::Rect paint_area(25, 26);
759 gfx::Rect root_area(root_view->size()); 759 gfx::Rect root_area(root_view->size());
760 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 760 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
761 761
762 EXPECT_FALSE(v1->did_paint_); 762 EXPECT_FALSE(v1->did_paint_);
763 EXPECT_FALSE(v2->did_paint_); 763 EXPECT_FALSE(v2->did_paint_);
764 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 764 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
765 EXPECT_TRUE(v1->did_paint_); 765 EXPECT_TRUE(v1->did_paint_);
766 EXPECT_TRUE(v2->did_paint_); 766 EXPECT_TRUE(v2->did_paint_);
767 } 767 }
768 768
769 TEST_F(ViewTest, PaintContainsChildrenInRTL) { 769 TEST_F(ViewTest, PaintContainsChildrenInRTL) {
770 ScopedRTL rtl; 770 ScopedRTL rtl;
(...skipping 16 matching lines...) Expand all
787 787
788 v2->SetPaintToLayer(true); 788 v2->SetPaintToLayer(true);
789 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 789 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
790 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 790 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
791 v2->SetPaintToLayer(false); 791 v2->SetPaintToLayer(false);
792 792
793 // Paint everything once, since it has to build its cache. Then we can test 793 // Paint everything once, since it has to build its cache. Then we can test
794 // invalidation. 794 // invalidation.
795 gfx::Rect first_paint(1, 1); 795 gfx::Rect first_paint(1, 1);
796 scoped_refptr<cc::DisplayItemList> list = 796 scoped_refptr<cc::DisplayItemList> list =
797 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 797 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
798 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 798 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
799 v1->Reset(); 799 v1->Reset();
800 v2->Reset(); 800 v2->Reset();
801 801
802 gfx::Rect paint_area(25, 26); 802 gfx::Rect paint_area(25, 26);
803 gfx::Rect root_area(root_view->size()); 803 gfx::Rect root_area(root_view->size());
804 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 804 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
805 805
806 EXPECT_FALSE(v1->did_paint_); 806 EXPECT_FALSE(v1->did_paint_);
807 EXPECT_FALSE(v2->did_paint_); 807 EXPECT_FALSE(v2->did_paint_);
808 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 808 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
809 EXPECT_TRUE(v1->did_paint_); 809 EXPECT_TRUE(v1->did_paint_);
810 EXPECT_TRUE(v2->did_paint_); 810 EXPECT_TRUE(v2->did_paint_);
811 } 811 }
812 812
813 TEST_F(ViewTest, PaintIntersectsChildren) { 813 TEST_F(ViewTest, PaintIntersectsChildren) {
814 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 814 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
815 View* root_view = widget->GetRootView(); 815 View* root_view = widget->GetRootView();
816 816
817 TestView* v1 = new TestView; 817 TestView* v1 = new TestView;
818 v1->SetBounds(10, 11, 12, 13); 818 v1->SetBounds(10, 11, 12, 13);
819 root_view->AddChildView(v1); 819 root_view->AddChildView(v1);
820 820
821 TestView* v2 = new TestView; 821 TestView* v2 = new TestView;
822 v2->SetBounds(3, 4, 6, 5); 822 v2->SetBounds(3, 4, 6, 5);
823 v1->AddChildView(v2); 823 v1->AddChildView(v2);
824 824
825 // Paint everything once, since it has to build its cache. Then we can test 825 // Paint everything once, since it has to build its cache. Then we can test
826 // invalidation. 826 // invalidation.
827 gfx::Rect first_paint(1, 1); 827 gfx::Rect first_paint(1, 1);
828 scoped_refptr<cc::DisplayItemList> list = 828 scoped_refptr<cc::DisplayItemList> list =
829 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 829 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
830 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 830 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
831 v1->Reset(); 831 v1->Reset();
832 v2->Reset(); 832 v2->Reset();
833 833
834 gfx::Rect paint_area(9, 10, 5, 6); 834 gfx::Rect paint_area(9, 10, 5, 6);
835 gfx::Rect root_area(root_view->size()); 835 gfx::Rect root_area(root_view->size());
836 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 836 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
837 837
838 EXPECT_FALSE(v1->did_paint_); 838 EXPECT_FALSE(v1->did_paint_);
839 EXPECT_FALSE(v2->did_paint_); 839 EXPECT_FALSE(v2->did_paint_);
840 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 840 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
841 EXPECT_TRUE(v1->did_paint_); 841 EXPECT_TRUE(v1->did_paint_);
842 EXPECT_TRUE(v2->did_paint_); 842 EXPECT_TRUE(v2->did_paint_);
843 } 843 }
844 844
845 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { 845 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) {
846 ScopedRTL rtl; 846 ScopedRTL rtl;
(...skipping 16 matching lines...) Expand all
863 863
864 v2->SetPaintToLayer(true); 864 v2->SetPaintToLayer(true);
865 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 865 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
866 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 866 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
867 v2->SetPaintToLayer(false); 867 v2->SetPaintToLayer(false);
868 868
869 // Paint everything once, since it has to build its cache. Then we can test 869 // Paint everything once, since it has to build its cache. Then we can test
870 // invalidation. 870 // invalidation.
871 gfx::Rect first_paint(1, 1); 871 gfx::Rect first_paint(1, 1);
872 scoped_refptr<cc::DisplayItemList> list = 872 scoped_refptr<cc::DisplayItemList> list =
873 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 873 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
874 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 874 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
875 v1->Reset(); 875 v1->Reset();
876 v2->Reset(); 876 v2->Reset();
877 877
878 gfx::Rect paint_area(2, 10, 5, 6); 878 gfx::Rect paint_area(2, 10, 5, 6);
879 gfx::Rect root_area(root_view->size()); 879 gfx::Rect root_area(root_view->size());
880 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 880 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
881 881
882 EXPECT_FALSE(v1->did_paint_); 882 EXPECT_FALSE(v1->did_paint_);
883 EXPECT_FALSE(v2->did_paint_); 883 EXPECT_FALSE(v2->did_paint_);
884 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 884 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
885 EXPECT_TRUE(v1->did_paint_); 885 EXPECT_TRUE(v1->did_paint_);
886 EXPECT_TRUE(v2->did_paint_); 886 EXPECT_TRUE(v2->did_paint_);
887 } 887 }
888 888
889 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { 889 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) {
890 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 890 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
891 View* root_view = widget->GetRootView(); 891 View* root_view = widget->GetRootView();
892 892
893 TestView* v1 = new TestView; 893 TestView* v1 = new TestView;
894 v1->SetBounds(10, 11, 12, 13); 894 v1->SetBounds(10, 11, 12, 13);
895 root_view->AddChildView(v1); 895 root_view->AddChildView(v1);
896 896
897 TestView* v2 = new TestView; 897 TestView* v2 = new TestView;
898 v2->SetBounds(3, 4, 6, 5); 898 v2->SetBounds(3, 4, 6, 5);
899 v1->AddChildView(v2); 899 v1->AddChildView(v2);
900 900
901 // Paint everything once, since it has to build its cache. Then we can test 901 // Paint everything once, since it has to build its cache. Then we can test
902 // invalidation. 902 // invalidation.
903 gfx::Rect first_paint(1, 1); 903 gfx::Rect first_paint(1, 1);
904 scoped_refptr<cc::DisplayItemList> list = 904 scoped_refptr<cc::DisplayItemList> list =
905 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 905 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
906 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 906 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
907 v1->Reset(); 907 v1->Reset();
908 v2->Reset(); 908 v2->Reset();
909 909
910 gfx::Rect paint_area(9, 10, 2, 3); 910 gfx::Rect paint_area(9, 10, 2, 3);
911 gfx::Rect root_area(root_view->size()); 911 gfx::Rect root_area(root_view->size());
912 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 912 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
913 913
914 EXPECT_FALSE(v1->did_paint_); 914 EXPECT_FALSE(v1->did_paint_);
915 EXPECT_FALSE(v2->did_paint_); 915 EXPECT_FALSE(v2->did_paint_);
916 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 916 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
917 EXPECT_TRUE(v1->did_paint_); 917 EXPECT_TRUE(v1->did_paint_);
918 EXPECT_FALSE(v2->did_paint_); 918 EXPECT_FALSE(v2->did_paint_);
919 } 919 }
920 920
921 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { 921 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) {
922 ScopedRTL rtl; 922 ScopedRTL rtl;
(...skipping 16 matching lines...) Expand all
939 939
940 v2->SetPaintToLayer(true); 940 v2->SetPaintToLayer(true);
941 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 941 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
942 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 942 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
943 v2->SetPaintToLayer(false); 943 v2->SetPaintToLayer(false);
944 944
945 // Paint everything once, since it has to build its cache. Then we can test 945 // Paint everything once, since it has to build its cache. Then we can test
946 // invalidation. 946 // invalidation.
947 gfx::Rect first_paint(1, 1); 947 gfx::Rect first_paint(1, 1);
948 scoped_refptr<cc::DisplayItemList> list = 948 scoped_refptr<cc::DisplayItemList> list =
949 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 949 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
950 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 950 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
951 v1->Reset(); 951 v1->Reset();
952 v2->Reset(); 952 v2->Reset();
953 953
954 gfx::Rect paint_area(2, 10, 2, 3); 954 gfx::Rect paint_area(2, 10, 2, 3);
955 gfx::Rect root_area(root_view->size()); 955 gfx::Rect root_area(root_view->size());
956 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 956 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
957 957
958 EXPECT_FALSE(v1->did_paint_); 958 EXPECT_FALSE(v1->did_paint_);
959 EXPECT_FALSE(v2->did_paint_); 959 EXPECT_FALSE(v2->did_paint_);
960 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 960 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
961 EXPECT_TRUE(v1->did_paint_); 961 EXPECT_TRUE(v1->did_paint_);
962 EXPECT_FALSE(v2->did_paint_); 962 EXPECT_FALSE(v2->did_paint_);
963 } 963 }
964 964
965 TEST_F(ViewTest, PaintIntersectsNoChildren) { 965 TEST_F(ViewTest, PaintIntersectsNoChildren) {
966 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 966 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
967 View* root_view = widget->GetRootView(); 967 View* root_view = widget->GetRootView();
968 968
969 TestView* v1 = new TestView; 969 TestView* v1 = new TestView;
970 v1->SetBounds(10, 11, 12, 13); 970 v1->SetBounds(10, 11, 12, 13);
971 root_view->AddChildView(v1); 971 root_view->AddChildView(v1);
972 972
973 TestView* v2 = new TestView; 973 TestView* v2 = new TestView;
974 v2->SetBounds(3, 4, 6, 5); 974 v2->SetBounds(3, 4, 6, 5);
975 v1->AddChildView(v2); 975 v1->AddChildView(v2);
976 976
977 // Paint everything once, since it has to build its cache. Then we can test 977 // Paint everything once, since it has to build its cache. Then we can test
978 // invalidation. 978 // invalidation.
979 gfx::Rect first_paint(1, 1); 979 gfx::Rect first_paint(1, 1);
980 scoped_refptr<cc::DisplayItemList> list = 980 scoped_refptr<cc::DisplayItemList> list =
981 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 981 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
982 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 982 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
983 v1->Reset(); 983 v1->Reset();
984 v2->Reset(); 984 v2->Reset();
985 985
986 gfx::Rect paint_area(9, 10, 2, 1); 986 gfx::Rect paint_area(9, 10, 2, 1);
987 gfx::Rect root_area(root_view->size()); 987 gfx::Rect root_area(root_view->size());
988 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 988 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
989 989
990 EXPECT_FALSE(v1->did_paint_); 990 EXPECT_FALSE(v1->did_paint_);
991 EXPECT_FALSE(v2->did_paint_); 991 EXPECT_FALSE(v2->did_paint_);
992 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 992 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
993 EXPECT_FALSE(v1->did_paint_); 993 EXPECT_FALSE(v1->did_paint_);
994 EXPECT_FALSE(v2->did_paint_); 994 EXPECT_FALSE(v2->did_paint_);
995 } 995 }
996 996
997 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { 997 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) {
998 ScopedRTL rtl; 998 ScopedRTL rtl;
(...skipping 16 matching lines...) Expand all
1015 1015
1016 v2->SetPaintToLayer(true); 1016 v2->SetPaintToLayer(true);
1017 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 1017 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
1018 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 1018 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
1019 v2->SetPaintToLayer(false); 1019 v2->SetPaintToLayer(false);
1020 1020
1021 // Paint everything once, since it has to build its cache. Then we can test 1021 // Paint everything once, since it has to build its cache. Then we can test
1022 // invalidation. 1022 // invalidation.
1023 gfx::Rect first_paint(1, 1); 1023 gfx::Rect first_paint(1, 1);
1024 scoped_refptr<cc::DisplayItemList> list = 1024 scoped_refptr<cc::DisplayItemList> list =
1025 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 1025 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1026 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1026 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
1027 v1->Reset(); 1027 v1->Reset();
1028 v2->Reset(); 1028 v2->Reset();
1029 1029
1030 gfx::Rect paint_area(2, 10, 2, 1); 1030 gfx::Rect paint_area(2, 10, 2, 1);
1031 gfx::Rect root_area(root_view->size()); 1031 gfx::Rect root_area(root_view->size());
1032 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 1032 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1033 1033
1034 EXPECT_FALSE(v1->did_paint_); 1034 EXPECT_FALSE(v1->did_paint_);
1035 EXPECT_FALSE(v2->did_paint_); 1035 EXPECT_FALSE(v2->did_paint_);
1036 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1036 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1037 EXPECT_FALSE(v1->did_paint_); 1037 EXPECT_FALSE(v1->did_paint_);
1038 EXPECT_FALSE(v2->did_paint_); 1038 EXPECT_FALSE(v2->did_paint_);
1039 } 1039 }
1040 1040
1041 TEST_F(ViewTest, PaintIntersectsOneChild) { 1041 TEST_F(ViewTest, PaintIntersectsOneChild) {
1042 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 1042 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
1043 View* root_view = widget->GetRootView(); 1043 View* root_view = widget->GetRootView();
1044 1044
1045 TestView* v1 = new TestView; 1045 TestView* v1 = new TestView;
1046 v1->SetBounds(10, 11, 12, 13); 1046 v1->SetBounds(10, 11, 12, 13);
1047 root_view->AddChildView(v1); 1047 root_view->AddChildView(v1);
1048 1048
1049 TestView* v2 = new TestView; 1049 TestView* v2 = new TestView;
1050 v2->SetBounds(3, 4, 6, 5); 1050 v2->SetBounds(3, 4, 6, 5);
1051 root_view->AddChildView(v2); 1051 root_view->AddChildView(v2);
1052 1052
1053 // Paint everything once, since it has to build its cache. Then we can test 1053 // Paint everything once, since it has to build its cache. Then we can test
1054 // invalidation. 1054 // invalidation.
1055 gfx::Rect first_paint(1, 1); 1055 gfx::Rect first_paint(1, 1);
1056 scoped_refptr<cc::DisplayItemList> list = 1056 scoped_refptr<cc::DisplayItemList> list =
1057 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 1057 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1058 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1058 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
1059 v1->Reset(); 1059 v1->Reset();
1060 v2->Reset(); 1060 v2->Reset();
1061 1061
1062 // Intersects with the second child only. 1062 // Intersects with the second child only.
1063 gfx::Rect paint_area(3, 3, 1, 2); 1063 gfx::Rect paint_area(3, 3, 1, 2);
1064 gfx::Rect root_area(root_view->size()); 1064 gfx::Rect root_area(root_view->size());
1065 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 1065 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1066 1066
1067 EXPECT_FALSE(v1->did_paint_); 1067 EXPECT_FALSE(v1->did_paint_);
1068 EXPECT_FALSE(v2->did_paint_); 1068 EXPECT_FALSE(v2->did_paint_);
1069 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1069 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1070 EXPECT_FALSE(v1->did_paint_); 1070 EXPECT_FALSE(v1->did_paint_);
1071 EXPECT_TRUE(v2->did_paint_); 1071 EXPECT_TRUE(v2->did_paint_);
1072 1072
1073 // Intersects with the first child only. 1073 // Intersects with the first child only.
1074 paint_area = gfx::Rect(20, 10, 1, 2); 1074 paint_area = gfx::Rect(20, 10, 1, 2);
1075 1075
(...skipping 27 matching lines...) Expand all
1103 1103
1104 v2->SetPaintToLayer(true); 1104 v2->SetPaintToLayer(true);
1105 // x: 25 - 3(x) - 6(width) = 16 1105 // x: 25 - 3(x) - 6(width) = 16
1106 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds()); 1106 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds());
1107 v2->SetPaintToLayer(false); 1107 v2->SetPaintToLayer(false);
1108 1108
1109 // Paint everything once, since it has to build its cache. Then we can test 1109 // Paint everything once, since it has to build its cache. Then we can test
1110 // invalidation. 1110 // invalidation.
1111 gfx::Rect first_paint(1, 1); 1111 gfx::Rect first_paint(1, 1);
1112 scoped_refptr<cc::DisplayItemList> list = 1112 scoped_refptr<cc::DisplayItemList> list =
1113 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 1113 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1114 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1114 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
1115 v1->Reset(); 1115 v1->Reset();
1116 v2->Reset(); 1116 v2->Reset();
1117 1117
1118 // Intersects with the first child only. 1118 // Intersects with the first child only.
1119 gfx::Rect paint_area(3, 10, 1, 2); 1119 gfx::Rect paint_area(3, 10, 1, 2);
1120 gfx::Rect root_area(root_view->size()); 1120 gfx::Rect root_area(root_view->size());
1121 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); 1121 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1122 1122
1123 EXPECT_FALSE(v1->did_paint_); 1123 EXPECT_FALSE(v1->did_paint_);
1124 EXPECT_FALSE(v2->did_paint_); 1124 EXPECT_FALSE(v2->did_paint_);
1125 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1125 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1126 EXPECT_TRUE(v1->did_paint_); 1126 EXPECT_TRUE(v1->did_paint_);
1127 EXPECT_FALSE(v2->did_paint_); 1127 EXPECT_FALSE(v2->did_paint_);
1128 1128
1129 // Intersects with the second child only. 1129 // Intersects with the second child only.
1130 paint_area = gfx::Rect(21, 3, 1, 2); 1130 paint_area = gfx::Rect(21, 3, 1, 2);
1131 1131
(...skipping 16 matching lines...) Expand all
1148 root_view->AddChildView(v1); 1148 root_view->AddChildView(v1);
1149 1149
1150 TestView* v2 = new TestView; 1150 TestView* v2 = new TestView;
1151 v2->SetBounds(3, 4, 6, 5); 1151 v2->SetBounds(3, 4, 6, 5);
1152 v1->AddChildView(v2); 1152 v1->AddChildView(v2);
1153 1153
1154 // Paint everything once, since it has to build its cache. Then we can test 1154 // Paint everything once, since it has to build its cache. Then we can test
1155 // invalidation. 1155 // invalidation.
1156 gfx::Rect first_paint(1, 1); 1156 gfx::Rect first_paint(1, 1);
1157 scoped_refptr<cc::DisplayItemList> list = 1157 scoped_refptr<cc::DisplayItemList> list =
1158 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); 1158 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1159 v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1159 v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint));
1160 v1->Reset(); 1160 v1->Reset();
1161 v2->Reset(); 1161 v2->Reset();
1162 1162
1163 { 1163 {
1164 gfx::Rect paint_area(25, 26); 1164 gfx::Rect paint_area(25, 26);
1165 gfx::Rect view_area(root_view->size()); 1165 gfx::Rect view_area(root_view->size());
1166 scoped_refptr<cc::DisplayItemList> list = 1166 scoped_refptr<cc::DisplayItemList> list =
1167 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); 1167 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1168 1168
1169 // The promoted views are not painted as they are separate paint roots. 1169 // The promoted views are not painted as they are separate paint roots.
1170 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1170 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1171 EXPECT_FALSE(v1->did_paint_); 1171 EXPECT_FALSE(v1->did_paint_);
1172 EXPECT_FALSE(v2->did_paint_); 1172 EXPECT_FALSE(v2->did_paint_);
1173 } 1173 }
1174 1174
1175 { 1175 {
1176 gfx::Rect paint_area(1, 1); 1176 gfx::Rect paint_area(1, 1);
1177 gfx::Rect view_area(v1->size()); 1177 gfx::Rect view_area(v1->size());
1178 scoped_refptr<cc::DisplayItemList> list = 1178 scoped_refptr<cc::DisplayItemList> list =
1179 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); 1179 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1180 1180
1181 // The |v1| view is painted. If it used its offset incorrect, it would think 1181 // The |v1| view is painted. If it used its offset incorrect, it would think
1182 // its at (10,11) instead of at (0,0) since it is the paint root. 1182 // its at (10,11) instead of at (0,0) since it is the paint root.
1183 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1183 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1184 EXPECT_TRUE(v1->did_paint_); 1184 EXPECT_TRUE(v1->did_paint_);
1185 EXPECT_FALSE(v2->did_paint_); 1185 EXPECT_FALSE(v2->did_paint_);
1186 } 1186 }
1187 1187
1188 v1->Reset(); 1188 v1->Reset();
1189 1189
1190 { 1190 {
1191 gfx::Rect paint_area(3, 3, 1, 2); 1191 gfx::Rect paint_area(3, 3, 1, 2);
1192 gfx::Rect view_area(v1->size()); 1192 gfx::Rect view_area(v1->size());
1193 scoped_refptr<cc::DisplayItemList> list = 1193 scoped_refptr<cc::DisplayItemList> list =
1194 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); 1194 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1195 1195
1196 // The |v2| view is painted also. If it used its offset incorrect, it would 1196 // The |v2| view is painted also. If it used its offset incorrect, it would
1197 // think its at (13,15) instead of at (3,4) since |v1| is the paint root. 1197 // think its at (13,15) instead of at (3,4) since |v1| is the paint root.
1198 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1198 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area));
1199 EXPECT_TRUE(v1->did_paint_); 1199 EXPECT_TRUE(v1->did_paint_);
1200 EXPECT_TRUE(v2->did_paint_); 1200 EXPECT_TRUE(v2->did_paint_);
1201 } 1201 }
1202 } 1202 }
1203 1203
1204 // A derived class for testing paint. 1204 // A derived class for testing paint.
(...skipping 26 matching lines...) Expand all
1231 1231
1232 // Set bounds for |v1| such that it has an offset to its parent and only part 1232 // Set bounds for |v1| such that it has an offset to its parent and only part
1233 // of it is visible. The visible bounds does not intersect with |root_view|'s 1233 // of it is visible. The visible bounds does not intersect with |root_view|'s
1234 // bounds. 1234 // bounds.
1235 v1->SetBounds(0, -1000, 100, 1100); 1235 v1->SetBounds(0, -1000, 100, 1100);
1236 root_view->AddChildView(v1); 1236 root_view->AddChildView(v1);
1237 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds()); 1237 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds());
1238 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds()); 1238 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds());
1239 1239
1240 scoped_refptr<cc::DisplayItemList> list = 1240 scoped_refptr<cc::DisplayItemList> list =
1241 cc::DisplayItemList::Create(gfx::Rect(), cc::DisplayItemListSettings()); 1241 cc::DisplayItemList::Create(cc::DisplayItemListSettings());
1242 ui::PaintContext context(list.get(), 1.f, gfx::Rect()); 1242 ui::PaintContext context(list.get(), 1.f, gfx::Rect());
1243 1243
1244 v1->Paint(context); 1244 v1->Paint(context);
1245 EXPECT_TRUE(v1->did_paint_); 1245 EXPECT_TRUE(v1->did_paint_);
1246 1246
1247 // Check that the canvas produced by |v1| for paint contains all of |v1|'s 1247 // Check that the canvas produced by |v1| for paint contains all of |v1|'s
1248 // visible bounds. 1248 // visible bounds.
1249 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds())); 1249 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds()));
1250 } 1250 }
1251 1251
(...skipping 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after
4571 widget.Init(params); 4571 widget.Init(params);
4572 4572
4573 AddViewWithChildLayer(widget.GetRootView()); 4573 AddViewWithChildLayer(widget.GetRootView());
4574 ViewThatAddsViewInOnNativeThemeChanged* v = 4574 ViewThatAddsViewInOnNativeThemeChanged* v =
4575 new ViewThatAddsViewInOnNativeThemeChanged; 4575 new ViewThatAddsViewInOnNativeThemeChanged;
4576 widget.GetRootView()->AddChildView(v); 4576 widget.GetRootView()->AddChildView(v);
4577 EXPECT_TRUE(v->on_native_theme_changed_called()); 4577 EXPECT_TRUE(v->on_native_theme_changed_called());
4578 } 4578 }
4579 4579
4580 } // namespace views 4580 } // namespace views
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698