| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "cc/layers/solid_color_layer.h" | 15 #include "cc/layers/solid_color_layer.h" |
| 16 #include "cc/layers/texture_layer_client.h" | 16 #include "cc/layers/texture_layer_client.h" |
| 17 #include "cc/layers/texture_layer_impl.h" | 17 #include "cc/layers/texture_layer_impl.h" |
| 18 #include "cc/output/compositor_frame_ack.h" | 18 #include "cc/output/compositor_frame_ack.h" |
| 19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
| 20 #include "cc/resources/returned_resource.h" | 20 #include "cc/resources/returned_resource.h" |
| 21 #include "cc/test/fake_impl_proxy.h" | 21 #include "cc/test/fake_impl_proxy.h" |
| 22 #include "cc/test/fake_layer_tree_host_client.h" | 22 #include "cc/test/fake_layer_tree_host_client.h" |
| 23 #include "cc/test/fake_layer_tree_host_impl.h" | 23 #include "cc/test/fake_layer_tree_host_impl.h" |
| 24 #include "cc/test/fake_output_surface.h" | 24 #include "cc/test/fake_output_surface.h" |
| 25 #include "cc/test/layer_test_common.h" | 25 #include "cc/test/layer_test_common.h" |
| 26 #include "cc/test/layer_tree_test.h" | 26 #include "cc/test/layer_tree_test.h" |
| 27 #include "cc/test/test_task_graph_runner.h" |
| 27 #include "cc/test/test_web_graphics_context_3d.h" | 28 #include "cc/test/test_web_graphics_context_3d.h" |
| 28 #include "cc/trees/blocking_task_runner.h" | 29 #include "cc/trees/blocking_task_runner.h" |
| 29 #include "cc/trees/layer_tree_host.h" | 30 #include "cc/trees/layer_tree_host.h" |
| 30 #include "cc/trees/layer_tree_impl.h" | 31 #include "cc/trees/layer_tree_impl.h" |
| 31 #include "cc/trees/single_thread_proxy.h" | 32 #include "cc/trees/single_thread_proxy.h" |
| 32 #include "gpu/GLES2/gl2extchromium.h" | 33 #include "gpu/GLES2/gl2extchromium.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 36 |
| 36 using ::testing::Mock; | 37 using ::testing::Mock; |
| 37 using ::testing::_; | 38 using ::testing::_; |
| 38 using ::testing::AtLeast; | 39 using ::testing::AtLeast; |
| 39 using ::testing::AnyNumber; | 40 using ::testing::AnyNumber; |
| 40 using ::testing::InvokeWithoutArgs; | 41 using ::testing::InvokeWithoutArgs; |
| 41 | 42 |
| 42 namespace cc { | 43 namespace cc { |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 gpu::Mailbox MailboxFromChar(char value) { | 46 gpu::Mailbox MailboxFromChar(char value) { |
| 46 gpu::Mailbox mailbox; | 47 gpu::Mailbox mailbox; |
| 47 memset(mailbox.name, value, sizeof(mailbox.name)); | 48 memset(mailbox.name, value, sizeof(mailbox.name)); |
| 48 return mailbox; | 49 return mailbox; |
| 49 } | 50 } |
| 50 | 51 |
| 51 class MockLayerTreeHost : public LayerTreeHost { | 52 class MockLayerTreeHost : public LayerTreeHost { |
| 52 public: | 53 public: |
| 53 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 54 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) |
| 54 : LayerTreeHost(client, nullptr, nullptr, LayerTreeSettings()) { | 55 : LayerTreeHost(client, nullptr, nullptr, nullptr, LayerTreeSettings()) { |
| 55 InitializeSingleThreaded(client, | 56 InitializeSingleThreaded(client, |
| 56 base::MessageLoopProxy::current(), | 57 base::MessageLoopProxy::current(), |
| 57 nullptr); | 58 nullptr); |
| 58 } | 59 } |
| 59 | 60 |
| 60 MOCK_METHOD0(SetNeedsCommit, void()); | 61 MOCK_METHOD0(SetNeedsCommit, void()); |
| 61 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 62 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
| 62 MOCK_METHOD0(StartRateLimiter, void()); | 63 MOCK_METHOD0(StartRateLimiter, void()); |
| 63 MOCK_METHOD0(StopRateLimiter, void()); | 64 MOCK_METHOD0(StopRateLimiter, void()); |
| 64 }; | 65 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 uint32 sync_point1_; | 166 uint32 sync_point1_; |
| 166 uint32 sync_point2_; | 167 uint32 sync_point2_; |
| 167 scoped_ptr<SharedBitmap> shared_bitmap_; | 168 scoped_ptr<SharedBitmap> shared_bitmap_; |
| 168 }; | 169 }; |
| 169 | 170 |
| 170 class TextureLayerTest : public testing::Test { | 171 class TextureLayerTest : public testing::Test { |
| 171 public: | 172 public: |
| 172 TextureLayerTest() | 173 TextureLayerTest() |
| 173 : fake_client_( | 174 : fake_client_( |
| 174 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), | 175 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), |
| 175 host_impl_(&proxy_, &shared_bitmap_manager_), | 176 host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), |
| 176 test_data_(&shared_bitmap_manager_) {} | 177 test_data_(&shared_bitmap_manager_) {} |
| 177 | 178 |
| 178 protected: | 179 protected: |
| 179 void SetUp() override { | 180 void SetUp() override { |
| 180 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); | 181 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); |
| 181 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 182 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
| 182 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); | 183 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); |
| 183 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 184 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 184 } | 185 } |
| 185 | 186 |
| 186 void TearDown() override { | 187 void TearDown() override { |
| 187 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 188 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 188 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 189 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
| 189 | 190 |
| 190 layer_tree_host_->SetRootLayer(nullptr); | 191 layer_tree_host_->SetRootLayer(nullptr); |
| 191 layer_tree_host_ = nullptr; | 192 layer_tree_host_ = nullptr; |
| 192 } | 193 } |
| 193 | 194 |
| 194 scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 195 scoped_ptr<MockLayerTreeHost> layer_tree_host_; |
| 195 FakeImplProxy proxy_; | 196 FakeImplProxy proxy_; |
| 196 FakeLayerTreeHostClient fake_client_; | 197 FakeLayerTreeHostClient fake_client_; |
| 197 TestSharedBitmapManager shared_bitmap_manager_; | 198 TestSharedBitmapManager shared_bitmap_manager_; |
| 199 TestTaskGraphRunner task_graph_runner_; |
| 198 FakeLayerTreeHostImpl host_impl_; | 200 FakeLayerTreeHostImpl host_impl_; |
| 199 CommonMailboxObjects test_data_; | 201 CommonMailboxObjects test_data_; |
| 200 }; | 202 }; |
| 201 | 203 |
| 202 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 204 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
| 203 scoped_refptr<TextureLayer> test_layer = | 205 scoped_refptr<TextureLayer> test_layer = |
| 204 TextureLayer::CreateForMailbox(nullptr); | 206 TextureLayer::CreateForMailbox(nullptr); |
| 205 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 207 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); |
| 206 | 208 |
| 207 // Test properties that should call SetNeedsCommit. All properties need to | 209 // Test properties that should call SetNeedsCommit. All properties need to |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 int callback_count_; | 1557 int callback_count_; |
| 1556 scoped_refptr<Layer> root_; | 1558 scoped_refptr<Layer> root_; |
| 1557 scoped_refptr<TextureLayer> layer_; | 1559 scoped_refptr<TextureLayer> layer_; |
| 1558 }; | 1560 }; |
| 1559 | 1561 |
| 1560 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1562 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1561 TextureLayerWithMailboxImplThreadDeleted); | 1563 TextureLayerWithMailboxImplThreadDeleted); |
| 1562 | 1564 |
| 1563 } // namespace | 1565 } // namespace |
| 1564 } // namespace cc | 1566 } // namespace cc |
| OLD | NEW |