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

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

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