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

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

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