OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 namespace { | 47 namespace { |
48 | 48 |
49 gpu::Mailbox MailboxFromChar(char value) { | 49 gpu::Mailbox MailboxFromChar(char value) { |
50 gpu::Mailbox mailbox; | 50 gpu::Mailbox mailbox; |
51 memset(mailbox.name, value, sizeof(mailbox.name)); | 51 memset(mailbox.name, value, sizeof(mailbox.name)); |
52 return mailbox; | 52 return mailbox; |
53 } | 53 } |
54 | 54 |
55 class MockLayerTreeHost : public LayerTreeHost { | 55 class MockLayerTreeHost : public LayerTreeHost { |
56 public: | 56 public: |
57 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 57 static scoped_ptr<MockLayerTreeHost> Create(FakeLayerTreeHostClient* client) { |
58 : LayerTreeHost(client, nullptr, nullptr, nullptr, LayerTreeSettings()) { | 58 LayerTreeHost::InitParams params; |
59 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(), | 59 params.client = client; |
60 nullptr); | 60 return make_scoped_ptr(new MockLayerTreeHost(client, ¶ms)); |
61 } | 61 } |
62 | 62 |
63 MOCK_METHOD0(SetNeedsCommit, void()); | 63 MOCK_METHOD0(SetNeedsCommit, void()); |
64 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 64 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
65 MOCK_METHOD0(StartRateLimiter, void()); | 65 MOCK_METHOD0(StartRateLimiter, void()); |
66 MOCK_METHOD0(StopRateLimiter, void()); | 66 MOCK_METHOD0(StopRateLimiter, void()); |
| 67 |
| 68 private: |
| 69 MockLayerTreeHost(FakeLayerTreeHostClient* client, |
| 70 LayerTreeHost::InitParams* params) |
| 71 : LayerTreeHost(params) { |
| 72 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(), |
| 73 nullptr); |
| 74 } |
67 }; | 75 }; |
68 | 76 |
69 class FakeTextureLayerClient : public TextureLayerClient { | 77 class FakeTextureLayerClient : public TextureLayerClient { |
70 public: | 78 public: |
71 FakeTextureLayerClient() : mailbox_changed_(true) {} | 79 FakeTextureLayerClient() : mailbox_changed_(true) {} |
72 | 80 |
73 bool PrepareTextureMailbox( | 81 bool PrepareTextureMailbox( |
74 TextureMailbox* mailbox, | 82 TextureMailbox* mailbox, |
75 scoped_ptr<SingleReleaseCallback>* release_callback, | 83 scoped_ptr<SingleReleaseCallback>* release_callback, |
76 bool use_shared_memory) override { | 84 bool use_shared_memory) override { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 class TextureLayerTest : public testing::Test { | 181 class TextureLayerTest : public testing::Test { |
174 public: | 182 public: |
175 TextureLayerTest() | 183 TextureLayerTest() |
176 : fake_client_( | 184 : fake_client_( |
177 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), | 185 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), |
178 host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), | 186 host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), |
179 test_data_(&shared_bitmap_manager_) {} | 187 test_data_(&shared_bitmap_manager_) {} |
180 | 188 |
181 protected: | 189 protected: |
182 void SetUp() override { | 190 void SetUp() override { |
183 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); | 191 layer_tree_host_ = MockLayerTreeHost::Create(&fake_client_); |
184 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 192 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
185 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); | 193 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); |
186 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 194 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
187 } | 195 } |
188 | 196 |
189 void TearDown() override { | 197 void TearDown() override { |
190 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 198 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
191 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 199 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
192 | 200 |
193 layer_tree_host_->SetRootLayer(nullptr); | 201 layer_tree_host_->SetRootLayer(nullptr); |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 TextureLayerMailboxIsActivatedDuringCommit); | 909 TextureLayerMailboxIsActivatedDuringCommit); |
902 | 910 |
903 class TextureLayerImplWithMailboxTest : public TextureLayerTest { | 911 class TextureLayerImplWithMailboxTest : public TextureLayerTest { |
904 protected: | 912 protected: |
905 TextureLayerImplWithMailboxTest() | 913 TextureLayerImplWithMailboxTest() |
906 : fake_client_( | 914 : fake_client_( |
907 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {} | 915 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {} |
908 | 916 |
909 void SetUp() override { | 917 void SetUp() override { |
910 TextureLayerTest::SetUp(); | 918 TextureLayerTest::SetUp(); |
911 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); | 919 layer_tree_host_ = MockLayerTreeHost::Create(&fake_client_); |
912 EXPECT_TRUE(host_impl_.InitializeRenderer(FakeOutputSurface::Create3d())); | 920 EXPECT_TRUE(host_impl_.InitializeRenderer(FakeOutputSurface::Create3d())); |
913 } | 921 } |
914 | 922 |
915 bool WillDraw(TextureLayerImpl* layer, DrawMode mode) { | 923 bool WillDraw(TextureLayerImpl* layer, DrawMode mode) { |
916 bool will_draw = layer->WillDraw( | 924 bool will_draw = layer->WillDraw( |
917 mode, host_impl_.active_tree()->resource_provider()); | 925 mode, host_impl_.active_tree()->resource_provider()); |
918 if (will_draw) | 926 if (will_draw) |
919 layer->DidDraw(host_impl_.active_tree()->resource_provider()); | 927 layer->DidDraw(host_impl_.active_tree()->resource_provider()); |
920 return will_draw; | 928 return will_draw; |
921 } | 929 } |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 int callback_count_; | 1540 int callback_count_; |
1533 scoped_refptr<Layer> root_; | 1541 scoped_refptr<Layer> root_; |
1534 scoped_refptr<TextureLayer> layer_; | 1542 scoped_refptr<TextureLayer> layer_; |
1535 }; | 1543 }; |
1536 | 1544 |
1537 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1545 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1538 TextureLayerWithMailboxImplThreadDeleted); | 1546 TextureLayerWithMailboxImplThreadDeleted); |
1539 | 1547 |
1540 } // namespace | 1548 } // namespace |
1541 } // namespace cc | 1549 } // namespace cc |
OLD | NEW |