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

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

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 <set> 7 #include <set>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/animation/transform_operations.h" 10 #include "cc/animation/transform_operations.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 LayerImpl::Create(host_impl.active_tree(), 1)); 302 LayerImpl::Create(host_impl.active_tree(), 1));
303 LayerImpl* sublayer = sublayer_scoped_ptr.get(); 303 LayerImpl* sublayer = sublayer_scoped_ptr.get();
304 sublayer->SetContentsScale(kPageScale * kDeviceScale, 304 sublayer->SetContentsScale(kPageScale * kDeviceScale,
305 kPageScale * kDeviceScale); 305 kPageScale * kDeviceScale);
306 SetLayerPropertiesForTesting(sublayer, 306 SetLayerPropertiesForTesting(sublayer,
307 identity_matrix, 307 identity_matrix,
308 gfx::Point3F(), 308 gfx::Point3F(),
309 gfx::PointF(), 309 gfx::PointF(),
310 gfx::Size(500, 500), 310 gfx::Size(500, 500),
311 true, 311 true,
312 false,
312 false); 313 false);
313 314
314 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr( 315 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr(
315 LayerImpl::Create(host_impl.active_tree(), 2)); 316 LayerImpl::Create(host_impl.active_tree(), 2));
316 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); 317 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get();
317 SetLayerPropertiesForTesting(scroll_layer, 318 SetLayerPropertiesForTesting(scroll_layer,
318 identity_matrix, 319 identity_matrix,
319 gfx::Point3F(), 320 gfx::Point3F(),
320 gfx::PointF(), 321 gfx::PointF(),
321 gfx::Size(10, 20), 322 gfx::Size(10, 20),
322 true, 323 true,
324 false,
323 false); 325 false);
324 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( 326 scoped_ptr<LayerImpl> clip_layer_scoped_ptr(
325 LayerImpl::Create(host_impl.active_tree(), 4)); 327 LayerImpl::Create(host_impl.active_tree(), 4));
326 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); 328 LayerImpl* clip_layer = clip_layer_scoped_ptr.get();
327 329
328 scroll_layer->SetScrollClipLayer(clip_layer->id()); 330 scroll_layer->SetScrollClipLayer(clip_layer->id());
329 clip_layer->SetBounds( 331 clip_layer->SetBounds(
330 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), 332 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(),
331 scroll_layer->bounds().height() + kMaxScrollOffset.y())); 333 scroll_layer->bounds().height() + kMaxScrollOffset.y()));
332 scroll_layer->SetScrollClipLayer(clip_layer->id()); 334 scroll_layer->SetScrollClipLayer(clip_layer->id());
333 scroll_layer->SetScrollDelta(kScrollDelta); 335 scroll_layer->SetScrollDelta(kScrollDelta);
334 gfx::Transform impl_transform; 336 gfx::Transform impl_transform;
335 scroll_layer->AddChild(sublayer_scoped_ptr.Pass()); 337 scroll_layer->AddChild(sublayer_scoped_ptr.Pass());
336 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); 338 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get();
337 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass()); 339 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass());
338 scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset); 340 scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset);
339 341
340 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); 342 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3));
341 SetLayerPropertiesForTesting(root.get(), 343 SetLayerPropertiesForTesting(root.get(),
342 identity_matrix, 344 identity_matrix,
343 gfx::Point3F(), 345 gfx::Point3F(),
344 gfx::PointF(), 346 gfx::PointF(),
345 gfx::Size(3, 4), 347 gfx::Size(3, 4),
346 true, 348 true,
349 false,
347 false); 350 false);
348 root->AddChild(clip_layer_scoped_ptr.Pass()); 351 root->AddChild(clip_layer_scoped_ptr.Pass());
352 root->SetHasRenderSurface(true);
349 353
350 ExecuteCalculateDrawProperties( 354 ExecuteCalculateDrawProperties(
351 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 355 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
352 gfx::Transform expected_transform = identity_matrix; 356 gfx::Transform expected_transform = identity_matrix;
353 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; 357 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
354 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); 358 sub_layer_screen_position.Scale(kPageScale * kDeviceScale);
355 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), 359 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()),
356 MathUtil::Round(sub_layer_screen_position.y())); 360 MathUtil::Round(sub_layer_screen_position.y()));
357 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 361 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
358 sublayer->draw_transform()); 362 sublayer->draw_transform());
359 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 363 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
360 sublayer->screen_space_transform()); 364 sublayer->screen_space_transform());
361 365
362 gfx::Transform arbitrary_translate; 366 gfx::Transform arbitrary_translate;
363 const float kTranslateX = 10.6f; 367 const float kTranslateX = 10.6f;
364 const float kTranslateY = 20.6f; 368 const float kTranslateY = 20.6f;
365 arbitrary_translate.Translate(kTranslateX, kTranslateY); 369 arbitrary_translate.Translate(kTranslateX, kTranslateY);
366 SetLayerPropertiesForTesting(scroll_layer, 370 SetLayerPropertiesForTesting(scroll_layer,
367 arbitrary_translate, 371 arbitrary_translate,
368 gfx::Point3F(), 372 gfx::Point3F(),
369 gfx::PointF(), 373 gfx::PointF(),
370 gfx::Size(10, 20), 374 gfx::Size(10, 20),
371 true, 375 true,
376 false,
372 false); 377 false);
373 ExecuteCalculateDrawProperties( 378 ExecuteCalculateDrawProperties(
374 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 379 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
375 expected_transform.MakeIdentity(); 380 expected_transform.MakeIdentity();
376 expected_transform.Translate( 381 expected_transform.Translate(
377 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale + 382 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale +
378 sub_layer_screen_position.x()), 383 sub_layer_screen_position.x()),
379 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale + 384 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale +
380 sub_layer_screen_position.y())); 385 sub_layer_screen_position.y()));
381 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 386 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
(...skipping 3320 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 gfx::Size(100, 100), 3707 gfx::Size(100, 100),
3703 true, 3708 true,
3704 true); 3709 true);
3705 3710
3706 RenderSurfaceLayerList render_surface_layer_list; 3711 RenderSurfaceLayerList render_surface_layer_list;
3707 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 3712 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
3708 parent.get(), parent->bounds(), &render_surface_layer_list); 3713 parent.get(), parent->bounds(), &render_surface_layer_list);
3709 inputs.can_adjust_raster_scales = true; 3714 inputs.can_adjust_raster_scales = true;
3710 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 3715 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3711 3716
3712 // Verify which render surfaces were created. 3717 // Verify which render surfaces were created and used.
3713 EXPECT_FALSE(front_facing_child->render_surface()); 3718 EXPECT_FALSE(front_facing_child->render_surface());
3714 EXPECT_FALSE(back_facing_child->render_surface()); 3719 EXPECT_FALSE(back_facing_child->render_surface());
3715 EXPECT_TRUE(front_facing_surface->render_surface()); 3720 EXPECT_TRUE(front_facing_surface->render_surface());
3716 EXPECT_FALSE(back_facing_surface->render_surface()); 3721 EXPECT_NE(back_facing_surface->render_target(), back_facing_surface);
3722 // We expect that a render_surface was creatd but not used.
3723 EXPECT_TRUE(back_facing_surface->render_surface());
3717 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface()); 3724 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface());
3718 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface()); 3725 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface());
3719 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface()); 3726 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface());
3720 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface()); 3727 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface());
3721 3728
3722 // Verify the render_surface_layer_list. The back-facing surface should be 3729 // Verify the render_surface_layer_list. The back-facing surface should be
3723 // culled. 3730 // culled.
3724 ASSERT_EQ(2u, render_surface_layer_list.size()); 3731 ASSERT_EQ(2u, render_surface_layer_list.size());
3725 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 3732 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
3726 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); 3733 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id());
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 3977
3971 front_facing_surface->Set3dSortingContextId(1); 3978 front_facing_surface->Set3dSortingContextId(1);
3972 back_facing_surface->Set3dSortingContextId(1); 3979 back_facing_surface->Set3dSortingContextId(1);
3973 3980
3974 RenderSurfaceLayerList render_surface_layer_list; 3981 RenderSurfaceLayerList render_surface_layer_list;
3975 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 3982 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
3976 parent.get(), parent->bounds(), &render_surface_layer_list); 3983 parent.get(), parent->bounds(), &render_surface_layer_list);
3977 inputs.can_adjust_raster_scales = true; 3984 inputs.can_adjust_raster_scales = true;
3978 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 3985 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3979 3986
3980 // Verify which render surfaces were created. 3987 // Verify which render surfaces were created and used.
3981 EXPECT_TRUE(front_facing_surface->render_surface()); 3988 EXPECT_TRUE(front_facing_surface->render_surface());
3982 EXPECT_FALSE( 3989
3983 back_facing_surface->render_surface()); // because it should be culled 3990 // We expect the render surface to have been created, but remain unused.
3991 EXPECT_TRUE(back_facing_surface->render_surface());
3992 EXPECT_NE(back_facing_surface->render_target(),
3993 back_facing_surface); // because it should be culled
3984 EXPECT_FALSE(child1->render_surface()); 3994 EXPECT_FALSE(child1->render_surface());
3985 EXPECT_FALSE(child2->render_surface()); 3995 EXPECT_FALSE(child2->render_surface());
3986 3996
3987 // Verify the render_surface_layer_list. The back-facing surface should be 3997 // Verify the render_surface_layer_list. The back-facing surface should be
3988 // culled. 3998 // culled.
3989 ASSERT_EQ(2u, render_surface_layer_list.size()); 3999 ASSERT_EQ(2u, render_surface_layer_list.size());
3990 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 4000 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
3991 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); 4001 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id());
3992 4002
3993 // Verify root surface's layer list. 4003 // Verify root surface's layer list.
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
5629 host_impl.CreatePendingTree(); 5639 host_impl.CreatePendingTree();
5630 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 5640 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
5631 5641
5632 const gfx::Transform identity_matrix; 5642 const gfx::Transform identity_matrix;
5633 SetLayerPropertiesForTesting(root.get(), 5643 SetLayerPropertiesForTesting(root.get(),
5634 identity_matrix, 5644 identity_matrix,
5635 gfx::Point3F(), 5645 gfx::Point3F(),
5636 gfx::PointF(), 5646 gfx::PointF(),
5637 gfx::Size(100, 100), 5647 gfx::Size(100, 100),
5638 true, 5648 true,
5649 false,
5639 false); 5650 false);
5640 root->SetDrawsContent(true); 5651 root->SetDrawsContent(true);
5641 5652
5642 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5653 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
5643 SetLayerPropertiesForTesting(child.get(), 5654 SetLayerPropertiesForTesting(child.get(),
5644 identity_matrix, 5655 identity_matrix,
5645 gfx::Point3F(), 5656 gfx::Point3F(),
5646 gfx::PointF(), 5657 gfx::PointF(),
5647 gfx::Size(50, 50), 5658 gfx::Size(50, 50),
5648 true, 5659 true,
5660 false,
5649 false); 5661 false);
5650 child->SetDrawsContent(true); 5662 child->SetDrawsContent(true);
5651 child->SetOpacity(0.0f); 5663 child->SetOpacity(0.0f);
5652 5664
5653 // Add opacity animation. 5665 // Add opacity animation.
5654 AddOpacityTransitionToController( 5666 AddOpacityTransitionToController(
5655 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); 5667 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false);
5656 5668
5657 root->AddChild(child.Pass()); 5669 root->AddChild(child.Pass());
5670 root->SetHasRenderSurface(true);
5658 5671
5659 LayerImplList render_surface_layer_list; 5672 LayerImplList render_surface_layer_list;
5660 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5673 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5661 root.get(), root->bounds(), &render_surface_layer_list); 5674 root.get(), root->bounds(), &render_surface_layer_list);
5662 inputs.can_adjust_raster_scales = true; 5675 inputs.can_adjust_raster_scales = true;
5663 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5676 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5664 5677
5665 // We should have one render surface and two layers. The child 5678 // We should have one render surface and two layers. The child
5666 // layer should be included even though it is transparent. 5679 // layer should be included even though it is transparent.
5667 ASSERT_EQ(1u, render_surface_layer_list.size()); 5680 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
5887 host_impl.CreatePendingTree(); 5900 host_impl.CreatePendingTree();
5888 const gfx::Transform identity_matrix; 5901 const gfx::Transform identity_matrix;
5889 5902
5890 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 5903 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
5891 SetLayerPropertiesForTesting(root.get(), 5904 SetLayerPropertiesForTesting(root.get(),
5892 identity_matrix, 5905 identity_matrix,
5893 gfx::Point3F(), 5906 gfx::Point3F(),
5894 gfx::PointF(), 5907 gfx::PointF(),
5895 gfx::Size(50, 50), 5908 gfx::Size(50, 50),
5896 true, 5909 true,
5910 false,
5897 false); 5911 false);
5898 root->SetDrawsContent(true); 5912 root->SetDrawsContent(true);
5899 5913
5900 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5914 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
5901 SetLayerPropertiesForTesting(child.get(), 5915 SetLayerPropertiesForTesting(child.get(),
5902 identity_matrix, 5916 identity_matrix,
5903 gfx::Point3F(), 5917 gfx::Point3F(),
5904 gfx::PointF(), 5918 gfx::PointF(),
5905 gfx::Size(40, 40), 5919 gfx::Size(40, 40),
5906 true, 5920 true,
5921 false,
5907 false); 5922 false);
5908 child->SetDrawsContent(true); 5923 child->SetDrawsContent(true);
5909 5924
5910 scoped_ptr<LayerImpl> grand_child = 5925 scoped_ptr<LayerImpl> grand_child =
5911 LayerImpl::Create(host_impl.pending_tree(), 3); 5926 LayerImpl::Create(host_impl.pending_tree(), 3);
5912 SetLayerPropertiesForTesting(grand_child.get(), 5927 SetLayerPropertiesForTesting(grand_child.get(),
5913 identity_matrix, 5928 identity_matrix,
5914 gfx::Point3F(), 5929 gfx::Point3F(),
5915 gfx::PointF(), 5930 gfx::PointF(),
5916 gfx::Size(30, 30), 5931 gfx::Size(30, 30),
5917 true, 5932 true,
5933 false,
5918 false); 5934 false);
5919 grand_child->SetDrawsContent(true); 5935 grand_child->SetDrawsContent(true);
5920 grand_child->SetHideLayerAndSubtree(true); 5936 grand_child->SetHideLayerAndSubtree(true);
5921 5937
5922 child->AddChild(grand_child.Pass()); 5938 child->AddChild(grand_child.Pass());
5923 root->AddChild(child.Pass()); 5939 root->AddChild(child.Pass());
5940 root->SetHasRenderSurface(true);
5924 5941
5925 LayerImplList render_surface_layer_list; 5942 LayerImplList render_surface_layer_list;
5926 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5943 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5927 root.get(), root->bounds(), &render_surface_layer_list); 5944 root.get(), root->bounds(), &render_surface_layer_list);
5928 inputs.can_adjust_raster_scales = true; 5945 inputs.can_adjust_raster_scales = true;
5929 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5946 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5930 5947
5931 // We should have one render surface and two layers. The grand child has 5948 // We should have one render surface and two layers. The grand child has
5932 // hidden itself. 5949 // hidden itself.
5933 ASSERT_EQ(1u, render_surface_layer_list.size()); 5950 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
6000 host_impl.CreatePendingTree(); 6017 host_impl.CreatePendingTree();
6001 const gfx::Transform identity_matrix; 6018 const gfx::Transform identity_matrix;
6002 6019
6003 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 6020 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
6004 SetLayerPropertiesForTesting(root.get(), 6021 SetLayerPropertiesForTesting(root.get(),
6005 identity_matrix, 6022 identity_matrix,
6006 gfx::Point3F(), 6023 gfx::Point3F(),
6007 gfx::PointF(), 6024 gfx::PointF(),
6008 gfx::Size(50, 50), 6025 gfx::Size(50, 50),
6009 true, 6026 true,
6010 false); 6027 false,
6028 true);
6011 root->SetDrawsContent(true); 6029 root->SetDrawsContent(true);
6012 6030
6013 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 6031 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
6014 SetLayerPropertiesForTesting(child.get(), 6032 SetLayerPropertiesForTesting(child.get(),
6015 identity_matrix, 6033 identity_matrix,
6016 gfx::Point3F(), 6034 gfx::Point3F(),
6017 gfx::PointF(), 6035 gfx::PointF(),
6018 gfx::Size(40, 40), 6036 gfx::Size(40, 40),
6019 true, 6037 true,
6038 false,
6020 false); 6039 false);
6021 child->SetDrawsContent(true); 6040 child->SetDrawsContent(true);
6022 child->SetHideLayerAndSubtree(true); 6041 child->SetHideLayerAndSubtree(true);
6023 6042
6024 scoped_ptr<LayerImpl> grand_child = 6043 scoped_ptr<LayerImpl> grand_child =
6025 LayerImpl::Create(host_impl.pending_tree(), 3); 6044 LayerImpl::Create(host_impl.pending_tree(), 3);
6026 SetLayerPropertiesForTesting(grand_child.get(), 6045 SetLayerPropertiesForTesting(grand_child.get(),
6027 identity_matrix, 6046 identity_matrix,
6028 gfx::Point3F(), 6047 gfx::Point3F(),
6029 gfx::PointF(), 6048 gfx::PointF(),
6030 gfx::Size(30, 30), 6049 gfx::Size(30, 30),
6031 true, 6050 true,
6051 false,
6032 false); 6052 false);
6033 grand_child->SetDrawsContent(true); 6053 grand_child->SetDrawsContent(true);
6034 6054
6035 child->AddChild(grand_child.Pass()); 6055 child->AddChild(grand_child.Pass());
6036 root->AddChild(child.Pass()); 6056 root->AddChild(child.Pass());
6037 6057
6038 LayerImplList render_surface_layer_list; 6058 LayerImplList render_surface_layer_list;
6039 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6059 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6040 root.get(), root->bounds(), &render_surface_layer_list); 6060 root.get(), root->bounds(), &render_surface_layer_list);
6041 inputs.can_adjust_raster_scales = true; 6061 inputs.can_adjust_raster_scales = true;
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
6879 render_surface2->render_surface()->content_rect().ToString()); 6899 render_surface2->render_surface()->content_rect().ToString());
6880 6900
6881 // Sanity check our num_unclipped_descendants values. 6901 // Sanity check our num_unclipped_descendants values.
6882 EXPECT_EQ(1, render_surface1->num_unclipped_descendants()); 6902 EXPECT_EQ(1, render_surface1->num_unclipped_descendants());
6883 EXPECT_EQ(0, render_surface2->num_unclipped_descendants()); 6903 EXPECT_EQ(0, render_surface2->num_unclipped_descendants());
6884 } 6904 }
6885 6905
6886 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { 6906 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
6887 FakeImplProxy proxy; 6907 FakeImplProxy proxy;
6888 TestSharedBitmapManager shared_bitmap_manager; 6908 TestSharedBitmapManager shared_bitmap_manager;
6889 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 6909 scoped_ptr<LayerTreeHost> host =
6890 scoped_ptr<LayerImpl> root = 6910 FakeLayerTreeHost::Create().PassAs<LayerTreeHost>();
6891 LayerImpl::Create(host_impl.active_tree(), 12345); 6911 scoped_refptr<Layer> root = Layer::Create();
6892 scoped_ptr<LayerImpl> child1 = 6912 root->SetLayerTreeHost(host.get());
6893 LayerImpl::Create(host_impl.active_tree(), 123456); 6913 scoped_refptr<Layer> child1 = Layer::Create();
6894 scoped_ptr<LayerImpl> child2 = 6914 scoped_refptr<Layer> child2 = Layer::Create();
6895 LayerImpl::Create(host_impl.active_tree(), 1234567); 6915 scoped_refptr<Layer> child3 = Layer::Create();
6896 scoped_ptr<LayerImpl> child3 =
6897 LayerImpl::Create(host_impl.active_tree(), 12345678);
6898 6916
6899 gfx::Transform identity_matrix; 6917 gfx::Transform identity_matrix;
6900 gfx::Point3F transform_origin; 6918 gfx::Point3F transform_origin;
6901 gfx::PointF position; 6919 gfx::PointF position;
6902 gfx::Size bounds(100, 100); 6920 gfx::Size bounds(100, 100);
6903 SetLayerPropertiesForTesting(root.get(), 6921 SetLayerPropertiesForTesting(root.get(),
6904 identity_matrix, 6922 identity_matrix,
6905 transform_origin, 6923 transform_origin,
6906 position, 6924 position,
6907 bounds, 6925 bounds,
6908 true, 6926 true,
6909 false); 6927 false);
6910 root->SetDrawsContent(true); 6928 root->SetIsDrawable(true);
6911 6929
6912 // This layer structure normally forces render surface due to preserves3d 6930 // This layer structure normally forces render surface due to preserves3d
6913 // behavior. 6931 // behavior.
6914 SetLayerPropertiesForTesting(child1.get(), 6932 SetLayerPropertiesForTesting(child1.get(),
6915 identity_matrix, 6933 identity_matrix,
6916 transform_origin, 6934 transform_origin,
6917 position, 6935 position,
6918 bounds, 6936 bounds,
6919 false, 6937 false,
6920 true); 6938 true);
6921 child1->SetDrawsContent(true); 6939 child1->SetIsDrawable(true);
6922 SetLayerPropertiesForTesting(child2.get(), 6940 SetLayerPropertiesForTesting(child2.get(),
6923 identity_matrix, 6941 identity_matrix,
6924 transform_origin, 6942 transform_origin,
6925 position, 6943 position,
6926 bounds, 6944 bounds,
6927 true, 6945 true,
6928 false); 6946 false);
6929 child2->SetDrawsContent(true); 6947 child2->SetIsDrawable(true);
6930 SetLayerPropertiesForTesting(child3.get(), 6948 SetLayerPropertiesForTesting(child3.get(),
6931 identity_matrix, 6949 identity_matrix,
6932 transform_origin, 6950 transform_origin,
6933 position, 6951 position,
6934 bounds, 6952 bounds,
6935 true, 6953 true,
6936 false); 6954 false);
6937 child3->SetDrawsContent(true); 6955 child3->SetIsDrawable(true);
6938 6956
6939 child2->Set3dSortingContextId(1); 6957 child2->Set3dSortingContextId(1);
6940 child3->Set3dSortingContextId(1); 6958 child3->Set3dSortingContextId(1);
6941 6959
6942 child2->AddChild(child3.Pass()); 6960 child2->AddChild(child3.get());
6943 child1->AddChild(child2.Pass()); 6961 child1->AddChild(child2.get());
6944 root->AddChild(child1.Pass()); 6962 root->AddChild(child1.get());
6945 6963
6946 { 6964 {
6947 LayerImplList render_surface_layer_list; 6965 RenderSurfaceLayerList render_surface_layer_list;
6948 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); 6966 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
6949 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6950 root.get(), root->bounds(), &render_surface_layer_list); 6967 root.get(), root->bounds(), &render_surface_layer_list);
6951 inputs.can_render_to_separate_surface = true; 6968 inputs.can_render_to_separate_surface = true;
6952 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6969 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
6953 6970
6954 EXPECT_EQ(2u, render_surface_layer_list.size()); 6971 EXPECT_EQ(2u, render_surface_layer_list.size());
6955 } 6972 }
6956 6973
6957 { 6974 {
6958 LayerImplList render_surface_layer_list; 6975 RenderSurfaceLayerList render_surface_layer_list;
6959 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6976 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
6960 root.get(), root->bounds(), &render_surface_layer_list); 6977 root.get(), root->bounds(), &render_surface_layer_list);
6961 inputs.can_render_to_separate_surface = false; 6978 inputs.can_render_to_separate_surface = false;
6962 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6979 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
6963 6980
6964 EXPECT_EQ(1u, render_surface_layer_list.size()); 6981 EXPECT_EQ(1u, render_surface_layer_list.size());
6965 } 6982 }
6983 root->SetLayerTreeHost(NULL);
6966 } 6984 }
6967 6985
6968 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { 6986 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
6969 scoped_refptr<Layer> root = Layer::Create(); 6987 scoped_refptr<Layer> root = Layer::Create();
6970 scoped_refptr<Layer> render_surface = Layer::Create(); 6988 scoped_refptr<Layer> render_surface = Layer::Create();
6971 scoped_refptr<LayerWithForcedDrawsContent> child = 6989 scoped_refptr<LayerWithForcedDrawsContent> child =
6972 make_scoped_refptr(new LayerWithForcedDrawsContent); 6990 make_scoped_refptr(new LayerWithForcedDrawsContent);
6973 6991
6974 root->AddChild(render_surface); 6992 root->AddChild(render_surface);
6975 render_surface->AddChild(child); 6993 render_surface->AddChild(child);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
7574 top_transform.Translate3d(0.0, 0.0, 5.0); 7592 top_transform.Translate3d(0.0, 0.0, 5.0);
7575 gfx::Transform bottom_transform; 7593 gfx::Transform bottom_transform;
7576 bottom_transform.Translate3d(0.0, 0.0, 3.0); 7594 bottom_transform.Translate3d(0.0, 0.0, 3.0);
7577 7595
7578 SetLayerPropertiesForTesting(root.get(), 7596 SetLayerPropertiesForTesting(root.get(),
7579 identity_transform, 7597 identity_transform,
7580 gfx::Point3F(), 7598 gfx::Point3F(),
7581 gfx::PointF(), 7599 gfx::PointF(),
7582 gfx::Size(50, 50), 7600 gfx::Size(50, 50),
7583 true, 7601 true,
7584 false); 7602 false,
7603 true);
7585 SetLayerPropertiesForTesting(scroll_parent_border.get(), 7604 SetLayerPropertiesForTesting(scroll_parent_border.get(),
7586 identity_transform, 7605 identity_transform,
7587 gfx::Point3F(), 7606 gfx::Point3F(),
7588 gfx::PointF(), 7607 gfx::PointF(),
7589 gfx::Size(40, 40), 7608 gfx::Size(40, 40),
7590 true, 7609 true,
7610 false,
7591 false); 7611 false);
7592 SetLayerPropertiesForTesting(scroll_parent_clip.get(), 7612 SetLayerPropertiesForTesting(scroll_parent_clip.get(),
7593 identity_transform, 7613 identity_transform,
7594 gfx::Point3F(), 7614 gfx::Point3F(),
7595 gfx::PointF(), 7615 gfx::PointF(),
7596 gfx::Size(30, 30), 7616 gfx::Size(30, 30),
7597 true, 7617 true,
7618 false,
7598 false); 7619 false);
7599 SetLayerPropertiesForTesting(scroll_parent.get(), 7620 SetLayerPropertiesForTesting(scroll_parent.get(),
7600 identity_transform, 7621 identity_transform,
7601 gfx::Point3F(), 7622 gfx::Point3F(),
7602 gfx::PointF(), 7623 gfx::PointF(),
7603 gfx::Size(50, 50), 7624 gfx::Size(50, 50),
7604 true, 7625 true,
7626 false,
7605 false); 7627 false);
7606 SetLayerPropertiesForTesting(scroll_child.get(), 7628 SetLayerPropertiesForTesting(scroll_child.get(),
7607 identity_transform, 7629 identity_transform,
7608 gfx::Point3F(), 7630 gfx::Point3F(),
7609 gfx::PointF(), 7631 gfx::PointF(),
7610 gfx::Size(50, 50), 7632 gfx::Size(50, 50),
7611 true, 7633 true,
7634 false,
7612 false); 7635 false);
7613 SetLayerPropertiesForTesting(top_content.get(), 7636 SetLayerPropertiesForTesting(top_content.get(),
7614 top_transform, 7637 top_transform,
7615 gfx::Point3F(), 7638 gfx::Point3F(),
7616 gfx::PointF(), 7639 gfx::PointF(),
7617 gfx::Size(50, 50), 7640 gfx::Size(50, 50),
7618 false, 7641 false,
7642 true,
7619 true); 7643 true);
7620 SetLayerPropertiesForTesting(bottom_content.get(), 7644 SetLayerPropertiesForTesting(bottom_content.get(),
7621 bottom_transform, 7645 bottom_transform,
7622 gfx::Point3F(), 7646 gfx::Point3F(),
7623 gfx::PointF(), 7647 gfx::PointF(),
7624 gfx::Size(50, 50), 7648 gfx::Size(50, 50),
7625 false, 7649 false,
7650 true,
7626 true); 7651 true);
7627 7652
7628 scroll_child->SetShouldFlattenTransform(false); 7653 scroll_child->SetShouldFlattenTransform(false);
7629 scroll_child->Set3dSortingContextId(1); 7654 scroll_child->Set3dSortingContextId(1);
7630 7655
7631 scroll_child->AddChild(top_content.Pass()); 7656 scroll_child->AddChild(top_content.Pass());
7632 scroll_child->AddChild(bottom_content.Pass()); 7657 scroll_child->AddChild(bottom_content.Pass());
7633 root->AddChild(scroll_child.Pass()); 7658 root->AddChild(scroll_child.Pass());
7634 7659
7635 scroll_parent_clip->AddChild(scroll_parent.Pass()); 7660 scroll_parent_clip->AddChild(scroll_parent.Pass());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
7692 gfx::Transform container_transform; 7717 gfx::Transform container_transform;
7693 container_transform.Translate3d(10.0, 20.0, 0.0); 7718 container_transform.Translate3d(10.0, 20.0, 0.0);
7694 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); 7719 gfx::Vector2dF container_offset = container_transform.To2dTranslation();
7695 7720
7696 SetLayerPropertiesForTesting(root.get(), 7721 SetLayerPropertiesForTesting(root.get(),
7697 identity_transform, 7722 identity_transform,
7698 gfx::Point3F(), 7723 gfx::Point3F(),
7699 gfx::PointF(), 7724 gfx::PointF(),
7700 gfx::Size(50, 50), 7725 gfx::Size(50, 50),
7701 true, 7726 true,
7702 false); 7727 false,
7728 true);
7703 SetLayerPropertiesForTesting(container.get(), 7729 SetLayerPropertiesForTesting(container.get(),
7704 container_transform, 7730 container_transform,
7705 gfx::Point3F(), 7731 gfx::Point3F(),
7706 gfx::PointF(), 7732 gfx::PointF(),
7707 gfx::Size(40, 40), 7733 gfx::Size(40, 40),
7708 true, 7734 true,
7735 false,
7709 false); 7736 false);
7710 SetLayerPropertiesForTesting(scroller.get(), 7737 SetLayerPropertiesForTesting(scroller.get(),
7711 identity_transform, 7738 identity_transform,
7712 gfx::Point3F(), 7739 gfx::Point3F(),
7713 gfx::PointF(), 7740 gfx::PointF(),
7714 gfx::Size(30, 30), 7741 gfx::Size(30, 30),
7715 true, 7742 true,
7743 false,
7716 false); 7744 false);
7717 SetLayerPropertiesForTesting(fixed.get(), 7745 SetLayerPropertiesForTesting(fixed.get(),
7718 identity_transform, 7746 identity_transform,
7719 gfx::Point3F(), 7747 gfx::Point3F(),
7720 gfx::PointF(), 7748 gfx::PointF(),
7721 gfx::Size(50, 50), 7749 gfx::Size(50, 50),
7722 true, 7750 true,
7751 false,
7723 false); 7752 false);
7724 7753
7725 scroller->AddChild(fixed.Pass()); 7754 scroller->AddChild(fixed.Pass());
7726 container->AddChild(scroller.Pass()); 7755 container->AddChild(scroller.Pass());
7727 root->AddChild(container.Pass()); 7756 root->AddChild(container.Pass());
7728 7757
7729 // Rounded to integers already. 7758 // Rounded to integers already.
7730 { 7759 {
7731 gfx::Vector2dF scroll_delta(3.0, 5.0); 7760 gfx::Vector2dF scroll_delta(3.0, 5.0);
7732 scroll_layer->SetScrollDelta(scroll_delta); 7761 scroll_layer->SetScrollDelta(scroll_delta);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7856 child->AddChild(grand_child.PassAs<LayerImpl>()); 7885 child->AddChild(grand_child.PassAs<LayerImpl>());
7857 parent->AddChild(child.PassAs<LayerImpl>()); 7886 parent->AddChild(child.PassAs<LayerImpl>());
7858 grand_parent->AddChild(parent.PassAs<LayerImpl>()); 7887 grand_parent->AddChild(parent.PassAs<LayerImpl>());
7859 7888
7860 SetLayerPropertiesForTesting(grand_parent.get(), 7889 SetLayerPropertiesForTesting(grand_parent.get(),
7861 identity_matrix, 7890 identity_matrix,
7862 gfx::Point3F(), 7891 gfx::Point3F(),
7863 gfx::PointF(), 7892 gfx::PointF(),
7864 gfx::Size(1, 2), 7893 gfx::Size(1, 2),
7865 true, 7894 true,
7866 false); 7895 false,
7896 true);
7867 SetLayerPropertiesForTesting(parent_raw, 7897 SetLayerPropertiesForTesting(parent_raw,
7868 identity_matrix, 7898 identity_matrix,
7869 gfx::Point3F(), 7899 gfx::Point3F(),
7870 gfx::PointF(), 7900 gfx::PointF(),
7871 gfx::Size(1, 2), 7901 gfx::Size(1, 2),
7872 true, 7902 true,
7903 false,
7873 false); 7904 false);
7874 SetLayerPropertiesForTesting(child_raw, 7905 SetLayerPropertiesForTesting(child_raw,
7875 identity_matrix, 7906 identity_matrix,
7876 gfx::Point3F(), 7907 gfx::Point3F(),
7877 gfx::PointF(), 7908 gfx::PointF(),
7878 gfx::Size(1, 2), 7909 gfx::Size(1, 2),
7879 true, 7910 true,
7911 false,
7880 false); 7912 false);
7913
7881 SetLayerPropertiesForTesting(grand_child_raw, 7914 SetLayerPropertiesForTesting(grand_child_raw,
7882 identity_matrix, 7915 identity_matrix,
7883 gfx::Point3F(), 7916 gfx::Point3F(),
7884 gfx::PointF(), 7917 gfx::PointF(),
7885 gfx::Size(1, 2), 7918 gfx::Size(1, 2),
7886 true, 7919 true,
7920 false,
7887 false); 7921 false);
7888 7922
7889 ExecuteCalculateDrawProperties(grand_parent.get()); 7923 ExecuteCalculateDrawProperties(grand_parent.get());
7890 7924
7891 // No layers have animations. 7925 // No layers have animations.
7892 EXPECT_EQ(0.f, 7926 EXPECT_EQ(0.f,
7893 grand_parent->draw_properties().maximum_animation_contents_scale); 7927 grand_parent->draw_properties().maximum_animation_contents_scale);
7894 EXPECT_EQ(0.f, 7928 EXPECT_EQ(0.f,
7895 parent_raw->draw_properties().maximum_animation_contents_scale); 7929 parent_raw->draw_properties().maximum_animation_contents_scale);
7896 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7930 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
8092 child->AddChild(grand_child2.Pass()); 8126 child->AddChild(grand_child2.Pass());
8093 parent->AddChild(child.Pass()); 8127 parent->AddChild(child.Pass());
8094 grand_parent->AddChild(parent.Pass()); 8128 grand_parent->AddChild(parent.Pass());
8095 8129
8096 SetLayerPropertiesForTesting(grand_parent_raw, 8130 SetLayerPropertiesForTesting(grand_parent_raw,
8097 identity_matrix, 8131 identity_matrix,
8098 gfx::Point3F(), 8132 gfx::Point3F(),
8099 gfx::PointF(), 8133 gfx::PointF(),
8100 gfx::Size(1, 2), 8134 gfx::Size(1, 2),
8101 true, 8135 true,
8102 false); 8136 false,
8137 true);
8103 SetLayerPropertiesForTesting(parent_raw, 8138 SetLayerPropertiesForTesting(parent_raw,
8104 identity_matrix, 8139 identity_matrix,
8105 gfx::Point3F(), 8140 gfx::Point3F(),
8106 gfx::PointF(), 8141 gfx::PointF(),
8107 gfx::Size(1, 2), 8142 gfx::Size(1, 2),
8108 true, 8143 true,
8144 false,
8109 false); 8145 false);
8146
8110 SetLayerPropertiesForTesting(child_raw, 8147 SetLayerPropertiesForTesting(child_raw,
8111 identity_matrix, 8148 identity_matrix,
8112 gfx::Point3F(), 8149 gfx::Point3F(),
8113 gfx::PointF(), 8150 gfx::PointF(),
8114 gfx::Size(1, 2), 8151 gfx::Size(1, 2),
8115 true, 8152 true,
8153 false,
8116 false); 8154 false);
8155
8117 SetLayerPropertiesForTesting(grand_child1_raw, 8156 SetLayerPropertiesForTesting(grand_child1_raw,
8118 identity_matrix, 8157 identity_matrix,
8119 gfx::Point3F(), 8158 gfx::Point3F(),
8120 gfx::PointF(), 8159 gfx::PointF(),
8121 gfx::Size(1, 2), 8160 gfx::Size(1, 2),
8122 true, 8161 true,
8162 false,
8123 false); 8163 false);
8164
8124 SetLayerPropertiesForTesting(grand_child2_raw, 8165 SetLayerPropertiesForTesting(grand_child2_raw,
8125 identity_matrix, 8166 identity_matrix,
8126 gfx::Point3F(), 8167 gfx::Point3F(),
8127 gfx::PointF(), 8168 gfx::PointF(),
8128 gfx::Size(1, 2), 8169 gfx::Size(1, 2),
8129 true, 8170 true,
8171 false,
8130 false); 8172 false);
8131 8173
8132 // Start with nothing being drawn. 8174 // Start with nothing being drawn.
8133 ExecuteCalculateDrawProperties(grand_parent_raw); 8175 ExecuteCalculateDrawProperties(grand_parent_raw);
8134 int member_id = render_surface_layer_list_count(); 8176 int member_id = render_surface_layer_list_count();
8135 8177
8136 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8178 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8137 EXPECT_NE(member_id, membership_id(parent_raw)); 8179 EXPECT_NE(member_id, membership_id(parent_raw));
8138 EXPECT_NE(member_id, membership_id(child_raw)); 8180 EXPECT_NE(member_id, membership_id(child_raw));
8139 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8181 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8140 EXPECT_NE(member_id, membership_id(grand_child2_raw)); 8182 EXPECT_NE(member_id, membership_id(grand_child2_raw));
8141 8183
8142 std::set<LayerImpl*> expected; 8184 std::set<LayerImpl*> expected;
8143 std::set<LayerImpl*> actual; 8185 std::set<LayerImpl*> actual;
8144 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 8186 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
8145 EXPECT_EQ(expected, actual); 8187 EXPECT_EQ(expected, actual);
8146 8188
8147 // If we force render surface, but none of the layers are in the layer list, 8189 // If we force render surface, but none of the layers are in the layer list,
8148 // then this layer should not appear in RSLL. 8190 // then this layer should not appear in RSLL.
8149 grand_child1_raw->SetForceRenderSurface(true); 8191 grand_child1_raw->SetHasRenderSurface(true);
8150 8192
8151 ExecuteCalculateDrawProperties(grand_parent_raw); 8193 ExecuteCalculateDrawProperties(grand_parent_raw);
8152 member_id = render_surface_layer_list_count(); 8194 member_id = render_surface_layer_list_count();
8153 8195
8154 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8196 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8155 EXPECT_NE(member_id, membership_id(parent_raw)); 8197 EXPECT_NE(member_id, membership_id(parent_raw));
8156 EXPECT_NE(member_id, membership_id(child_raw)); 8198 EXPECT_NE(member_id, membership_id(child_raw));
8157 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8199 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8158 EXPECT_NE(member_id, membership_id(grand_child2_raw)); 8200 EXPECT_NE(member_id, membership_id(grand_child2_raw));
8159 8201
(...skipping 18 matching lines...) Expand all
8178 expected.clear(); 8220 expected.clear();
8179 expected.insert(grand_child1_raw); 8221 expected.insert(grand_child1_raw);
8180 8222
8181 actual.clear(); 8223 actual.clear();
8182 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 8224 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
8183 EXPECT_EQ(expected, actual); 8225 EXPECT_EQ(expected, actual);
8184 8226
8185 // Now child is forced to have a render surface, and one if its children draws 8227 // Now child is forced to have a render surface, and one if its children draws
8186 // content. 8228 // content.
8187 grand_child1_raw->SetDrawsContent(false); 8229 grand_child1_raw->SetDrawsContent(false);
8188 grand_child1_raw->SetForceRenderSurface(false); 8230 grand_child1_raw->SetHasRenderSurface(false);
8189 child_raw->SetForceRenderSurface(true); 8231 child_raw->SetHasRenderSurface(true);
8190 grand_child2_raw->SetDrawsContent(true); 8232 grand_child2_raw->SetDrawsContent(true);
8191 8233
8192 ExecuteCalculateDrawProperties(grand_parent_raw); 8234 ExecuteCalculateDrawProperties(grand_parent_raw);
8193 member_id = render_surface_layer_list_count(); 8235 member_id = render_surface_layer_list_count();
8194 8236
8195 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8237 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8196 EXPECT_NE(member_id, membership_id(parent_raw)); 8238 EXPECT_NE(member_id, membership_id(parent_raw));
8197 EXPECT_NE(member_id, membership_id(child_raw)); 8239 EXPECT_NE(member_id, membership_id(child_raw));
8198 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8240 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8199 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); 8241 EXPECT_EQ(member_id, membership_id(grand_child2_raw));
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
8346 scale_transform_child2; 8388 scale_transform_child2;
8347 scale_transform_child1.Scale(2, 3); 8389 scale_transform_child1.Scale(2, 3);
8348 scale_transform_child2.Scale(4, 5); 8390 scale_transform_child2.Scale(4, 5);
8349 8391
8350 SetLayerPropertiesForTesting(root_layer, 8392 SetLayerPropertiesForTesting(root_layer,
8351 identity_matrix, 8393 identity_matrix,
8352 gfx::Point3F(), 8394 gfx::Point3F(),
8353 gfx::PointF(), 8395 gfx::PointF(),
8354 gfx::Size(1, 1), 8396 gfx::Size(1, 1),
8355 true, 8397 true,
8356 false); 8398 false,
8399 true);
8357 SetLayerPropertiesForTesting(child1_layer, 8400 SetLayerPropertiesForTesting(child1_layer,
8358 scale_transform_child1, 8401 scale_transform_child1,
8359 gfx::Point3F(), 8402 gfx::Point3F(),
8360 gfx::PointF(), 8403 gfx::PointF(),
8361 gfx::Size(), 8404 gfx::Size(),
8362 true, 8405 true,
8406 false,
8363 false); 8407 false);
8364 8408
8365 child1_layer->SetMaskLayer( 8409 child1_layer->SetMaskLayer(
8366 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); 8410 LayerImpl::Create(host_impl.active_tree(), 4).Pass());
8367 8411
8368 scoped_ptr<LayerImpl> replica_layer = 8412 scoped_ptr<LayerImpl> replica_layer =
8369 LayerImpl::Create(host_impl.active_tree(), 5); 8413 LayerImpl::Create(host_impl.active_tree(), 5);
8370 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 8414 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6));
8371 child1_layer->SetReplicaLayer(replica_layer.Pass()); 8415 child1_layer->SetReplicaLayer(replica_layer.Pass());
8372 8416
8373 ExecuteCalculateDrawProperties(root_layer); 8417 ExecuteCalculateDrawProperties(root_layer);
8374 8418
8375 TransformOperations scale; 8419 TransformOperations scale;
8376 scale.AppendScale(5.f, 8.f, 3.f); 8420 scale.AppendScale(5.f, 8.f, 3.f);
8377 8421
8378 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); 8422 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale);
8379 SetLayerPropertiesForTesting(child2_layer, 8423 SetLayerPropertiesForTesting(child2_layer,
8380 scale_transform_child2, 8424 scale_transform_child2,
8381 gfx::Point3F(), 8425 gfx::Point3F(),
8382 gfx::PointF(), 8426 gfx::PointF(),
8383 gfx::Size(), 8427 gfx::Size(),
8384 true, 8428 true,
8429 false,
8385 false); 8430 false);
8386 8431
8387 ExecuteCalculateDrawProperties(root_layer); 8432 ExecuteCalculateDrawProperties(root_layer);
8388 8433
8389 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); 8434 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale);
8390 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); 8435 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale);
8391 EXPECT_FLOAT_EQ( 8436 EXPECT_FLOAT_EQ(
8392 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); 8437 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale);
8393 EXPECT_FLOAT_EQ(3.f, 8438 EXPECT_FLOAT_EQ(3.f,
8394 child1_layer->replica_layer() 8439 child1_layer->replica_layer()
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
8554 EXPECT_FLOAT_EQ(4.f, 8599 EXPECT_FLOAT_EQ(4.f,
8555 child1_layer->replica_layer() 8600 child1_layer->replica_layer()
8556 ->mask_layer() 8601 ->mask_layer()
8557 ->draw_properties() 8602 ->draw_properties()
8558 .device_scale_factor); 8603 .device_scale_factor);
8559 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); 8604 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor);
8560 } 8605 }
8561 8606
8562 } // namespace 8607 } // namespace
8563 } // namespace cc 8608 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698