| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CC_TEST_FAKE_LAYER_TREE_HOST_H_ | 5 #ifndef CC_TEST_FAKE_LAYER_TREE_HOST_H_ |
| 6 #define CC_TEST_FAKE_LAYER_TREE_HOST_H_ | 6 #define CC_TEST_FAKE_LAYER_TREE_HOST_H_ |
| 7 | 7 |
| 8 #include "cc/debug/micro_benchmark_controller.h" | 8 #include "cc/debug/micro_benchmark_controller.h" |
| 9 #include "cc/test/fake_impl_task_runner_provider.h" | 9 #include "cc/test/fake_impl_task_runner_provider.h" |
| 10 #include "cc/test/fake_layer_tree_host_client.h" | 10 #include "cc/test/fake_layer_tree_host_client.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/trees/layer_tree_host_in_process.h" | 12 #include "cc/trees/layer_tree_host_in_process.h" |
| 13 #include "cc/trees/layer_tree_impl.h" | 13 #include "cc/trees/layer_tree_impl.h" |
| 14 #include "cc/trees/tree_synchronizer.h" | 14 #include "cc/trees/tree_synchronizer.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class ImageSerializationProcessor; | |
| 19 class MutatorHost; | 18 class MutatorHost; |
| 20 class TestTaskGraphRunner; | 19 class TestTaskGraphRunner; |
| 21 | 20 |
| 22 class FakeLayerTreeHost : public LayerTreeHostInProcess { | 21 class FakeLayerTreeHost : public LayerTreeHostInProcess { |
| 23 public: | 22 public: |
| 24 static std::unique_ptr<FakeLayerTreeHost> Create( | 23 static std::unique_ptr<FakeLayerTreeHost> Create( |
| 25 FakeLayerTreeHostClient* client, | 24 FakeLayerTreeHostClient* client, |
| 26 TestTaskGraphRunner* task_graph_runner, | 25 TestTaskGraphRunner* task_graph_runner, |
| 27 MutatorHost* mutator_host); | 26 MutatorHost* mutator_host); |
| 28 static std::unique_ptr<FakeLayerTreeHost> Create( | 27 static std::unique_ptr<FakeLayerTreeHost> Create( |
| 29 FakeLayerTreeHostClient* client, | 28 FakeLayerTreeHostClient* client, |
| 30 TestTaskGraphRunner* task_graph_runner, | 29 TestTaskGraphRunner* task_graph_runner, |
| 31 MutatorHost* mutator_host, | 30 MutatorHost* mutator_host, |
| 32 const LayerTreeSettings& settings); | 31 const LayerTreeSettings& settings); |
| 33 static std::unique_ptr<FakeLayerTreeHost> Create( | 32 static std::unique_ptr<FakeLayerTreeHost> Create( |
| 34 FakeLayerTreeHostClient* client, | 33 FakeLayerTreeHostClient* client, |
| 35 TestTaskGraphRunner* task_graph_runner, | 34 TestTaskGraphRunner* task_graph_runner, |
| 36 MutatorHost* mutator_host, | 35 MutatorHost* mutator_host, |
| 37 const LayerTreeSettings& settings, | 36 const LayerTreeSettings& settings, |
| 38 CompositorMode mode); | 37 CompositorMode mode); |
| 39 static std::unique_ptr<FakeLayerTreeHost> Create( | 38 static std::unique_ptr<FakeLayerTreeHost> Create( |
| 40 FakeLayerTreeHostClient* client, | 39 FakeLayerTreeHostClient* client, |
| 41 TestTaskGraphRunner* task_graph_runner, | 40 TestTaskGraphRunner* task_graph_runner, |
| 42 MutatorHost* mutator_host, | 41 MutatorHost* mutator_host, |
| 43 const LayerTreeSettings& settings, | 42 const LayerTreeSettings& settings, |
| 44 CompositorMode mode, | 43 CompositorMode mode, |
| 45 InitParams params); | 44 InitParams params); |
| 46 static std::unique_ptr<FakeLayerTreeHost> Create( | |
| 47 FakeLayerTreeHostClient* client, | |
| 48 TestTaskGraphRunner* task_graph_runner, | |
| 49 MutatorHost* mutator_host, | |
| 50 const LayerTreeSettings& settings, | |
| 51 CompositorMode mode, | |
| 52 ImageSerializationProcessor* image_serialization_processor); | |
| 53 ~FakeLayerTreeHost() override; | 45 ~FakeLayerTreeHost() override; |
| 54 | 46 |
| 55 void SetNeedsCommit() override; | 47 void SetNeedsCommit() override; |
| 56 void SetNeedsUpdateLayers() override {} | 48 void SetNeedsUpdateLayers() override {} |
| 57 | 49 |
| 58 void SetRootLayer(scoped_refptr<Layer> root_layer) { | 50 void SetRootLayer(scoped_refptr<Layer> root_layer) { |
| 59 layer_tree_->SetRootLayer(root_layer); | 51 layer_tree_->SetRootLayer(root_layer); |
| 60 } | 52 } |
| 61 Layer* root_layer() const { return layer_tree_->root_layer(); } | 53 Layer* root_layer() const { return layer_tree_->root_layer(); } |
| 62 PropertyTrees* property_trees() const { | 54 PropertyTrees* property_trees() const { |
| 63 return layer_tree_->property_trees(); | 55 return layer_tree_->property_trees(); |
| 64 } | 56 } |
| 65 void BuildPropertyTreesForTesting() { | 57 void BuildPropertyTreesForTesting() { |
| 66 layer_tree_->BuildPropertyTreesForTesting(); | 58 layer_tree_->BuildPropertyTreesForTesting(); |
| 67 } | 59 } |
| 68 | 60 |
| 69 LayerImpl* CommitAndCreateLayerImplTree(); | 61 LayerImpl* CommitAndCreateLayerImplTree(); |
| 70 LayerImpl* CommitAndCreatePendingTree(); | 62 LayerImpl* CommitAndCreatePendingTree(); |
| 71 | 63 |
| 72 FakeLayerTreeHostImpl* host_impl() { return &host_impl_; } | 64 FakeLayerTreeHostImpl* host_impl() { return &host_impl_; } |
| 73 LayerTreeImpl* active_tree() { return host_impl_.active_tree(); } | 65 LayerTreeImpl* active_tree() { return host_impl_.active_tree(); } |
| 74 LayerTreeImpl* pending_tree() { return host_impl_.pending_tree(); } | 66 LayerTreeImpl* pending_tree() { return host_impl_.pending_tree(); } |
| 75 | 67 |
| 76 using LayerTreeHostInProcess::ScheduleMicroBenchmark; | 68 using LayerTreeHostInProcess::ScheduleMicroBenchmark; |
| 77 using LayerTreeHostInProcess::SendMessageToMicroBenchmark; | 69 using LayerTreeHostInProcess::SendMessageToMicroBenchmark; |
| 78 using LayerTreeHostInProcess::InitializeSingleThreaded; | 70 using LayerTreeHostInProcess::InitializeSingleThreaded; |
| 79 using LayerTreeHostInProcess::InitializeForTesting; | 71 using LayerTreeHostInProcess::InitializeForTesting; |
| 80 using LayerTreeHostInProcess::InitializePictureCacheForTesting; | |
| 81 using LayerTreeHostInProcess::RecordGpuRasterizationHistogram; | 72 using LayerTreeHostInProcess::RecordGpuRasterizationHistogram; |
| 82 using LayerTreeHostInProcess::SetUIResourceManagerForTesting; | 73 using LayerTreeHostInProcess::SetUIResourceManagerForTesting; |
| 83 | 74 |
| 84 void UpdateLayers() { LayerTreeHostInProcess::UpdateLayers(); } | 75 void UpdateLayers() { LayerTreeHostInProcess::UpdateLayers(); } |
| 85 | 76 |
| 86 MicroBenchmarkController* GetMicroBenchmarkController() { | 77 MicroBenchmarkController* GetMicroBenchmarkController() { |
| 87 return µ_benchmark_controller_; | 78 return µ_benchmark_controller_; |
| 88 } | 79 } |
| 89 | 80 |
| 90 bool needs_commit() { return needs_commit_; } | 81 bool needs_commit() { return needs_commit_; } |
| 91 void reset_needs_commit() { needs_commit_ = false; } | 82 void reset_needs_commit() { needs_commit_ = false; } |
| 92 | 83 |
| 93 FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 84 FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
| 94 LayerTreeHostInProcess::InitParams* params, | 85 LayerTreeHostInProcess::InitParams* params, |
| 95 CompositorMode mode); | 86 CompositorMode mode); |
| 96 | 87 |
| 97 private: | 88 private: |
| 98 FakeImplTaskRunnerProvider task_runner_provider_; | 89 FakeImplTaskRunnerProvider task_runner_provider_; |
| 99 FakeLayerTreeHostClient* client_; | 90 FakeLayerTreeHostClient* client_; |
| 100 FakeLayerTreeHostImpl host_impl_; | 91 FakeLayerTreeHostImpl host_impl_; |
| 101 bool needs_commit_; | 92 bool needs_commit_; |
| 102 }; | 93 }; |
| 103 | 94 |
| 104 } // namespace cc | 95 } // namespace cc |
| 105 | 96 |
| 106 #endif // CC_TEST_FAKE_LAYER_TREE_HOST_H_ | 97 #endif // CC_TEST_FAKE_LAYER_TREE_HOST_H_ |
| OLD | NEW |