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

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

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r248052. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_layerScopedPtr( 425 scoped_ptr<LayerImpl> scroll_layer_scoped_ptr(
426 LayerImpl::Create(host_impl.active_tree(), 2)); 426 LayerImpl::Create(host_impl.active_tree(), 2));
427 LayerImpl* scroll_layer = scroll_layerScopedPtr.get(); 427 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.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 scroll_layer->SetScrollable(true); 435
436 scroll_layer->SetMaxScrollOffset(kMaxScrollOffset); 436 scoped_ptr<LayerImpl> clip_layer_scoped_ptr(
437 scroll_layer->SetScrollOffset(kScrollOffset); 437 LayerImpl::Create(host_impl.active_tree(), 4));
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());
438 scroll_layer->SetScrollDelta(kScrollDelta); 445 scroll_layer->SetScrollDelta(kScrollDelta);
439 gfx::Transform impl_transform; 446 gfx::Transform impl_transform;
440 scroll_layer->AddChild(sublayer_scoped_ptr.Pass()); 447 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);
441 451
442 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); 452 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3));
443 SetLayerPropertiesForTesting(root.get(), 453 SetLayerPropertiesForTesting(root.get(),
444 identity_matrix, 454 identity_matrix,
445 identity_matrix, 455 identity_matrix,
446 gfx::PointF(), 456 gfx::PointF(),
447 gfx::PointF(), 457 gfx::PointF(),
448 gfx::Size(3, 4), 458 gfx::Size(3, 4),
449 false); 459 false);
450 root->AddChild(scroll_layerScopedPtr.Pass()); 460 root->AddChild(clip_layer_scoped_ptr.Pass());
451 461
452 ExecuteCalculateDrawProperties( 462 ExecuteCalculateDrawProperties(
453 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 463 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
454 gfx::Transform expected_transform = identity_matrix; 464 gfx::Transform expected_transform = identity_matrix;
455 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; 465 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
456 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); 466 sub_layer_screen_position.Scale(kPageScale * kDeviceScale);
457 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), 467 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()),
458 MathUtil::Round(sub_layer_screen_position.y())); 468 MathUtil::Round(sub_layer_screen_position.y()));
459 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 469 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
460 sublayer->draw_transform()); 470 sublayer->draw_transform());
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 1383 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
1374 grand_child->draw_transform()); 1384 grand_child->draw_transform());
1375 } 1385 }
1376 1386
1377 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1387 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1378 // Transformations applied at the root of the tree should be forwarded 1388 // Transformations applied at the root of the tree should be forwarded
1379 // to child layers instead of applied to the root RenderSurface. 1389 // to child layers instead of applied to the root RenderSurface.
1380 const gfx::Transform identity_matrix; 1390 const gfx::Transform identity_matrix;
1381 scoped_refptr<Layer> root = Layer::Create(); 1391 scoped_refptr<Layer> root = Layer::Create();
1382 scoped_refptr<Layer> child = Layer::Create(); 1392 scoped_refptr<Layer> child = Layer::Create();
1383 child->SetScrollable(true); 1393 child->SetScrollClipLayerId(root->id());
1384 root->AddChild(child); 1394 root->AddChild(child);
1385 1395
1386 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); 1396 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
1387 host->SetRootLayer(root); 1397 host->SetRootLayer(root);
1388 1398
1389 SetLayerPropertiesForTesting(root.get(), 1399 SetLayerPropertiesForTesting(root.get(),
1390 identity_matrix, 1400 identity_matrix,
1391 identity_matrix, 1401 identity_matrix,
1392 gfx::PointF(), 1402 gfx::PointF(),
1393 gfx::PointF(), 1403 gfx::PointF(),
(...skipping 7231 matching lines...) Expand 10 before | Expand all | Expand 10 after
8625 root->AddChild(clip_parent); 8635 root->AddChild(clip_parent);
8626 clip_parent->AddChild(render_surface1); 8636 clip_parent->AddChild(render_surface1);
8627 render_surface1->AddChild(intervening); 8637 render_surface1->AddChild(intervening);
8628 intervening->AddChild(render_surface2); 8638 intervening->AddChild(render_surface2);
8629 render_surface2->AddChild(clip_child); 8639 render_surface2->AddChild(clip_child);
8630 8640
8631 clip_child->SetClipParent(clip_parent.get()); 8641 clip_child->SetClipParent(clip_parent.get());
8632 8642
8633 intervening->SetMasksToBounds(true); 8643 intervening->SetMasksToBounds(true);
8634 clip_parent->SetMasksToBounds(true); 8644 clip_parent->SetMasksToBounds(true);
8635 intervening->SetScrollable(true); 8645 intervening->SetScrollClipLayerId(clip_parent->id());
8636 intervening->SetMaxScrollOffset(gfx::Vector2d(50, 50));
8637 intervening->SetScrollOffset(gfx::Vector2d(3, 3)); 8646 intervening->SetScrollOffset(gfx::Vector2d(3, 3));
8638 8647
8639 render_surface1->SetForceRenderSurface(true); 8648 render_surface1->SetForceRenderSurface(true);
8640 render_surface2->SetForceRenderSurface(true); 8649 render_surface2->SetForceRenderSurface(true);
8641 8650
8642 gfx::Transform translation_transform; 8651 gfx::Transform translation_transform;
8643 translation_transform.Translate(2, 2); 8652 translation_transform.Translate(2, 2);
8644 8653
8645 gfx::Transform identity_transform; 8654 gfx::Transform identity_transform;
8646 SetLayerPropertiesForTesting(root.get(), 8655 SetLayerPropertiesForTesting(root.get(),
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
9653 LayerImpl* scroll_layer = scroller.get(); 9662 LayerImpl* scroll_layer = scroller.get();
9654 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); 9663 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4);
9655 LayerImpl* fixed_layer = fixed.get(); 9664 LayerImpl* fixed_layer = fixed.get();
9656 9665
9657 container->SetIsContainerForFixedPositionLayers(true); 9666 container->SetIsContainerForFixedPositionLayers(true);
9658 9667
9659 LayerPositionConstraint constraint; 9668 LayerPositionConstraint constraint;
9660 constraint.set_is_fixed_position(true); 9669 constraint.set_is_fixed_position(true);
9661 fixed->SetPositionConstraint(constraint); 9670 fixed->SetPositionConstraint(constraint);
9662 9671
9663 scroller->SetScrollable(true); 9672 scroller->SetScrollClipLayer(container->id());
9664 9673
9665 gfx::Transform identity_transform; 9674 gfx::Transform identity_transform;
9666 gfx::Transform container_transform; 9675 gfx::Transform container_transform;
9667 container_transform.Translate3d(10.0, 20.0, 0.0); 9676 container_transform.Translate3d(10.0, 20.0, 0.0);
9668 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); 9677 gfx::Vector2dF container_offset = container_transform.To2dTranslation();
9669 9678
9670 SetLayerPropertiesForTesting(root.get(), 9679 SetLayerPropertiesForTesting(root.get(),
9671 identity_transform, 9680 identity_transform,
9672 identity_transform, 9681 identity_transform,
9673 gfx::PointF(), 9682 gfx::PointF(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
9740 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 9749 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
9741 container_offset); 9750 container_offset);
9742 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 9751 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
9743 .screen_space_transform.To2dTranslation(), 9752 .screen_space_transform.To2dTranslation(),
9744 container_offset - rounded_scroll_delta); 9753 container_offset - rounded_scroll_delta);
9745 } 9754 }
9746 } 9755 }
9747 9756
9748 } // namespace 9757 } // namespace
9749 } // namespace cc 9758 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698