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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Fix applist_unittest and sync with ToT Created 3 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
« ui/views/view.h ('K') | « ui/views/view.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 22 matching lines...) Expand all
33 #include "ui/events/test/event_generator.h" 33 #include "ui/events/test/event_generator.h"
34 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
35 #include "ui/gfx/path.h" 35 #include "ui/gfx/path.h"
36 #include "ui/gfx/transform.h" 36 #include "ui/gfx/transform.h"
37 #include "ui/native_theme/native_theme.h" 37 #include "ui/native_theme/native_theme.h"
38 #include "ui/strings/grit/ui_strings.h" 38 #include "ui/strings/grit/ui_strings.h"
39 #include "ui/views/background.h" 39 #include "ui/views/background.h"
40 #include "ui/views/controls/native/native_view_host.h" 40 #include "ui/views/controls/native/native_view_host.h"
41 #include "ui/views/controls/scroll_view.h" 41 #include "ui/views/controls/scroll_view.h"
42 #include "ui/views/controls/textfield/textfield.h" 42 #include "ui/views/controls/textfield/textfield.h"
43 #include "ui/views/paint_info.h"
43 #include "ui/views/test/views_test_base.h" 44 #include "ui/views/test/views_test_base.h"
44 #include "ui/views/view_observer.h" 45 #include "ui/views/view_observer.h"
45 #include "ui/views/widget/native_widget.h" 46 #include "ui/views/widget/native_widget.h"
46 #include "ui/views/widget/root_view.h" 47 #include "ui/views/widget/root_view.h"
47 #include "ui/views/window/dialog_client_view.h" 48 #include "ui/views/window/dialog_client_view.h"
48 #include "ui/views/window/dialog_delegate.h" 49 #include "ui/views/window/dialog_delegate.h"
49 50
50 using base::ASCIIToUTF16; 51 using base::ASCIIToUTF16;
51 52
52 namespace { 53 namespace {
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 v1->AddChildView(v11); 521 v1->AddChildView(v11);
521 522
522 // |v2| is not. 523 // |v2| is not.
523 TestView* v2 = new TestView; 524 TestView* v2 = new TestView;
524 v2->SetBounds(3, 4, 6, 5); 525 v2->SetBounds(3, 4, 6, 5);
525 root_view->AddChildView(v2); 526 root_view->AddChildView(v2);
526 527
527 // Paint "everything". 528 // Paint "everything".
528 gfx::Rect first_paint(1, 1); 529 gfx::Rect first_paint(1, 1);
529 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 530 auto list = base::MakeRefCounted<cc::DisplayItemList>();
530 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 531 root_view->Paint(PaintInfo::CreateRootPaintInfo(
532 ui::PaintContext(list.get(), 1.f, first_paint, false),
533 first_paint.size()));
531 534
532 // The empty view has nothing to paint so it doesn't try build a cache, nor do 535 // 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. 536 // its children which would be clipped by its (empty) self.
534 EXPECT_FALSE(v1->did_paint_); 537 EXPECT_FALSE(v1->did_paint_);
535 EXPECT_FALSE(v11->did_paint_); 538 EXPECT_FALSE(v11->did_paint_);
536 EXPECT_TRUE(v2->did_paint_); 539 EXPECT_TRUE(v2->did_paint_);
537 } 540 }
538 541
539 TEST_F(ViewTest, PaintWithMovedViewUsesCache) { 542 TEST_F(ViewTest, PaintWithMovedViewUsesCache) {
540 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 543 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
541 View* root_view = widget->GetRootView(); 544 View* root_view = widget->GetRootView();
542 TestView* v1 = new TestView; 545 TestView* v1 = new TestView;
543 v1->SetBounds(10, 11, 12, 13); 546 v1->SetBounds(10, 11, 12, 13);
544 root_view->AddChildView(v1); 547 root_view->AddChildView(v1);
545 548
546 // Paint everything once, since it has to build its cache. Then we can test 549 // Paint everything once, since it has to build its cache. Then we can test
547 // invalidation. 550 // invalidation.
548 gfx::Rect pixel_rect = gfx::Rect(1, 1); 551 gfx::Rect pixel_rect = gfx::Rect(1, 1);
549 float device_scale_factor = 1.f; 552 float device_scale_factor = 1.f;
550 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 553 auto list = base::MakeRefCounted<cc::DisplayItemList>();
551 root_view->Paint( 554 root_view->PaintFromPaintRoot(
552 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 555 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
553 EXPECT_TRUE(v1->did_paint_); 556 EXPECT_TRUE(v1->did_paint_);
554 v1->Reset(); 557 v1->Reset();
555 // The visual rects for (clip, drawing, transform) should be in layer space. 558 // 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); 559 gfx::Rect expected_visual_rect_in_layer_space(10, 11, 12, 13);
557 int item_index = 3; 560 int item_index = 3;
558 EXPECT_EQ(expected_visual_rect_in_layer_space, 561 EXPECT_EQ(expected_visual_rect_in_layer_space,
559 list->VisualRectForTesting(item_index++)); 562 list->VisualRectForTesting(item_index++));
560 EXPECT_EQ(expected_visual_rect_in_layer_space, 563 EXPECT_EQ(expected_visual_rect_in_layer_space,
561 list->VisualRectForTesting(item_index++)); 564 list->VisualRectForTesting(item_index++));
562 EXPECT_EQ(expected_visual_rect_in_layer_space, 565 EXPECT_EQ(expected_visual_rect_in_layer_space,
563 list->VisualRectForTesting(item_index)); 566 list->VisualRectForTesting(item_index));
564 567
565 // If invalidation doesn't intersect v1, we paint with the cache. 568 // If invalidation doesn't intersect v1, we paint with the cache.
566 list = base::MakeRefCounted<cc::DisplayItemList>(); 569 list = base::MakeRefCounted<cc::DisplayItemList>();
567 root_view->Paint( 570 root_view->PaintFromPaintRoot(
568 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 571 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
569 EXPECT_FALSE(v1->did_paint_); 572 EXPECT_FALSE(v1->did_paint_);
570 v1->Reset(); 573 v1->Reset();
571 574
572 // If invalidation does intersect v1, we don't paint with the cache. 575 // If invalidation does intersect v1, we don't paint with the cache.
573 list = base::MakeRefCounted<cc::DisplayItemList>(); 576 list = base::MakeRefCounted<cc::DisplayItemList>();
574 root_view->Paint( 577 root_view->PaintFromPaintRoot(
575 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); 578 ui::PaintContext(list.get(), device_scale_factor, v1->bounds(), false));
576 EXPECT_TRUE(v1->did_paint_); 579 EXPECT_TRUE(v1->did_paint_);
577 v1->Reset(); 580 v1->Reset();
578 581
579 // Moving the view should still use the cache when the invalidation doesn't 582 // Moving the view should still use the cache when the invalidation doesn't
580 // intersect v1. 583 // intersect v1.
581 list = base::MakeRefCounted<cc::DisplayItemList>(); 584 list = base::MakeRefCounted<cc::DisplayItemList>();
582 v1->SetX(9); 585 v1->SetX(9);
583 root_view->Paint( 586 root_view->PaintFromPaintRoot(
584 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 587 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
585 EXPECT_FALSE(v1->did_paint_); 588 EXPECT_FALSE(v1->did_paint_);
586 v1->Reset(); 589 v1->Reset();
587 item_index = 3; 590 item_index = 3;
588 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13); 591 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13);
589 EXPECT_EQ(expected_visual_rect_in_layer_space, 592 EXPECT_EQ(expected_visual_rect_in_layer_space,
590 list->VisualRectForTesting(item_index++)); 593 list->VisualRectForTesting(item_index++));
591 EXPECT_EQ(expected_visual_rect_in_layer_space, 594 EXPECT_EQ(expected_visual_rect_in_layer_space,
592 list->VisualRectForTesting(item_index++)); 595 list->VisualRectForTesting(item_index++));
593 EXPECT_EQ(expected_visual_rect_in_layer_space, 596 EXPECT_EQ(expected_visual_rect_in_layer_space,
594 list->VisualRectForTesting(item_index)); 597 list->VisualRectForTesting(item_index));
595 598
596 // Moving the view should not use the cache when painting without 599 // Moving the view should not use the cache when painting without
597 // invalidation. 600 // invalidation.
598 list = base::MakeRefCounted<cc::DisplayItemList>(); 601 list = base::MakeRefCounted<cc::DisplayItemList>();
599 v1->SetX(8); 602 v1->SetX(8);
600 root_view->Paint(ui::PaintContext( 603 root_view->PaintFromPaintRoot(ui::PaintContext(
601 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), 604 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false),
602 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); 605 ui::PaintContext::CLONE_WITHOUT_INVALIDATION));
603 EXPECT_TRUE(v1->did_paint_); 606 EXPECT_TRUE(v1->did_paint_);
604 v1->Reset(); 607 v1->Reset();
605 item_index = 3; 608 item_index = 3;
606 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13); 609 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13);
607 EXPECT_EQ(expected_visual_rect_in_layer_space, 610 EXPECT_EQ(expected_visual_rect_in_layer_space,
608 list->VisualRectForTesting(item_index++)); 611 list->VisualRectForTesting(item_index++));
609 EXPECT_EQ(expected_visual_rect_in_layer_space, 612 EXPECT_EQ(expected_visual_rect_in_layer_space,
610 list->VisualRectForTesting(item_index++)); 613 list->VisualRectForTesting(item_index++));
611 EXPECT_EQ(expected_visual_rect_in_layer_space, 614 EXPECT_EQ(expected_visual_rect_in_layer_space,
612 list->VisualRectForTesting(item_index)); 615 list->VisualRectForTesting(item_index));
613 } 616 }
614 617
615 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { 618 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) {
616 ScopedRTL rtl; 619 ScopedRTL rtl;
617 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 620 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
618 View* root_view = widget->GetRootView(); 621 View* root_view = widget->GetRootView();
619 TestView* v1 = new TestView; 622 TestView* v1 = new TestView;
620 v1->SetBounds(10, 11, 12, 13); 623 v1->SetBounds(10, 11, 12, 13);
621 root_view->AddChildView(v1); 624 root_view->AddChildView(v1);
622 625
623 // Paint everything once, since it has to build its cache. Then we can test 626 // Paint everything once, since it has to build its cache. Then we can test
624 // invalidation. 627 // invalidation.
625 gfx::Rect pixel_rect = gfx::Rect(1, 1); 628 gfx::Rect pixel_rect = gfx::Rect(1, 1);
626 float device_scale_factor = 1.f; 629 float device_scale_factor = 1.f;
627 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 630 auto list = base::MakeRefCounted<cc::DisplayItemList>();
628 root_view->Paint( 631 root_view->PaintFromPaintRoot(
629 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 632 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
630 EXPECT_TRUE(v1->did_paint_); 633 EXPECT_TRUE(v1->did_paint_);
631 v1->Reset(); 634 v1->Reset();
632 // The visual rects for (clip, drawing, transform) should be in layer space. 635 // The visual rects for (clip, drawing, transform) should be in layer space.
633 // x: 25 - 10(x) - 12(width) = 3 636 // x: 25 - 10(x) - 12(width) = 3
634 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13); 637 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13);
635 int item_index = 3; 638 int item_index = 3;
636 EXPECT_EQ(expected_visual_rect_in_layer_space, 639 EXPECT_EQ(expected_visual_rect_in_layer_space,
637 list->VisualRectForTesting(item_index++)); 640 list->VisualRectForTesting(item_index++));
638 EXPECT_EQ(expected_visual_rect_in_layer_space, 641 EXPECT_EQ(expected_visual_rect_in_layer_space,
639 list->VisualRectForTesting(item_index++)); 642 list->VisualRectForTesting(item_index++));
640 EXPECT_EQ(expected_visual_rect_in_layer_space, 643 EXPECT_EQ(expected_visual_rect_in_layer_space,
641 list->VisualRectForTesting(item_index)); 644 list->VisualRectForTesting(item_index));
642 645
643 // If invalidation doesn't intersect v1, we paint with the cache. 646 // If invalidation doesn't intersect v1, we paint with the cache.
644 list = base::MakeRefCounted<cc::DisplayItemList>(); 647 list = base::MakeRefCounted<cc::DisplayItemList>();
645 root_view->Paint( 648 root_view->PaintFromPaintRoot(
646 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 649 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
647 EXPECT_FALSE(v1->did_paint_); 650 EXPECT_FALSE(v1->did_paint_);
648 v1->Reset(); 651 v1->Reset();
649 652
650 // If invalidation does intersect v1, we don't paint with the cache. 653 // If invalidation does intersect v1, we don't paint with the cache.
651 list = base::MakeRefCounted<cc::DisplayItemList>(); 654 list = base::MakeRefCounted<cc::DisplayItemList>();
652 root_view->Paint( 655 root_view->PaintFromPaintRoot(
653 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); 656 ui::PaintContext(list.get(), device_scale_factor, v1->bounds(), false));
654 EXPECT_TRUE(v1->did_paint_); 657 EXPECT_TRUE(v1->did_paint_);
655 v1->Reset(); 658 v1->Reset();
656 659
657 // Moving the view should still use the cache when the invalidation doesn't 660 // Moving the view should still use the cache when the invalidation doesn't
658 // intersect v1. 661 // intersect v1.
659 list = base::MakeRefCounted<cc::DisplayItemList>(); 662 list = base::MakeRefCounted<cc::DisplayItemList>();
660 v1->SetX(9); 663 v1->SetX(9);
661 root_view->Paint( 664 root_view->PaintFromPaintRoot(
662 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); 665 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false));
663 EXPECT_FALSE(v1->did_paint_); 666 EXPECT_FALSE(v1->did_paint_);
664 v1->Reset(); 667 v1->Reset();
665 item_index = 3; 668 item_index = 3;
666 // x: 25 - 9(x) - 12(width) = 4 669 // x: 25 - 9(x) - 12(width) = 4
667 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13); 670 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13);
668 EXPECT_EQ(expected_visual_rect_in_layer_space, 671 EXPECT_EQ(expected_visual_rect_in_layer_space,
669 list->VisualRectForTesting(item_index++)); 672 list->VisualRectForTesting(item_index++));
670 EXPECT_EQ(expected_visual_rect_in_layer_space, 673 EXPECT_EQ(expected_visual_rect_in_layer_space,
671 list->VisualRectForTesting(item_index++)); 674 list->VisualRectForTesting(item_index++));
672 EXPECT_EQ(expected_visual_rect_in_layer_space, 675 EXPECT_EQ(expected_visual_rect_in_layer_space,
673 list->VisualRectForTesting(item_index)); 676 list->VisualRectForTesting(item_index));
674 677
675 // Moving the view should not use the cache when painting without 678 // Moving the view should not use the cache when painting without
676 // invalidation. 679 // invalidation.
677 list = base::MakeRefCounted<cc::DisplayItemList>(); 680 list = base::MakeRefCounted<cc::DisplayItemList>();
678 v1->SetX(8); 681 v1->SetX(8);
679 root_view->Paint(ui::PaintContext( 682 root_view->PaintFromPaintRoot(ui::PaintContext(
680 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), 683 ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false),
681 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); 684 ui::PaintContext::CLONE_WITHOUT_INVALIDATION));
682 EXPECT_TRUE(v1->did_paint_); 685 EXPECT_TRUE(v1->did_paint_);
683 v1->Reset(); 686 v1->Reset();
684 item_index = 3; 687 item_index = 3;
685 // x: 25 - 8(x) - 12(width) = 5 688 // x: 25 - 8(x) - 12(width) = 5
686 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13); 689 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13);
687 EXPECT_EQ(expected_visual_rect_in_layer_space, 690 EXPECT_EQ(expected_visual_rect_in_layer_space,
688 list->VisualRectForTesting(item_index++)); 691 list->VisualRectForTesting(item_index++));
689 EXPECT_EQ(expected_visual_rect_in_layer_space, 692 EXPECT_EQ(expected_visual_rect_in_layer_space,
690 list->VisualRectForTesting(item_index++)); 693 list->VisualRectForTesting(item_index++));
(...skipping 10 matching lines...) Expand all
701 root_view->AddChildView(v1); 704 root_view->AddChildView(v1);
702 705
703 TestView* v2 = new TestView; 706 TestView* v2 = new TestView;
704 v2->SetBounds(3, 4, 6, 5); 707 v2->SetBounds(3, 4, 6, 5);
705 v1->AddChildView(v2); 708 v1->AddChildView(v2);
706 709
707 // Paint everything once, since it has to build its cache. Then we can test 710 // Paint everything once, since it has to build its cache. Then we can test
708 // invalidation. 711 // invalidation.
709 gfx::Rect first_paint(1, 1); 712 gfx::Rect first_paint(1, 1);
710 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 713 auto list = base::MakeRefCounted<cc::DisplayItemList>();
711 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 714 root_view->PaintFromPaintRoot(
715 ui::PaintContext(list.get(), 1.f, first_paint, false));
712 v1->Reset(); 716 v1->Reset();
713 v2->Reset(); 717 v2->Reset();
714 718
715 gfx::Rect paint_area(1, 1); 719 gfx::Rect paint_area(1, 1);
716 gfx::Rect root_area(root_view->size()); 720 gfx::Rect root_area(root_view->size());
717 list = base::MakeRefCounted<cc::DisplayItemList>(); 721 list = base::MakeRefCounted<cc::DisplayItemList>();
718 722
719 // With a known invalidation, v1 and v2 are not painted. 723 // With a known invalidation, v1 and v2 are not painted.
720 EXPECT_FALSE(v1->did_paint_); 724 EXPECT_FALSE(v1->did_paint_);
721 EXPECT_FALSE(v2->did_paint_); 725 EXPECT_FALSE(v2->did_paint_);
722 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 726 root_view->PaintFromPaintRoot(
727 ui::PaintContext(list.get(), 1.f, paint_area, false));
723 EXPECT_FALSE(v1->did_paint_); 728 EXPECT_FALSE(v1->did_paint_);
724 EXPECT_FALSE(v2->did_paint_); 729 EXPECT_FALSE(v2->did_paint_);
725 730
726 // With unknown invalidation, v1 and v2 are painted. 731 // With unknown invalidation, v1 and v2 are painted.
727 root_view->Paint( 732 root_view->PaintFromPaintRoot(
728 ui::PaintContext(ui::PaintContext(list.get(), 1.f, paint_area), 733 ui::PaintContext(ui::PaintContext(list.get(), 1.f, paint_area, false),
729 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); 734 ui::PaintContext::CLONE_WITHOUT_INVALIDATION));
730 EXPECT_TRUE(v1->did_paint_); 735 EXPECT_TRUE(v1->did_paint_);
731 EXPECT_TRUE(v2->did_paint_); 736 EXPECT_TRUE(v2->did_paint_);
732 } 737 }
733 738
734 TEST_F(ViewTest, PaintContainsChildren) { 739 TEST_F(ViewTest, PaintContainsChildren) {
735 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 740 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
736 View* root_view = widget->GetRootView(); 741 View* root_view = widget->GetRootView();
737 742
738 TestView* v1 = new TestView; 743 TestView* v1 = new TestView;
739 v1->SetBounds(10, 11, 12, 13); 744 v1->SetBounds(10, 11, 12, 13);
740 root_view->AddChildView(v1); 745 root_view->AddChildView(v1);
741 746
742 TestView* v2 = new TestView; 747 TestView* v2 = new TestView;
743 v2->SetBounds(3, 4, 6, 5); 748 v2->SetBounds(3, 4, 6, 5);
744 v1->AddChildView(v2); 749 v1->AddChildView(v2);
745 750
746 // Paint everything once, since it has to build its cache. Then we can test 751 // Paint everything once, since it has to build its cache. Then we can test
747 // invalidation. 752 // invalidation.
748 gfx::Rect first_paint(1, 1); 753 gfx::Rect first_paint(1, 1);
749 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 754 auto list = base::MakeRefCounted<cc::DisplayItemList>();
750 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 755 root_view->Paint(PaintInfo::CreateRootPaintInfo(
756 ui::PaintContext(list.get(), 1.f, first_paint, false),
757 root_view->size()));
751 v1->Reset(); 758 v1->Reset();
752 v2->Reset(); 759 v2->Reset();
753 760
754 gfx::Rect paint_area(25, 26); 761 gfx::Rect paint_area(25, 26);
755 gfx::Rect root_area(root_view->size()); 762 gfx::Rect root_area(root_view->size());
756 list = base::MakeRefCounted<cc::DisplayItemList>(); 763 list = base::MakeRefCounted<cc::DisplayItemList>();
757 764
758 EXPECT_FALSE(v1->did_paint_); 765 EXPECT_FALSE(v1->did_paint_);
759 EXPECT_FALSE(v2->did_paint_); 766 EXPECT_FALSE(v2->did_paint_);
760 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 767 root_view->Paint(PaintInfo::CreateRootPaintInfo(
768 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
761 EXPECT_TRUE(v1->did_paint_); 769 EXPECT_TRUE(v1->did_paint_);
762 EXPECT_TRUE(v2->did_paint_); 770 EXPECT_TRUE(v2->did_paint_);
763 } 771 }
764 772
765 TEST_F(ViewTest, PaintContainsChildrenInRTL) { 773 TEST_F(ViewTest, PaintContainsChildrenInRTL) {
766 ScopedRTL rtl; 774 ScopedRTL rtl;
767 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 775 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
768 View* root_view = widget->GetRootView(); 776 View* root_view = widget->GetRootView();
769 777
770 TestView* v1 = new TestView; 778 TestView* v1 = new TestView;
(...skipping 12 matching lines...) Expand all
783 791
784 v2->SetPaintToLayer(); 792 v2->SetPaintToLayer();
785 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 793 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
786 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 794 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
787 v2->DestroyLayer(); 795 v2->DestroyLayer();
788 796
789 // Paint everything once, since it has to build its cache. Then we can test 797 // Paint everything once, since it has to build its cache. Then we can test
790 // invalidation. 798 // invalidation.
791 gfx::Rect first_paint(1, 1); 799 gfx::Rect first_paint(1, 1);
792 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 800 auto list = base::MakeRefCounted<cc::DisplayItemList>();
793 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 801 root_view->Paint(PaintInfo::CreateRootPaintInfo(
802 ui::PaintContext(list.get(), 1.f, first_paint, false),
803 root_view->size()));
794 v1->Reset(); 804 v1->Reset();
795 v2->Reset(); 805 v2->Reset();
796 806
797 gfx::Rect paint_area(25, 26); 807 gfx::Rect paint_area(25, 26);
798 gfx::Rect root_area(root_view->size()); 808 gfx::Rect root_area(root_view->size());
799 list = base::MakeRefCounted<cc::DisplayItemList>(); 809 list = base::MakeRefCounted<cc::DisplayItemList>();
800 810
801 EXPECT_FALSE(v1->did_paint_); 811 EXPECT_FALSE(v1->did_paint_);
802 EXPECT_FALSE(v2->did_paint_); 812 EXPECT_FALSE(v2->did_paint_);
803 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 813 root_view->Paint(PaintInfo::CreateRootPaintInfo(
814 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
804 EXPECT_TRUE(v1->did_paint_); 815 EXPECT_TRUE(v1->did_paint_);
805 EXPECT_TRUE(v2->did_paint_); 816 EXPECT_TRUE(v2->did_paint_);
806 } 817 }
807 818
808 TEST_F(ViewTest, PaintIntersectsChildren) { 819 TEST_F(ViewTest, PaintIntersectsChildren) {
809 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 820 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
810 View* root_view = widget->GetRootView(); 821 View* root_view = widget->GetRootView();
811 822
812 TestView* v1 = new TestView; 823 TestView* v1 = new TestView;
813 v1->SetBounds(10, 11, 12, 13); 824 v1->SetBounds(10, 11, 12, 13);
814 root_view->AddChildView(v1); 825 root_view->AddChildView(v1);
815 826
816 TestView* v2 = new TestView; 827 TestView* v2 = new TestView;
817 v2->SetBounds(3, 4, 6, 5); 828 v2->SetBounds(3, 4, 6, 5);
818 v1->AddChildView(v2); 829 v1->AddChildView(v2);
819 830
820 // Paint everything once, since it has to build its cache. Then we can test 831 // Paint everything once, since it has to build its cache. Then we can test
821 // invalidation. 832 // invalidation.
822 gfx::Rect first_paint(1, 1); 833 gfx::Rect first_paint(1, 1);
823 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 834 auto list = base::MakeRefCounted<cc::DisplayItemList>();
824 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 835 root_view->Paint(PaintInfo::CreateRootPaintInfo(
836 ui::PaintContext(list.get(), 1.f, first_paint, false),
837 root_view->size()));
825 v1->Reset(); 838 v1->Reset();
826 v2->Reset(); 839 v2->Reset();
827 840
828 gfx::Rect paint_area(9, 10, 5, 6); 841 gfx::Rect paint_area(9, 10, 5, 6);
829 gfx::Rect root_area(root_view->size()); 842 gfx::Rect root_area(root_view->size());
830 list = base::MakeRefCounted<cc::DisplayItemList>(); 843 list = base::MakeRefCounted<cc::DisplayItemList>();
831 844
832 EXPECT_FALSE(v1->did_paint_); 845 EXPECT_FALSE(v1->did_paint_);
833 EXPECT_FALSE(v2->did_paint_); 846 EXPECT_FALSE(v2->did_paint_);
834 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 847 root_view->Paint(PaintInfo::CreateRootPaintInfo(
848 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
835 EXPECT_TRUE(v1->did_paint_); 849 EXPECT_TRUE(v1->did_paint_);
836 EXPECT_TRUE(v2->did_paint_); 850 EXPECT_TRUE(v2->did_paint_);
837 } 851 }
838 852
839 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { 853 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) {
840 ScopedRTL rtl; 854 ScopedRTL rtl;
841 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 855 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
842 View* root_view = widget->GetRootView(); 856 View* root_view = widget->GetRootView();
843 857
844 TestView* v1 = new TestView; 858 TestView* v1 = new TestView;
(...skipping 12 matching lines...) Expand all
857 871
858 v2->SetPaintToLayer(); 872 v2->SetPaintToLayer();
859 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 873 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
860 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 874 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
861 v2->DestroyLayer(); 875 v2->DestroyLayer();
862 876
863 // Paint everything once, since it has to build its cache. Then we can test 877 // Paint everything once, since it has to build its cache. Then we can test
864 // invalidation. 878 // invalidation.
865 gfx::Rect first_paint(1, 1); 879 gfx::Rect first_paint(1, 1);
866 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 880 auto list = base::MakeRefCounted<cc::DisplayItemList>();
867 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 881 root_view->Paint(PaintInfo::CreateRootPaintInfo(
882 ui::PaintContext(list.get(), 1.f, first_paint, false),
883 root_view->size()));
868 v1->Reset(); 884 v1->Reset();
869 v2->Reset(); 885 v2->Reset();
870 886
871 gfx::Rect paint_area(2, 10, 5, 6); 887 gfx::Rect paint_area(2, 10, 5, 6);
872 gfx::Rect root_area(root_view->size()); 888 gfx::Rect root_area(root_view->size());
873 list = base::MakeRefCounted<cc::DisplayItemList>(); 889 list = base::MakeRefCounted<cc::DisplayItemList>();
874 890
875 EXPECT_FALSE(v1->did_paint_); 891 EXPECT_FALSE(v1->did_paint_);
876 EXPECT_FALSE(v2->did_paint_); 892 EXPECT_FALSE(v2->did_paint_);
877 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 893 root_view->Paint(PaintInfo::CreateRootPaintInfo(
894 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
878 EXPECT_TRUE(v1->did_paint_); 895 EXPECT_TRUE(v1->did_paint_);
879 EXPECT_TRUE(v2->did_paint_); 896 EXPECT_TRUE(v2->did_paint_);
880 } 897 }
881 898
882 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { 899 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) {
883 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 900 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
884 View* root_view = widget->GetRootView(); 901 View* root_view = widget->GetRootView();
885 902
886 TestView* v1 = new TestView; 903 TestView* v1 = new TestView;
887 v1->SetBounds(10, 11, 12, 13); 904 v1->SetBounds(10, 11, 12, 13);
888 root_view->AddChildView(v1); 905 root_view->AddChildView(v1);
889 906
890 TestView* v2 = new TestView; 907 TestView* v2 = new TestView;
891 v2->SetBounds(3, 4, 6, 5); 908 v2->SetBounds(3, 4, 6, 5);
892 v1->AddChildView(v2); 909 v1->AddChildView(v2);
893 910
894 // Paint everything once, since it has to build its cache. Then we can test 911 // Paint everything once, since it has to build its cache. Then we can test
895 // invalidation. 912 // invalidation.
896 gfx::Rect first_paint(1, 1); 913 gfx::Rect first_paint(1, 1);
897 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 914 auto list = base::MakeRefCounted<cc::DisplayItemList>();
898 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 915 root_view->Paint(PaintInfo::CreateRootPaintInfo(
916 ui::PaintContext(list.get(), 1.f, first_paint, false),
917 root_view->size()));
899 v1->Reset(); 918 v1->Reset();
900 v2->Reset(); 919 v2->Reset();
901 920
902 gfx::Rect paint_area(9, 10, 2, 3); 921 gfx::Rect paint_area(9, 10, 2, 3);
903 gfx::Rect root_area(root_view->size()); 922 gfx::Rect root_area(root_view->size());
904 list = base::MakeRefCounted<cc::DisplayItemList>(); 923 list = base::MakeRefCounted<cc::DisplayItemList>();
905 924
906 EXPECT_FALSE(v1->did_paint_); 925 EXPECT_FALSE(v1->did_paint_);
907 EXPECT_FALSE(v2->did_paint_); 926 EXPECT_FALSE(v2->did_paint_);
908 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 927 root_view->Paint(PaintInfo::CreateRootPaintInfo(
928 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
909 EXPECT_TRUE(v1->did_paint_); 929 EXPECT_TRUE(v1->did_paint_);
910 EXPECT_FALSE(v2->did_paint_); 930 EXPECT_FALSE(v2->did_paint_);
911 } 931 }
912 932
913 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { 933 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) {
914 ScopedRTL rtl; 934 ScopedRTL rtl;
915 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 935 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
916 View* root_view = widget->GetRootView(); 936 View* root_view = widget->GetRootView();
917 937
918 TestView* v1 = new TestView; 938 TestView* v1 = new TestView;
(...skipping 12 matching lines...) Expand all
931 951
932 v2->SetPaintToLayer(); 952 v2->SetPaintToLayer();
933 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 953 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
934 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 954 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
935 v2->DestroyLayer(); 955 v2->DestroyLayer();
936 956
937 // Paint everything once, since it has to build its cache. Then we can test 957 // Paint everything once, since it has to build its cache. Then we can test
938 // invalidation. 958 // invalidation.
939 gfx::Rect first_paint(1, 1); 959 gfx::Rect first_paint(1, 1);
940 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 960 auto list = base::MakeRefCounted<cc::DisplayItemList>();
941 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 961 root_view->Paint(PaintInfo::CreateRootPaintInfo(
962 ui::PaintContext(list.get(), 1.f, first_paint, false),
963 root_view->size()));
942 v1->Reset(); 964 v1->Reset();
943 v2->Reset(); 965 v2->Reset();
944 966
945 gfx::Rect paint_area(2, 10, 2, 3); 967 gfx::Rect paint_area(2, 10, 2, 3);
946 gfx::Rect root_area(root_view->size()); 968 gfx::Rect root_area(root_view->size());
947 list = base::MakeRefCounted<cc::DisplayItemList>(); 969 list = base::MakeRefCounted<cc::DisplayItemList>();
948 970
949 EXPECT_FALSE(v1->did_paint_); 971 EXPECT_FALSE(v1->did_paint_);
950 EXPECT_FALSE(v2->did_paint_); 972 EXPECT_FALSE(v2->did_paint_);
951 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 973 root_view->Paint(PaintInfo::CreateRootPaintInfo(
974 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
952 EXPECT_TRUE(v1->did_paint_); 975 EXPECT_TRUE(v1->did_paint_);
953 EXPECT_FALSE(v2->did_paint_); 976 EXPECT_FALSE(v2->did_paint_);
954 } 977 }
955 978
956 TEST_F(ViewTest, PaintIntersectsNoChildren) { 979 TEST_F(ViewTest, PaintIntersectsNoChildren) {
957 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 980 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
958 View* root_view = widget->GetRootView(); 981 View* root_view = widget->GetRootView();
959 982
960 TestView* v1 = new TestView; 983 TestView* v1 = new TestView;
961 v1->SetBounds(10, 11, 12, 13); 984 v1->SetBounds(10, 11, 12, 13);
962 root_view->AddChildView(v1); 985 root_view->AddChildView(v1);
963 986
964 TestView* v2 = new TestView; 987 TestView* v2 = new TestView;
965 v2->SetBounds(3, 4, 6, 5); 988 v2->SetBounds(3, 4, 6, 5);
966 v1->AddChildView(v2); 989 v1->AddChildView(v2);
967 990
968 // Paint everything once, since it has to build its cache. Then we can test 991 // Paint everything once, since it has to build its cache. Then we can test
969 // invalidation. 992 // invalidation.
970 gfx::Rect first_paint(1, 1); 993 gfx::Rect first_paint(1, 1);
971 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 994 auto list = base::MakeRefCounted<cc::DisplayItemList>();
972 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 995 root_view->Paint(PaintInfo::CreateRootPaintInfo(
996 ui::PaintContext(list.get(), 1.f, first_paint, false),
997 root_view->size()));
973 v1->Reset(); 998 v1->Reset();
974 v2->Reset(); 999 v2->Reset();
975 1000
976 gfx::Rect paint_area(9, 10, 2, 1); 1001 gfx::Rect paint_area(9, 10, 2, 1);
977 gfx::Rect root_area(root_view->size()); 1002 gfx::Rect root_area(root_view->size());
978 list = base::MakeRefCounted<cc::DisplayItemList>(); 1003 list = base::MakeRefCounted<cc::DisplayItemList>();
979 1004
980 EXPECT_FALSE(v1->did_paint_); 1005 EXPECT_FALSE(v1->did_paint_);
981 EXPECT_FALSE(v2->did_paint_); 1006 EXPECT_FALSE(v2->did_paint_);
982 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1007 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1008 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
983 EXPECT_FALSE(v1->did_paint_); 1009 EXPECT_FALSE(v1->did_paint_);
984 EXPECT_FALSE(v2->did_paint_); 1010 EXPECT_FALSE(v2->did_paint_);
985 } 1011 }
986 1012
987 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { 1013 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) {
988 ScopedRTL rtl; 1014 ScopedRTL rtl;
989 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 1015 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
990 View* root_view = widget->GetRootView(); 1016 View* root_view = widget->GetRootView();
991 1017
992 TestView* v1 = new TestView; 1018 TestView* v1 = new TestView;
(...skipping 12 matching lines...) Expand all
1005 1031
1006 v2->SetPaintToLayer(); 1032 v2->SetPaintToLayer();
1007 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 1033 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6
1008 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); 1034 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds());
1009 v2->DestroyLayer(); 1035 v2->DestroyLayer();
1010 1036
1011 // Paint everything once, since it has to build its cache. Then we can test 1037 // Paint everything once, since it has to build its cache. Then we can test
1012 // invalidation. 1038 // invalidation.
1013 gfx::Rect first_paint(1, 1); 1039 gfx::Rect first_paint(1, 1);
1014 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1040 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1015 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1041 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1042 ui::PaintContext(list.get(), 1.f, first_paint, false),
1043 root_view->size()));
1016 v1->Reset(); 1044 v1->Reset();
1017 v2->Reset(); 1045 v2->Reset();
1018 1046
1019 gfx::Rect paint_area(2, 10, 2, 1); 1047 gfx::Rect paint_area(2, 10, 2, 1);
1020 gfx::Rect root_area(root_view->size()); 1048 gfx::Rect root_area(root_view->size());
1021 list = base::MakeRefCounted<cc::DisplayItemList>(); 1049 list = base::MakeRefCounted<cc::DisplayItemList>();
1022 1050
1023 EXPECT_FALSE(v1->did_paint_); 1051 EXPECT_FALSE(v1->did_paint_);
1024 EXPECT_FALSE(v2->did_paint_); 1052 EXPECT_FALSE(v2->did_paint_);
1025 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1053 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1054 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
1026 EXPECT_FALSE(v1->did_paint_); 1055 EXPECT_FALSE(v1->did_paint_);
1027 EXPECT_FALSE(v2->did_paint_); 1056 EXPECT_FALSE(v2->did_paint_);
1028 } 1057 }
1029 1058
1030 TEST_F(ViewTest, PaintIntersectsOneChild) { 1059 TEST_F(ViewTest, PaintIntersectsOneChild) {
1031 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 1060 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
1032 View* root_view = widget->GetRootView(); 1061 View* root_view = widget->GetRootView();
1033 1062
1034 TestView* v1 = new TestView; 1063 TestView* v1 = new TestView;
1035 v1->SetBounds(10, 11, 12, 13); 1064 v1->SetBounds(10, 11, 12, 13);
1036 root_view->AddChildView(v1); 1065 root_view->AddChildView(v1);
1037 1066
1038 TestView* v2 = new TestView; 1067 TestView* v2 = new TestView;
1039 v2->SetBounds(3, 4, 6, 5); 1068 v2->SetBounds(3, 4, 6, 5);
1040 root_view->AddChildView(v2); 1069 root_view->AddChildView(v2);
1041 1070
1042 // Paint everything once, since it has to build its cache. Then we can test 1071 // Paint everything once, since it has to build its cache. Then we can test
1043 // invalidation. 1072 // invalidation.
1044 gfx::Rect first_paint(1, 1); 1073 gfx::Rect first_paint(1, 1);
1045 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1074 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1046 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1075 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1076 ui::PaintContext(list.get(), 1.f, first_paint, false),
1077 root_view->size()));
1047 v1->Reset(); 1078 v1->Reset();
1048 v2->Reset(); 1079 v2->Reset();
1049 1080
1050 // Intersects with the second child only. 1081 // Intersects with the second child only.
1051 gfx::Rect paint_area(3, 3, 1, 2); 1082 gfx::Rect paint_area(3, 3, 1, 2);
1052 gfx::Rect root_area(root_view->size()); 1083 gfx::Rect root_area(root_view->size());
1053 list = base::MakeRefCounted<cc::DisplayItemList>(); 1084 list = base::MakeRefCounted<cc::DisplayItemList>();
1054 1085
1055 EXPECT_FALSE(v1->did_paint_); 1086 EXPECT_FALSE(v1->did_paint_);
1056 EXPECT_FALSE(v2->did_paint_); 1087 EXPECT_FALSE(v2->did_paint_);
1057 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1088 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1089 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
1058 EXPECT_FALSE(v1->did_paint_); 1090 EXPECT_FALSE(v1->did_paint_);
1059 EXPECT_TRUE(v2->did_paint_); 1091 EXPECT_TRUE(v2->did_paint_);
1060 1092
1061 // Intersects with the first child only. 1093 // Intersects with the first child only.
1062 paint_area = gfx::Rect(20, 10, 1, 2); 1094 paint_area = gfx::Rect(20, 10, 1, 2);
1063 1095
1064 v1->Reset(); 1096 v1->Reset();
1065 v2->Reset(); 1097 v2->Reset();
1066 EXPECT_FALSE(v1->did_paint_); 1098 EXPECT_FALSE(v1->did_paint_);
1067 EXPECT_FALSE(v2->did_paint_); 1099 EXPECT_FALSE(v2->did_paint_);
1068 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1100 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1101 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
1069 EXPECT_TRUE(v1->did_paint_); 1102 EXPECT_TRUE(v1->did_paint_);
1070 EXPECT_FALSE(v2->did_paint_); 1103 EXPECT_FALSE(v2->did_paint_);
1071 } 1104 }
1072 1105
1073 TEST_F(ViewTest, PaintIntersectsOneChildInRTL) { 1106 TEST_F(ViewTest, PaintIntersectsOneChildInRTL) {
1074 ScopedRTL rtl; 1107 ScopedRTL rtl;
1075 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 1108 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
1076 View* root_view = widget->GetRootView(); 1109 View* root_view = widget->GetRootView();
1077 1110
1078 TestView* v1 = new TestView; 1111 TestView* v1 = new TestView;
(...skipping 12 matching lines...) Expand all
1091 1124
1092 v2->SetPaintToLayer(); 1125 v2->SetPaintToLayer();
1093 // x: 25 - 3(x) - 6(width) = 16 1126 // x: 25 - 3(x) - 6(width) = 16
1094 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds()); 1127 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds());
1095 v2->DestroyLayer(); 1128 v2->DestroyLayer();
1096 1129
1097 // Paint everything once, since it has to build its cache. Then we can test 1130 // Paint everything once, since it has to build its cache. Then we can test
1098 // invalidation. 1131 // invalidation.
1099 gfx::Rect first_paint(1, 1); 1132 gfx::Rect first_paint(1, 1);
1100 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1133 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1101 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1134 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1135 ui::PaintContext(list.get(), 1.f, first_paint, false),
1136 root_view->size()));
1102 v1->Reset(); 1137 v1->Reset();
1103 v2->Reset(); 1138 v2->Reset();
1104 1139
1105 // Intersects with the first child only. 1140 // Intersects with the first child only.
1106 gfx::Rect paint_area(3, 10, 1, 2); 1141 gfx::Rect paint_area(3, 10, 1, 2);
1107 gfx::Rect root_area(root_view->size()); 1142 gfx::Rect root_area(root_view->size());
1108 list = base::MakeRefCounted<cc::DisplayItemList>(); 1143 list = base::MakeRefCounted<cc::DisplayItemList>();
1109 1144
1110 EXPECT_FALSE(v1->did_paint_); 1145 EXPECT_FALSE(v1->did_paint_);
1111 EXPECT_FALSE(v2->did_paint_); 1146 EXPECT_FALSE(v2->did_paint_);
1112 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1147 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1148 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
1113 EXPECT_TRUE(v1->did_paint_); 1149 EXPECT_TRUE(v1->did_paint_);
1114 EXPECT_FALSE(v2->did_paint_); 1150 EXPECT_FALSE(v2->did_paint_);
1115 1151
1116 // Intersects with the second child only. 1152 // Intersects with the second child only.
1117 paint_area = gfx::Rect(21, 3, 1, 2); 1153 paint_area = gfx::Rect(21, 3, 1, 2);
1118 1154
1119 v1->Reset(); 1155 v1->Reset();
1120 v2->Reset(); 1156 v2->Reset();
1121 EXPECT_FALSE(v1->did_paint_); 1157 EXPECT_FALSE(v1->did_paint_);
1122 EXPECT_FALSE(v2->did_paint_); 1158 EXPECT_FALSE(v2->did_paint_);
1123 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1159 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1160 ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size()));
1124 EXPECT_FALSE(v1->did_paint_); 1161 EXPECT_FALSE(v1->did_paint_);
1125 EXPECT_TRUE(v2->did_paint_); 1162 EXPECT_TRUE(v2->did_paint_);
1126 } 1163 }
1127 1164
1128 TEST_F(ViewTest, PaintInPromotedToLayer) { 1165 TEST_F(ViewTest, PaintInPromotedToLayer) {
1129 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); 1166 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP));
1130 View* root_view = widget->GetRootView(); 1167 View* root_view = widget->GetRootView();
1131 1168
1132 TestView* v1 = new TestView; 1169 TestView* v1 = new TestView;
1133 v1->SetPaintToLayer(); 1170 v1->SetPaintToLayer();
1134 v1->SetBounds(10, 11, 12, 13); 1171 v1->SetBounds(10, 11, 12, 13);
1135 root_view->AddChildView(v1); 1172 root_view->AddChildView(v1);
1136 1173
1137 TestView* v2 = new TestView; 1174 TestView* v2 = new TestView;
1138 v2->SetBounds(3, 4, 6, 5); 1175 v2->SetBounds(3, 4, 6, 5);
1139 v1->AddChildView(v2); 1176 v1->AddChildView(v2);
1140 1177
1141 // Paint everything once, since it has to build its cache. Then we can test 1178 // Paint everything once, since it has to build its cache. Then we can test
1142 // invalidation. 1179 // invalidation.
1143 gfx::Rect first_paint(1, 1); 1180 gfx::Rect first_paint(1, 1);
1144 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1181 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1145 v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); 1182 v1->Paint(PaintInfo::CreateRootPaintInfo(
1183 ui::PaintContext(list.get(), 1.f, first_paint, false), v1->size()));
1146 v1->Reset(); 1184 v1->Reset();
1147 v2->Reset(); 1185 v2->Reset();
1148 1186
1149 { 1187 {
1150 gfx::Rect paint_area(25, 26); 1188 gfx::Rect paint_area(25, 26);
1151 gfx::Rect view_area(root_view->size()); 1189 gfx::Rect view_area(root_view->size());
1152 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1190 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1153 1191
1154 // The promoted views are not painted as they are separate paint roots. 1192 // The promoted views are not painted as they are separate paint roots.
1155 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1193 root_view->Paint(PaintInfo::CreateRootPaintInfo(
1194 ui::PaintContext(list.get(), 1.f, paint_area, false),
1195 root_view->size()));
1156 EXPECT_FALSE(v1->did_paint_); 1196 EXPECT_FALSE(v1->did_paint_);
1157 EXPECT_FALSE(v2->did_paint_); 1197 EXPECT_FALSE(v2->did_paint_);
1158 } 1198 }
1159 1199
1160 { 1200 {
1161 gfx::Rect paint_area(1, 1); 1201 gfx::Rect paint_area(1, 1);
1162 gfx::Rect view_area(v1->size()); 1202 gfx::Rect view_area(v1->size());
1163 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1203 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1164 1204
1165 // The |v1| view is painted. If it used its offset incorrect, it would think 1205 // The |v1| view is painted. If it used its offset incorrect, it would think
1166 // its at (10,11) instead of at (0,0) since it is the paint root. 1206 // its at (10,11) instead of at (0,0) since it is the paint root.
1167 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1207 v1->Paint(PaintInfo::CreateRootPaintInfo(
1208 ui::PaintContext(list.get(), 1.f, paint_area, false), v1->size()));
1168 EXPECT_TRUE(v1->did_paint_); 1209 EXPECT_TRUE(v1->did_paint_);
1169 EXPECT_FALSE(v2->did_paint_); 1210 EXPECT_FALSE(v2->did_paint_);
1170 } 1211 }
1171 1212
1172 v1->Reset(); 1213 v1->Reset();
1173 1214
1174 { 1215 {
1175 gfx::Rect paint_area(3, 3, 1, 2); 1216 gfx::Rect paint_area(3, 3, 1, 2);
1176 gfx::Rect view_area(v1->size()); 1217 gfx::Rect view_area(v1->size());
1177 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1218 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1178 1219
1179 // The |v2| view is painted also. If it used its offset incorrect, it would 1220 // The |v2| view is painted also. If it used its offset incorrect, it would
1180 // think its at (13,15) instead of at (3,4) since |v1| is the paint root. 1221 // think its at (13,15) instead of at (3,4) since |v1| is the paint root.
1181 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); 1222 v1->Paint(PaintInfo::CreateRootPaintInfo(
1223 ui::PaintContext(list.get(), 1.f, paint_area, false), v1->size()));
1182 EXPECT_TRUE(v1->did_paint_); 1224 EXPECT_TRUE(v1->did_paint_);
1183 EXPECT_TRUE(v2->did_paint_); 1225 EXPECT_TRUE(v2->did_paint_);
1184 } 1226 }
1185 } 1227 }
1186 1228
1187 // A derived class for testing paint. 1229 // A derived class for testing paint.
1188 class TestPaintView : public TestView { 1230 class TestPaintView : public TestView {
1189 public: 1231 public:
1190 TestPaintView() : TestView(), canvas_bounds_(gfx::Rect()) {} 1232 TestPaintView() : TestView(), canvas_bounds_(gfx::Rect()) {}
1191 ~TestPaintView() override {} 1233 ~TestPaintView() override {}
(...skipping 22 matching lines...) Expand all
1214 1256
1215 // Set bounds for |v1| such that it has an offset to its parent and only part 1257 // Set bounds for |v1| such that it has an offset to its parent and only part
1216 // of it is visible. The visible bounds does not intersect with |root_view|'s 1258 // of it is visible. The visible bounds does not intersect with |root_view|'s
1217 // bounds. 1259 // bounds.
1218 v1->SetBounds(0, -1000, 100, 1100); 1260 v1->SetBounds(0, -1000, 100, 1100);
1219 root_view->AddChildView(v1); 1261 root_view->AddChildView(v1);
1220 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds()); 1262 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds());
1221 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds()); 1263 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds());
1222 1264
1223 auto list = base::MakeRefCounted<cc::DisplayItemList>(); 1265 auto list = base::MakeRefCounted<cc::DisplayItemList>();
1224 ui::PaintContext context(list.get(), 1.f, gfx::Rect()); 1266 ui::PaintContext context(list.get(), 1.f, gfx::Rect(), false);
1225 1267
1226 v1->Paint(context); 1268 v1->Paint(PaintInfo::CreateRootPaintInfo(context, gfx::Size()));
1227 EXPECT_TRUE(v1->did_paint_); 1269 EXPECT_TRUE(v1->did_paint_);
1228 1270
1229 // Check that the canvas produced by |v1| for paint contains all of |v1|'s 1271 // Check that the canvas produced by |v1| for paint contains all of |v1|'s
1230 // visible bounds. 1272 // visible bounds.
1231 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds())); 1273 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds()));
1232 } 1274 }
1233 1275
1234 void TestView::SchedulePaintInRect(const gfx::Rect& rect) { 1276 void TestView::SchedulePaintInRect(const gfx::Rect& rect) {
1235 scheduled_paint_rects_.push_back(rect); 1277 scheduled_paint_rects_.push_back(rect);
1236 View::SchedulePaintInRect(rect); 1278 View::SchedulePaintInRect(rect);
(...skipping 3744 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 EXPECT_TRUE(parent_view->received_layer_change_notification()); 5023 EXPECT_TRUE(parent_view->received_layer_change_notification());
4982 EXPECT_EQ(1, parent_view->layer_change_count()); 5024 EXPECT_EQ(1, parent_view->layer_change_count());
4983 5025
4984 parent_view->Reset(); 5026 parent_view->Reset();
4985 child_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR); 5027 child_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
4986 EXPECT_TRUE(parent_view->received_layer_change_notification()); 5028 EXPECT_TRUE(parent_view->received_layer_change_notification());
4987 EXPECT_EQ(1, parent_view->layer_change_count()); 5029 EXPECT_EQ(1, parent_view->layer_change_count());
4988 } 5030 }
4989 5031
4990 } // namespace views 5032 } // namespace views
OLDNEW
« ui/views/view.h ('K') | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698