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, nullptr, LayerTreeSettings()) { | 44 : LayerTreeHost(client, nullptr, nullptr, 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 EXPECT_FALSE(layer->transform_is_invertible()); | 919 EXPECT_FALSE(layer->transform_is_invertible()); |
919 EXPECT_FALSE(impl_layer->transform_is_invertible()); | 920 EXPECT_FALSE(impl_layer->transform_is_invertible()); |
920 | 921 |
921 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 922 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
922 } | 923 } |
923 | 924 |
924 class LayerTreeHostFactory { | 925 class LayerTreeHostFactory { |
925 public: | 926 public: |
926 LayerTreeHostFactory() | 927 LayerTreeHostFactory() |
927 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 928 : client_(FakeLayerTreeHostClient::DIRECT_3D), |
928 shared_bitmap_manager_(new TestSharedBitmapManager()) {} | 929 shared_bitmap_manager_(new TestSharedBitmapManager), |
| 930 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager) {} |
929 | 931 |
930 scoped_ptr<LayerTreeHost> Create() { | 932 scoped_ptr<LayerTreeHost> Create() { |
931 return LayerTreeHost::CreateSingleThreaded( | 933 return LayerTreeHost::CreateSingleThreaded( |
932 &client_, | 934 &client_, |
933 &client_, | 935 &client_, |
934 shared_bitmap_manager_.get(), | 936 shared_bitmap_manager_.get(), |
| 937 gpu_memory_buffer_manager_.get(), |
935 LayerTreeSettings(), | 938 LayerTreeSettings(), |
936 base::MessageLoopProxy::current()).Pass(); | 939 base::MessageLoopProxy::current()).Pass(); |
937 } | 940 } |
938 | 941 |
939 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 942 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
940 return LayerTreeHost::CreateSingleThreaded( | 943 return LayerTreeHost::CreateSingleThreaded( |
941 &client_, | 944 &client_, |
942 &client_, | 945 &client_, |
943 shared_bitmap_manager_.get(), | 946 shared_bitmap_manager_.get(), |
| 947 gpu_memory_buffer_manager_.get(), |
944 settings, | 948 settings, |
945 base::MessageLoopProxy::current()).Pass(); | 949 base::MessageLoopProxy::current()).Pass(); |
946 } | 950 } |
947 | 951 |
948 private: | 952 private: |
949 FakeLayerTreeHostClient client_; | 953 FakeLayerTreeHostClient client_; |
950 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 954 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 955 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
951 }; | 956 }; |
952 | 957 |
953 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { | 958 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { |
954 EXPECT_EQ(host, layer->layer_tree_host()); | 959 EXPECT_EQ(host, layer->layer_tree_host()); |
955 | 960 |
956 for (size_t i = 0; i < layer->children().size(); ++i) | 961 for (size_t i = 0; i < layer->children().size(); ++i) |
957 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 962 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
958 | 963 |
959 if (layer->mask_layer()) | 964 if (layer->mask_layer()) |
960 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); | 965 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 root_layer->AddChild(becomes_not_draws_content); | 1249 root_layer->AddChild(becomes_not_draws_content); |
1245 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1250 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1246 | 1251 |
1247 becomes_draws_content->SetIsDrawable(true); | 1252 becomes_draws_content->SetIsDrawable(true); |
1248 root_layer->AddChild(becomes_draws_content); | 1253 root_layer->AddChild(becomes_draws_content); |
1249 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1254 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
1250 } | 1255 } |
1251 | 1256 |
1252 } // namespace | 1257 } // namespace |
1253 } // namespace cc | 1258 } // namespace cc |
OLD | NEW |