OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 scoped_ptr<Layer> layer(CreateTextureRootLayer(gfx::Rect(0, 0, 0, 0))); | 597 scoped_ptr<Layer> layer(CreateTextureRootLayer(gfx::Rect(0, 0, 0, 0))); |
598 Draw(); | 598 Draw(); |
599 EXPECT_TRUE(layer->texture() == NULL); | 599 EXPECT_TRUE(layer->texture() == NULL); |
600 | 600 |
601 layer->SetBounds(gfx::Rect(0, 0, 400, 400)); | 601 layer->SetBounds(gfx::Rect(0, 0, 400, 400)); |
602 Draw(); | 602 Draw(); |
603 EXPECT_TRUE(layer->texture() != NULL); | 603 EXPECT_TRUE(layer->texture() != NULL); |
604 } | 604 } |
605 | 605 |
606 // Verifies that when there are many potential holes, the largest one is picked. | 606 // Verifies that when there are many potential holes, the largest one is picked. |
607 TEST_F(LayerWithNullDelegateTest, LargestHole) { | 607 TEST_F(LayerWithNullDelegateTest, |
| 608 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(LargestHole)) { |
608 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 609 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
609 | 610 |
610 scoped_ptr<Layer> child1(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 611 scoped_ptr<Layer> child1(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
611 parent->Add(child1.get()); | 612 parent->Add(child1.get()); |
612 | 613 |
613 scoped_ptr<Layer> child2(CreateTextureLayer(gfx::Rect(75, 75, 200, 200))); | 614 scoped_ptr<Layer> child2(CreateTextureLayer(gfx::Rect(75, 75, 200, 200))); |
614 parent->Add(child2.get()); | 615 parent->Add(child2.get()); |
615 | 616 |
616 Draw(); | 617 Draw(); |
617 | 618 |
618 EXPECT_EQ(gfx::Rect(75, 75, 200, 200), parent->hole_rect()); | 619 EXPECT_EQ(gfx::Rect(75, 75, 200, 200), parent->hole_rect()); |
619 } | 620 } |
620 | 621 |
621 // Verifies that the largest hole in the draw order is picked | 622 // Verifies that the largest hole in the draw order is picked |
622 TEST_F(LayerWithNullDelegateTest, HoleGeneratedFromLeaf) { | 623 TEST_F(LayerWithNullDelegateTest, |
| 624 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(HoleGeneratedFromLeaf)) { |
623 // Layer tree looks like: | 625 // Layer tree looks like: |
624 // node 1 | 626 // node 1 |
625 // |_ node 11 | 627 // |_ node 11 |
626 // |_ node 111 | 628 // |_ node 111 |
627 // |_ node 12 | 629 // |_ node 12 |
628 // |_ node 121 | 630 // |_ node 121 |
629 | 631 |
630 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 632 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
631 | 633 |
632 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 634 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
633 node1->Add(node11.get()); | 635 node1->Add(node11.get()); |
634 | 636 |
635 scoped_ptr<Layer> node12(CreateTextureLayer(gfx::Rect(75, 75, 200, 200))); | 637 scoped_ptr<Layer> node12(CreateTextureLayer(gfx::Rect(75, 75, 200, 200))); |
636 node1->Add(node12.get()); | 638 node1->Add(node12.get()); |
637 | 639 |
638 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); | 640 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); |
639 node11->Add(node111.get()); | 641 node11->Add(node111.get()); |
640 | 642 |
641 scoped_ptr<Layer> node121(CreateTextureLayer(gfx::Rect(10, 10, 190, 190))); | 643 scoped_ptr<Layer> node121(CreateTextureLayer(gfx::Rect(10, 10, 190, 190))); |
642 node12->Add(node121.get()); | 644 node12->Add(node121.get()); |
643 | 645 |
644 Draw(); | 646 Draw(); |
645 | 647 |
646 EXPECT_EQ(gfx::Rect(75, 75, 200, 200), node1->hole_rect()); | 648 EXPECT_EQ(gfx::Rect(75, 75, 200, 200), node1->hole_rect()); |
647 EXPECT_EQ(gfx::Rect(25, 25, 75, 75), node11->hole_rect()); | 649 EXPECT_EQ(gfx::Rect(25, 25, 75, 75), node11->hole_rect()); |
648 EXPECT_EQ(gfx::Rect(10, 10, 190, 190), node12->hole_rect()); | 650 EXPECT_EQ(gfx::Rect(10, 10, 190, 190), node12->hole_rect()); |
649 } | 651 } |
650 | 652 |
651 // Verifies that a hole can only punched into a layer with opacity = 1.0f. | 653 // Verifies that a hole can only punched into a layer with opacity = 1.0f. |
652 TEST_F(LayerWithNullDelegateTest, NoHoleWhenPartialOpacity) { | 654 TEST_F(LayerWithNullDelegateTest, |
| 655 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(NoHoleWhenPartialOpacity)) { |
653 // Layer tree looks like: | 656 // Layer tree looks like: |
654 // node 1 | 657 // node 1 |
655 // |_ node 11 | 658 // |_ node 11 |
656 // |_ node 111 | 659 // |_ node 111 |
657 | 660 |
658 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 661 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
659 | 662 |
660 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 663 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
661 node1->Add(node11.get()); | 664 node1->Add(node11.get()); |
662 | 665 |
663 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); | 666 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); |
664 node11->Add(node111.get()); | 667 node11->Add(node111.get()); |
665 | 668 |
666 Draw(); | 669 Draw(); |
667 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); | 670 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); |
668 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); | 671 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); |
669 | 672 |
670 | 673 |
671 node11->SetOpacity(0.5f); | 674 node11->SetOpacity(0.5f); |
672 Draw(); | 675 Draw(); |
673 EXPECT_TRUE(node1->hole_rect().IsEmpty()); | 676 EXPECT_TRUE(node1->hole_rect().IsEmpty()); |
674 EXPECT_TRUE(node11->hole_rect().IsEmpty()); | 677 EXPECT_TRUE(node11->hole_rect().IsEmpty()); |
675 } | 678 } |
676 | 679 |
677 // Verifies that a non visible layer or any of its children is not a hole. | 680 // Verifies that a non visible layer or any of its children is not a hole. |
678 TEST_F(LayerWithNullDelegateTest, NonVisibleLayerCannotBeHole) { | 681 TEST_F(LayerWithNullDelegateTest, |
| 682 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(NonVisibleLayerCannotBeHole)) { |
679 // Layer tree looks like: | 683 // Layer tree looks like: |
680 // node 1 | 684 // node 1 |
681 // |_ node 11 | 685 // |_ node 11 |
682 // |_ node 111 | 686 // |_ node 111 |
683 | 687 |
684 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 688 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
685 | 689 |
686 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 690 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
687 node1->Add(node11.get()); | 691 node1->Add(node11.get()); |
688 | 692 |
689 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); | 693 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); |
690 node11->Add(node111.get()); | 694 node11->Add(node111.get()); |
691 | 695 |
692 Draw(); | 696 Draw(); |
693 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); | 697 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); |
694 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); | 698 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); |
695 | 699 |
696 | 700 |
697 node11->SetVisible(false); | 701 node11->SetVisible(false); |
698 Draw(); | 702 Draw(); |
699 EXPECT_TRUE(node1->hole_rect().IsEmpty()); | 703 EXPECT_TRUE(node1->hole_rect().IsEmpty()); |
700 EXPECT_TRUE(node11->hole_rect().IsEmpty()); | 704 EXPECT_TRUE(node11->hole_rect().IsEmpty()); |
701 } | 705 } |
702 | 706 |
703 // Verifies that a layer which doesn't fill its bounds opaquely cannot punch a | 707 // Verifies that a layer which doesn't fill its bounds opaquely cannot punch a |
704 // hole. However its children should still be able to punch a hole. | 708 // hole. However its children should still be able to punch a hole. |
705 TEST_F(LayerWithNullDelegateTest, LayerNotFillingBoundsOpaquelyCannotBeHole) { | 709 TEST_F(LayerWithNullDelegateTest, |
| 710 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR( |
| 711 LayerNotFillingBoundsOpaquelyCannotBeHole)) { |
706 // Layer tree looks like: | 712 // Layer tree looks like: |
707 // node 1 | 713 // node 1 |
708 // |_ node 11 | 714 // |_ node 11 |
709 // |_ node 111 | 715 // |_ node 111 |
710 | 716 |
711 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 717 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
712 | 718 |
713 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 719 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
714 node1->Add(node11.get()); | 720 node1->Add(node11.get()); |
715 | 721 |
716 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); | 722 scoped_ptr<Layer> node111(CreateTextureLayer(gfx::Rect(10, 10, 20, 20))); |
717 node11->Add(node111.get()); | 723 node11->Add(node111.get()); |
718 | 724 |
719 Draw(); | 725 Draw(); |
720 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); | 726 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), node1->hole_rect()); |
721 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); | 727 EXPECT_EQ(gfx::Rect(10, 10, 20, 20), node11->hole_rect()); |
722 | 728 |
723 | 729 |
724 node11->SetFillsBoundsOpaquely(false); | 730 node11->SetFillsBoundsOpaquely(false); |
725 Draw(); | 731 Draw(); |
726 EXPECT_EQ(gfx::Rect(60, 60, 20, 20), node1->hole_rect()); | 732 EXPECT_EQ(gfx::Rect(60, 60, 20, 20), node1->hole_rect()); |
727 EXPECT_TRUE(node11->hole_rect().IsEmpty()); | 733 EXPECT_TRUE(node11->hole_rect().IsEmpty()); |
728 } | 734 } |
729 | 735 |
730 // Verifies that the hole is with respect to the local bounds of its parent. | 736 // Verifies that the hole is with respect to the local bounds of its parent. |
731 TEST_F(LayerWithNullDelegateTest, HoleLocalBounds) { | 737 TEST_F(LayerWithNullDelegateTest, |
| 738 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(HoleLocalBounds)) { |
732 scoped_ptr<Layer> parent(CreateTextureRootLayer( | 739 scoped_ptr<Layer> parent(CreateTextureRootLayer( |
733 gfx::Rect(100, 100, 150, 150))); | 740 gfx::Rect(100, 100, 150, 150))); |
734 | 741 |
735 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 742 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
736 parent->Add(child.get()); | 743 parent->Add(child.get()); |
737 | 744 |
738 Draw(); | 745 Draw(); |
739 | 746 |
740 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), parent->hole_rect()); | 747 EXPECT_EQ(gfx::Rect(50, 50, 100, 100), parent->hole_rect()); |
741 } | 748 } |
742 | 749 |
743 // Verifies that there is no hole present when one of the child layers has a | 750 // Verifies that there is no hole present when one of the child layers has a |
744 // transform. | 751 // transform. |
745 TEST_F(LayerWithNullDelegateTest, NoHoleWithTransform) { | 752 TEST_F(LayerWithNullDelegateTest, |
| 753 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(NoHoleWithTransform)) { |
746 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 754 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
747 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); | 755 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); |
748 parent->Add(child.get()); | 756 parent->Add(child.get()); |
749 | 757 |
750 Draw(); | 758 Draw(); |
751 | 759 |
752 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); | 760 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); |
753 | 761 |
754 ui::Transform t; | 762 ui::Transform t; |
755 t.SetTranslate(-50, -50); | 763 t.SetTranslate(-50, -50); |
756 t.ConcatRotate(45.0f); | 764 t.ConcatRotate(45.0f); |
757 t.ConcatTranslate(50, 50); | 765 t.ConcatTranslate(50, 50); |
758 child->SetTransform(t); | 766 child->SetTransform(t); |
759 | 767 |
760 Draw(); | 768 Draw(); |
761 | 769 |
762 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), parent->hole_rect()); | 770 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), parent->hole_rect()); |
763 } | 771 } |
764 | 772 |
765 // Verifies that if the child layer is rotated by a multiple of ninety degrees | 773 // Verifies that if the child layer is rotated by a multiple of ninety degrees |
766 // we punch a hole | 774 // we punch a hole |
767 TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) { | 775 TEST_F(LayerWithNullDelegateTest, |
| 776 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(HoleWithNinetyDegreeTransforms)) { |
768 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 777 scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
769 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 50, 50))); | 778 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 50, 50))); |
770 parent->Add(child.get()); | 779 parent->Add(child.get()); |
771 | 780 |
772 Draw(); | 781 Draw(); |
773 | 782 |
774 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); | 783 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); |
775 | 784 |
776 for (int i = -4; i <= 4; ++i) { | 785 for (int i = -4; i <= 4; ++i) { |
777 SCOPED_TRACE(::testing::Message() << "Iteration " << i); | 786 SCOPED_TRACE(::testing::Message() << "Iteration " << i); |
(...skipping 10 matching lines...) Expand all Loading... |
788 t.TransformRect(&target_rect); | 797 t.TransformRect(&target_rect); |
789 | 798 |
790 Draw(); | 799 Draw(); |
791 | 800 |
792 EXPECT_EQ(target_rect, parent->hole_rect()); | 801 EXPECT_EQ(target_rect, parent->hole_rect()); |
793 } | 802 } |
794 } | 803 } |
795 | 804 |
796 // Verifies that a layer which doesn't have a texture cannot punch a | 805 // Verifies that a layer which doesn't have a texture cannot punch a |
797 // hole. However its children should still be able to punch a hole. | 806 // hole. However its children should still be able to punch a hole. |
798 TEST_F(LayerWithNullDelegateTest, HoleWithRelativeNinetyDegreeTransforms) { | 807 TEST_F(LayerWithNullDelegateTest, |
| 808 NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR( |
| 809 HoleWithRelativeNinetyDegreeTransforms)) { |
799 // Layer tree looks like: | 810 // Layer tree looks like: |
800 // node 1 | 811 // node 1 |
801 // |_ node 11 | 812 // |_ node 11 |
802 // |_ node 12 | 813 // |_ node 12 |
803 | 814 |
804 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); | 815 scoped_ptr<Layer> node1(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); |
805 | 816 |
806 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 50, 50))); | 817 scoped_ptr<Layer> node11(CreateTextureLayer(gfx::Rect(50, 50, 50, 50))); |
807 node1->Add(node11.get()); | 818 node1->Add(node11.get()); |
808 | 819 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 GetCompositor()->RemoveObserver(&observer); | 1122 GetCompositor()->RemoveObserver(&observer); |
1112 | 1123 |
1113 // Opacity changes should no longer alert the removed observer. | 1124 // Opacity changes should no longer alert the removed observer. |
1114 observer.Reset(); | 1125 observer.Reset(); |
1115 l2->SetOpacity(0.5f); | 1126 l2->SetOpacity(0.5f); |
1116 RunPendingMessages(); | 1127 RunPendingMessages(); |
1117 EXPECT_FALSE(observer.notified()); | 1128 EXPECT_FALSE(observer.notified()); |
1118 } | 1129 } |
1119 | 1130 |
1120 } // namespace ui | 1131 } // namespace ui |
OLD | NEW |