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

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

Issue 19075002: cc: layer_or_descendant_has_copy_request is inherited by siblings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include "cc/animation/layer_animation_controller.h" 7 #include "cc/animation/layer_animation_controller.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/layers/content_layer.h" 9 #include "cc/layers/content_layer.h"
10 #include "cc/layers/content_layer_client.h" 10 #include "cc/layers/content_layer_client.h"
(...skipping 8187 matching lines...) Expand 10 before | Expand all | Expand 10 after
8198 scoped_refptr<Layer> copy_child = Layer::Create(); 8198 scoped_refptr<Layer> copy_child = Layer::Create();
8199 SetLayerPropertiesForTesting(copy_child.get(), 8199 SetLayerPropertiesForTesting(copy_child.get(),
8200 identity_matrix, 8200 identity_matrix,
8201 identity_matrix, 8201 identity_matrix,
8202 gfx::PointF(), 8202 gfx::PointF(),
8203 gfx::PointF(), 8203 gfx::PointF(),
8204 gfx::Size(20, 20), 8204 gfx::Size(20, 20),
8205 false); 8205 false);
8206 copy_child->SetIsDrawable(true); 8206 copy_child->SetIsDrawable(true);
8207 8207
8208 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create();
8209 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
8210 identity_matrix,
8211 identity_matrix,
8212 gfx::PointF(),
8213 gfx::PointF(),
8214 gfx::Size(40, 40),
8215 false);
8216 copy_grand_parent_sibling_before->SetIsDrawable(true);
8217
8218 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create();
8219 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
8220 identity_matrix,
8221 identity_matrix,
8222 gfx::PointF(),
8223 gfx::PointF(),
8224 gfx::Size(40, 40),
8225 false);
8226 copy_grand_parent_sibling_after->SetIsDrawable(true);
8227
8208 copy_layer->AddChild(copy_child); 8228 copy_layer->AddChild(copy_child);
8209 copy_parent->AddChild(copy_layer); 8229 copy_parent->AddChild(copy_layer);
8210 copy_grand_parent->AddChild(copy_parent); 8230 copy_grand_parent->AddChild(copy_parent);
8231 root->AddChild(copy_grand_parent_sibling_before);
8211 root->AddChild(copy_grand_parent); 8232 root->AddChild(copy_grand_parent);
8233 root->AddChild(copy_grand_parent_sibling_after);
8212 8234
8213 // Hide the copy_grand_parent and its subtree. But make a copy request in that 8235 // Hide the copy_grand_parent and its subtree. But make a copy request in that
8214 // hidden subtree on copy_layer. 8236 // hidden subtree on copy_layer.
8215 copy_grand_parent->SetHideLayerAndSubtree(true); 8237 copy_grand_parent->SetHideLayerAndSubtree(true);
8238 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true);
8239 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true);
8216 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( 8240 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest(
8217 base::Bind(&EmptyCopyOutputCallback))); 8241 base::Bind(&EmptyCopyOutputCallback)));
8218 EXPECT_TRUE(copy_layer->HasCopyRequest()); 8242 EXPECT_TRUE(copy_layer->HasCopyRequest());
8219 8243
8220 LayerList render_surface_layer_list; 8244 LayerList render_surface_layer_list;
8221 int dummy_max_texture_size = 512; 8245 int dummy_max_texture_size = 512;
8222 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 8246 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
8223 root->bounds(), 8247 root->bounds(),
8224 gfx::Transform(), 8248 gfx::Transform(),
8225 1.f, 8249 1.f,
8226 1.f, 8250 1.f,
8227 NULL, 8251 NULL,
8228 dummy_max_texture_size, 8252 dummy_max_texture_size,
8229 false, 8253 false,
8230 true, // can_adjust_raster_scale 8254 true, // can_adjust_raster_scale
8231 &render_surface_layer_list); 8255 &render_surface_layer_list);
8232 8256
8257 EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request);
8258 EXPECT_TRUE(copy_grand_parent->draw_properties().
8259 layer_or_descendant_has_copy_request);
8260 EXPECT_TRUE(copy_parent->draw_properties().
8261 layer_or_descendant_has_copy_request);
8262 EXPECT_TRUE(copy_layer->draw_properties().
8263 layer_or_descendant_has_copy_request);
8264 EXPECT_FALSE(copy_child->draw_properties().
8265 layer_or_descendant_has_copy_request);
8266 EXPECT_FALSE(copy_grand_parent_sibling_before->draw_properties().
8267 layer_or_descendant_has_copy_request);
8268 EXPECT_FALSE(copy_grand_parent_sibling_after->draw_properties().
8269 layer_or_descendant_has_copy_request);
8270
8233 // We should have three render surfaces, one for the root, one for the parent 8271 // We should have three render surfaces, one for the root, one for the parent
8234 // since it owns a surface, and one for the copy_layer. 8272 // since it owns a surface, and one for the copy_layer.
8235 ASSERT_EQ(3u, render_surface_layer_list.size()); 8273 ASSERT_EQ(3u, render_surface_layer_list.size());
8236 EXPECT_EQ(root->id(), render_surface_layer_list[0]->id()); 8274 EXPECT_EQ(root->id(), render_surface_layer_list[0]->id());
8237 EXPECT_EQ(copy_parent->id(), render_surface_layer_list[1]->id()); 8275 EXPECT_EQ(copy_parent->id(), render_surface_layer_list[1]->id());
8238 EXPECT_EQ(copy_layer->id(), render_surface_layer_list[2]->id()); 8276 EXPECT_EQ(copy_layer->id(), render_surface_layer_list[2]->id());
8239 8277
8240 // The root render surface should have 2 contributing layers. The 8278 // The root render surface should have 2 contributing layers. The
8241 // copy_grand_parent is hidden, but the copy_parent will appear since 8279 // copy_grand_parent is hidden along with its siblings, but the copy_parent
8242 // something in its subtree needs to be drawn for a copy request. 8280 // will appear since something in its subtree needs to be drawn for a copy
8281 // request.
8243 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 8282 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
8244 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id()); 8283 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id());
8245 EXPECT_EQ(copy_parent->id(), root->render_surface()->layer_list()[1]->id()); 8284 EXPECT_EQ(copy_parent->id(), root->render_surface()->layer_list()[1]->id());
8246 8285
8247 // Nothing actually drawns into the copy parent, so only the copy_layer will 8286 // Nothing actually drawns into the copy parent, so only the copy_layer will
8248 // appear in its list, since it needs to be drawn for the copy request. 8287 // appear in its list, since it needs to be drawn for the copy request.
8249 ASSERT_EQ(1u, copy_parent->render_surface()->layer_list().size()); 8288 ASSERT_EQ(1u, copy_parent->render_surface()->layer_list().size());
8250 EXPECT_EQ(copy_layer->id(), 8289 EXPECT_EQ(copy_layer->id(),
8251 copy_parent->render_surface()->layer_list()[0]->id()); 8290 copy_parent->render_surface()->layer_list()[0]->id());
8252 8291
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
8331 EXPECT_EQ(root->id(), render_surface_layer_list[0]->id()); 8370 EXPECT_EQ(root->id(), render_surface_layer_list[0]->id());
8332 8371
8333 // The root render surface should only have 1 contributing layer, since the 8372 // The root render surface should only have 1 contributing layer, since the
8334 // other layers are empty/clipped away. 8373 // other layers are empty/clipped away.
8335 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 8374 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
8336 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id()); 8375 EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id());
8337 } 8376 }
8338 8377
8339 } // namespace 8378 } // namespace
8340 } // namespace cc 8379 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common.cc ('K') | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698