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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 1715973002: cc: Move tracking of layer_property_changed to main thread (3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove LayerImpl::stacking_order_changed Created 4 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
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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 node = layer_tree_host_->property_trees()->transform_tree.Node( 1039 node = layer_tree_host_->property_trees()->transform_tree.Node(
1040 child->transform_tree_index()); 1040 child->transform_tree_index());
1041 EXPECT_FALSE(node->data.transform_changed); 1041 EXPECT_FALSE(node->data.transform_changed);
1042 1042
1043 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); 1043 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
1044 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 1044 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1045 root->SetTransformOrigin(arbitrary_point_3f); 1045 root->SetTransformOrigin(arbitrary_point_3f);
1046 node = layer_tree_host_->property_trees()->transform_tree.Node( 1046 node = layer_tree_host_->property_trees()->transform_tree.Node(
1047 root->transform_tree_index()); 1047 root->transform_tree_index());
1048 EXPECT_TRUE(node->data.transform_changed); 1048 EXPECT_TRUE(node->data.transform_changed);
1049 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1050 root->PushPropertiesTo(root_impl.get());
1051 child->PushPropertiesTo(child_impl.get());
1052 child2->PushPropertiesTo(child2_impl.get());
1053 grand_child->PushPropertiesTo(grand_child_impl.get());
1054 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking());
1055
1056 gfx::Transform arbitrary_transform;
1057 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
1058 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1059 root->SetTransform(arbitrary_transform);
1060 node = layer_tree_host_->property_trees()->transform_tree.Node(
1061 root->transform_tree_index());
1062 EXPECT_TRUE(node->data.transform_changed);
1049 } 1063 }
1050 1064
1051 TEST_F(LayerTest, AddAndRemoveChild) { 1065 TEST_F(LayerTest, AddAndRemoveChild) {
1052 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); 1066 scoped_refptr<Layer> parent = Layer::Create(layer_settings_);
1053 scoped_refptr<Layer> child = Layer::Create(layer_settings_); 1067 scoped_refptr<Layer> child = Layer::Create(layer_settings_);
1054 1068
1055 // Upon creation, layers should not have children or parent. 1069 // Upon creation, layers should not have children or parent.
1056 ASSERT_EQ(0U, parent->children().size()); 1070 ASSERT_EQ(0U, parent->children().size());
1057 EXPECT_FALSE(child->parent()); 1071 EXPECT_FALSE(child->parent());
1058 1072
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); 1605 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f));
1592 1606
1593 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); 1607 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1594 1608
1595 test_layer->PushPropertiesTo(impl_layer.get()); 1609 test_layer->PushPropertiesTo(impl_layer.get());
1596 1610
1597 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); 1611 EXPECT_TRUE(impl_layer->LayerPropertyChanged());
1598 } 1612 }
1599 1613
1600 TEST_F(LayerTest, 1614 TEST_F(LayerTest,
1601 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyTransformAnim) {
1602 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
1603 scoped_ptr<LayerImpl> impl_layer =
1604 LayerImpl::Create(host_impl_.active_tree(), 1);
1605
1606 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1607 layer_tree_host_->SetRootLayer(test_layer));
1608
1609 scoped_ptr<AnimationRegistrar> registrar;
1610 if (settings().use_compositor_animation_timelines) {
1611 AddAnimatedTransformToLayerWithPlayer(impl_layer->id(), timeline_impl(),
1612 1.0, 0, 100);
1613 } else {
1614 registrar = AnimationRegistrar::Create();
1615 impl_layer->layer_animation_controller()->SetAnimationRegistrar(
1616 registrar.get());
1617
1618 AddAnimatedTransformToController(impl_layer->layer_animation_controller(),
1619 1.0, 0, 100);
1620 }
1621
1622 gfx::Transform transform;
1623 transform.Rotate(45.0);
1624 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform));
1625
1626 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1627 test_layer->PushPropertiesTo(impl_layer.get());
1628 EXPECT_TRUE(impl_layer->LayerPropertyChanged());
1629
1630 impl_layer->ResetAllChangeTrackingForSubtree();
1631 if (settings().use_compositor_animation_timelines) {
1632 int animation_id = AddAnimatedTransformToLayerWithPlayer(
1633 impl_layer->id(), timeline_impl(), 1.0, 0, 100);
1634 GetAnimationFromLayerWithExistingPlayer(impl_layer->id(), timeline_impl(),
1635 animation_id)
1636 ->set_is_impl_only(true);
1637 } else {
1638 AddAnimatedTransformToController(impl_layer->layer_animation_controller(),
1639 1.0, 0, 100);
1640 impl_layer->layer_animation_controller()
1641 ->GetAnimation(Animation::TRANSFORM)
1642 ->set_is_impl_only(true);
1643 }
1644 transform.Rotate(45.0);
1645 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform));
1646
1647 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1648 test_layer->PushPropertiesTo(impl_layer.get());
1649 EXPECT_FALSE(impl_layer->LayerPropertyChanged());
1650 }
1651
1652 TEST_F(LayerTest,
1653 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyOpacityAnim) { 1615 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyOpacityAnim) {
1654 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); 1616 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
1655 scoped_ptr<LayerImpl> impl_layer = 1617 scoped_ptr<LayerImpl> impl_layer =
1656 LayerImpl::Create(host_impl_.active_tree(), 1); 1618 LayerImpl::Create(host_impl_.active_tree(), 1);
1657 1619
1658 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, 1620 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1659 layer_tree_host_->SetRootLayer(test_layer)); 1621 layer_tree_host_->SetRootLayer(test_layer));
1660 1622
1661 scoped_ptr<AnimationRegistrar> registrar; 1623 scoped_ptr<AnimationRegistrar> registrar;
1662 if (settings().use_compositor_animation_timelines) { 1624 if (settings().use_compositor_animation_timelines) {
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 scoped_refptr<Layer> layer_src_b_replica = Layer::Create(LayerSettings()); 2500 scoped_refptr<Layer> layer_src_b_replica = Layer::Create(LayerSettings());
2539 scoped_refptr<Layer> layer_src_c = Layer::Create(LayerSettings()); 2501 scoped_refptr<Layer> layer_src_c = Layer::Create(LayerSettings());
2540 scoped_refptr<Layer> layer_src_d = Layer::Create(LayerSettings()); 2502 scoped_refptr<Layer> layer_src_d = Layer::Create(LayerSettings());
2541 layer_src_root->AddChild(layer_src_a); 2503 layer_src_root->AddChild(layer_src_a);
2542 layer_src_root->AddChild(layer_src_b); 2504 layer_src_root->AddChild(layer_src_b);
2543 layer_src_a->AddChild(layer_src_c); 2505 layer_src_a->AddChild(layer_src_c);
2544 layer_src_b->AddChild(layer_src_d); 2506 layer_src_b->AddChild(layer_src_d);
2545 layer_src_b->SetMaskLayer(layer_src_b_mask.get()); 2507 layer_src_b->SetMaskLayer(layer_src_b_mask.get());
2546 layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); 2508 layer_src_b->SetReplicaLayer(layer_src_b_replica.get());
2547 2509
2510 proto::LayerUpdate layer_update_root;
2511 // Only layers with descendants that require pushing properties will
2512 // return true from ToLayerPropertiesProto and AddChild will change the
2513 // stacking order of child which will make it push properties.
2514 EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root));
2515 proto::LayerUpdate layer_update_a;
2516 EXPECT_TRUE(layer_src_a->ToLayerPropertiesProto(&layer_update_a));
2517 proto::LayerUpdate layer_update_b;
2518 EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b));
2519 proto::LayerUpdate layer_update_c;
2520 EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c));
2521 proto::LayerUpdate layer_update_d;
2522 EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d));
2523 layer_update_root.Clear();
2524 layer_update_a.Clear();
2525 layer_update_b.Clear();
2526 layer_update_c.Clear();
2527 layer_update_d.Clear();
2528
2548 layer_src_a->SetNeedsPushProperties(); 2529 layer_src_a->SetNeedsPushProperties();
2549 layer_src_b->SetNeedsPushProperties(); 2530 layer_src_b->SetNeedsPushProperties();
2550 layer_src_b_mask->SetNeedsPushProperties(); 2531 layer_src_b_mask->SetNeedsPushProperties();
2551 layer_src_d->SetNeedsPushProperties(); 2532 layer_src_d->SetNeedsPushProperties();
2552 2533
2553 // Only layers with descendants that require pushing properties will 2534 // Only layers with descendants that require pushing properties will
2554 // return true from ToLayerPropertiesProto. 2535 // return true from ToLayerPropertiesProto.
2555 proto::LayerUpdate layer_update_root;
2556 EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root)); 2536 EXPECT_TRUE(layer_src_root->ToLayerPropertiesProto(&layer_update_root));
2557 proto::LayerUpdate layer_update_a;
2558 EXPECT_FALSE(layer_src_a->ToLayerPropertiesProto(&layer_update_a)); 2537 EXPECT_FALSE(layer_src_a->ToLayerPropertiesProto(&layer_update_a));
2559 proto::LayerUpdate layer_update_b;
2560 EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b)); 2538 EXPECT_TRUE(layer_src_b->ToLayerPropertiesProto(&layer_update_b));
2561 proto::LayerUpdate layer_update_b_mask; 2539 proto::LayerUpdate layer_update_b_mask;
2562 EXPECT_FALSE(layer_src_b_mask->ToLayerPropertiesProto(&layer_update_b_mask)); 2540 EXPECT_FALSE(layer_src_b_mask->ToLayerPropertiesProto(&layer_update_b_mask));
2563 proto::LayerUpdate layer_update_b_replica; 2541 proto::LayerUpdate layer_update_b_replica;
2564 EXPECT_FALSE( 2542 EXPECT_FALSE(
2565 layer_src_b_replica->ToLayerPropertiesProto(&layer_update_b_replica)); 2543 layer_src_b_replica->ToLayerPropertiesProto(&layer_update_b_replica));
2566 proto::LayerUpdate layer_update_c;
2567 EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c)); 2544 EXPECT_FALSE(layer_src_c->ToLayerPropertiesProto(&layer_update_c));
2568 proto::LayerUpdate layer_update_d;
2569 EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d)); 2545 EXPECT_FALSE(layer_src_d->ToLayerPropertiesProto(&layer_update_d));
2570 2546
2571 // All flags for pushing properties should have been cleared. 2547 // All flags for pushing properties should have been cleared.
2572 EXPECT_FALSE(layer_src_root->needs_push_properties()); 2548 EXPECT_FALSE(layer_src_root->needs_push_properties());
2573 EXPECT_FALSE(layer_src_root->descendant_needs_push_properties()); 2549 EXPECT_FALSE(layer_src_root->descendant_needs_push_properties());
2574 EXPECT_FALSE(layer_src_a->needs_push_properties()); 2550 EXPECT_FALSE(layer_src_a->needs_push_properties());
2575 EXPECT_FALSE(layer_src_a->descendant_needs_push_properties()); 2551 EXPECT_FALSE(layer_src_a->descendant_needs_push_properties());
2576 EXPECT_FALSE(layer_src_b->needs_push_properties()); 2552 EXPECT_FALSE(layer_src_b->needs_push_properties());
2577 EXPECT_FALSE(layer_src_b->descendant_needs_push_properties()); 2553 EXPECT_FALSE(layer_src_b->descendant_needs_push_properties());
2578 EXPECT_FALSE(layer_src_b_mask->needs_push_properties()); 2554 EXPECT_FALSE(layer_src_b_mask->needs_push_properties());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2667 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2692 2668
2693 test_layer->PushPropertiesTo(impl_layer.get()); 2669 test_layer->PushPropertiesTo(impl_layer.get());
2694 2670
2695 EXPECT_EQ(2lu, impl_layer->element_id()); 2671 EXPECT_EQ(2lu, impl_layer->element_id());
2696 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2672 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2697 } 2673 }
2698 2674
2699 } // namespace 2675 } // namespace
2700 } // namespace cc 2676 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698