OLD | NEW |
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 Loading... |
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 3384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3787 gfx::Size(100, 100), | 3772 gfx::Size(100, 100), |
3788 true, | 3773 true, |
3789 true); | 3774 true); |
3790 | 3775 |
3791 RenderSurfaceLayerList render_surface_layer_list; | 3776 RenderSurfaceLayerList render_surface_layer_list; |
3792 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 3777 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
3793 parent.get(), parent->bounds(), &render_surface_layer_list); | 3778 parent.get(), parent->bounds(), &render_surface_layer_list); |
3794 inputs.can_adjust_raster_scales = true; | 3779 inputs.can_adjust_raster_scales = true; |
3795 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 3780 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
3796 | 3781 |
3797 // Verify which render surfaces were created. | 3782 // Verify which render surfaces were created and used. |
3798 EXPECT_FALSE(front_facing_child->render_surface()); | 3783 EXPECT_FALSE(front_facing_child->render_surface()); |
3799 EXPECT_FALSE(back_facing_child->render_surface()); | 3784 EXPECT_FALSE(back_facing_child->render_surface()); |
3800 EXPECT_TRUE(front_facing_surface->render_surface()); | 3785 EXPECT_TRUE(front_facing_surface->render_surface()); |
3801 EXPECT_FALSE(back_facing_surface->render_surface()); | 3786 EXPECT_NE(back_facing_surface->render_target(), back_facing_surface); |
| 3787 // We expect that a render_surface was created but not used. |
| 3788 EXPECT_TRUE(back_facing_surface->render_surface()); |
3802 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface()); | 3789 EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface()); |
3803 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface()); | 3790 EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface()); |
3804 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface()); | 3791 EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface()); |
3805 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface()); | 3792 EXPECT_FALSE(back_facing_child_of_back_facing_surface->render_surface()); |
3806 | 3793 |
3807 // Verify the render_surface_layer_list. The back-facing surface should be | 3794 // Verify the render_surface_layer_list. The back-facing surface should be |
3808 // culled. | 3795 // culled. |
3809 ASSERT_EQ(2u, render_surface_layer_list.size()); | 3796 ASSERT_EQ(2u, render_surface_layer_list.size()); |
3810 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); | 3797 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); |
3811 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); | 3798 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 Loading... |
4055 | 4042 |
4056 front_facing_surface->Set3dSortingContextId(1); | 4043 front_facing_surface->Set3dSortingContextId(1); |
4057 back_facing_surface->Set3dSortingContextId(1); | 4044 back_facing_surface->Set3dSortingContextId(1); |
4058 | 4045 |
4059 RenderSurfaceLayerList render_surface_layer_list; | 4046 RenderSurfaceLayerList render_surface_layer_list; |
4060 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4047 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4061 parent.get(), parent->bounds(), &render_surface_layer_list); | 4048 parent.get(), parent->bounds(), &render_surface_layer_list); |
4062 inputs.can_adjust_raster_scales = true; | 4049 inputs.can_adjust_raster_scales = true; |
4063 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4050 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4064 | 4051 |
4065 // Verify which render surfaces were created. | 4052 // Verify which render surfaces were created and used. |
4066 EXPECT_TRUE(front_facing_surface->render_surface()); | 4053 EXPECT_TRUE(front_facing_surface->render_surface()); |
4067 EXPECT_FALSE( | 4054 |
4068 back_facing_surface->render_surface()); // because it should be culled | 4055 // We expect the render surface to have been created, but remain unused. |
| 4056 EXPECT_TRUE(back_facing_surface->render_surface()); |
| 4057 EXPECT_NE(back_facing_surface->render_target(), |
| 4058 back_facing_surface); // because it should be culled |
4069 EXPECT_FALSE(child1->render_surface()); | 4059 EXPECT_FALSE(child1->render_surface()); |
4070 EXPECT_FALSE(child2->render_surface()); | 4060 EXPECT_FALSE(child2->render_surface()); |
4071 | 4061 |
4072 // Verify the render_surface_layer_list. The back-facing surface should be | 4062 // Verify the render_surface_layer_list. The back-facing surface should be |
4073 // culled. | 4063 // culled. |
4074 ASSERT_EQ(2u, render_surface_layer_list.size()); | 4064 ASSERT_EQ(2u, render_surface_layer_list.size()); |
4075 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); | 4065 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); |
4076 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); | 4066 EXPECT_EQ(front_facing_surface->id(), render_surface_layer_list.at(1)->id()); |
4077 | 4067 |
4078 // Verify root surface's layer list. | 4068 // Verify root surface's layer list. |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5639 } | 5629 } |
5640 | 5630 |
5641 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { | 5631 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { |
5642 FakeImplProxy proxy; | 5632 FakeImplProxy proxy; |
5643 TestSharedBitmapManager shared_bitmap_manager; | 5633 TestSharedBitmapManager shared_bitmap_manager; |
5644 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5634 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
5645 host_impl.CreatePendingTree(); | 5635 host_impl.CreatePendingTree(); |
5646 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 5636 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
5647 | 5637 |
5648 const gfx::Transform identity_matrix; | 5638 const gfx::Transform identity_matrix; |
5649 SetLayerPropertiesForTesting(root.get(), | 5639 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5650 identity_matrix, | 5640 gfx::PointF(), gfx::Size(100, 100), true, false, |
5651 gfx::Point3F(), | |
5652 gfx::PointF(), | |
5653 gfx::Size(100, 100), | |
5654 true, | |
5655 false); | 5641 false); |
5656 root->SetDrawsContent(true); | 5642 root->SetDrawsContent(true); |
5657 | 5643 |
5658 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5644 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
5659 SetLayerPropertiesForTesting(child.get(), | 5645 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
5660 identity_matrix, | 5646 gfx::PointF(), gfx::Size(50, 50), true, false, |
5661 gfx::Point3F(), | |
5662 gfx::PointF(), | |
5663 gfx::Size(50, 50), | |
5664 true, | |
5665 false); | 5647 false); |
5666 child->SetDrawsContent(true); | 5648 child->SetDrawsContent(true); |
5667 child->SetOpacity(0.0f); | 5649 child->SetOpacity(0.0f); |
5668 | 5650 |
5669 // Add opacity animation. | 5651 // Add opacity animation. |
5670 AddOpacityTransitionToController( | 5652 AddOpacityTransitionToController( |
5671 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); | 5653 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); |
5672 | 5654 |
5673 root->AddChild(child.Pass()); | 5655 root->AddChild(child.Pass()); |
| 5656 root->SetHasRenderSurface(true); |
5674 | 5657 |
5675 LayerImplList render_surface_layer_list; | 5658 LayerImplList render_surface_layer_list; |
5676 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5659 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5677 root.get(), root->bounds(), &render_surface_layer_list); | 5660 root.get(), root->bounds(), &render_surface_layer_list); |
5678 inputs.can_adjust_raster_scales = true; | 5661 inputs.can_adjust_raster_scales = true; |
5679 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5662 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5680 | 5663 |
5681 // We should have one render surface and two layers. The child | 5664 // We should have one render surface and two layers. The child |
5682 // layer should be included even though it is transparent. | 5665 // layer should be included even though it is transparent. |
5683 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5666 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5684 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5667 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5685 } | 5668 } |
5686 | 5669 |
5687 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; | 5670 using LCDTextTestParam = std::tr1::tuple<bool, bool, bool>; |
5688 class LCDTextTest | 5671 class LCDTextTest |
5689 : public LayerTreeHostCommonTestBase, | 5672 : public LayerTreeHostCommonTestBase, |
5690 public testing::TestWithParam<LCDTextTestParam> { | 5673 public testing::TestWithParam<LCDTextTestParam> { |
5691 protected: | 5674 protected: |
5692 virtual void SetUp() { | 5675 void SetUp() override { |
5693 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); | 5676 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); |
5694 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); | 5677 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); |
5695 | 5678 |
5696 root_ = Layer::Create(); | 5679 root_ = Layer::Create(); |
5697 child_ = Layer::Create(); | 5680 child_ = Layer::Create(); |
5698 grand_child_ = Layer::Create(); | 5681 grand_child_ = Layer::Create(); |
5699 child_->AddChild(grand_child_.get()); | 5682 child_->AddChild(grand_child_.get()); |
5700 root_->AddChild(child_.get()); | 5683 root_->AddChild(child_.get()); |
5701 | 5684 |
5702 root_->SetContentsOpaque(true); | 5685 root_->SetContentsOpaque(true); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5926 } | 5909 } |
5927 | 5910 |
5928 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | 5911 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
5929 FakeImplProxy proxy; | 5912 FakeImplProxy proxy; |
5930 TestSharedBitmapManager shared_bitmap_manager; | 5913 TestSharedBitmapManager shared_bitmap_manager; |
5931 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5914 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
5932 host_impl.CreatePendingTree(); | 5915 host_impl.CreatePendingTree(); |
5933 const gfx::Transform identity_matrix; | 5916 const gfx::Transform identity_matrix; |
5934 | 5917 |
5935 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 5918 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
5936 SetLayerPropertiesForTesting(root.get(), | 5919 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5937 identity_matrix, | 5920 gfx::PointF(), gfx::Size(50, 50), true, false, |
5938 gfx::Point3F(), | |
5939 gfx::PointF(), | |
5940 gfx::Size(50, 50), | |
5941 true, | |
5942 false); | 5921 false); |
5943 root->SetDrawsContent(true); | 5922 root->SetDrawsContent(true); |
5944 | 5923 |
5945 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5924 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
5946 SetLayerPropertiesForTesting(child.get(), | 5925 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
5947 identity_matrix, | 5926 gfx::PointF(), gfx::Size(40, 40), true, false, |
5948 gfx::Point3F(), | |
5949 gfx::PointF(), | |
5950 gfx::Size(40, 40), | |
5951 true, | |
5952 false); | 5927 false); |
5953 child->SetDrawsContent(true); | 5928 child->SetDrawsContent(true); |
5954 | 5929 |
5955 scoped_ptr<LayerImpl> grand_child = | 5930 scoped_ptr<LayerImpl> grand_child = |
5956 LayerImpl::Create(host_impl.pending_tree(), 3); | 5931 LayerImpl::Create(host_impl.pending_tree(), 3); |
5957 SetLayerPropertiesForTesting(grand_child.get(), | 5932 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
5958 identity_matrix, | 5933 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
5959 gfx::Point3F(), | 5934 true, false, false); |
5960 gfx::PointF(), | |
5961 gfx::Size(30, 30), | |
5962 true, | |
5963 false); | |
5964 grand_child->SetDrawsContent(true); | 5935 grand_child->SetDrawsContent(true); |
5965 grand_child->SetHideLayerAndSubtree(true); | 5936 grand_child->SetHideLayerAndSubtree(true); |
5966 | 5937 |
5967 child->AddChild(grand_child.Pass()); | 5938 child->AddChild(grand_child.Pass()); |
5968 root->AddChild(child.Pass()); | 5939 root->AddChild(child.Pass()); |
| 5940 root->SetHasRenderSurface(true); |
5969 | 5941 |
5970 LayerImplList render_surface_layer_list; | 5942 LayerImplList render_surface_layer_list; |
5971 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5943 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5972 root.get(), root->bounds(), &render_surface_layer_list); | 5944 root.get(), root->bounds(), &render_surface_layer_list); |
5973 inputs.can_adjust_raster_scales = true; | 5945 inputs.can_adjust_raster_scales = true; |
5974 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5946 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5975 | 5947 |
5976 // 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 |
5977 // hidden itself. | 5949 // hidden itself. |
5978 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5950 ASSERT_EQ(1u, render_surface_layer_list.size()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6039 } | 6011 } |
6040 | 6012 |
6041 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 6013 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
6042 FakeImplProxy proxy; | 6014 FakeImplProxy proxy; |
6043 TestSharedBitmapManager shared_bitmap_manager; | 6015 TestSharedBitmapManager shared_bitmap_manager; |
6044 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 6016 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
6045 host_impl.CreatePendingTree(); | 6017 host_impl.CreatePendingTree(); |
6046 const gfx::Transform identity_matrix; | 6018 const gfx::Transform identity_matrix; |
6047 | 6019 |
6048 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 6020 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
6049 SetLayerPropertiesForTesting(root.get(), | 6021 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
6050 identity_matrix, | 6022 gfx::PointF(), gfx::Size(50, 50), true, false, |
6051 gfx::Point3F(), | 6023 true); |
6052 gfx::PointF(), | |
6053 gfx::Size(50, 50), | |
6054 true, | |
6055 false); | |
6056 root->SetDrawsContent(true); | 6024 root->SetDrawsContent(true); |
6057 | 6025 |
6058 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 6026 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
6059 SetLayerPropertiesForTesting(child.get(), | 6027 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
6060 identity_matrix, | 6028 gfx::PointF(), gfx::Size(40, 40), true, false, |
6061 gfx::Point3F(), | |
6062 gfx::PointF(), | |
6063 gfx::Size(40, 40), | |
6064 true, | |
6065 false); | 6029 false); |
6066 child->SetDrawsContent(true); | 6030 child->SetDrawsContent(true); |
6067 child->SetHideLayerAndSubtree(true); | 6031 child->SetHideLayerAndSubtree(true); |
6068 | 6032 |
6069 scoped_ptr<LayerImpl> grand_child = | 6033 scoped_ptr<LayerImpl> grand_child = |
6070 LayerImpl::Create(host_impl.pending_tree(), 3); | 6034 LayerImpl::Create(host_impl.pending_tree(), 3); |
6071 SetLayerPropertiesForTesting(grand_child.get(), | 6035 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
6072 identity_matrix, | 6036 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
6073 gfx::Point3F(), | 6037 true, false, false); |
6074 gfx::PointF(), | |
6075 gfx::Size(30, 30), | |
6076 true, | |
6077 false); | |
6078 grand_child->SetDrawsContent(true); | 6038 grand_child->SetDrawsContent(true); |
6079 | 6039 |
6080 child->AddChild(grand_child.Pass()); | 6040 child->AddChild(grand_child.Pass()); |
6081 root->AddChild(child.Pass()); | 6041 root->AddChild(child.Pass()); |
6082 | 6042 |
6083 LayerImplList render_surface_layer_list; | 6043 LayerImplList render_surface_layer_list; |
6084 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6044 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6085 root.get(), root->bounds(), &render_surface_layer_list); | 6045 root.get(), root->bounds(), &render_surface_layer_list); |
6086 inputs.can_adjust_raster_scales = true; | 6046 inputs.can_adjust_raster_scales = true; |
6087 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6047 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6938 LayerImpl::Create(host_impl.active_tree(), 123456); | 6898 LayerImpl::Create(host_impl.active_tree(), 123456); |
6939 scoped_ptr<LayerImpl> child2 = | 6899 scoped_ptr<LayerImpl> child2 = |
6940 LayerImpl::Create(host_impl.active_tree(), 1234567); | 6900 LayerImpl::Create(host_impl.active_tree(), 1234567); |
6941 scoped_ptr<LayerImpl> child3 = | 6901 scoped_ptr<LayerImpl> child3 = |
6942 LayerImpl::Create(host_impl.active_tree(), 12345678); | 6902 LayerImpl::Create(host_impl.active_tree(), 12345678); |
6943 | 6903 |
6944 gfx::Transform identity_matrix; | 6904 gfx::Transform identity_matrix; |
6945 gfx::Point3F transform_origin; | 6905 gfx::Point3F transform_origin; |
6946 gfx::PointF position; | 6906 gfx::PointF position; |
6947 gfx::Size bounds(100, 100); | 6907 gfx::Size bounds(100, 100); |
6948 SetLayerPropertiesForTesting(root.get(), | 6908 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
6949 identity_matrix, | 6909 position, bounds, true, false, true); |
6950 transform_origin, | |
6951 position, | |
6952 bounds, | |
6953 true, | |
6954 false); | |
6955 root->SetDrawsContent(true); | 6910 root->SetDrawsContent(true); |
6956 | 6911 |
6957 // This layer structure normally forces render surface due to preserves3d | 6912 // This layer structure normally forces render surface due to preserves3d |
6958 // behavior. | 6913 // behavior. |
6959 SetLayerPropertiesForTesting(child1.get(), | 6914 SetLayerPropertiesForTesting(child1.get(), identity_matrix, transform_origin, |
6960 identity_matrix, | 6915 position, bounds, false, true, true); |
6961 transform_origin, | |
6962 position, | |
6963 bounds, | |
6964 false, | |
6965 true); | |
6966 child1->SetDrawsContent(true); | 6916 child1->SetDrawsContent(true); |
6967 SetLayerPropertiesForTesting(child2.get(), | 6917 SetLayerPropertiesForTesting(child2.get(), identity_matrix, transform_origin, |
6968 identity_matrix, | 6918 position, bounds, true, false, false); |
6969 transform_origin, | |
6970 position, | |
6971 bounds, | |
6972 true, | |
6973 false); | |
6974 child2->SetDrawsContent(true); | 6919 child2->SetDrawsContent(true); |
6975 SetLayerPropertiesForTesting(child3.get(), | 6920 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, |
6976 identity_matrix, | 6921 position, bounds, true, false, false); |
6977 transform_origin, | |
6978 position, | |
6979 bounds, | |
6980 true, | |
6981 false); | |
6982 child3->SetDrawsContent(true); | 6922 child3->SetDrawsContent(true); |
6983 | 6923 |
6984 child2->Set3dSortingContextId(1); | 6924 child2->Set3dSortingContextId(1); |
6985 child3->Set3dSortingContextId(1); | 6925 child3->Set3dSortingContextId(1); |
6986 | 6926 |
6987 child2->AddChild(child3.Pass()); | 6927 child2->AddChild(child3.Pass()); |
6988 child1->AddChild(child2.Pass()); | 6928 child1->AddChild(child2.Pass()); |
6989 root->AddChild(child1.Pass()); | 6929 root->AddChild(child1.Pass()); |
6990 | 6930 |
6991 { | 6931 { |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7613 scroll_parent->SetDrawsContent(true); | 7553 scroll_parent->SetDrawsContent(true); |
7614 top_content->SetDrawsContent(true); | 7554 top_content->SetDrawsContent(true); |
7615 bottom_content->SetDrawsContent(true); | 7555 bottom_content->SetDrawsContent(true); |
7616 | 7556 |
7617 gfx::Transform identity_transform; | 7557 gfx::Transform identity_transform; |
7618 gfx::Transform top_transform; | 7558 gfx::Transform top_transform; |
7619 top_transform.Translate3d(0.0, 0.0, 5.0); | 7559 top_transform.Translate3d(0.0, 0.0, 5.0); |
7620 gfx::Transform bottom_transform; | 7560 gfx::Transform bottom_transform; |
7621 bottom_transform.Translate3d(0.0, 0.0, 3.0); | 7561 bottom_transform.Translate3d(0.0, 0.0, 3.0); |
7622 | 7562 |
7623 SetLayerPropertiesForTesting(root.get(), | 7563 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
7624 identity_transform, | 7564 gfx::PointF(), gfx::Size(50, 50), true, false, |
7625 gfx::Point3F(), | |
7626 gfx::PointF(), | |
7627 gfx::Size(50, 50), | |
7628 true, | |
7629 false); | |
7630 SetLayerPropertiesForTesting(scroll_parent_border.get(), | |
7631 identity_transform, | |
7632 gfx::Point3F(), | |
7633 gfx::PointF(), | |
7634 gfx::Size(40, 40), | |
7635 true, | |
7636 false); | |
7637 SetLayerPropertiesForTesting(scroll_parent_clip.get(), | |
7638 identity_transform, | |
7639 gfx::Point3F(), | |
7640 gfx::PointF(), | |
7641 gfx::Size(30, 30), | |
7642 true, | |
7643 false); | |
7644 SetLayerPropertiesForTesting(scroll_parent.get(), | |
7645 identity_transform, | |
7646 gfx::Point3F(), | |
7647 gfx::PointF(), | |
7648 gfx::Size(50, 50), | |
7649 true, | |
7650 false); | |
7651 SetLayerPropertiesForTesting(scroll_child.get(), | |
7652 identity_transform, | |
7653 gfx::Point3F(), | |
7654 gfx::PointF(), | |
7655 gfx::Size(50, 50), | |
7656 true, | |
7657 false); | |
7658 SetLayerPropertiesForTesting(top_content.get(), | |
7659 top_transform, | |
7660 gfx::Point3F(), | |
7661 gfx::PointF(), | |
7662 gfx::Size(50, 50), | |
7663 false, | |
7664 true); | 7565 true); |
7665 SetLayerPropertiesForTesting(bottom_content.get(), | 7566 SetLayerPropertiesForTesting(scroll_parent_border.get(), identity_transform, |
7666 bottom_transform, | 7567 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
7667 gfx::Point3F(), | 7568 true, false, false); |
7668 gfx::PointF(), | 7569 SetLayerPropertiesForTesting(scroll_parent_clip.get(), identity_transform, |
7669 gfx::Size(50, 50), | 7570 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
7670 false, | 7571 true, false, false); |
| 7572 SetLayerPropertiesForTesting(scroll_parent.get(), identity_transform, |
| 7573 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 7574 true, false, false); |
| 7575 SetLayerPropertiesForTesting(scroll_child.get(), identity_transform, |
| 7576 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 7577 true, false, false); |
| 7578 SetLayerPropertiesForTesting(top_content.get(), top_transform, gfx::Point3F(), |
| 7579 gfx::PointF(), gfx::Size(50, 50), false, true, |
7671 true); | 7580 true); |
| 7581 SetLayerPropertiesForTesting(bottom_content.get(), bottom_transform, |
| 7582 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 7583 false, true, true); |
7672 | 7584 |
7673 scroll_child->SetShouldFlattenTransform(false); | 7585 scroll_child->SetShouldFlattenTransform(false); |
7674 scroll_child->Set3dSortingContextId(1); | 7586 scroll_child->Set3dSortingContextId(1); |
7675 | 7587 |
7676 scroll_child->AddChild(top_content.Pass()); | 7588 scroll_child->AddChild(top_content.Pass()); |
7677 scroll_child->AddChild(bottom_content.Pass()); | 7589 scroll_child->AddChild(bottom_content.Pass()); |
7678 root->AddChild(scroll_child.Pass()); | 7590 root->AddChild(scroll_child.Pass()); |
7679 | 7591 |
7680 scroll_parent_clip->AddChild(scroll_parent.Pass()); | 7592 scroll_parent_clip->AddChild(scroll_parent.Pass()); |
7681 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); | 7593 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7731 constraint.set_is_fixed_position(true); | 7643 constraint.set_is_fixed_position(true); |
7732 fixed->SetPositionConstraint(constraint); | 7644 fixed->SetPositionConstraint(constraint); |
7733 | 7645 |
7734 scroller->SetScrollClipLayer(container->id()); | 7646 scroller->SetScrollClipLayer(container->id()); |
7735 | 7647 |
7736 gfx::Transform identity_transform; | 7648 gfx::Transform identity_transform; |
7737 gfx::Transform container_transform; | 7649 gfx::Transform container_transform; |
7738 container_transform.Translate3d(10.0, 20.0, 0.0); | 7650 container_transform.Translate3d(10.0, 20.0, 0.0); |
7739 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 7651 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
7740 | 7652 |
7741 SetLayerPropertiesForTesting(root.get(), | 7653 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
7742 identity_transform, | 7654 gfx::PointF(), gfx::Size(50, 50), true, false, |
7743 gfx::Point3F(), | 7655 true); |
7744 gfx::PointF(), | 7656 SetLayerPropertiesForTesting(container.get(), container_transform, |
7745 gfx::Size(50, 50), | 7657 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
7746 true, | 7658 true, false, false); |
7747 false); | 7659 SetLayerPropertiesForTesting(scroller.get(), identity_transform, |
7748 SetLayerPropertiesForTesting(container.get(), | 7660 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
7749 container_transform, | 7661 true, false, false); |
7750 gfx::Point3F(), | 7662 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), |
7751 gfx::PointF(), | 7663 gfx::PointF(), gfx::Size(50, 50), true, false, |
7752 gfx::Size(40, 40), | |
7753 true, | |
7754 false); | |
7755 SetLayerPropertiesForTesting(scroller.get(), | |
7756 identity_transform, | |
7757 gfx::Point3F(), | |
7758 gfx::PointF(), | |
7759 gfx::Size(30, 30), | |
7760 true, | |
7761 false); | |
7762 SetLayerPropertiesForTesting(fixed.get(), | |
7763 identity_transform, | |
7764 gfx::Point3F(), | |
7765 gfx::PointF(), | |
7766 gfx::Size(50, 50), | |
7767 true, | |
7768 false); | 7664 false); |
7769 | 7665 |
7770 scroller->AddChild(fixed.Pass()); | 7666 scroller->AddChild(fixed.Pass()); |
7771 container->AddChild(scroller.Pass()); | 7667 container->AddChild(scroller.Pass()); |
7772 root->AddChild(container.Pass()); | 7668 root->AddChild(container.Pass()); |
7773 | 7669 |
7774 // Rounded to integers already. | 7670 // Rounded to integers already. |
7775 { | 7671 { |
7776 gfx::Vector2dF scroll_delta(3.0, 5.0); | 7672 gfx::Vector2dF scroll_delta(3.0, 5.0); |
7777 scroll_layer->SetScrollDelta(scroll_delta); | 7673 scroll_layer->SetScrollDelta(scroll_delta); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7895 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); | 7791 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); |
7896 | 7792 |
7897 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); | 7793 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); |
7898 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); | 7794 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); |
7899 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); | 7795 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); |
7900 | 7796 |
7901 child->AddChild(grand_child.Pass()); | 7797 child->AddChild(grand_child.Pass()); |
7902 parent->AddChild(child.Pass()); | 7798 parent->AddChild(child.Pass()); |
7903 grand_parent->AddChild(parent.Pass()); | 7799 grand_parent->AddChild(parent.Pass()); |
7904 | 7800 |
7905 SetLayerPropertiesForTesting(grand_parent.get(), | 7801 SetLayerPropertiesForTesting(grand_parent.get(), identity_matrix, |
7906 identity_matrix, | 7802 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
7907 gfx::Point3F(), | 7803 true, false, true); |
7908 gfx::PointF(), | 7804 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), |
7909 gfx::Size(1, 2), | 7805 gfx::PointF(), gfx::Size(1, 2), true, false, |
7910 true, | |
7911 false); | 7806 false); |
7912 SetLayerPropertiesForTesting(parent_raw, | 7807 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), |
7913 identity_matrix, | 7808 gfx::PointF(), gfx::Size(1, 2), true, false, |
7914 gfx::Point3F(), | |
7915 gfx::PointF(), | |
7916 gfx::Size(1, 2), | |
7917 true, | |
7918 false); | 7809 false); |
7919 SetLayerPropertiesForTesting(child_raw, | 7810 |
7920 identity_matrix, | 7811 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), |
7921 gfx::Point3F(), | 7812 gfx::PointF(), gfx::Size(1, 2), true, false, |
7922 gfx::PointF(), | |
7923 gfx::Size(1, 2), | |
7924 true, | |
7925 false); | |
7926 SetLayerPropertiesForTesting(grand_child_raw, | |
7927 identity_matrix, | |
7928 gfx::Point3F(), | |
7929 gfx::PointF(), | |
7930 gfx::Size(1, 2), | |
7931 true, | |
7932 false); | 7813 false); |
7933 | 7814 |
7934 ExecuteCalculateDrawProperties(grand_parent.get()); | 7815 ExecuteCalculateDrawProperties(grand_parent.get()); |
7935 | 7816 |
7936 // No layers have animations. | 7817 // No layers have animations. |
7937 EXPECT_EQ(0.f, | 7818 EXPECT_EQ(0.f, |
7938 grand_parent->draw_properties().maximum_animation_contents_scale); | 7819 grand_parent->draw_properties().maximum_animation_contents_scale); |
7939 EXPECT_EQ(0.f, | 7820 EXPECT_EQ(0.f, |
7940 parent_raw->draw_properties().maximum_animation_contents_scale); | 7821 parent_raw->draw_properties().maximum_animation_contents_scale); |
7941 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7822 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8131 LayerImpl* parent_raw = parent.get(); | 8012 LayerImpl* parent_raw = parent.get(); |
8132 LayerImpl* child_raw = child.get(); | 8013 LayerImpl* child_raw = child.get(); |
8133 LayerImpl* grand_child1_raw = grand_child1.get(); | 8014 LayerImpl* grand_child1_raw = grand_child1.get(); |
8134 LayerImpl* grand_child2_raw = grand_child2.get(); | 8015 LayerImpl* grand_child2_raw = grand_child2.get(); |
8135 | 8016 |
8136 child->AddChild(grand_child1.Pass()); | 8017 child->AddChild(grand_child1.Pass()); |
8137 child->AddChild(grand_child2.Pass()); | 8018 child->AddChild(grand_child2.Pass()); |
8138 parent->AddChild(child.Pass()); | 8019 parent->AddChild(child.Pass()); |
8139 grand_parent->AddChild(parent.Pass()); | 8020 grand_parent->AddChild(parent.Pass()); |
8140 | 8021 |
8141 SetLayerPropertiesForTesting(grand_parent_raw, | 8022 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, |
8142 identity_matrix, | 8023 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
8143 gfx::Point3F(), | 8024 true, false, true); |
8144 gfx::PointF(), | 8025 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), |
8145 gfx::Size(1, 2), | 8026 gfx::PointF(), gfx::Size(1, 2), true, false, |
8146 true, | |
8147 false); | 8027 false); |
8148 SetLayerPropertiesForTesting(parent_raw, | 8028 |
8149 identity_matrix, | 8029 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), |
8150 gfx::Point3F(), | 8030 gfx::PointF(), gfx::Size(1, 2), true, false, |
8151 gfx::PointF(), | |
8152 gfx::Size(1, 2), | |
8153 true, | |
8154 false); | 8031 false); |
8155 SetLayerPropertiesForTesting(child_raw, | 8032 |
8156 identity_matrix, | 8033 SetLayerPropertiesForTesting(grand_child1_raw, identity_matrix, |
8157 gfx::Point3F(), | 8034 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
8158 gfx::PointF(), | 8035 true, false, false); |
8159 gfx::Size(1, 2), | 8036 |
8160 true, | 8037 SetLayerPropertiesForTesting(grand_child2_raw, identity_matrix, |
8161 false); | 8038 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
8162 SetLayerPropertiesForTesting(grand_child1_raw, | 8039 true, false, false); |
8163 identity_matrix, | |
8164 gfx::Point3F(), | |
8165 gfx::PointF(), | |
8166 gfx::Size(1, 2), | |
8167 true, | |
8168 false); | |
8169 SetLayerPropertiesForTesting(grand_child2_raw, | |
8170 identity_matrix, | |
8171 gfx::Point3F(), | |
8172 gfx::PointF(), | |
8173 gfx::Size(1, 2), | |
8174 true, | |
8175 false); | |
8176 | 8040 |
8177 // Start with nothing being drawn. | 8041 // Start with nothing being drawn. |
8178 ExecuteCalculateDrawProperties(grand_parent_raw); | 8042 ExecuteCalculateDrawProperties(grand_parent_raw); |
8179 int member_id = render_surface_layer_list_count(); | 8043 int member_id = render_surface_layer_list_count(); |
8180 | 8044 |
8181 EXPECT_NE(member_id, membership_id(grand_parent_raw)); | 8045 EXPECT_NE(member_id, membership_id(grand_parent_raw)); |
8182 EXPECT_NE(member_id, membership_id(parent_raw)); | 8046 EXPECT_NE(member_id, membership_id(parent_raw)); |
8183 EXPECT_NE(member_id, membership_id(child_raw)); | 8047 EXPECT_NE(member_id, membership_id(child_raw)); |
8184 EXPECT_NE(member_id, membership_id(grand_child1_raw)); | 8048 EXPECT_NE(member_id, membership_id(grand_child1_raw)); |
8185 EXPECT_NE(member_id, membership_id(grand_child2_raw)); | 8049 EXPECT_NE(member_id, membership_id(grand_child2_raw)); |
8186 | 8050 |
8187 std::set<LayerImpl*> expected; | 8051 std::set<LayerImpl*> expected; |
8188 std::set<LayerImpl*> actual; | 8052 std::set<LayerImpl*> actual; |
8189 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8053 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
8190 EXPECT_EQ(expected, actual); | 8054 EXPECT_EQ(expected, actual); |
8191 | 8055 |
8192 // If we force render surface, but none of the layers are in the layer list, | 8056 // If we force render surface, but none of the layers are in the layer list, |
8193 // then this layer should not appear in RSLL. | 8057 // then this layer should not appear in RSLL. |
8194 grand_child1_raw->SetForceRenderSurface(true); | 8058 grand_child1_raw->SetHasRenderSurface(true); |
8195 | 8059 |
8196 ExecuteCalculateDrawProperties(grand_parent_raw); | 8060 ExecuteCalculateDrawProperties(grand_parent_raw); |
8197 member_id = render_surface_layer_list_count(); | 8061 member_id = render_surface_layer_list_count(); |
8198 | 8062 |
8199 EXPECT_NE(member_id, membership_id(grand_parent_raw)); | 8063 EXPECT_NE(member_id, membership_id(grand_parent_raw)); |
8200 EXPECT_NE(member_id, membership_id(parent_raw)); | 8064 EXPECT_NE(member_id, membership_id(parent_raw)); |
8201 EXPECT_NE(member_id, membership_id(child_raw)); | 8065 EXPECT_NE(member_id, membership_id(child_raw)); |
8202 EXPECT_NE(member_id, membership_id(grand_child1_raw)); | 8066 EXPECT_NE(member_id, membership_id(grand_child1_raw)); |
8203 EXPECT_NE(member_id, membership_id(grand_child2_raw)); | 8067 EXPECT_NE(member_id, membership_id(grand_child2_raw)); |
8204 | 8068 |
(...skipping 18 matching lines...) Expand all Loading... |
8223 expected.clear(); | 8087 expected.clear(); |
8224 expected.insert(grand_child1_raw); | 8088 expected.insert(grand_child1_raw); |
8225 | 8089 |
8226 actual.clear(); | 8090 actual.clear(); |
8227 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8091 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
8228 EXPECT_EQ(expected, actual); | 8092 EXPECT_EQ(expected, actual); |
8229 | 8093 |
8230 // Now child is forced to have a render surface, and one if its children draws | 8094 // Now child is forced to have a render surface, and one if its children draws |
8231 // content. | 8095 // content. |
8232 grand_child1_raw->SetDrawsContent(false); | 8096 grand_child1_raw->SetDrawsContent(false); |
8233 grand_child1_raw->SetForceRenderSurface(false); | 8097 grand_child1_raw->SetHasRenderSurface(false); |
8234 child_raw->SetForceRenderSurface(true); | 8098 child_raw->SetHasRenderSurface(true); |
8235 grand_child2_raw->SetDrawsContent(true); | 8099 grand_child2_raw->SetDrawsContent(true); |
8236 | 8100 |
8237 ExecuteCalculateDrawProperties(grand_parent_raw); | 8101 ExecuteCalculateDrawProperties(grand_parent_raw); |
8238 member_id = render_surface_layer_list_count(); | 8102 member_id = render_surface_layer_list_count(); |
8239 | 8103 |
8240 EXPECT_NE(member_id, membership_id(grand_parent_raw)); | 8104 EXPECT_NE(member_id, membership_id(grand_parent_raw)); |
8241 EXPECT_NE(member_id, membership_id(parent_raw)); | 8105 EXPECT_NE(member_id, membership_id(parent_raw)); |
8242 EXPECT_NE(member_id, membership_id(child_raw)); | 8106 EXPECT_NE(member_id, membership_id(child_raw)); |
8243 EXPECT_NE(member_id, membership_id(grand_child1_raw)); | 8107 EXPECT_NE(member_id, membership_id(grand_child1_raw)); |
8244 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); | 8108 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8379 | 8243 |
8380 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 8244 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
8381 LayerImpl* root_layer = root.get(); | 8245 LayerImpl* root_layer = root.get(); |
8382 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); | 8246 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); |
8383 LayerImpl* child1_layer = child1.get(); | 8247 LayerImpl* child1_layer = child1.get(); |
8384 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); | 8248 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); |
8385 LayerImpl* child2_layer = child2.get(); | 8249 LayerImpl* child2_layer = child2.get(); |
8386 | 8250 |
8387 root->AddChild(child1.Pass()); | 8251 root->AddChild(child1.Pass()); |
8388 root->AddChild(child2.Pass()); | 8252 root->AddChild(child2.Pass()); |
| 8253 root->SetHasRenderSurface(true); |
8389 | 8254 |
8390 gfx::Transform identity_matrix, scale_transform_child1, | 8255 gfx::Transform identity_matrix, scale_transform_child1, |
8391 scale_transform_child2; | 8256 scale_transform_child2; |
8392 scale_transform_child1.Scale(2, 3); | 8257 scale_transform_child1.Scale(2, 3); |
8393 scale_transform_child2.Scale(4, 5); | 8258 scale_transform_child2.Scale(4, 5); |
8394 | 8259 |
8395 SetLayerPropertiesForTesting(root_layer, | 8260 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
8396 identity_matrix, | 8261 gfx::PointF(), gfx::Size(1, 1), true, false, |
8397 gfx::Point3F(), | 8262 true); |
8398 gfx::PointF(), | 8263 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
8399 gfx::Size(1, 1), | 8264 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, |
8400 true, | 8265 false, false); |
8401 false); | |
8402 SetLayerPropertiesForTesting(child1_layer, | |
8403 scale_transform_child1, | |
8404 gfx::Point3F(), | |
8405 gfx::PointF(), | |
8406 gfx::Size(), | |
8407 true, | |
8408 false); | |
8409 | 8266 |
8410 child1_layer->SetMaskLayer( | 8267 child1_layer->SetMaskLayer( |
8411 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); | 8268 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); |
8412 | 8269 |
8413 scoped_ptr<LayerImpl> replica_layer = | 8270 scoped_ptr<LayerImpl> replica_layer = |
8414 LayerImpl::Create(host_impl.active_tree(), 5); | 8271 LayerImpl::Create(host_impl.active_tree(), 5); |
| 8272 replica_layer->SetHasRenderSurface(true); |
8415 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | 8273 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); |
8416 child1_layer->SetReplicaLayer(replica_layer.Pass()); | 8274 child1_layer->SetReplicaLayer(replica_layer.Pass()); |
| 8275 child1_layer->SetHasRenderSurface(true); |
8417 | 8276 |
8418 ExecuteCalculateDrawProperties(root_layer); | 8277 ExecuteCalculateDrawProperties(root_layer); |
8419 | 8278 |
8420 TransformOperations scale; | 8279 TransformOperations scale; |
8421 scale.AppendScale(5.f, 8.f, 3.f); | 8280 scale.AppendScale(5.f, 8.f, 3.f); |
8422 | 8281 |
8423 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); | 8282 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); |
8424 SetLayerPropertiesForTesting(child2_layer, | 8283 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
8425 scale_transform_child2, | 8284 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, |
8426 gfx::Point3F(), | 8285 false, false); |
8427 gfx::PointF(), | |
8428 gfx::Size(), | |
8429 true, | |
8430 false); | |
8431 | 8286 |
8432 ExecuteCalculateDrawProperties(root_layer); | 8287 ExecuteCalculateDrawProperties(root_layer); |
8433 | 8288 |
8434 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | 8289 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); |
8435 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); | 8290 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); |
8436 EXPECT_FLOAT_EQ( | 8291 EXPECT_FLOAT_EQ( |
8437 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); | 8292 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); |
8438 EXPECT_FLOAT_EQ(3.f, | 8293 EXPECT_FLOAT_EQ(3.f, |
8439 child1_layer->replica_layer() | 8294 child1_layer->replica_layer() |
8440 ->mask_layer() | 8295 ->mask_layer() |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8681 host_impl.active_tree()->SetRootLayer( | 8536 host_impl.active_tree()->SetRootLayer( |
8682 LayerImpl::Create(host_impl.active_tree(), 1)); | 8537 LayerImpl::Create(host_impl.active_tree(), 1)); |
8683 | 8538 |
8684 LayerImpl* root = host_impl.active_tree()->root_layer(); | 8539 LayerImpl* root = host_impl.active_tree()->root_layer(); |
8685 SetLayerPropertiesForTesting(root, | 8540 SetLayerPropertiesForTesting(root, |
8686 identity_matrix, | 8541 identity_matrix, |
8687 gfx::Point3F(), | 8542 gfx::Point3F(), |
8688 gfx::PointF(), | 8543 gfx::PointF(), |
8689 root_size, | 8544 root_size, |
8690 false, | 8545 false, |
8691 false); | 8546 false, |
| 8547 true); |
8692 | 8548 |
8693 root->SetContentBounds(root_size); | 8549 root->SetContentBounds(root_size); |
8694 root->SetMasksToBounds(true); | 8550 root->SetMasksToBounds(true); |
8695 | 8551 |
8696 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); | 8552 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); |
8697 | 8553 |
8698 LayerImpl* sublayer = root->child_at(0); | 8554 LayerImpl* sublayer = root->child_at(0); |
8699 SetLayerPropertiesForTesting(sublayer, | 8555 SetLayerPropertiesForTesting(sublayer, |
8700 identity_matrix, | 8556 identity_matrix, |
8701 gfx::Point3F(), | 8557 gfx::Point3F(), |
8702 gfx::PointF(), | 8558 gfx::PointF(), |
8703 sublayer_size, | 8559 sublayer_size, |
8704 false, | 8560 false, |
| 8561 false, |
8705 false); | 8562 false); |
8706 | 8563 |
8707 sublayer->SetContentBounds(sublayer_size); | 8564 sublayer->SetContentBounds(sublayer_size); |
8708 sublayer->SetDrawsContent(true); | 8565 sublayer->SetDrawsContent(true); |
8709 | 8566 |
8710 LayerImplList layer_impl_list; | 8567 LayerImplList layer_impl_list; |
8711 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 8568 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
8712 root, device_viewport_size, &layer_impl_list); | 8569 root, device_viewport_size, &layer_impl_list); |
8713 | 8570 |
8714 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 8571 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
8715 | 8572 |
8716 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_content_rect()); | 8573 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_content_rect()); |
8717 | 8574 |
8718 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); | 8575 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); |
8719 | 8576 |
8720 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 8577 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
8721 | 8578 |
8722 gfx::Rect affected_by_delta(0, 0, root_size.width(), | 8579 gfx::Rect affected_by_delta(0, 0, root_size.width(), |
8723 root_size.height() + 50); | 8580 root_size.height() + 50); |
8724 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); | 8581 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); |
8725 } | 8582 } |
8726 | 8583 |
8727 } // namespace | 8584 } // namespace |
8728 } // namespace cc | 8585 } // namespace cc |
OLD | NEW |