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 <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 sublayer->SetContentsScale(kPageScale * kDeviceScale, | 415 sublayer->SetContentsScale(kPageScale * kDeviceScale, |
416 kPageScale * kDeviceScale); | 416 kPageScale * kDeviceScale); |
417 SetLayerPropertiesForTesting(sublayer, | 417 SetLayerPropertiesForTesting(sublayer, |
418 identity_matrix, | 418 identity_matrix, |
419 identity_matrix, | 419 identity_matrix, |
420 gfx::Point(), | 420 gfx::Point(), |
421 gfx::PointF(), | 421 gfx::PointF(), |
422 gfx::Size(500, 500), | 422 gfx::Size(500, 500), |
423 false); | 423 false); |
424 | 424 |
425 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr( | 425 scoped_ptr<LayerImpl> scroll_layerScopedPtr( |
426 LayerImpl::Create(host_impl.active_tree(), 2)); | 426 LayerImpl::Create(host_impl.active_tree(), 2)); |
427 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); | 427 LayerImpl* scroll_layer = scroll_layerScopedPtr.get(); |
428 SetLayerPropertiesForTesting(scroll_layer, | 428 SetLayerPropertiesForTesting(scroll_layer, |
429 identity_matrix, | 429 identity_matrix, |
430 identity_matrix, | 430 identity_matrix, |
431 gfx::PointF(), | 431 gfx::PointF(), |
432 gfx::PointF(), | 432 gfx::PointF(), |
433 gfx::Size(10, 20), | 433 gfx::Size(10, 20), |
434 false); | 434 false); |
435 | 435 scroll_layer->SetScrollable(true); |
436 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( | 436 scroll_layer->SetMaxScrollOffset(kMaxScrollOffset); |
437 LayerImpl::Create(host_impl.active_tree(), 4)); | 437 scroll_layer->SetScrollOffset(kScrollOffset); |
438 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); | |
439 | |
440 scroll_layer->SetScrollClipLayer(clip_layer->id()); | |
441 clip_layer->SetBounds( | |
442 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), | |
443 scroll_layer->bounds().height() + kMaxScrollOffset.y())); | |
444 scroll_layer->SetScrollClipLayer(clip_layer->id()); | |
445 scroll_layer->SetScrollDelta(kScrollDelta); | 438 scroll_layer->SetScrollDelta(kScrollDelta); |
446 gfx::Transform impl_transform; | 439 gfx::Transform impl_transform; |
447 scroll_layer->AddChild(sublayer_scoped_ptr.Pass()); | 440 scroll_layer->AddChild(sublayer_scoped_ptr.Pass()); |
448 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); | |
449 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass()); | |
450 scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset); | |
451 | 441 |
452 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); | 442 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); |
453 SetLayerPropertiesForTesting(root.get(), | 443 SetLayerPropertiesForTesting(root.get(), |
454 identity_matrix, | 444 identity_matrix, |
455 identity_matrix, | 445 identity_matrix, |
456 gfx::PointF(), | 446 gfx::PointF(), |
457 gfx::PointF(), | 447 gfx::PointF(), |
458 gfx::Size(3, 4), | 448 gfx::Size(3, 4), |
459 false); | 449 false); |
460 root->AddChild(clip_layer_scoped_ptr.Pass()); | 450 root->AddChild(scroll_layerScopedPtr.Pass()); |
461 | 451 |
462 ExecuteCalculateDrawProperties( | 452 ExecuteCalculateDrawProperties( |
463 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); | 453 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); |
464 gfx::Transform expected_transform = identity_matrix; | 454 gfx::Transform expected_transform = identity_matrix; |
465 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; | 455 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; |
466 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); | 456 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); |
467 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), | 457 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), |
468 MathUtil::Round(sub_layer_screen_position.y())); | 458 MathUtil::Round(sub_layer_screen_position.y())); |
469 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 459 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
470 sublayer->draw_transform()); | 460 sublayer->draw_transform()); |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1373 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
1384 grand_child->draw_transform()); | 1374 grand_child->draw_transform()); |
1385 } | 1375 } |
1386 | 1376 |
1387 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { | 1377 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { |
1388 // Transformations applied at the root of the tree should be forwarded | 1378 // Transformations applied at the root of the tree should be forwarded |
1389 // to child layers instead of applied to the root RenderSurface. | 1379 // to child layers instead of applied to the root RenderSurface. |
1390 const gfx::Transform identity_matrix; | 1380 const gfx::Transform identity_matrix; |
1391 scoped_refptr<Layer> root = Layer::Create(); | 1381 scoped_refptr<Layer> root = Layer::Create(); |
1392 scoped_refptr<Layer> child = Layer::Create(); | 1382 scoped_refptr<Layer> child = Layer::Create(); |
1393 child->SetScrollClipLayer(root.get()); | 1383 child->SetScrollable(true); |
1394 root->AddChild(child); | 1384 root->AddChild(child); |
1395 | 1385 |
1396 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 1386 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
1397 host->SetRootLayer(root); | 1387 host->SetRootLayer(root); |
1398 | 1388 |
1399 SetLayerPropertiesForTesting(root.get(), | 1389 SetLayerPropertiesForTesting(root.get(), |
1400 identity_matrix, | 1390 identity_matrix, |
1401 identity_matrix, | 1391 identity_matrix, |
1402 gfx::PointF(), | 1392 gfx::PointF(), |
1403 gfx::PointF(), | 1393 gfx::PointF(), |
(...skipping 7231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8635 root->AddChild(clip_parent); | 8625 root->AddChild(clip_parent); |
8636 clip_parent->AddChild(render_surface1); | 8626 clip_parent->AddChild(render_surface1); |
8637 render_surface1->AddChild(intervening); | 8627 render_surface1->AddChild(intervening); |
8638 intervening->AddChild(render_surface2); | 8628 intervening->AddChild(render_surface2); |
8639 render_surface2->AddChild(clip_child); | 8629 render_surface2->AddChild(clip_child); |
8640 | 8630 |
8641 clip_child->SetClipParent(clip_parent.get()); | 8631 clip_child->SetClipParent(clip_parent.get()); |
8642 | 8632 |
8643 intervening->SetMasksToBounds(true); | 8633 intervening->SetMasksToBounds(true); |
8644 clip_parent->SetMasksToBounds(true); | 8634 clip_parent->SetMasksToBounds(true); |
8645 intervening->SetScrollClipLayer(clip_parent.get()); | 8635 intervening->SetScrollable(true); |
| 8636 intervening->SetMaxScrollOffset(gfx::Vector2d(50, 50)); |
8646 intervening->SetScrollOffset(gfx::Vector2d(3, 3)); | 8637 intervening->SetScrollOffset(gfx::Vector2d(3, 3)); |
8647 | 8638 |
8648 render_surface1->SetForceRenderSurface(true); | 8639 render_surface1->SetForceRenderSurface(true); |
8649 render_surface2->SetForceRenderSurface(true); | 8640 render_surface2->SetForceRenderSurface(true); |
8650 | 8641 |
8651 gfx::Transform translation_transform; | 8642 gfx::Transform translation_transform; |
8652 translation_transform.Translate(2, 2); | 8643 translation_transform.Translate(2, 2); |
8653 | 8644 |
8654 gfx::Transform identity_transform; | 8645 gfx::Transform identity_transform; |
8655 SetLayerPropertiesForTesting(root.get(), | 8646 SetLayerPropertiesForTesting(root.get(), |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9662 LayerImpl* scroll_layer = scroller.get(); | 9653 LayerImpl* scroll_layer = scroller.get(); |
9663 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); | 9654 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); |
9664 LayerImpl* fixed_layer = fixed.get(); | 9655 LayerImpl* fixed_layer = fixed.get(); |
9665 | 9656 |
9666 container->SetIsContainerForFixedPositionLayers(true); | 9657 container->SetIsContainerForFixedPositionLayers(true); |
9667 | 9658 |
9668 LayerPositionConstraint constraint; | 9659 LayerPositionConstraint constraint; |
9669 constraint.set_is_fixed_position(true); | 9660 constraint.set_is_fixed_position(true); |
9670 fixed->SetPositionConstraint(constraint); | 9661 fixed->SetPositionConstraint(constraint); |
9671 | 9662 |
9672 scroller->SetScrollClipLayer(container->id()); | 9663 scroller->SetScrollable(true); |
9673 | 9664 |
9674 gfx::Transform identity_transform; | 9665 gfx::Transform identity_transform; |
9675 gfx::Transform container_transform; | 9666 gfx::Transform container_transform; |
9676 container_transform.Translate3d(10.0, 20.0, 0.0); | 9667 container_transform.Translate3d(10.0, 20.0, 0.0); |
9677 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 9668 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
9678 | 9669 |
9679 SetLayerPropertiesForTesting(root.get(), | 9670 SetLayerPropertiesForTesting(root.get(), |
9680 identity_transform, | 9671 identity_transform, |
9681 identity_transform, | 9672 identity_transform, |
9682 gfx::PointF(), | 9673 gfx::PointF(), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9749 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 9740 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
9750 container_offset); | 9741 container_offset); |
9751 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 9742 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
9752 .screen_space_transform.To2dTranslation(), | 9743 .screen_space_transform.To2dTranslation(), |
9753 container_offset - rounded_scroll_delta); | 9744 container_offset - rounded_scroll_delta); |
9754 } | 9745 } |
9755 } | 9746 } |
9756 | 9747 |
9757 } // namespace | 9748 } // namespace |
9758 } // namespace cc | 9749 } // namespace cc |
OLD | NEW |