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

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 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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 FakeImplProxy proxy; 316 FakeImplProxy proxy;
317 TestSharedBitmapManager shared_bitmap_manager; 317 TestSharedBitmapManager shared_bitmap_manager;
318 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 318 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
319 319
320 gfx::Transform identity_matrix; 320 gfx::Transform identity_matrix;
321 scoped_ptr<LayerImpl> sublayer_scoped_ptr( 321 scoped_ptr<LayerImpl> sublayer_scoped_ptr(
322 LayerImpl::Create(host_impl.active_tree(), 1)); 322 LayerImpl::Create(host_impl.active_tree(), 1));
323 LayerImpl* sublayer = sublayer_scoped_ptr.get(); 323 LayerImpl* sublayer = sublayer_scoped_ptr.get();
324 sublayer->SetContentsScale(kPageScale * kDeviceScale, 324 sublayer->SetContentsScale(kPageScale * kDeviceScale,
325 kPageScale * kDeviceScale); 325 kPageScale * kDeviceScale);
326 SetLayerPropertiesForTesting(sublayer, 326 SetLayerPropertiesForTesting(sublayer, identity_matrix, gfx::Point3F(),
327 identity_matrix, 327 gfx::PointF(), gfx::Size(500, 500), true, false,
328 gfx::Point3F(),
329 gfx::PointF(),
330 gfx::Size(500, 500),
331 true,
332 false); 328 false);
333 329
334 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr( 330 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr(
335 LayerImpl::Create(host_impl.active_tree(), 2)); 331 LayerImpl::Create(host_impl.active_tree(), 2));
336 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); 332 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get();
337 SetLayerPropertiesForTesting(scroll_layer, 333 SetLayerPropertiesForTesting(scroll_layer, identity_matrix, gfx::Point3F(),
338 identity_matrix, 334 gfx::PointF(), gfx::Size(10, 20), true, false,
339 gfx::Point3F(),
340 gfx::PointF(),
341 gfx::Size(10, 20),
342 true,
343 false); 335 false);
344 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( 336 scoped_ptr<LayerImpl> clip_layer_scoped_ptr(
345 LayerImpl::Create(host_impl.active_tree(), 4)); 337 LayerImpl::Create(host_impl.active_tree(), 4));
346 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); 338 LayerImpl* clip_layer = clip_layer_scoped_ptr.get();
347 339
348 scroll_layer->SetScrollClipLayer(clip_layer->id()); 340 scroll_layer->SetScrollClipLayer(clip_layer->id());
349 clip_layer->SetBounds( 341 clip_layer->SetBounds(
350 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), 342 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(),
351 scroll_layer->bounds().height() + kMaxScrollOffset.y())); 343 scroll_layer->bounds().height() + kMaxScrollOffset.y()));
352 scroll_layer->SetScrollClipLayer(clip_layer->id()); 344 scroll_layer->SetScrollClipLayer(clip_layer->id());
353 scroll_layer->SetScrollDelta(kScrollDelta); 345 scroll_layer->SetScrollDelta(kScrollDelta);
354 gfx::Transform impl_transform; 346 gfx::Transform impl_transform;
355 scroll_layer->AddChild(sublayer_scoped_ptr.Pass()); 347 scroll_layer->AddChild(sublayer_scoped_ptr.Pass());
356 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); 348 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get();
357 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass()); 349 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass());
358 scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset); 350 scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset);
359 351
360 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); 352 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3));
361 SetLayerPropertiesForTesting(root.get(), 353 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
362 identity_matrix, 354 gfx::PointF(), gfx::Size(3, 4), true, false,
363 gfx::Point3F(),
364 gfx::PointF(),
365 gfx::Size(3, 4),
366 true,
367 false); 355 false);
368 root->AddChild(clip_layer_scoped_ptr.Pass()); 356 root->AddChild(clip_layer_scoped_ptr.Pass());
357 root->SetHasRenderSurface(true);
369 358
370 ExecuteCalculateDrawProperties( 359 ExecuteCalculateDrawProperties(
371 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 360 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
372 gfx::Transform expected_transform = identity_matrix; 361 gfx::Transform expected_transform = identity_matrix;
373 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; 362 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
374 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); 363 sub_layer_screen_position.Scale(kPageScale * kDeviceScale);
375 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), 364 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()),
376 MathUtil::Round(sub_layer_screen_position.y())); 365 MathUtil::Round(sub_layer_screen_position.y()));
377 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 366 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
378 sublayer->draw_transform()); 367 sublayer->draw_transform());
379 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 368 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
380 sublayer->screen_space_transform()); 369 sublayer->screen_space_transform());
381 370
382 gfx::Transform arbitrary_translate; 371 gfx::Transform arbitrary_translate;
383 const float kTranslateX = 10.6f; 372 const float kTranslateX = 10.6f;
384 const float kTranslateY = 20.6f; 373 const float kTranslateY = 20.6f;
385 arbitrary_translate.Translate(kTranslateX, kTranslateY); 374 arbitrary_translate.Translate(kTranslateX, kTranslateY);
386 SetLayerPropertiesForTesting(scroll_layer, 375 SetLayerPropertiesForTesting(scroll_layer, arbitrary_translate,
387 arbitrary_translate, 376 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 20),
388 gfx::Point3F(), 377 true, false, false);
389 gfx::PointF(),
390 gfx::Size(10, 20),
391 true,
392 false);
393 ExecuteCalculateDrawProperties( 378 ExecuteCalculateDrawProperties(
394 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 379 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
395 expected_transform.MakeIdentity(); 380 expected_transform.MakeIdentity();
396 expected_transform.Translate( 381 expected_transform.Translate(
397 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale + 382 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale +
398 sub_layer_screen_position.x()), 383 sub_layer_screen_position.x()),
399 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale + 384 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale +
400 sub_layer_screen_position.y())); 385 sub_layer_screen_position.y()));
401 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 386 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
402 sublayer->draw_transform()); 387 sublayer->draw_transform());
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 gfx::Size(100, 100), 3737 gfx::Size(100, 100),
3753 true, 3738 true,
3754 true); 3739 true);
3755 3740
3756 RenderSurfaceLayerList render_surface_layer_list; 3741 RenderSurfaceLayerList render_surface_layer_list;
3757 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 3742 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
3758 parent.get(), parent->bounds(), &render_surface_layer_list); 3743 parent.get(), parent->bounds(), &render_surface_layer_list);
3759 inputs.can_adjust_raster_scales = true; 3744 inputs.can_adjust_raster_scales = true;
3760 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 3745 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3761 3746
3762 // Verify which render surfaces were created. 3747 // Verify which render surfaces were created and used.
3763 EXPECT_FALSE(front_facing_child->render_surface()); 3748 EXPECT_FALSE(front_facing_child->render_surface());
3764 EXPECT_FALSE(back_facing_child->render_surface()); 3749 EXPECT_FALSE(back_facing_child->render_surface());
3765 EXPECT_TRUE(front_facing_surface->render_surface()); 3750 EXPECT_TRUE(front_facing_surface->render_surface());
3766 EXPECT_FALSE(back_facing_surface->render_surface()); 3751 EXPECT_NE(back_facing_surface->render_target(), back_facing_surface);
3752 // We expect that a render_surface was created but not used.
3753 EXPECT_TRUE(back_facing_surface->render_surface());
3767 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface()); 3754 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface());
3768 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface()); 3755 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface());
3769 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface()); 3756 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface());
3770 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface()); 3757 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface());
3771 3758
3772 // Verify the render_surface_layer_list. The back-facing surface should be 3759 // Verify the render_surface_layer_list. The back-facing surface should be
3773 // culled. 3760 // culled.
3774 ASSERT_EQ(2u, render_surface_layer_list.size()); 3761 ASSERT_EQ(2u, render_surface_layer_list.size());
3775 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 3762 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
3776 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); 3763 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
4020 4007
4021 front_facing_surface->Set3dSortingContextId(1); 4008 front_facing_surface->Set3dSortingContextId(1);
4022 back_facing_surface->Set3dSortingContextId(1); 4009 back_facing_surface->Set3dSortingContextId(1);
4023 4010
4024 RenderSurfaceLayerList render_surface_layer_list; 4011 RenderSurfaceLayerList render_surface_layer_list;
4025 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 4012 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
4026 parent.get(), parent->bounds(), &render_surface_layer_list); 4013 parent.get(), parent->bounds(), &render_surface_layer_list);
4027 inputs.can_adjust_raster_scales = true; 4014 inputs.can_adjust_raster_scales = true;
4028 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 4015 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
4029 4016
4030 // Verify which render surfaces were created. 4017 // Verify which render surfaces were created and used.
4031 EXPECT_TRUE(front_facing_surface->render_surface()); 4018 EXPECT_TRUE(front_facing_surface->render_surface());
4032 EXPECT_FALSE( 4019
4033 back_facing_surface->render_surface()); // because it should be culled 4020 // We expect the render surface to have been created, but remain unused.
4021 EXPECT_TRUE(back_facing_surface->render_surface());
4022 EXPECT_NE(back_facing_surface->render_target(),
4023 back_facing_surface); // because it should be culled
4034 EXPECT_FALSE(child1->render_surface()); 4024 EXPECT_FALSE(child1->render_surface());
4035 EXPECT_FALSE(child2->render_surface()); 4025 EXPECT_FALSE(child2->render_surface());
4036 4026
4037 // Verify the render_surface_layer_list. The back-facing surface should be 4027 // Verify the render_surface_layer_list. The back-facing surface should be
4038 // culled. 4028 // culled.
4039 ASSERT_EQ(2u, render_surface_layer_list.size()); 4029 ASSERT_EQ(2u, render_surface_layer_list.size());
4040 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 4030 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
4041 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); 4031 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id());
4042 4032
4043 // Verify root surface's layer list. 4033 // Verify root surface's layer list.
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
5604 } 5594 }
5605 5595
5606 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { 5596 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
5607 FakeImplProxy proxy; 5597 FakeImplProxy proxy;
5608 TestSharedBitmapManager shared_bitmap_manager; 5598 TestSharedBitmapManager shared_bitmap_manager;
5609 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 5599 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
5610 host_impl.CreatePendingTree(); 5600 host_impl.CreatePendingTree();
5611 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 5601 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
5612 5602
5613 const gfx::Transform identity_matrix; 5603 const gfx::Transform identity_matrix;
5614 SetLayerPropertiesForTesting(root.get(), 5604 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5615 identity_matrix, 5605 gfx::PointF(), gfx::Size(100, 100), true, false,
5616 gfx::Point3F(),
5617 gfx::PointF(),
5618 gfx::Size(100, 100),
5619 true,
5620 false); 5606 false);
5621 root->SetDrawsContent(true); 5607 root->SetDrawsContent(true);
5622 5608
5623 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5609 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
5624 SetLayerPropertiesForTesting(child.get(), 5610 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5625 identity_matrix, 5611 gfx::PointF(), gfx::Size(50, 50), true, false,
5626 gfx::Point3F(),
5627 gfx::PointF(),
5628 gfx::Size(50, 50),
5629 true,
5630 false); 5612 false);
5631 child->SetDrawsContent(true); 5613 child->SetDrawsContent(true);
5632 child->SetOpacity(0.0f); 5614 child->SetOpacity(0.0f);
5633 5615
5634 // Add opacity animation. 5616 // Add opacity animation.
5635 AddOpacityTransitionToController( 5617 AddOpacityTransitionToController(
5636 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); 5618 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false);
5637 5619
5638 root->AddChild(child.Pass()); 5620 root->AddChild(child.Pass());
5621 root->SetHasRenderSurface(true);
5639 5622
5640 LayerImplList render_surface_layer_list; 5623 LayerImplList render_surface_layer_list;
5641 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5624 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5642 root.get(), root->bounds(), &render_surface_layer_list); 5625 root.get(), root->bounds(), &render_surface_layer_list);
5643 inputs.can_adjust_raster_scales = true; 5626 inputs.can_adjust_raster_scales = true;
5644 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5627 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5645 5628
5646 // We should have one render surface and two layers. The child 5629 // We should have one render surface and two layers. The child
5647 // layer should be included even though it is transparent. 5630 // layer should be included even though it is transparent.
5648 ASSERT_EQ(1u, render_surface_layer_list.size()); 5631 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
5891 } 5874 }
5892 5875
5893 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { 5876 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
5894 FakeImplProxy proxy; 5877 FakeImplProxy proxy;
5895 TestSharedBitmapManager shared_bitmap_manager; 5878 TestSharedBitmapManager shared_bitmap_manager;
5896 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 5879 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
5897 host_impl.CreatePendingTree(); 5880 host_impl.CreatePendingTree();
5898 const gfx::Transform identity_matrix; 5881 const gfx::Transform identity_matrix;
5899 5882
5900 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 5883 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
5901 SetLayerPropertiesForTesting(root.get(), 5884 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5902 identity_matrix, 5885 gfx::PointF(), gfx::Size(50, 50), true, false,
5903 gfx::Point3F(),
5904 gfx::PointF(),
5905 gfx::Size(50, 50),
5906 true,
5907 false); 5886 false);
5908 root->SetDrawsContent(true); 5887 root->SetDrawsContent(true);
5909 5888
5910 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5889 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
5911 SetLayerPropertiesForTesting(child.get(), 5890 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5912 identity_matrix, 5891 gfx::PointF(), gfx::Size(40, 40), true, false,
5913 gfx::Point3F(),
5914 gfx::PointF(),
5915 gfx::Size(40, 40),
5916 true,
5917 false); 5892 false);
5918 child->SetDrawsContent(true); 5893 child->SetDrawsContent(true);
5919 5894
5920 scoped_ptr<LayerImpl> grand_child = 5895 scoped_ptr<LayerImpl> grand_child =
5921 LayerImpl::Create(host_impl.pending_tree(), 3); 5896 LayerImpl::Create(host_impl.pending_tree(), 3);
5922 SetLayerPropertiesForTesting(grand_child.get(), 5897 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
5923 identity_matrix, 5898 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5924 gfx::Point3F(), 5899 true, false, false);
5925 gfx::PointF(),
5926 gfx::Size(30, 30),
5927 true,
5928 false);
5929 grand_child->SetDrawsContent(true); 5900 grand_child->SetDrawsContent(true);
5930 grand_child->SetHideLayerAndSubtree(true); 5901 grand_child->SetHideLayerAndSubtree(true);
5931 5902
5932 child->AddChild(grand_child.Pass()); 5903 child->AddChild(grand_child.Pass());
5933 root->AddChild(child.Pass()); 5904 root->AddChild(child.Pass());
5905 root->SetHasRenderSurface(true);
5934 5906
5935 LayerImplList render_surface_layer_list; 5907 LayerImplList render_surface_layer_list;
5936 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5908 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5937 root.get(), root->bounds(), &render_surface_layer_list); 5909 root.get(), root->bounds(), &render_surface_layer_list);
5938 inputs.can_adjust_raster_scales = true; 5910 inputs.can_adjust_raster_scales = true;
5939 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5911 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5940 5912
5941 // We should have one render surface and two layers. The grand child has 5913 // We should have one render surface and two layers. The grand child has
5942 // hidden itself. 5914 // hidden itself.
5943 ASSERT_EQ(1u, render_surface_layer_list.size()); 5915 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 } 5976 }
6005 5977
6006 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { 5978 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
6007 FakeImplProxy proxy; 5979 FakeImplProxy proxy;
6008 TestSharedBitmapManager shared_bitmap_manager; 5980 TestSharedBitmapManager shared_bitmap_manager;
6009 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 5981 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
6010 host_impl.CreatePendingTree(); 5982 host_impl.CreatePendingTree();
6011 const gfx::Transform identity_matrix; 5983 const gfx::Transform identity_matrix;
6012 5984
6013 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); 5985 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
6014 SetLayerPropertiesForTesting(root.get(), 5986 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
6015 identity_matrix, 5987 gfx::PointF(), gfx::Size(50, 50), true, false,
6016 gfx::Point3F(), 5988 true);
6017 gfx::PointF(),
6018 gfx::Size(50, 50),
6019 true,
6020 false);
6021 root->SetDrawsContent(true); 5989 root->SetDrawsContent(true);
6022 5990
6023 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5991 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
6024 SetLayerPropertiesForTesting(child.get(), 5992 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
6025 identity_matrix, 5993 gfx::PointF(), gfx::Size(40, 40), true, false,
6026 gfx::Point3F(),
6027 gfx::PointF(),
6028 gfx::Size(40, 40),
6029 true,
6030 false); 5994 false);
6031 child->SetDrawsContent(true); 5995 child->SetDrawsContent(true);
6032 child->SetHideLayerAndSubtree(true); 5996 child->SetHideLayerAndSubtree(true);
6033 5997
6034 scoped_ptr<LayerImpl> grand_child = 5998 scoped_ptr<LayerImpl> grand_child =
6035 LayerImpl::Create(host_impl.pending_tree(), 3); 5999 LayerImpl::Create(host_impl.pending_tree(), 3);
6036 SetLayerPropertiesForTesting(grand_child.get(), 6000 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
6037 identity_matrix, 6001 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
6038 gfx::Point3F(), 6002 true, false, false);
6039 gfx::PointF(),
6040 gfx::Size(30, 30),
6041 true,
6042 false);
6043 grand_child->SetDrawsContent(true); 6003 grand_child->SetDrawsContent(true);
6044 6004
6045 child->AddChild(grand_child.Pass()); 6005 child->AddChild(grand_child.Pass());
6046 root->AddChild(child.Pass()); 6006 root->AddChild(child.Pass());
6047 6007
6048 LayerImplList render_surface_layer_list; 6008 LayerImplList render_surface_layer_list;
6049 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6009 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6050 root.get(), root->bounds(), &render_surface_layer_list); 6010 root.get(), root->bounds(), &render_surface_layer_list);
6051 inputs.can_adjust_raster_scales = true; 6011 inputs.can_adjust_raster_scales = true;
6052 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6012 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
6903 LayerImpl::Create(host_impl.active_tree(), 123456); 6863 LayerImpl::Create(host_impl.active_tree(), 123456);
6904 scoped_ptr<LayerImpl> child2 = 6864 scoped_ptr<LayerImpl> child2 =
6905 LayerImpl::Create(host_impl.active_tree(), 1234567); 6865 LayerImpl::Create(host_impl.active_tree(), 1234567);
6906 scoped_ptr<LayerImpl> child3 = 6866 scoped_ptr<LayerImpl> child3 =
6907 LayerImpl::Create(host_impl.active_tree(), 12345678); 6867 LayerImpl::Create(host_impl.active_tree(), 12345678);
6908 6868
6909 gfx::Transform identity_matrix; 6869 gfx::Transform identity_matrix;
6910 gfx::Point3F transform_origin; 6870 gfx::Point3F transform_origin;
6911 gfx::PointF position; 6871 gfx::PointF position;
6912 gfx::Size bounds(100, 100); 6872 gfx::Size bounds(100, 100);
6913 SetLayerPropertiesForTesting(root.get(), 6873 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
6914 identity_matrix, 6874 position, bounds, true, false, true);
6915 transform_origin,
6916 position,
6917 bounds,
6918 true,
6919 false);
6920 root->SetDrawsContent(true); 6875 root->SetDrawsContent(true);
6921 6876
6922 // This layer structure normally forces render surface due to preserves3d 6877 // This layer structure normally forces render surface due to preserves3d
6923 // behavior. 6878 // behavior.
6924 SetLayerPropertiesForTesting(child1.get(), 6879 SetLayerPropertiesForTesting(child1.get(), identity_matrix, transform_origin,
6925 identity_matrix, 6880 position, bounds, false, true, true);
6926 transform_origin,
6927 position,
6928 bounds,
6929 false,
6930 true);
6931 child1->SetDrawsContent(true); 6881 child1->SetDrawsContent(true);
6932 SetLayerPropertiesForTesting(child2.get(), 6882 SetLayerPropertiesForTesting(child2.get(), identity_matrix, transform_origin,
6933 identity_matrix, 6883 position, bounds, true, false, false);
6934 transform_origin,
6935 position,
6936 bounds,
6937 true,
6938 false);
6939 child2->SetDrawsContent(true); 6884 child2->SetDrawsContent(true);
6940 SetLayerPropertiesForTesting(child3.get(), 6885 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin,
6941 identity_matrix, 6886 position, bounds, true, false, false);
6942 transform_origin,
6943 position,
6944 bounds,
6945 true,
6946 false);
6947 child3->SetDrawsContent(true); 6887 child3->SetDrawsContent(true);
6948 6888
6949 child2->Set3dSortingContextId(1); 6889 child2->Set3dSortingContextId(1);
6950 child3->Set3dSortingContextId(1); 6890 child3->Set3dSortingContextId(1);
6951 6891
6952 child2->AddChild(child3.Pass()); 6892 child2->AddChild(child3.Pass());
6953 child1->AddChild(child2.Pass()); 6893 child1->AddChild(child2.Pass());
6954 root->AddChild(child1.Pass()); 6894 root->AddChild(child1.Pass());
6955 6895
6956 { 6896 {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
7578 scroll_parent->SetDrawsContent(true); 7518 scroll_parent->SetDrawsContent(true);
7579 top_content->SetDrawsContent(true); 7519 top_content->SetDrawsContent(true);
7580 bottom_content->SetDrawsContent(true); 7520 bottom_content->SetDrawsContent(true);
7581 7521
7582 gfx::Transform identity_transform; 7522 gfx::Transform identity_transform;
7583 gfx::Transform top_transform; 7523 gfx::Transform top_transform;
7584 top_transform.Translate3d(0.0, 0.0, 5.0); 7524 top_transform.Translate3d(0.0, 0.0, 5.0);
7585 gfx::Transform bottom_transform; 7525 gfx::Transform bottom_transform;
7586 bottom_transform.Translate3d(0.0, 0.0, 3.0); 7526 bottom_transform.Translate3d(0.0, 0.0, 3.0);
7587 7527
7588 SetLayerPropertiesForTesting(root.get(), 7528 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
7589 identity_transform, 7529 gfx::PointF(), gfx::Size(50, 50), true, false,
7590 gfx::Point3F(),
7591 gfx::PointF(),
7592 gfx::Size(50, 50),
7593 true,
7594 false);
7595 SetLayerPropertiesForTesting(scroll_parent_border.get(),
7596 identity_transform,
7597 gfx::Point3F(),
7598 gfx::PointF(),
7599 gfx::Size(40, 40),
7600 true,
7601 false);
7602 SetLayerPropertiesForTesting(scroll_parent_clip.get(),
7603 identity_transform,
7604 gfx::Point3F(),
7605 gfx::PointF(),
7606 gfx::Size(30, 30),
7607 true,
7608 false);
7609 SetLayerPropertiesForTesting(scroll_parent.get(),
7610 identity_transform,
7611 gfx::Point3F(),
7612 gfx::PointF(),
7613 gfx::Size(50, 50),
7614 true,
7615 false);
7616 SetLayerPropertiesForTesting(scroll_child.get(),
7617 identity_transform,
7618 gfx::Point3F(),
7619 gfx::PointF(),
7620 gfx::Size(50, 50),
7621 true,
7622 false);
7623 SetLayerPropertiesForTesting(top_content.get(),
7624 top_transform,
7625 gfx::Point3F(),
7626 gfx::PointF(),
7627 gfx::Size(50, 50),
7628 false,
7629 true); 7530 true);
7630 SetLayerPropertiesForTesting(bottom_content.get(), 7531 SetLayerPropertiesForTesting(scroll_parent_border.get(), identity_transform,
7631 bottom_transform, 7532 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
7632 gfx::Point3F(), 7533 true, false, false);
7633 gfx::PointF(), 7534 SetLayerPropertiesForTesting(scroll_parent_clip.get(), identity_transform,
7634 gfx::Size(50, 50), 7535 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
7635 false, 7536 true, false, false);
7537 SetLayerPropertiesForTesting(scroll_parent.get(), identity_transform,
7538 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7539 true, false, false);
7540 SetLayerPropertiesForTesting(scroll_child.get(), identity_transform,
7541 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7542 true, false, false);
7543 SetLayerPropertiesForTesting(top_content.get(), top_transform, gfx::Point3F(),
7544 gfx::PointF(), gfx::Size(50, 50), false, true,
7636 true); 7545 true);
7546 SetLayerPropertiesForTesting(bottom_content.get(), bottom_transform,
7547 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7548 false, true, true);
7637 7549
7638 scroll_child->SetShouldFlattenTransform(false); 7550 scroll_child->SetShouldFlattenTransform(false);
7639 scroll_child->Set3dSortingContextId(1); 7551 scroll_child->Set3dSortingContextId(1);
7640 7552
7641 scroll_child->AddChild(top_content.Pass()); 7553 scroll_child->AddChild(top_content.Pass());
7642 scroll_child->AddChild(bottom_content.Pass()); 7554 scroll_child->AddChild(bottom_content.Pass());
7643 root->AddChild(scroll_child.Pass()); 7555 root->AddChild(scroll_child.Pass());
7644 7556
7645 scroll_parent_clip->AddChild(scroll_parent.Pass()); 7557 scroll_parent_clip->AddChild(scroll_parent.Pass());
7646 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); 7558 scroll_parent_border->AddChild(scroll_parent_clip.Pass());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
7696 constraint.set_is_fixed_position(true); 7608 constraint.set_is_fixed_position(true);
7697 fixed->SetPositionConstraint(constraint); 7609 fixed->SetPositionConstraint(constraint);
7698 7610
7699 scroller->SetScrollClipLayer(container->id()); 7611 scroller->SetScrollClipLayer(container->id());
7700 7612
7701 gfx::Transform identity_transform; 7613 gfx::Transform identity_transform;
7702 gfx::Transform container_transform; 7614 gfx::Transform container_transform;
7703 container_transform.Translate3d(10.0, 20.0, 0.0); 7615 container_transform.Translate3d(10.0, 20.0, 0.0);
7704 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); 7616 gfx::Vector2dF container_offset = container_transform.To2dTranslation();
7705 7617
7706 SetLayerPropertiesForTesting(root.get(), 7618 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
7707 identity_transform, 7619 gfx::PointF(), gfx::Size(50, 50), true, false,
7708 gfx::Point3F(), 7620 true);
7709 gfx::PointF(), 7621 SetLayerPropertiesForTesting(container.get(), container_transform,
7710 gfx::Size(50, 50), 7622 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
7711 true, 7623 true, false, false);
7712 false); 7624 SetLayerPropertiesForTesting(scroller.get(), identity_transform,
7713 SetLayerPropertiesForTesting(container.get(), 7625 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
7714 container_transform, 7626 true, false, false);
7715 gfx::Point3F(), 7627 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(),
7716 gfx::PointF(), 7628 gfx::PointF(), gfx::Size(50, 50), true, false,
7717 gfx::Size(40, 40),
7718 true,
7719 false);
7720 SetLayerPropertiesForTesting(scroller.get(),
7721 identity_transform,
7722 gfx::Point3F(),
7723 gfx::PointF(),
7724 gfx::Size(30, 30),
7725 true,
7726 false);
7727 SetLayerPropertiesForTesting(fixed.get(),
7728 identity_transform,
7729 gfx::Point3F(),
7730 gfx::PointF(),
7731 gfx::Size(50, 50),
7732 true,
7733 false); 7629 false);
7734 7630
7735 scroller->AddChild(fixed.Pass()); 7631 scroller->AddChild(fixed.Pass());
7736 container->AddChild(scroller.Pass()); 7632 container->AddChild(scroller.Pass());
7737 root->AddChild(container.Pass()); 7633 root->AddChild(container.Pass());
7738 7634
7739 // Rounded to integers already. 7635 // Rounded to integers already.
7740 { 7636 {
7741 gfx::Vector2dF scroll_delta(3.0, 5.0); 7637 gfx::Vector2dF scroll_delta(3.0, 5.0);
7742 scroll_layer->SetScrollDelta(scroll_delta); 7638 scroll_layer->SetScrollDelta(scroll_delta);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7860 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); 7756 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4);
7861 7757
7862 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); 7758 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get();
7863 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); 7759 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get();
7864 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); 7760 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get();
7865 7761
7866 child->AddChild(grand_child.Pass()); 7762 child->AddChild(grand_child.Pass());
7867 parent->AddChild(child.Pass()); 7763 parent->AddChild(child.Pass());
7868 grand_parent->AddChild(parent.Pass()); 7764 grand_parent->AddChild(parent.Pass());
7869 7765
7870 SetLayerPropertiesForTesting(grand_parent.get(), 7766 SetLayerPropertiesForTesting(grand_parent.get(), identity_matrix,
7871 identity_matrix, 7767 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
7872 gfx::Point3F(), 7768 true, false, true);
7873 gfx::PointF(), 7769 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
7874 gfx::Size(1, 2), 7770 gfx::PointF(), gfx::Size(1, 2), true, false,
7875 true,
7876 false); 7771 false);
7877 SetLayerPropertiesForTesting(parent_raw, 7772 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
7878 identity_matrix, 7773 gfx::PointF(), gfx::Size(1, 2), true, false,
7879 gfx::Point3F(),
7880 gfx::PointF(),
7881 gfx::Size(1, 2),
7882 true,
7883 false); 7774 false);
7884 SetLayerPropertiesForTesting(child_raw, 7775
7885 identity_matrix, 7776 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(),
7886 gfx::Point3F(), 7777 gfx::PointF(), gfx::Size(1, 2), true, false,
7887 gfx::PointF(),
7888 gfx::Size(1, 2),
7889 true,
7890 false);
7891 SetLayerPropertiesForTesting(grand_child_raw,
7892 identity_matrix,
7893 gfx::Point3F(),
7894 gfx::PointF(),
7895 gfx::Size(1, 2),
7896 true,
7897 false); 7778 false);
7898 7779
7899 ExecuteCalculateDrawProperties(grand_parent.get()); 7780 ExecuteCalculateDrawProperties(grand_parent.get());
7900 7781
7901 // No layers have animations. 7782 // No layers have animations.
7902 EXPECT_EQ(0.f, 7783 EXPECT_EQ(0.f,
7903 grand_parent->draw_properties().maximum_animation_contents_scale); 7784 grand_parent->draw_properties().maximum_animation_contents_scale);
7904 EXPECT_EQ(0.f, 7785 EXPECT_EQ(0.f,
7905 parent_raw->draw_properties().maximum_animation_contents_scale); 7786 parent_raw->draw_properties().maximum_animation_contents_scale);
7906 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7787 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
8096 LayerImpl* parent_raw = parent.get(); 7977 LayerImpl* parent_raw = parent.get();
8097 LayerImpl* child_raw = child.get(); 7978 LayerImpl* child_raw = child.get();
8098 LayerImpl* grand_child1_raw = grand_child1.get(); 7979 LayerImpl* grand_child1_raw = grand_child1.get();
8099 LayerImpl* grand_child2_raw = grand_child2.get(); 7980 LayerImpl* grand_child2_raw = grand_child2.get();
8100 7981
8101 child->AddChild(grand_child1.Pass()); 7982 child->AddChild(grand_child1.Pass());
8102 child->AddChild(grand_child2.Pass()); 7983 child->AddChild(grand_child2.Pass());
8103 parent->AddChild(child.Pass()); 7984 parent->AddChild(child.Pass());
8104 grand_parent->AddChild(parent.Pass()); 7985 grand_parent->AddChild(parent.Pass());
8105 7986
8106 SetLayerPropertiesForTesting(grand_parent_raw, 7987 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
8107 identity_matrix, 7988 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
8108 gfx::Point3F(), 7989 true, false, true);
8109 gfx::PointF(), 7990 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
8110 gfx::Size(1, 2), 7991 gfx::PointF(), gfx::Size(1, 2), true, false,
8111 true,
8112 false); 7992 false);
8113 SetLayerPropertiesForTesting(parent_raw, 7993
8114 identity_matrix, 7994 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
8115 gfx::Point3F(), 7995 gfx::PointF(), gfx::Size(1, 2), true, false,
8116 gfx::PointF(),
8117 gfx::Size(1, 2),
8118 true,
8119 false); 7996 false);
8120 SetLayerPropertiesForTesting(child_raw, 7997
8121 identity_matrix, 7998 SetLayerPropertiesForTesting(grand_child1_raw, identity_matrix,
8122 gfx::Point3F(), 7999 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
8123 gfx::PointF(), 8000 true, false, false);
8124 gfx::Size(1, 2), 8001
8125 true, 8002 SetLayerPropertiesForTesting(grand_child2_raw, identity_matrix,
8126 false); 8003 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
8127 SetLayerPropertiesForTesting(grand_child1_raw, 8004 true, false, false);
8128 identity_matrix,
8129 gfx::Point3F(),
8130 gfx::PointF(),
8131 gfx::Size(1, 2),
8132 true,
8133 false);
8134 SetLayerPropertiesForTesting(grand_child2_raw,
8135 identity_matrix,
8136 gfx::Point3F(),
8137 gfx::PointF(),
8138 gfx::Size(1, 2),
8139 true,
8140 false);
8141 8005
8142 // Start with nothing being drawn. 8006 // Start with nothing being drawn.
8143 ExecuteCalculateDrawProperties(grand_parent_raw); 8007 ExecuteCalculateDrawProperties(grand_parent_raw);
8144 int member_id = render_surface_layer_list_count(); 8008 int member_id = render_surface_layer_list_count();
8145 8009
8146 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8010 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8147 EXPECT_NE(member_id, membership_id(parent_raw)); 8011 EXPECT_NE(member_id, membership_id(parent_raw));
8148 EXPECT_NE(member_id, membership_id(child_raw)); 8012 EXPECT_NE(member_id, membership_id(child_raw));
8149 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8013 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8150 EXPECT_NE(member_id, membership_id(grand_child2_raw)); 8014 EXPECT_NE(member_id, membership_id(grand_child2_raw));
8151 8015
8152 std::set<LayerImpl*> expected; 8016 std::set<LayerImpl*> expected;
8153 std::set<LayerImpl*> actual; 8017 std::set<LayerImpl*> actual;
8154 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 8018 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
8155 EXPECT_EQ(expected, actual); 8019 EXPECT_EQ(expected, actual);
8156 8020
8157 // If we force render surface, but none of the layers are in the layer list, 8021 // If we force render surface, but none of the layers are in the layer list,
8158 // then this layer should not appear in RSLL. 8022 // then this layer should not appear in RSLL.
8159 grand_child1_raw->SetForceRenderSurface(true); 8023 grand_child1_raw->SetHasRenderSurface(true);
8160 8024
8161 ExecuteCalculateDrawProperties(grand_parent_raw); 8025 ExecuteCalculateDrawProperties(grand_parent_raw);
8162 member_id = render_surface_layer_list_count(); 8026 member_id = render_surface_layer_list_count();
8163 8027
8164 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8028 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8165 EXPECT_NE(member_id, membership_id(parent_raw)); 8029 EXPECT_NE(member_id, membership_id(parent_raw));
8166 EXPECT_NE(member_id, membership_id(child_raw)); 8030 EXPECT_NE(member_id, membership_id(child_raw));
8167 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8031 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8168 EXPECT_NE(member_id, membership_id(grand_child2_raw)); 8032 EXPECT_NE(member_id, membership_id(grand_child2_raw));
8169 8033
(...skipping 18 matching lines...) Expand all
8188 expected.clear(); 8052 expected.clear();
8189 expected.insert(grand_child1_raw); 8053 expected.insert(grand_child1_raw);
8190 8054
8191 actual.clear(); 8055 actual.clear();
8192 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 8056 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
8193 EXPECT_EQ(expected, actual); 8057 EXPECT_EQ(expected, actual);
8194 8058
8195 // Now child is forced to have a render surface, and one if its children draws 8059 // Now child is forced to have a render surface, and one if its children draws
8196 // content. 8060 // content.
8197 grand_child1_raw->SetDrawsContent(false); 8061 grand_child1_raw->SetDrawsContent(false);
8198 grand_child1_raw->SetForceRenderSurface(false); 8062 grand_child1_raw->SetHasRenderSurface(false);
8199 child_raw->SetForceRenderSurface(true); 8063 child_raw->SetHasRenderSurface(true);
8200 grand_child2_raw->SetDrawsContent(true); 8064 grand_child2_raw->SetDrawsContent(true);
8201 8065
8202 ExecuteCalculateDrawProperties(grand_parent_raw); 8066 ExecuteCalculateDrawProperties(grand_parent_raw);
8203 member_id = render_surface_layer_list_count(); 8067 member_id = render_surface_layer_list_count();
8204 8068
8205 EXPECT_NE(member_id, membership_id(grand_parent_raw)); 8069 EXPECT_NE(member_id, membership_id(grand_parent_raw));
8206 EXPECT_NE(member_id, membership_id(parent_raw)); 8070 EXPECT_NE(member_id, membership_id(parent_raw));
8207 EXPECT_NE(member_id, membership_id(child_raw)); 8071 EXPECT_NE(member_id, membership_id(child_raw));
8208 EXPECT_NE(member_id, membership_id(grand_child1_raw)); 8072 EXPECT_NE(member_id, membership_id(grand_child1_raw));
8209 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); 8073 EXPECT_EQ(member_id, membership_id(grand_child2_raw));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
8344 8208
8345 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); 8209 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
8346 LayerImpl* root_layer = root.get(); 8210 LayerImpl* root_layer = root.get();
8347 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); 8211 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2);
8348 LayerImpl* child1_layer = child1.get(); 8212 LayerImpl* child1_layer = child1.get();
8349 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); 8213 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3);
8350 LayerImpl* child2_layer = child2.get(); 8214 LayerImpl* child2_layer = child2.get();
8351 8215
8352 root->AddChild(child1.Pass()); 8216 root->AddChild(child1.Pass());
8353 root->AddChild(child2.Pass()); 8217 root->AddChild(child2.Pass());
8218 root->SetHasRenderSurface(true);
8354 8219
8355 gfx::Transform identity_matrix, scale_transform_child1, 8220 gfx::Transform identity_matrix, scale_transform_child1,
8356 scale_transform_child2; 8221 scale_transform_child2;
8357 scale_transform_child1.Scale(2, 3); 8222 scale_transform_child1.Scale(2, 3);
8358 scale_transform_child2.Scale(4, 5); 8223 scale_transform_child2.Scale(4, 5);
8359 8224
8360 SetLayerPropertiesForTesting(root_layer, 8225 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(),
8361 identity_matrix, 8226 gfx::PointF(), gfx::Size(1, 1), true, false,
8362 gfx::Point3F(), 8227 true);
8363 gfx::PointF(), 8228 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1,
8364 gfx::Size(1, 1), 8229 gfx::Point3F(), gfx::PointF(), gfx::Size(), true,
8365 true, 8230 false, false);
8366 false);
8367 SetLayerPropertiesForTesting(child1_layer,
8368 scale_transform_child1,
8369 gfx::Point3F(),
8370 gfx::PointF(),
8371 gfx::Size(),
8372 true,
8373 false);
8374 8231
8375 child1_layer->SetMaskLayer( 8232 child1_layer->SetMaskLayer(
8376 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); 8233 LayerImpl::Create(host_impl.active_tree(), 4).Pass());
8377 8234
8378 scoped_ptr<LayerImpl> replica_layer = 8235 scoped_ptr<LayerImpl> replica_layer =
8379 LayerImpl::Create(host_impl.active_tree(), 5); 8236 LayerImpl::Create(host_impl.active_tree(), 5);
8237 replica_layer->SetHasRenderSurface(true);
8380 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 8238 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6));
8381 child1_layer->SetReplicaLayer(replica_layer.Pass()); 8239 child1_layer->SetReplicaLayer(replica_layer.Pass());
8240 child1_layer->SetHasRenderSurface(true);
8382 8241
8383 ExecuteCalculateDrawProperties(root_layer); 8242 ExecuteCalculateDrawProperties(root_layer);
8384 8243
8385 TransformOperations scale; 8244 TransformOperations scale;
8386 scale.AppendScale(5.f, 8.f, 3.f); 8245 scale.AppendScale(5.f, 8.f, 3.f);
8387 8246
8388 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); 8247 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale);
8389 SetLayerPropertiesForTesting(child2_layer, 8248 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2,
8390 scale_transform_child2, 8249 gfx::Point3F(), gfx::PointF(), gfx::Size(), true,
8391 gfx::Point3F(), 8250 false, false);
8392 gfx::PointF(),
8393 gfx::Size(),
8394 true,
8395 false);
8396 8251
8397 ExecuteCalculateDrawProperties(root_layer); 8252 ExecuteCalculateDrawProperties(root_layer);
8398 8253
8399 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); 8254 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale);
8400 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); 8255 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale);
8401 EXPECT_FLOAT_EQ( 8256 EXPECT_FLOAT_EQ(
8402 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); 8257 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale);
8403 EXPECT_FLOAT_EQ(3.f, 8258 EXPECT_FLOAT_EQ(3.f,
8404 child1_layer->replica_layer() 8259 child1_layer->replica_layer()
8405 ->mask_layer() 8260 ->mask_layer()
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
8621 // by the viewport. 8476 // by the viewport.
8622 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); 8477 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect());
8623 8478
8624 // Layers drawing to a child render surface should still have their visible 8479 // Layers drawing to a child render surface should still have their visible
8625 // content rect clipped by the viewport. 8480 // content rect clipped by the viewport.
8626 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); 8481 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect());
8627 } 8482 }
8628 8483
8629 } // namespace 8484 } // namespace
8630 } // namespace cc 8485 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698