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

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: Backup 2013.10.29 Created 7 years, 1 month 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
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 LayerImpl::Create(host_impl.active_tree(), 4));
438 LayerImpl* clip_layer = clip_layer_scoped_ptr.get();
439
440 scroll_layer->SetScrollable(clip_layer->id());
441 clip_layer->SetBounds(
442 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(),
443 scroll_layer->bounds().height() + kMaxScrollOffset.y()));
437 scroll_layer->SetScrollOffset(kScrollOffset); 444 scroll_layer->SetScrollOffset(kScrollOffset);
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 clip_layer->AddChild(scroll_layer_scoped_ptr.Pass());
441 449
442 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); 450 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3));
443 SetLayerPropertiesForTesting(root.get(), 451 SetLayerPropertiesForTesting(root.get(),
444 identity_matrix, 452 identity_matrix,
445 identity_matrix, 453 identity_matrix,
446 gfx::PointF(), 454 gfx::PointF(),
447 gfx::PointF(), 455 gfx::PointF(),
448 gfx::Size(3, 4), 456 gfx::Size(3, 4),
449 false); 457 false);
450 root->AddChild(scroll_layerScopedPtr.Pass()); 458 root->AddChild(clip_layer_scoped_ptr.Pass());
451 459
452 ExecuteCalculateDrawProperties( 460 ExecuteCalculateDrawProperties(
453 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); 461 root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
454 gfx::Transform expected_transform = identity_matrix; 462 gfx::Transform expected_transform = identity_matrix;
455 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; 463 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
456 sub_layer_screen_position.Scale(kPageScale * kDeviceScale); 464 sub_layer_screen_position.Scale(kPageScale * kDeviceScale);
457 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()), 465 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x()),
458 MathUtil::Round(sub_layer_screen_position.y())); 466 MathUtil::Round(sub_layer_screen_position.y()));
459 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 467 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
460 sublayer->draw_transform()); 468 sublayer->draw_transform());
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 1381 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
1374 grand_child->draw_transform()); 1382 grand_child->draw_transform());
1375 } 1383 }
1376 1384
1377 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1385 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1378 // Transformations applied at the root of the tree should be forwarded 1386 // Transformations applied at the root of the tree should be forwarded
1379 // to child layers instead of applied to the root RenderSurface. 1387 // to child layers instead of applied to the root RenderSurface.
1380 const gfx::Transform identity_matrix; 1388 const gfx::Transform identity_matrix;
1381 scoped_refptr<Layer> root = Layer::Create(); 1389 scoped_refptr<Layer> root = Layer::Create();
1382 scoped_refptr<Layer> child = Layer::Create(); 1390 scoped_refptr<Layer> child = Layer::Create();
1383 child->SetScrollable(true); 1391 child->SetScrollable(root.get());
1384 root->AddChild(child); 1392 root->AddChild(child);
1385 1393
1386 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); 1394 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
1387 host->SetRootLayer(root); 1395 host->SetRootLayer(root);
1388 1396
1389 SetLayerPropertiesForTesting(root.get(), 1397 SetLayerPropertiesForTesting(root.get(),
1390 identity_matrix, 1398 identity_matrix,
1391 identity_matrix, 1399 identity_matrix,
1392 gfx::PointF(), 1400 gfx::PointF(),
1393 gfx::PointF(), 1401 gfx::PointF(),
(...skipping 7132 matching lines...) Expand 10 before | Expand all | Expand 10 after
8526 // root (a render surface) 8534 // root (a render surface)
8527 // + clip_parent (masks to bounds) 8535 // + clip_parent (masks to bounds)
8528 // + render_surface1 (sets opacity) 8536 // + render_surface1 (sets opacity)
8529 // + intervening (masks to bounds AND scrolls) 8537 // + intervening (masks to bounds AND scrolls)
8530 // + render_surface2 (also sets opacity) 8538 // + render_surface2 (also sets opacity)
8531 // + clip_child 8539 // + clip_child
8532 // 8540 //
8533 scoped_refptr<Layer> root = Layer::Create(); 8541 scoped_refptr<Layer> root = Layer::Create();
8534 scoped_refptr<Layer> clip_parent = Layer::Create(); 8542 scoped_refptr<Layer> clip_parent = Layer::Create();
8535 scoped_refptr<Layer> render_surface1 = Layer::Create(); 8543 scoped_refptr<Layer> render_surface1 = Layer::Create();
8544 scoped_refptr<Layer> clip_intervening = Layer::Create();
8536 scoped_refptr<Layer> intervening = Layer::Create(); 8545 scoped_refptr<Layer> intervening = Layer::Create();
8537 scoped_refptr<Layer> render_surface2 = Layer::Create(); 8546 scoped_refptr<Layer> render_surface2 = Layer::Create();
8538 scoped_refptr<LayerWithForcedDrawsContent> clip_child = 8547 scoped_refptr<LayerWithForcedDrawsContent> clip_child =
8539 make_scoped_refptr(new LayerWithForcedDrawsContent); 8548 make_scoped_refptr(new LayerWithForcedDrawsContent);
8540 8549
8541 root->AddChild(clip_parent); 8550 root->AddChild(clip_parent);
8542 clip_parent->AddChild(render_surface1); 8551 clip_parent->AddChild(render_surface1);
8543 render_surface1->AddChild(intervening); 8552 render_surface1->AddChild(clip_intervening);
8553 clip_intervening->AddChild(intervening);
8544 intervening->AddChild(render_surface2); 8554 intervening->AddChild(render_surface2);
8545 render_surface2->AddChild(clip_child); 8555 render_surface2->AddChild(clip_child);
8546 8556
8547 clip_child->SetClipParent(clip_parent.get()); 8557 clip_child->SetClipParent(clip_parent.get());
8548 8558
8549 intervening->SetMasksToBounds(true); 8559 intervening->SetMasksToBounds(true);
8550 clip_parent->SetMasksToBounds(true); 8560 clip_parent->SetMasksToBounds(true);
8551 intervening->SetScrollable(true); 8561 intervening->SetScrollable(clip_intervening.get());
8552 intervening->SetMaxScrollOffset(gfx::Vector2d(50, 50)); 8562 clip_intervening->SetBounds(gfx::Size(5, 5));
8553 intervening->SetScrollOffset(gfx::Vector2d(3, 3)); 8563 intervening->SetScrollOffset(gfx::Vector2d(3, 3));
8554 8564
8555 render_surface1->SetForceRenderSurface(true); 8565 render_surface1->SetForceRenderSurface(true);
8556 render_surface2->SetForceRenderSurface(true); 8566 render_surface2->SetForceRenderSurface(true);
8557 8567
8558 gfx::Transform translation_transform; 8568 gfx::Transform translation_transform;
8559 translation_transform.Translate(2, 2); 8569 translation_transform.Translate(2, 2);
8560 8570
8561 gfx::Transform identity_transform; 8571 gfx::Transform identity_transform;
8562 SetLayerPropertiesForTesting(root.get(), 8572 SetLayerPropertiesForTesting(root.get(),
(...skipping 15 matching lines...) Expand all
8578 identity_transform, 8588 identity_transform,
8579 gfx::PointF(), 8589 gfx::PointF(),
8580 gfx::PointF(), 8590 gfx::PointF(),
8581 gfx::Size(10, 10), 8591 gfx::Size(10, 10),
8582 false); 8592 false);
8583 SetLayerPropertiesForTesting(intervening.get(), 8593 SetLayerPropertiesForTesting(intervening.get(),
8584 identity_transform, 8594 identity_transform,
8585 identity_transform, 8595 identity_transform,
8586 gfx::PointF(), 8596 gfx::PointF(),
8587 gfx::PointF(1.f, 1.f), 8597 gfx::PointF(1.f, 1.f),
8588 gfx::Size(5, 5), 8598 gfx::Size(55, 55),
8589 false); 8599 false);
8590 SetLayerPropertiesForTesting(render_surface2.get(), 8600 SetLayerPropertiesForTesting(render_surface2.get(),
8591 identity_transform, 8601 identity_transform,
8592 identity_transform, 8602 identity_transform,
8593 gfx::PointF(), 8603 gfx::PointF(),
8594 gfx::PointF(), 8604 gfx::PointF(),
8595 gfx::Size(10, 10), 8605 gfx::Size(10, 10),
8596 false); 8606 false);
8597 SetLayerPropertiesForTesting(clip_child.get(), 8607 SetLayerPropertiesForTesting(clip_child.get(),
8598 identity_transform, 8608 identity_transform,
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
9543 // due to layer sorting). 9553 // due to layer sorting).
9544 EXPECT_EQ(4u, root->render_surface()->layer_list().size()); 9554 EXPECT_EQ(4u, root->render_surface()->layer_list().size());
9545 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id()); 9555 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id());
9546 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id()); 9556 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id());
9547 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id()); 9557 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id());
9548 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id()); 9558 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id());
9549 } 9559 }
9550 9560
9551 } // namespace 9561 } // namespace
9552 } // namespace cc 9562 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698