| 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 "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/resources/layer_painter.h" | 10 #include "cc/resources/layer_painter.h" |
| 11 #include "cc/test/animation_test_common.h" | 11 #include "cc/test/animation_test_common.h" |
| 12 #include "cc/test/fake_impl_proxy.h" | 12 #include "cc/test/fake_impl_proxy.h" |
| 13 #include "cc/test/fake_layer_tree_host_client.h" | 13 #include "cc/test/fake_layer_tree_host_client.h" |
| 14 #include "cc/test/fake_layer_tree_host_impl.h" | 14 #include "cc/test/fake_layer_tree_host_impl.h" |
| 15 #include "cc/test/geometry_test_utils.h" | 15 #include "cc/test/geometry_test_utils.h" |
| 16 #include "cc/test/layer_test_common.h" | 16 #include "cc/test/layer_test_common.h" |
| 17 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 17 #include "cc/test/test_shared_bitmap_manager.h" | 18 #include "cc/test/test_shared_bitmap_manager.h" |
| 18 #include "cc/trees/layer_tree_host.h" | 19 #include "cc/trees/layer_tree_host.h" |
| 19 #include "cc/trees/single_thread_proxy.h" | 20 #include "cc/trees/single_thread_proxy.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 23 | 24 |
| 24 using ::testing::AnyNumber; | 25 using ::testing::AnyNumber; |
| 25 using ::testing::AtLeast; | 26 using ::testing::AtLeast; |
| 26 using ::testing::Mock; | 27 using ::testing::Mock; |
| 27 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
| 28 using ::testing::_; | 29 using ::testing::_; |
| 29 | 30 |
| 30 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ | 31 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ |
| 31 do { \ | 32 do { \ |
| 32 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ | 33 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ |
| 33 code_to_test; \ | 34 code_to_test; \ |
| 34 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 35 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
| 35 } while (false) | 36 } while (false) |
| 36 | 37 |
| 37 namespace cc { | 38 namespace cc { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 class MockLayerTreeHost : public LayerTreeHost { | 41 class MockLayerTreeHost : public LayerTreeHost { |
| 41 public: | 42 public: |
| 42 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 43 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) |
| 43 : LayerTreeHost(client, NULL, LayerTreeSettings()) { | 44 : LayerTreeHost(client, NULL, NULL, LayerTreeSettings()) { |
| 44 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 45 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
| 45 } | 46 } |
| 46 | 47 |
| 47 MOCK_METHOD0(SetNeedsCommit, void()); | 48 MOCK_METHOD0(SetNeedsCommit, void()); |
| 48 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 49 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
| 49 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | 50 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class MockLayerPainter : public LayerPainter { | 53 class MockLayerPainter : public LayerPainter { |
| 53 public: | 54 public: |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 EXPECT_FALSE(layer->transform_is_invertible()); | 920 EXPECT_FALSE(layer->transform_is_invertible()); |
| 920 EXPECT_FALSE(impl_layer->transform_is_invertible()); | 921 EXPECT_FALSE(impl_layer->transform_is_invertible()); |
| 921 | 922 |
| 922 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 923 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 923 } | 924 } |
| 924 | 925 |
| 925 class LayerTreeHostFactory { | 926 class LayerTreeHostFactory { |
| 926 public: | 927 public: |
| 927 LayerTreeHostFactory() | 928 LayerTreeHostFactory() |
| 928 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 929 : client_(FakeLayerTreeHostClient::DIRECT_3D), |
| 929 shared_bitmap_manager_(new TestSharedBitmapManager()) {} | 930 shared_bitmap_manager_(new TestSharedBitmapManager), |
| 931 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager) {} |
| 930 | 932 |
| 931 scoped_ptr<LayerTreeHost> Create() { | 933 scoped_ptr<LayerTreeHost> Create() { |
| 932 return LayerTreeHost::CreateSingleThreaded( | 934 return LayerTreeHost::CreateSingleThreaded( |
| 933 &client_, | 935 &client_, |
| 934 &client_, | 936 &client_, |
| 935 shared_bitmap_manager_.get(), | 937 shared_bitmap_manager_.get(), |
| 938 gpu_memory_buffer_manager_.get(), |
| 936 LayerTreeSettings(), | 939 LayerTreeSettings(), |
| 937 base::MessageLoopProxy::current()).Pass(); | 940 base::MessageLoopProxy::current()).Pass(); |
| 938 } | 941 } |
| 939 | 942 |
| 940 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 943 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
| 941 return LayerTreeHost::CreateSingleThreaded( | 944 return LayerTreeHost::CreateSingleThreaded( |
| 942 &client_, | 945 &client_, |
| 943 &client_, | 946 &client_, |
| 944 shared_bitmap_manager_.get(), | 947 shared_bitmap_manager_.get(), |
| 948 gpu_memory_buffer_manager_.get(), |
| 945 settings, | 949 settings, |
| 946 base::MessageLoopProxy::current()).Pass(); | 950 base::MessageLoopProxy::current()).Pass(); |
| 947 } | 951 } |
| 948 | 952 |
| 949 private: | 953 private: |
| 950 FakeLayerTreeHostClient client_; | 954 FakeLayerTreeHostClient client_; |
| 951 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 955 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 956 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 952 }; | 957 }; |
| 953 | 958 |
| 954 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { | 959 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { |
| 955 EXPECT_EQ(host, layer->layer_tree_host()); | 960 EXPECT_EQ(host, layer->layer_tree_host()); |
| 956 | 961 |
| 957 for (size_t i = 0; i < layer->children().size(); ++i) | 962 for (size_t i = 0; i < layer->children().size(); ++i) |
| 958 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 963 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
| 959 | 964 |
| 960 if (layer->mask_layer()) | 965 if (layer->mask_layer()) |
| 961 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); | 966 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 root_layer->AddChild(becomes_not_draws_content); | 1250 root_layer->AddChild(becomes_not_draws_content); |
| 1246 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1251 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
| 1247 | 1252 |
| 1248 becomes_draws_content->SetIsDrawable(true); | 1253 becomes_draws_content->SetIsDrawable(true); |
| 1249 root_layer->AddChild(becomes_draws_content); | 1254 root_layer->AddChild(becomes_draws_content); |
| 1250 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1255 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
| 1251 } | 1256 } |
| 1252 | 1257 |
| 1253 } // namespace | 1258 } // namespace |
| 1254 } // namespace cc | 1259 } // namespace cc |
| OLD | NEW |