OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/damage_tracker.h" | 5 #include "cc/damage_tracker.h" |
6 | 6 |
7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
8 #include "cc/layer_tree_host_common.h" | 8 #include "cc/layer_tree_host_common.h" |
9 #include "cc/math_util.h" | 9 #include "cc/math_util.h" |
10 #include "cc/single_thread_proxy.h" | 10 #include "cc/single_thread_proxy.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 class DamageTrackerTest : public testing::Test { | 68 class DamageTrackerTest : public testing::Test { |
69 public: | 69 public: |
70 DamageTrackerTest() | 70 DamageTrackerTest() |
71 : m_hostImpl(&m_proxy) | 71 : m_hostImpl(&m_proxy) |
72 { | 72 { |
73 } | 73 } |
74 | 74 |
75 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() | 75 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() |
76 { | 76 { |
77 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1); | 77 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(),
1); |
78 scoped_ptr<LayerImpl> child = LayerImpl::create(&m_hostImpl, 2); | 78 scoped_ptr<LayerImpl> child = LayerImpl::create(m_hostImpl.activeTree(),
2); |
79 | 79 |
80 root->setPosition(gfx::PointF()); | 80 root->setPosition(gfx::PointF()); |
81 root->setAnchorPoint(gfx::PointF()); | 81 root->setAnchorPoint(gfx::PointF()); |
82 root->setBounds(gfx::Size(500, 500)); | 82 root->setBounds(gfx::Size(500, 500)); |
83 root->setContentBounds(gfx::Size(500, 500)); | 83 root->setContentBounds(gfx::Size(500, 500)); |
84 root->setDrawsContent(true); | 84 root->setDrawsContent(true); |
85 root->createRenderSurface(); | 85 root->createRenderSurface(); |
86 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(
500, 500))); | 86 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(
500, 500))); |
87 | 87 |
88 child->setPosition(gfx::PointF(100, 100)); | 88 child->setPosition(gfx::PointF(100, 100)); |
89 child->setAnchorPoint(gfx::PointF()); | 89 child->setAnchorPoint(gfx::PointF()); |
90 child->setBounds(gfx::Size(30, 30)); | 90 child->setBounds(gfx::Size(30, 30)); |
91 child->setContentBounds(gfx::Size(30, 30)); | 91 child->setContentBounds(gfx::Size(30, 30)); |
92 child->setDrawsContent(true); | 92 child->setDrawsContent(true); |
93 root->addChild(child.Pass()); | 93 root->addChild(child.Pass()); |
94 | 94 |
95 return root.Pass(); | 95 return root.Pass(); |
96 } | 96 } |
97 | 97 |
98 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces() | 98 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces() |
99 { | 99 { |
100 // This test tree has two render surfaces: one for the root, and one for | 100 // This test tree has two render surfaces: one for the root, and one for |
101 // child1. Additionally, the root has a second child layer, and child1 h
as two | 101 // child1. Additionally, the root has a second child layer, and child1 h
as two |
102 // children of its own. | 102 // children of its own. |
103 | 103 |
104 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1); | 104 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(),
1); |
105 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&m_hostImpl, 2); | 105 scoped_ptr<LayerImpl> child1 = LayerImpl::create(m_hostImpl.activeTree()
, 2); |
106 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3); | 106 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree()
, 3); |
107 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&m_hostImpl, 4); | 107 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(m_hostImpl.activeT
ree(), 4); |
108 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::create(&m_hostImpl, 5); | 108 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::create(m_hostImpl.activeT
ree(), 5); |
109 | 109 |
110 root->setPosition(gfx::PointF()); | 110 root->setPosition(gfx::PointF()); |
111 root->setAnchorPoint(gfx::PointF()); | 111 root->setAnchorPoint(gfx::PointF()); |
112 root->setBounds(gfx::Size(500, 500)); | 112 root->setBounds(gfx::Size(500, 500)); |
113 root->setContentBounds(gfx::Size(500, 500)); | 113 root->setContentBounds(gfx::Size(500, 500)); |
114 root->setDrawsContent(true); | 114 root->setDrawsContent(true); |
115 root->createRenderSurface(); | 115 root->createRenderSurface(); |
116 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(
500, 500))); | 116 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(
500, 500))); |
117 | 117 |
118 child1->setPosition(gfx::PointF(100, 100)); | 118 child1->setPosition(gfx::PointF(100, 100)); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 529 |
530 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer) | 530 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer) |
531 { | 531 { |
532 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 532 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
533 LayerImpl* child1 = root->children()[0]; | 533 LayerImpl* child1 = root->children()[0]; |
534 | 534 |
535 // CASE 1: Adding a new layer should cause the appropriate damage. | 535 // CASE 1: Adding a new layer should cause the appropriate damage. |
536 // | 536 // |
537 clearDamageForAllSurfaces(root.get()); | 537 clearDamageForAllSurfaces(root.get()); |
538 { | 538 { |
539 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3); | 539 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree()
, 3); |
540 child2->setPosition(gfx::PointF(400, 380)); | 540 child2->setPosition(gfx::PointF(400, 380)); |
541 child2->setAnchorPoint(gfx::PointF()); | 541 child2->setAnchorPoint(gfx::PointF()); |
542 child2->setBounds(gfx::Size(6, 8)); | 542 child2->setBounds(gfx::Size(6, 8)); |
543 child2->setContentBounds(gfx::Size(6, 8)); | 543 child2->setContentBounds(gfx::Size(6, 8)); |
544 child2->setDrawsContent(true); | 544 child2->setDrawsContent(true); |
545 root->addChild(child2.Pass()); | 545 root->addChild(child2.Pass()); |
546 } | 546 } |
547 emulateDrawingOneFrame(root.get()); | 547 emulateDrawingOneFrame(root.get()); |
548 | 548 |
549 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. | 549 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. |
(...skipping 20 matching lines...) Expand all Loading... |
570 | 570 |
571 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer) | 571 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer) |
572 { | 572 { |
573 // If child2 is added to the layer tree, but it doesn't have any explicit da
mage of | 573 // If child2 is added to the layer tree, but it doesn't have any explicit da
mage of |
574 // its own, it should still indeed damage the target surface. | 574 // its own, it should still indeed damage the target surface. |
575 | 575 |
576 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 576 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
577 | 577 |
578 clearDamageForAllSurfaces(root.get()); | 578 clearDamageForAllSurfaces(root.get()); |
579 { | 579 { |
580 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3); | 580 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree()
, 3); |
581 child2->setPosition(gfx::PointF(400, 380)); | 581 child2->setPosition(gfx::PointF(400, 380)); |
582 child2->setAnchorPoint(gfx::PointF()); | 582 child2->setAnchorPoint(gfx::PointF()); |
583 child2->setBounds(gfx::Size(6, 8)); | 583 child2->setBounds(gfx::Size(6, 8)); |
584 child2->setContentBounds(gfx::Size(6, 8)); | 584 child2->setContentBounds(gfx::Size(6, 8)); |
585 child2->setDrawsContent(true); | 585 child2->setDrawsContent(true); |
586 child2->resetAllChangeTrackingForSubtree(); | 586 child2->resetAllChangeTrackingForSubtree(); |
587 // Sanity check the initial conditions of the test, if these asserts tri
gger, it | 587 // Sanity check the initial conditions of the test, if these asserts tri
gger, it |
588 // means the test no longer actually covers the intended scenario. | 588 // means the test no longer actually covers the intended scenario. |
589 ASSERT_FALSE(child2->layerPropertyChanged()); | 589 ASSERT_FALSE(child2->layerPropertyChanged()); |
590 ASSERT_TRUE(child2->updateRect().IsEmpty()); | 590 ASSERT_TRUE(child2->updateRect().IsEmpty()); |
591 root->addChild(child2.Pass()); | 591 root->addChild(child2.Pass()); |
592 } | 592 } |
593 emulateDrawingOneFrame(root.get()); | 593 emulateDrawingOneFrame(root.get()); |
594 | 594 |
595 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. | 595 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. |
596 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); | 596 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); |
597 | 597 |
598 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); | 598 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); |
599 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); | 599 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); |
600 } | 600 } |
601 | 601 |
602 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers) | 602 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers) |
603 { | 603 { |
604 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 604 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
605 LayerImpl* child1 = root->children()[0]; | 605 LayerImpl* child1 = root->children()[0]; |
606 | 606 |
607 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. | 607 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. |
608 clearDamageForAllSurfaces(root.get()); | 608 clearDamageForAllSurfaces(root.get()); |
609 { | 609 { |
610 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3); | 610 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree()
, 3); |
611 child2->setPosition(gfx::PointF(400, 380)); | 611 child2->setPosition(gfx::PointF(400, 380)); |
612 child2->setAnchorPoint(gfx::PointF()); | 612 child2->setAnchorPoint(gfx::PointF()); |
613 child2->setBounds(gfx::Size(6, 8)); | 613 child2->setBounds(gfx::Size(6, 8)); |
614 child2->setContentBounds(gfx::Size(6, 8)); | 614 child2->setContentBounds(gfx::Size(6, 8)); |
615 child2->setDrawsContent(true); | 615 child2->setDrawsContent(true); |
616 root->addChild(child2.Pass()); | 616 root->addChild(child2.Pass()); |
617 } | 617 } |
618 LayerImpl* child2 = root->children()[1]; | 618 LayerImpl* child2 = root->children()[1]; |
619 emulateDrawingOneFrame(root.get()); | 619 emulateDrawingOneFrame(root.get()); |
620 | 620 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 LayerImpl* grandChild2 = child1->children()[1]; | 821 LayerImpl* grandChild2 = child1->children()[1]; |
822 | 822 |
823 // Damage on a surface that has a reflection should cause the target surface
to | 823 // Damage on a surface that has a reflection should cause the target surface
to |
824 // receive the surface's damage and the surface's reflected damage. | 824 // receive the surface's damage and the surface's reflected damage. |
825 | 825 |
826 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds | 826 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds |
827 // of child1's surface. This way, we can test reflection changes without cha
nging | 827 // of child1's surface. This way, we can test reflection changes without cha
nging |
828 // contentBounds of the surface. | 828 // contentBounds of the surface. |
829 grandChild2->setPosition(gfx::PointF(180, 180)); | 829 grandChild2->setPosition(gfx::PointF(180, 180)); |
830 { | 830 { |
831 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::create(&m_hostImpl, 6); | 831 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::create(m_hostImpl.activeT
ree(), 6); |
832 grandChild3->setPosition(gfx::PointF(240, 240)); | 832 grandChild3->setPosition(gfx::PointF(240, 240)); |
833 grandChild3->setAnchorPoint(gfx::PointF()); | 833 grandChild3->setAnchorPoint(gfx::PointF()); |
834 grandChild3->setBounds(gfx::Size(10, 10)); | 834 grandChild3->setBounds(gfx::Size(10, 10)); |
835 grandChild3->setContentBounds(gfx::Size(10, 10)); | 835 grandChild3->setContentBounds(gfx::Size(10, 10)); |
836 grandChild3->setDrawsContent(true); | 836 grandChild3->setDrawsContent(true); |
837 child1->addChild(grandChild3.Pass()); | 837 child1->addChild(grandChild3.Pass()); |
838 } | 838 } |
839 child1->setOpacity(0.5); | 839 child1->setOpacity(0.5); |
840 emulateDrawingOneFrame(root.get()); | 840 emulateDrawingOneFrame(root.get()); |
841 | 841 |
842 // CASE 1: adding a reflection about the left edge of grandChild1. | 842 // CASE 1: adding a reflection about the left edge of grandChild1. |
843 // | 843 // |
844 clearDamageForAllSurfaces(root.get()); | 844 clearDamageForAllSurfaces(root.get()); |
845 { | 845 { |
846 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl
, 7); | 846 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl.
activeTree(), 7); |
847 grandChild1Replica->setPosition(gfx::PointF()); | 847 grandChild1Replica->setPosition(gfx::PointF()); |
848 grandChild1Replica->setAnchorPoint(gfx::PointF()); | 848 grandChild1Replica->setAnchorPoint(gfx::PointF()); |
849 gfx::Transform reflection; | 849 gfx::Transform reflection; |
850 reflection.Scale3d(-1, 1, 1); | 850 reflection.Scale3d(-1, 1, 1); |
851 grandChild1Replica->setTransform(reflection); | 851 grandChild1Replica->setTransform(reflection); |
852 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 852 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
853 } | 853 } |
854 emulateDrawingOneFrame(root.get()); | 854 emulateDrawingOneFrame(root.get()); |
855 | 855 |
856 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke
r()->currentDamageRect(); | 856 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke
r()->currentDamageRect(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 904 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
905 LayerImpl* child = root->children()[0]; | 905 LayerImpl* child = root->children()[0]; |
906 | 906 |
907 // In the current implementation of the damage tracker, changes to mask laye
rs should | 907 // In the current implementation of the damage tracker, changes to mask laye
rs should |
908 // damage the entire corresponding surface. | 908 // damage the entire corresponding surface. |
909 | 909 |
910 clearDamageForAllSurfaces(root.get()); | 910 clearDamageForAllSurfaces(root.get()); |
911 | 911 |
912 // Set up the mask layer. | 912 // Set up the mask layer. |
913 { | 913 { |
914 scoped_ptr<LayerImpl> maskLayer = LayerImpl::create(&m_hostImpl, 3); | 914 scoped_ptr<LayerImpl> maskLayer = LayerImpl::create(m_hostImpl.activeTre
e(), 3); |
915 maskLayer->setPosition(child->position()); | 915 maskLayer->setPosition(child->position()); |
916 maskLayer->setAnchorPoint(gfx::PointF()); | 916 maskLayer->setAnchorPoint(gfx::PointF()); |
917 maskLayer->setBounds(child->bounds()); | 917 maskLayer->setBounds(child->bounds()); |
918 maskLayer->setContentBounds(child->bounds()); | 918 maskLayer->setContentBounds(child->bounds()); |
919 child->setMaskLayer(maskLayer.Pass()); | 919 child->setMaskLayer(maskLayer.Pass()); |
920 } | 920 } |
921 LayerImpl* maskLayer = child->maskLayer(); | 921 LayerImpl* maskLayer = child->maskLayer(); |
922 | 922 |
923 // Add opacity and a grandChild so that the render surface persists even aft
er we remove the mask. | 923 // Add opacity and a grandChild so that the render surface persists even aft
er we remove the mask. |
924 child->setOpacity(0.5); | 924 child->setOpacity(0.5); |
925 { | 925 { |
926 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(&m_hostImpl, 4); | 926 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(m_hostImpl.activeTr
ee(), 4); |
927 grandChild->setPosition(gfx::PointF(2, 2)); | 927 grandChild->setPosition(gfx::PointF(2, 2)); |
928 grandChild->setAnchorPoint(gfx::PointF()); | 928 grandChild->setAnchorPoint(gfx::PointF()); |
929 grandChild->setBounds(gfx::Size(2, 2)); | 929 grandChild->setBounds(gfx::Size(2, 2)); |
930 grandChild->setContentBounds(gfx::Size(2, 2)); | 930 grandChild->setContentBounds(gfx::Size(2, 2)); |
931 grandChild->setDrawsContent(true); | 931 grandChild->setDrawsContent(true); |
932 child->addChild(grandChild.Pass()); | 932 child->addChild(grandChild.Pass()); |
933 } | 933 } |
934 emulateDrawingOneFrame(root.get()); | 934 emulateDrawingOneFrame(root.get()); |
935 | 935 |
936 // Sanity check that a new surface was created for the child. | 936 // Sanity check that a new surface was created for the child. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 LayerImpl* child1 = root->children()[0]; | 989 LayerImpl* child1 = root->children()[0]; |
990 LayerImpl* grandChild1 = child1->children()[0]; | 990 LayerImpl* grandChild1 = child1->children()[0]; |
991 | 991 |
992 // Changes to a replica's mask should not damage the original surface, becau
se it is | 992 // Changes to a replica's mask should not damage the original surface, becau
se it is |
993 // not masked. But it does damage the ancestor target surface. | 993 // not masked. But it does damage the ancestor target surface. |
994 | 994 |
995 clearDamageForAllSurfaces(root.get()); | 995 clearDamageForAllSurfaces(root.get()); |
996 | 996 |
997 // Create a reflection about the left edge of grandChild1. | 997 // Create a reflection about the left edge of grandChild1. |
998 { | 998 { |
999 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl
, 6); | 999 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl.
activeTree(), 6); |
1000 grandChild1Replica->setPosition(gfx::PointF()); | 1000 grandChild1Replica->setPosition(gfx::PointF()); |
1001 grandChild1Replica->setAnchorPoint(gfx::PointF()); | 1001 grandChild1Replica->setAnchorPoint(gfx::PointF()); |
1002 gfx::Transform reflection; | 1002 gfx::Transform reflection; |
1003 reflection.Scale3d(-1, 1, 1); | 1003 reflection.Scale3d(-1, 1, 1); |
1004 grandChild1Replica->setTransform(reflection); | 1004 grandChild1Replica->setTransform(reflection); |
1005 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 1005 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
1006 } | 1006 } |
1007 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 1007 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
1008 | 1008 |
1009 // Set up the mask layer on the replica layer | 1009 // Set up the mask layer on the replica layer |
1010 { | 1010 { |
1011 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(&m_hostImpl,
7); | 1011 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(m_hostImpl.ac
tiveTree(), 7); |
1012 replicaMaskLayer->setPosition(gfx::PointF()); | 1012 replicaMaskLayer->setPosition(gfx::PointF()); |
1013 replicaMaskLayer->setAnchorPoint(gfx::PointF()); | 1013 replicaMaskLayer->setAnchorPoint(gfx::PointF()); |
1014 replicaMaskLayer->setBounds(grandChild1->bounds()); | 1014 replicaMaskLayer->setBounds(grandChild1->bounds()); |
1015 replicaMaskLayer->setContentBounds(grandChild1->bounds()); | 1015 replicaMaskLayer->setContentBounds(grandChild1->bounds()); |
1016 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); | 1016 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); |
1017 } | 1017 } |
1018 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); | 1018 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); |
1019 | 1019 |
1020 emulateDrawingOneFrame(root.get()); | 1020 emulateDrawingOneFrame(root.get()); |
1021 | 1021 |
(...skipping 29 matching lines...) Expand all Loading... |
1051 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 1051 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
1052 LayerImpl* child1 = root->children()[0]; | 1052 LayerImpl* child1 = root->children()[0]; |
1053 LayerImpl* grandChild1 = child1->children()[0]; | 1053 LayerImpl* grandChild1 = child1->children()[0]; |
1054 | 1054 |
1055 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; | 1055 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; |
1056 clearDamageForAllSurfaces(root.get()); | 1056 clearDamageForAllSurfaces(root.get()); |
1057 | 1057 |
1058 grandChild1->setAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a
nchor being tested, but by convention its expected to be the same as the replica
's anchor point. | 1058 grandChild1->setAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a
nchor being tested, but by convention its expected to be the same as the replica
's anchor point. |
1059 | 1059 |
1060 { | 1060 { |
1061 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl
, 6); | 1061 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl.
activeTree(), 6); |
1062 grandChild1Replica->setPosition(gfx::PointF()); | 1062 grandChild1Replica->setPosition(gfx::PointF()); |
1063 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an
chor being tested. | 1063 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an
chor being tested. |
1064 gfx::Transform reflection; | 1064 gfx::Transform reflection; |
1065 reflection.Scale3d(-1, 1, 1); | 1065 reflection.Scale3d(-1, 1, 1); |
1066 grandChild1Replica->setTransform(reflection); | 1066 grandChild1Replica->setTransform(reflection); |
1067 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 1067 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
1068 } | 1068 } |
1069 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 1069 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
1070 | 1070 |
1071 // Set up the mask layer on the replica layer | 1071 // Set up the mask layer on the replica layer |
1072 { | 1072 { |
1073 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(&m_hostImpl,
7); | 1073 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(m_hostImpl.ac
tiveTree(), 7); |
1074 replicaMaskLayer->setPosition(gfx::PointF()); | 1074 replicaMaskLayer->setPosition(gfx::PointF()); |
1075 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th
e anchor being tested. | 1075 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th
e anchor being tested. |
1076 replicaMaskLayer->setBounds(grandChild1->bounds()); | 1076 replicaMaskLayer->setBounds(grandChild1->bounds()); |
1077 replicaMaskLayer->setContentBounds(grandChild1->bounds()); | 1077 replicaMaskLayer->setContentBounds(grandChild1->bounds()); |
1078 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); | 1078 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); |
1079 } | 1079 } |
1080 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); | 1080 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); |
1081 | 1081 |
1082 emulateDrawingOneFrame(root.get()); | 1082 emulateDrawingOneFrame(root.get()); |
1083 | 1083 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 emulateDrawingOneFrame(root.get()); | 1117 emulateDrawingOneFrame(root.get()); |
1118 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1118 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1119 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); | 1119 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); |
1120 } | 1120 } |
1121 | 1121 |
1122 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList) | 1122 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList) |
1123 { | 1123 { |
1124 // Though it should never happen, its a good idea to verify that the damage
tracker | 1124 // Though it should never happen, its a good idea to verify that the damage
tracker |
1125 // does not crash when it receives an empty layerList. | 1125 // does not crash when it receives an empty layerList. |
1126 | 1126 |
1127 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1); | 1127 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(), 1); |
1128 root->createRenderSurface(); | 1128 root->createRenderSurface(); |
1129 | 1129 |
1130 ASSERT_TRUE(root == root->renderTarget()); | 1130 ASSERT_TRUE(root == root->renderTarget()); |
1131 RenderSurfaceImpl* targetSurface = root->renderSurface(); | 1131 RenderSurfaceImpl* targetSurface = root->renderSurface(); |
1132 targetSurface->clearLayerLists(); | 1132 targetSurface->clearLayerLists(); |
1133 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay
erList(), targetSurface->owningLayerId(), false, gfx::Rect(), 0, WebFilterOperat
ions(), 0); | 1133 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay
erList(), targetSurface->owningLayerId(), false, gfx::Rect(), 0, WebFilterOperat
ions(), 0); |
1134 | 1134 |
1135 gfx::RectF damageRect = targetSurface->damageTracker()->currentDamageRect(); | 1135 gfx::RectF damageRect = targetSurface->damageTracker()->currentDamageRect(); |
1136 EXPECT_TRUE(damageRect.IsEmpty()); | 1136 EXPECT_TRUE(damageRect.IsEmpty()); |
1137 } | 1137 } |
(...skipping 25 matching lines...) Expand all Loading... |
1163 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1163 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
1164 | 1164 |
1165 // Damage should remain empty even after one frame, since there's yet no new
damage | 1165 // Damage should remain empty even after one frame, since there's yet no new
damage |
1166 emulateDrawingOneFrame(root.get()); | 1166 emulateDrawingOneFrame(root.get()); |
1167 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1167 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1168 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1168 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
1169 } | 1169 } |
1170 | 1170 |
1171 } // namespace | 1171 } // namespace |
1172 } // namespace cc | 1172 } // namespace cc |
OLD | NEW |