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

Side by Side Diff: cc/trees/damage_tracker_unittest.cc

Issue 1491033002: Create RenderSurface on Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alwayspt
Patch Set: fix for crash Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager_perftest.cc ('k') | cc/trees/draw_property_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/trees/damage_tracker.h" 5 #include "cc/trees/damage_tracker.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/layers/layer_impl.h" 8 #include "cc/layers/layer_impl.h"
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "cc/output/filter_operations.h" 10 #include "cc/output/filter_operations.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/gfx/geometry/rect_conversions.h" 22 #include "ui/gfx/geometry/rect_conversions.h"
23 23
24 namespace cc { 24 namespace cc {
25 namespace { 25 namespace {
26 26
27 void ExecuteCalculateDrawProperties(LayerImpl* root, 27 void ExecuteCalculateDrawProperties(LayerImpl* root,
28 LayerImplList* render_surface_layer_list) { 28 LayerImplList* render_surface_layer_list) {
29 // Sanity check: The test itself should create the root layer's render 29 // Sanity check: The test itself should create the root layer's render
30 // surface, so that the surface (and its damage tracker) can 30 // surface, so that the surface (and its damage tracker) can
31 // persist across multiple calls to this function. 31 // persist across multiple calls to this function.
32 ASSERT_TRUE(root->render_surface());
33 ASSERT_FALSE(render_surface_layer_list->size()); 32 ASSERT_FALSE(render_surface_layer_list->size());
34 33
35 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); 34 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root);
36 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 35 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
37 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 36 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
38 root, root->bounds(), render_surface_layer_list, 37 root, root->bounds(), render_surface_layer_list,
39 root->layer_tree_impl()->current_render_surface_list_id()); 38 root->layer_tree_impl()->current_render_surface_list_id());
40 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 39 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
40 ASSERT_TRUE(root->render_surface());
41 } 41 }
42 42
43 void ClearDamageForAllSurfaces(LayerImpl* layer) { 43 void ClearDamageForAllSurfaces(LayerImpl* layer) {
44 if (layer->render_surface()) 44 if (layer->render_surface())
45 layer->render_surface()->damage_tracker()->DidDrawDamagedArea(); 45 layer->render_surface()->damage_tracker()->DidDrawDamagedArea();
46 46
47 // Recursively clear damage for any existing surface. 47 // Recursively clear damage for any existing surface.
48 for (size_t i = 0; i < layer->children().size(); ++i) 48 for (size_t i = 0; i < layer->children().size(); ++i)
49 ClearDamageForAllSurfaces(layer->children()[i].get()); 49 ClearDamageForAllSurfaces(layer->children()[i].get());
50 } 50 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { 88 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() {
89 scoped_ptr<LayerImpl> root = 89 scoped_ptr<LayerImpl> root =
90 LayerImpl::Create(host_impl_.active_tree(), 1); 90 LayerImpl::Create(host_impl_.active_tree(), 1);
91 scoped_ptr<LayerImpl> child = 91 scoped_ptr<LayerImpl> child =
92 LayerImpl::Create(host_impl_.active_tree(), 2); 92 LayerImpl::Create(host_impl_.active_tree(), 2);
93 93
94 root->SetPosition(gfx::PointF()); 94 root->SetPosition(gfx::PointF());
95 root->SetBounds(gfx::Size(500, 500)); 95 root->SetBounds(gfx::Size(500, 500));
96 root->SetDrawsContent(true); 96 root->SetDrawsContent(true);
97 root->SetHasRenderSurface(true); 97 root->SetForceRenderSurface(true);
98 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500));
99 98
100 child->SetPosition(gfx::PointF(100.f, 100.f)); 99 child->SetPosition(gfx::PointF(100.f, 100.f));
101 child->SetBounds(gfx::Size(30, 30)); 100 child->SetBounds(gfx::Size(30, 30));
102 child->SetDrawsContent(true); 101 child->SetDrawsContent(true);
103 root->AddChild(std::move(child)); 102 root->AddChild(std::move(child));
104 103
105 return root; 104 return root;
106 } 105 }
107 106
108 scoped_ptr<LayerImpl> CreateTestTreeWithTwoSurfaces() { 107 scoped_ptr<LayerImpl> CreateTestTreeWithTwoSurfaces() {
109 // This test tree has two render surfaces: one for the root, and one for 108 // This test tree has two render surfaces: one for the root, and one for
110 // child1. Additionally, the root has a second child layer, and child1 has 109 // child1. Additionally, the root has a second child layer, and child1 has
111 // two children of its own. 110 // two children of its own.
112 111
113 scoped_ptr<LayerImpl> root = 112 scoped_ptr<LayerImpl> root =
114 LayerImpl::Create(host_impl_.active_tree(), 1); 113 LayerImpl::Create(host_impl_.active_tree(), 1);
115 scoped_ptr<LayerImpl> child1 = 114 scoped_ptr<LayerImpl> child1 =
116 LayerImpl::Create(host_impl_.active_tree(), 2); 115 LayerImpl::Create(host_impl_.active_tree(), 2);
117 scoped_ptr<LayerImpl> child2 = 116 scoped_ptr<LayerImpl> child2 =
118 LayerImpl::Create(host_impl_.active_tree(), 3); 117 LayerImpl::Create(host_impl_.active_tree(), 3);
119 scoped_ptr<LayerImpl> grand_child1 = 118 scoped_ptr<LayerImpl> grand_child1 =
120 LayerImpl::Create(host_impl_.active_tree(), 4); 119 LayerImpl::Create(host_impl_.active_tree(), 4);
121 scoped_ptr<LayerImpl> grand_child2 = 120 scoped_ptr<LayerImpl> grand_child2 =
122 LayerImpl::Create(host_impl_.active_tree(), 5); 121 LayerImpl::Create(host_impl_.active_tree(), 5);
123 122
124 root->SetPosition(gfx::PointF()); 123 root->SetPosition(gfx::PointF());
125 root->SetBounds(gfx::Size(500, 500)); 124 root->SetBounds(gfx::Size(500, 500));
126 root->SetDrawsContent(true); 125 root->SetDrawsContent(true);
127 root->SetHasRenderSurface(true); 126 root->SetForceRenderSurface(true);
128 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500));
129 127
130 child1->SetPosition(gfx::PointF(100.f, 100.f)); 128 child1->SetPosition(gfx::PointF(100.f, 100.f));
131 child1->SetBounds(gfx::Size(30, 30)); 129 child1->SetBounds(gfx::Size(30, 30));
132 // With a child that draws_content, opacity will cause the layer to create 130 // With a child that draws_content, opacity will cause the layer to create
133 // its own RenderSurface. This layer does not draw, but is intended to 131 // its own RenderSurface. This layer does not draw, but is intended to
134 // create its own RenderSurface. 132 // create its own RenderSurface.
135 child1->SetDrawsContent(false); 133 child1->SetDrawsContent(false);
136 child1->SetHasRenderSurface(true); 134 child1->SetForceRenderSurface(true);
137 135
138 child2->SetPosition(gfx::PointF(11.f, 11.f)); 136 child2->SetPosition(gfx::PointF(11.f, 11.f));
139 child2->SetBounds(gfx::Size(18, 18)); 137 child2->SetBounds(gfx::Size(18, 18));
140 child2->SetDrawsContent(true); 138 child2->SetDrawsContent(true);
141 139
142 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); 140 grand_child1->SetPosition(gfx::PointF(200.f, 200.f));
143 grand_child1->SetBounds(gfx::Size(6, 8)); 141 grand_child1->SetBounds(gfx::Size(6, 8));
144 grand_child1->SetDrawsContent(true); 142 grand_child1->SetDrawsContent(true);
145 143
146 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); 144 grand_child2->SetPosition(gfx::PointF(190.f, 190.f));
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 535
538 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( 536 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(
539 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2))); 537 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2)));
540 FilterOperations filters; 538 FilterOperations filters;
541 filters.Append(FilterOperation::CreateReferenceFilter(filter)); 539 filters.Append(FilterOperation::CreateReferenceFilter(filter));
542 int outset_top, outset_right, outset_bottom, outset_left; 540 int outset_top, outset_right, outset_bottom, outset_left;
543 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); 541 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left);
544 542
545 // Setting the filter will damage the whole surface. 543 // Setting the filter will damage the whole surface.
546 ClearDamageForAllSurfaces(root.get()); 544 ClearDamageForAllSurfaces(root.get());
547 child->SetHasRenderSurface(true); 545 child->SetForceRenderSurface(true);
548 child->SetFilters(filters); 546 child->SetFilters(filters);
549 EmulateDrawingOneFrame(root.get()); 547 EmulateDrawingOneFrame(root.get());
550 root_damage_rect = 548 root_damage_rect =
551 root->render_surface()->damage_tracker()->current_damage_rect(); 549 root->render_surface()->damage_tracker()->current_damage_rect();
552 child_damage_rect = 550 child_damage_rect =
553 child->render_surface()->damage_tracker()->current_damage_rect(); 551 child->render_surface()->damage_tracker()->current_damage_rect();
554 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), 552 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(),
555 root_damage_rect.ToString()); 553 root_damage_rect.ToString());
556 EXPECT_EQ( 554 EXPECT_EQ(
557 gfx::Rect(-outset_left, -outset_top, 30 + (outset_left + outset_right), 555 gfx::Rect(-outset_left, -outset_top, 30 + (outset_left + outset_right),
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 928
931 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { 929 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) {
932 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); 930 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces();
933 LayerImpl* child1 = root->children()[0].get(); 931 LayerImpl* child1 = root->children()[0].get();
934 gfx::Rect child_damage_rect; 932 gfx::Rect child_damage_rect;
935 gfx::Rect root_damage_rect; 933 gfx::Rect root_damage_rect;
936 934
937 // CASE 1: If a descendant surface disappears, its entire old area becomes 935 // CASE 1: If a descendant surface disappears, its entire old area becomes
938 // exposed. 936 // exposed.
939 ClearDamageForAllSurfaces(root.get()); 937 ClearDamageForAllSurfaces(root.get());
940 child1->SetHasRenderSurface(false); 938 child1->SetForceRenderSurface(false);
941 EmulateDrawingOneFrame(root.get()); 939 EmulateDrawingOneFrame(root.get());
942 940
943 // Sanity check that there is only one surface now. 941 // Sanity check that there is only one surface now.
944 ASSERT_FALSE(child1->render_surface()); 942 ASSERT_FALSE(child1->render_surface());
945 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); 943 ASSERT_EQ(4u, root->render_surface()->layer_list().size());
946 944
947 root_damage_rect = 945 root_damage_rect =
948 root->render_surface()->damage_tracker()->current_damage_rect(); 946 root->render_surface()->damage_tracker()->current_damage_rect();
949 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), 947 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(),
950 root_damage_rect.ToString()); 948 root_damage_rect.ToString());
951 949
952 // CASE 2: If a descendant surface appears, its entire old area becomes 950 // CASE 2: If a descendant surface appears, its entire old area becomes
953 // exposed. 951 // exposed.
954 952
955 // Cycle one frame of no change, just to sanity check that the next rect is 953 // Cycle one frame of no change, just to sanity check that the next rect is
956 // not because of the old damage state. 954 // not because of the old damage state.
957 ClearDamageForAllSurfaces(root.get()); 955 ClearDamageForAllSurfaces(root.get());
958 EmulateDrawingOneFrame(root.get()); 956 EmulateDrawingOneFrame(root.get());
959 root_damage_rect = 957 root_damage_rect =
960 root->render_surface()->damage_tracker()->current_damage_rect(); 958 root->render_surface()->damage_tracker()->current_damage_rect();
961 EXPECT_TRUE(root_damage_rect.IsEmpty()); 959 EXPECT_TRUE(root_damage_rect.IsEmpty());
962 960
963 // Then change the tree so that the render surface is added back. 961 // Then change the tree so that the render surface is added back.
964 ClearDamageForAllSurfaces(root.get()); 962 ClearDamageForAllSurfaces(root.get());
965 child1->SetHasRenderSurface(true); 963 child1->SetForceRenderSurface(true);
966 964
967 EmulateDrawingOneFrame(root.get()); 965 EmulateDrawingOneFrame(root.get());
968 966
969 // Sanity check that there is a new surface now. 967 // Sanity check that there is a new surface now.
970 ASSERT_TRUE(child1->render_surface()); 968 ASSERT_TRUE(child1->render_surface());
971 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); 969 EXPECT_EQ(3u, root->render_surface()->layer_list().size());
972 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); 970 EXPECT_EQ(2u, child1->render_surface()->layer_list().size());
973 971
974 child_damage_rect = 972 child_damage_rect =
975 child1->render_surface()->damage_tracker()->current_damage_rect(); 973 child1->render_surface()->damage_tracker()->current_damage_rect();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 // 1056 //
1059 ClearDamageForAllSurfaces(root.get()); 1057 ClearDamageForAllSurfaces(root.get());
1060 { 1058 {
1061 scoped_ptr<LayerImpl> grand_child1_replica = 1059 scoped_ptr<LayerImpl> grand_child1_replica =
1062 LayerImpl::Create(host_impl_.active_tree(), 7); 1060 LayerImpl::Create(host_impl_.active_tree(), 7);
1063 grand_child1_replica->SetPosition(gfx::PointF()); 1061 grand_child1_replica->SetPosition(gfx::PointF());
1064 gfx::Transform reflection; 1062 gfx::Transform reflection;
1065 reflection.Scale3d(-1.0, 1.0, 1.0); 1063 reflection.Scale3d(-1.0, 1.0, 1.0);
1066 grand_child1_replica->SetTransform(reflection); 1064 grand_child1_replica->SetTransform(reflection);
1067 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); 1065 grand_child1->SetReplicaLayer(std::move(grand_child1_replica));
1068 grand_child1->SetHasRenderSurface(true); 1066 grand_child1->SetForceRenderSurface(true);
1069 } 1067 }
1070 EmulateDrawingOneFrame(root.get()); 1068 EmulateDrawingOneFrame(root.get());
1071 1069
1072 gfx::Rect grand_child_damage_rect = 1070 gfx::Rect grand_child_damage_rect =
1073 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); 1071 grand_child1->render_surface()->damage_tracker()->current_damage_rect();
1074 gfx::Rect child_damage_rect = 1072 gfx::Rect child_damage_rect =
1075 child1->render_surface()->damage_tracker()->current_damage_rect(); 1073 child1->render_surface()->damage_tracker()->current_damage_rect();
1076 gfx::Rect root_damage_rect = 1074 gfx::Rect root_damage_rect =
1077 root->render_surface()->damage_tracker()->current_damage_rect(); 1075 root->render_surface()->damage_tracker()->current_damage_rect();
1078 1076
(...skipping 30 matching lines...) Expand all
1109 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); 1107 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString());
1110 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), 1108 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(),
1111 child_damage_rect.ToString()); 1109 child_damage_rect.ToString());
1112 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), 1110 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(),
1113 root_damage_rect.ToString()); 1111 root_damage_rect.ToString());
1114 1112
1115 // CASE 3: removing the reflection should cause the entire region including 1113 // CASE 3: removing the reflection should cause the entire region including
1116 // reflection to damage the target surface. 1114 // reflection to damage the target surface.
1117 ClearDamageForAllSurfaces(root.get()); 1115 ClearDamageForAllSurfaces(root.get());
1118 grand_child1->SetReplicaLayer(nullptr); 1116 grand_child1->SetReplicaLayer(nullptr);
1119 grand_child1->SetHasRenderSurface(false); 1117 grand_child1->SetForceRenderSurface(false);
1120 EmulateDrawingOneFrame(root.get()); 1118 EmulateDrawingOneFrame(root.get());
1121 ASSERT_EQ(old_content_rect.width(), 1119 ASSERT_EQ(old_content_rect.width(),
1122 child1->render_surface()->content_rect().width()); 1120 child1->render_surface()->content_rect().width());
1123 ASSERT_EQ(old_content_rect.height(), 1121 ASSERT_EQ(old_content_rect.height(),
1124 child1->render_surface()->content_rect().height()); 1122 child1->render_surface()->content_rect().height());
1125 1123
1126 EXPECT_FALSE(grand_child1->render_surface()); 1124 EXPECT_FALSE(grand_child1->render_surface());
1127 child_damage_rect = 1125 child_damage_rect =
1128 child1->render_surface()->damage_tracker()->current_damage_rect(); 1126 child1->render_surface()->damage_tracker()->current_damage_rect();
1129 root_damage_rect = 1127 root_damage_rect =
(...skipping 13 matching lines...) Expand all
1143 1141
1144 ClearDamageForAllSurfaces(root.get()); 1142 ClearDamageForAllSurfaces(root.get());
1145 1143
1146 // Set up the mask layer. 1144 // Set up the mask layer.
1147 { 1145 {
1148 scoped_ptr<LayerImpl> mask_layer = 1146 scoped_ptr<LayerImpl> mask_layer =
1149 LayerImpl::Create(host_impl_.active_tree(), 3); 1147 LayerImpl::Create(host_impl_.active_tree(), 3);
1150 mask_layer->SetPosition(child->position()); 1148 mask_layer->SetPosition(child->position());
1151 mask_layer->SetBounds(child->bounds()); 1149 mask_layer->SetBounds(child->bounds());
1152 child->SetMaskLayer(std::move(mask_layer)); 1150 child->SetMaskLayer(std::move(mask_layer));
1153 child->SetHasRenderSurface(true); 1151 child->SetForceRenderSurface(true);
1154 } 1152 }
1155 LayerImpl* mask_layer = child->mask_layer(); 1153 LayerImpl* mask_layer = child->mask_layer();
1156 1154
1157 // Add opacity and a grand_child so that the render surface persists even 1155 // Add opacity and a grand_child so that the render surface persists even
1158 // after we remove the mask. 1156 // after we remove the mask.
1159 { 1157 {
1160 scoped_ptr<LayerImpl> grand_child = 1158 scoped_ptr<LayerImpl> grand_child =
1161 LayerImpl::Create(host_impl_.active_tree(), 4); 1159 LayerImpl::Create(host_impl_.active_tree(), 4);
1162 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); 1160 grand_child->SetPosition(gfx::PointF(2.f, 2.f));
1163 grand_child->SetBounds(gfx::Size(2, 2)); 1161 grand_child->SetBounds(gfx::Size(2, 2));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1230
1233 // Create a reflection about the left edge of grand_child1. 1231 // Create a reflection about the left edge of grand_child1.
1234 { 1232 {
1235 scoped_ptr<LayerImpl> grand_child1_replica = 1233 scoped_ptr<LayerImpl> grand_child1_replica =
1236 LayerImpl::Create(host_impl_.active_tree(), 6); 1234 LayerImpl::Create(host_impl_.active_tree(), 6);
1237 grand_child1_replica->SetPosition(gfx::PointF()); 1235 grand_child1_replica->SetPosition(gfx::PointF());
1238 gfx::Transform reflection; 1236 gfx::Transform reflection;
1239 reflection.Scale3d(-1.0, 1.0, 1.0); 1237 reflection.Scale3d(-1.0, 1.0, 1.0);
1240 grand_child1_replica->SetTransform(reflection); 1238 grand_child1_replica->SetTransform(reflection);
1241 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); 1239 grand_child1->SetReplicaLayer(std::move(grand_child1_replica));
1242 grand_child1->SetHasRenderSurface(true); 1240 grand_child1->SetForceRenderSurface(true);
1243 } 1241 }
1244 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); 1242 LayerImpl* grand_child1_replica = grand_child1->replica_layer();
1245 1243
1246 // Set up the mask layer on the replica layer 1244 // Set up the mask layer on the replica layer
1247 { 1245 {
1248 scoped_ptr<LayerImpl> replica_mask_layer = 1246 scoped_ptr<LayerImpl> replica_mask_layer =
1249 LayerImpl::Create(host_impl_.active_tree(), 7); 1247 LayerImpl::Create(host_impl_.active_tree(), 7);
1250 replica_mask_layer->SetPosition(gfx::PointF()); 1248 replica_mask_layer->SetPosition(gfx::PointF());
1251 replica_mask_layer->SetBounds(grand_child1->bounds()); 1249 replica_mask_layer->SetBounds(grand_child1->bounds());
1252 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); 1250 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 LayerImpl::Create(host_impl_.active_tree(), 6); 1307 LayerImpl::Create(host_impl_.active_tree(), 6);
1310 grand_child1_replica->SetPosition(gfx::PointF()); 1308 grand_child1_replica->SetPosition(gfx::PointF());
1311 1309
1312 // This is the anchor being tested. 1310 // This is the anchor being tested.
1313 grand_child1_replica->SetTransformOrigin( 1311 grand_child1_replica->SetTransformOrigin(
1314 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); 1312 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f));
1315 gfx::Transform reflection; 1313 gfx::Transform reflection;
1316 reflection.Scale3d(-1.0, 1.0, 1.0); 1314 reflection.Scale3d(-1.0, 1.0, 1.0);
1317 grand_child1_replica->SetTransform(reflection); 1315 grand_child1_replica->SetTransform(reflection);
1318 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); 1316 grand_child1->SetReplicaLayer(std::move(grand_child1_replica));
1319 grand_child1->SetHasRenderSurface(true); 1317 grand_child1->SetForceRenderSurface(true);
1320 } 1318 }
1321 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); 1319 LayerImpl* grand_child1_replica = grand_child1->replica_layer();
1322 1320
1323 // Set up the mask layer on the replica layer 1321 // Set up the mask layer on the replica layer
1324 { 1322 {
1325 scoped_ptr<LayerImpl> replica_mask_layer = 1323 scoped_ptr<LayerImpl> replica_mask_layer =
1326 LayerImpl::Create(host_impl_.active_tree(), 7); 1324 LayerImpl::Create(host_impl_.active_tree(), 7);
1327 replica_mask_layer->SetPosition(gfx::PointF()); 1325 replica_mask_layer->SetPosition(gfx::PointF());
1328 // Note: this is not the transform origin being tested. 1326 // Note: this is not the transform origin being tested.
1329 replica_mask_layer->SetBounds(grand_child1->bounds()); 1327 replica_mask_layer->SetBounds(grand_child1->bounds());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 root_damage_rect = 1374 root_damage_rect =
1377 root->render_surface()->damage_tracker()->current_damage_rect(); 1375 root->render_surface()->damage_tracker()->current_damage_rect();
1378 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); 1376 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString());
1379 } 1377 }
1380 1378
1381 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { 1379 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) {
1382 // Though it should never happen, its a good idea to verify that the damage 1380 // Though it should never happen, its a good idea to verify that the damage
1383 // tracker does not crash when it receives an empty layer_list. 1381 // tracker does not crash when it receives an empty layer_list.
1384 1382
1385 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); 1383 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1);
1386 root->SetHasRenderSurface(true); 1384 root->SetForceRenderSurface(true);
1385 EmulateDrawingOneFrame(root.get());
1387 root->draw_properties().render_target = root.get(); 1386 root->draw_properties().render_target = root.get();
1388 1387
1389 ASSERT_EQ(root.get(), root->render_target()); 1388 ASSERT_EQ(root.get(), root->render_target());
1390 RenderSurfaceImpl* target_surface = root->render_surface(); 1389 RenderSurfaceImpl* target_surface = root->render_surface();
1391 1390
1392 LayerImplList empty_list; 1391 LayerImplList empty_list;
1393 target_surface->damage_tracker()->UpdateDamageTrackingState( 1392 target_surface->damage_tracker()->UpdateDamageTrackingState(
1394 empty_list, 1393 empty_list,
1395 target_surface->OwningLayerId(), 1394 target_surface->OwningLayerId(),
1396 false, 1395 false,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 gfx::Rect root_damage_rect = 1467 gfx::Rect root_damage_rect =
1469 root->render_surface()->damage_tracker()->current_damage_rect(); 1468 root->render_surface()->damage_tracker()->current_damage_rect();
1470 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1469 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1471 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1470 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1472 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1471 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1473 } 1472 }
1474 } 1473 }
1475 1474
1476 } // namespace 1475 } // namespace
1477 } // namespace cc 1476 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager_perftest.cc ('k') | cc/trees/draw_property_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698