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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 MainThreadScrollingReason::kNonFastScrollableRegion)); | 922 MainThreadScrollingReason::kNonFastScrollableRegion)); |
923 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNonFastScrollableRegion( | 923 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNonFastScrollableRegion( |
924 Region(gfx::Rect(1, 1, 2, 2)))); | 924 Region(gfx::Rect(1, 1, 2, 2)))); |
925 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform( | 925 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform( |
926 gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))); | 926 gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))); |
927 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDoubleSided(false)); | 927 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDoubleSided(false)); |
928 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTouchEventHandlerRegion( | 928 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTouchEventHandlerRegion( |
929 gfx::Rect(10, 10))); | 929 gfx::Rect(10, 10))); |
930 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetForceRenderSurfaceForTesting(true)); | 930 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetForceRenderSurfaceForTesting(true)); |
931 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetHideLayerAndSubtree(true)); | 931 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetHideLayerAndSubtree(true)); |
932 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetElementId(ElementId(2, 0))); | 932 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetElementId(ElementId(2))); |
933 EXPECT_SET_NEEDS_COMMIT( | 933 EXPECT_SET_NEEDS_COMMIT( |
934 1, test_layer->SetMutableProperties(MutableProperty::kTransform)); | 934 1, test_layer->SetMutableProperties(MutableProperty::kTransform)); |
935 | 935 |
936 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( | 936 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( |
937 dummy_layer1.get())); | 937 dummy_layer1.get())); |
938 | 938 |
939 // The above tests should not have caused a change to the needs_display flag. | 939 // The above tests should not have caused a change to the needs_display flag. |
940 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 940 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
941 | 941 |
942 // As layers are removed from the tree, they will cause a tree sync. | 942 // As layers are removed from the tree, they will cause a tree sync. |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 EXPECT_EQ(1, did_receive_result_from_different_source); | 1378 EXPECT_EQ(1, did_receive_result_from_different_source); |
1379 EXPECT_EQ(1, did_receive_result_from_anonymous_source); | 1379 EXPECT_EQ(1, did_receive_result_from_anonymous_source); |
1380 EXPECT_EQ(1, did_receive_second_result_from_this_source); | 1380 EXPECT_EQ(1, did_receive_second_result_from_this_source); |
1381 } | 1381 } |
1382 | 1382 |
1383 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { | 1383 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { |
1384 // TODO(weiliangc): This is really a LayerTreeHost unittest by this point, | 1384 // TODO(weiliangc): This is really a LayerTreeHost unittest by this point, |
1385 // though currently there is no good place for this unittest to go. Move to | 1385 // though currently there is no good place for this unittest to go. Move to |
1386 // LayerTreeHost unittest when there is a good setup. | 1386 // LayerTreeHost unittest when there is a good setup. |
1387 scoped_refptr<Layer> layer = Layer::Create(); | 1387 scoped_refptr<Layer> layer = Layer::Create(); |
1388 layer->SetElementId(ElementId(2, 0)); | 1388 layer->SetElementId(ElementId(2)); |
1389 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); | 1389 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); |
1390 auto element_id = layer->element_id(); | 1390 auto element_id = layer->element_id(); |
1391 | 1391 |
1392 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 1392 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
1393 layer_tree_host_->SetElementOpacityMutated(element_id, | 1393 layer_tree_host_->SetElementOpacityMutated(element_id, |
1394 ElementListType::ACTIVE, 0.5f); | 1394 ElementListType::ACTIVE, 0.5f); |
1395 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1395 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
1396 | 1396 |
1397 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 1397 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
1398 gfx::Transform transform; | 1398 gfx::Transform transform; |
(...skipping 13 matching lines...) Expand all Loading... |
1412 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { | 1412 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { |
1413 scoped_refptr<Layer> test_layer = Layer::Create(); | 1413 scoped_refptr<Layer> test_layer = Layer::Create(); |
1414 std::unique_ptr<LayerImpl> impl_layer = | 1414 std::unique_ptr<LayerImpl> impl_layer = |
1415 LayerImpl::Create(host_impl_.active_tree(), 1); | 1415 LayerImpl::Create(host_impl_.active_tree(), 1); |
1416 | 1416 |
1417 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1417 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
1418 layer_tree_host_->SetRootLayer(test_layer)); | 1418 layer_tree_host_->SetRootLayer(test_layer)); |
1419 | 1419 |
1420 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); | 1420 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); |
1421 | 1421 |
1422 test_layer->SetElementId(ElementId(2, 0)); | 1422 test_layer->SetElementId(ElementId(2)); |
1423 test_layer->SetMutableProperties(MutableProperty::kTransform); | 1423 test_layer->SetMutableProperties(MutableProperty::kTransform); |
1424 | 1424 |
1425 EXPECT_FALSE(impl_layer->element_id()); | 1425 EXPECT_FALSE(impl_layer->element_id()); |
1426 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 1426 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
1427 | 1427 |
1428 test_layer->PushPropertiesTo(impl_layer.get()); | 1428 test_layer->PushPropertiesTo(impl_layer.get()); |
1429 | 1429 |
1430 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 1430 EXPECT_EQ(ElementId(2), impl_layer->element_id()); |
1431 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 1431 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
1432 } | 1432 } |
1433 | 1433 |
1434 } // namespace | 1434 } // namespace |
1435 } // namespace cc | 1435 } // namespace cc |
OLD | NEW |