| 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 #ifndef CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class ImageSerializationProcessor; | 54 class ImageSerializationProcessor; |
| 55 class Layer; | 55 class Layer; |
| 56 class LayerTreeHostClient; | 56 class LayerTreeHostClient; |
| 57 class LayerTreeHostImpl; | 57 class LayerTreeHostImpl; |
| 58 class LayerTreeHostImplClient; | 58 class LayerTreeHostImplClient; |
| 59 class LayerTreeHostSingleThreadClient; | 59 class LayerTreeHostSingleThreadClient; |
| 60 class LayerTreeMutator; | 60 class LayerTreeMutator; |
| 61 class MutatorHost; | 61 class MutatorHost; |
| 62 class PropertyTrees; | 62 class PropertyTrees; |
| 63 class Region; | 63 class Region; |
| 64 class RemoteProtoChannel; | |
| 65 class RenderingStatsInstrumentation; | 64 class RenderingStatsInstrumentation; |
| 66 class ResourceProvider; | 65 class ResourceProvider; |
| 67 class ResourceUpdateQueue; | 66 class ResourceUpdateQueue; |
| 68 class TaskGraphRunner; | 67 class TaskGraphRunner; |
| 69 struct PendingPageScaleAnimation; | 68 struct PendingPageScaleAnimation; |
| 70 struct ReflectedMainFrameState; | 69 struct ReflectedMainFrameState; |
| 71 struct RenderingStats; | 70 struct RenderingStats; |
| 72 struct ScrollAndScaleSet; | 71 struct ScrollAndScaleSet; |
| 73 | 72 |
| 74 namespace proto { | |
| 75 class LayerTreeHost; | |
| 76 } | |
| 77 | |
| 78 class CC_EXPORT LayerTreeHostInProcess : public LayerTreeHost { | 73 class CC_EXPORT LayerTreeHostInProcess : public LayerTreeHost { |
| 79 public: | 74 public: |
| 80 // TODO(sad): InitParams should be a movable type so that it can be | 75 // TODO(sad): InitParams should be a movable type so that it can be |
| 81 // std::move()d to the Create* functions. | 76 // std::move()d to the Create* functions. |
| 82 struct CC_EXPORT InitParams { | 77 struct CC_EXPORT InitParams { |
| 83 LayerTreeHostClient* client = nullptr; | 78 LayerTreeHostClient* client = nullptr; |
| 84 TaskGraphRunner* task_graph_runner = nullptr; | 79 TaskGraphRunner* task_graph_runner = nullptr; |
| 85 LayerTreeSettings const* settings = nullptr; | 80 LayerTreeSettings const* settings = nullptr; |
| 86 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; | 81 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; |
| 87 ImageSerializationProcessor* image_serialization_processor = nullptr; | 82 ImageSerializationProcessor* image_serialization_processor = nullptr; |
| 88 MutatorHost* mutator_host; | 83 MutatorHost* mutator_host; |
| 89 | 84 |
| 90 InitParams(); | 85 InitParams(); |
| 91 ~InitParams(); | 86 ~InitParams(); |
| 92 }; | 87 }; |
| 93 | 88 |
| 94 static std::unique_ptr<LayerTreeHostInProcess> CreateThreaded( | 89 static std::unique_ptr<LayerTreeHostInProcess> CreateThreaded( |
| 95 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 90 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 96 InitParams* params); | 91 InitParams* params); |
| 97 | 92 |
| 98 static std::unique_ptr<LayerTreeHostInProcess> CreateSingleThreaded( | 93 static std::unique_ptr<LayerTreeHostInProcess> CreateSingleThreaded( |
| 99 LayerTreeHostSingleThreadClient* single_thread_client, | 94 LayerTreeHostSingleThreadClient* single_thread_client, |
| 100 InitParams* params); | 95 InitParams* params); |
| 101 | 96 |
| 102 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteServer( | |
| 103 RemoteProtoChannel* remote_proto_channel, | |
| 104 InitParams* params); | |
| 105 | |
| 106 // The lifetime of this LayerTreeHostInProcess is tied to the lifetime of the | |
| 107 // remote server LayerTreeHostInProcess. It should be created on receiving | |
| 108 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving | |
| 109 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures | |
| 110 // that the client will not send any compositor messages once the | |
| 111 // LayerTreeHostInProcess on the server is destroyed. | |
| 112 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteClient( | |
| 113 RemoteProtoChannel* remote_proto_channel, | |
| 114 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
| 115 InitParams* params); | |
| 116 | |
| 117 ~LayerTreeHostInProcess() override; | 97 ~LayerTreeHostInProcess() override; |
| 118 | 98 |
| 119 // LayerTreeHost implementation. | 99 // LayerTreeHost implementation. |
| 120 int GetId() const override; | 100 int GetId() const override; |
| 121 int SourceFrameNumber() const override; | 101 int SourceFrameNumber() const override; |
| 122 LayerTree* GetLayerTree() override; | 102 LayerTree* GetLayerTree() override; |
| 123 const LayerTree* GetLayerTree() const override; | 103 const LayerTree* GetLayerTree() const override; |
| 124 UIResourceManager* GetUIResourceManager() const override; | 104 UIResourceManager* GetUIResourceManager() const override; |
| 125 TaskRunnerProvider* GetTaskRunnerProvider() const override; | 105 TaskRunnerProvider* GetTaskRunnerProvider() const override; |
| 126 const LayerTreeSettings& GetSettings() const override; | 106 const LayerTreeSettings& GetSettings() const override; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 188 } |
| 209 | 189 |
| 210 void SetAnimationEvents(std::unique_ptr<MutatorEvents> events); | 190 void SetAnimationEvents(std::unique_ptr<MutatorEvents> events); |
| 211 | 191 |
| 212 bool has_gpu_rasterization_trigger() const { | 192 bool has_gpu_rasterization_trigger() const { |
| 213 return has_gpu_rasterization_trigger_; | 193 return has_gpu_rasterization_trigger_; |
| 214 } | 194 } |
| 215 | 195 |
| 216 Proxy* proxy() const { return proxy_.get(); } | 196 Proxy* proxy() const { return proxy_.get(); } |
| 217 | 197 |
| 218 // Serializes the parts of this LayerTreeHostInProcess that is needed for a | |
| 219 // commit to a protobuf message. Not all members are serialized as they are | |
| 220 // not helpful for remote usage. | |
| 221 // The |swap_promise_list_| is transferred to the serializer in | |
| 222 // |swap_promises|. | |
| 223 void ToProtobufForCommit( | |
| 224 proto::LayerTreeHost* proto, | |
| 225 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | |
| 226 | |
| 227 // Deserializes the protobuf into this LayerTreeHostInProcess before a commit. | |
| 228 // The expected input is a serialized remote LayerTreeHost. After | |
| 229 // deserializing the protobuf, the normal commit-flow should continue. | |
| 230 void FromProtobufForCommit(const proto::LayerTreeHost& proto); | |
| 231 | |
| 232 bool IsSingleThreaded() const; | 198 bool IsSingleThreaded() const; |
| 233 bool IsThreaded() const; | 199 bool IsThreaded() const; |
| 234 bool IsRemoteServer() const; | |
| 235 bool IsRemoteClient() const; | |
| 236 | 200 |
| 237 ImageSerializationProcessor* image_serialization_processor() const { | 201 ImageSerializationProcessor* image_serialization_processor() const { |
| 238 return image_serialization_processor_; | 202 return image_serialization_processor_; |
| 239 } | 203 } |
| 240 | 204 |
| 241 EnginePictureCache* engine_picture_cache() const { | 205 EnginePictureCache* engine_picture_cache() const { |
| 242 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 206 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
| 243 } | 207 } |
| 244 | 208 |
| 245 ClientPictureCache* client_picture_cache() const { | 209 ClientPictureCache* client_picture_cache() const { |
| 246 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 210 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
| 247 } | 211 } |
| 248 | 212 |
| 249 protected: | 213 protected: |
| 250 // Allow tests to inject the LayerTree. | 214 // Allow tests to inject the LayerTree. |
| 251 LayerTreeHostInProcess(InitParams* params, | 215 LayerTreeHostInProcess(InitParams* params, |
| 252 CompositorMode mode, | 216 CompositorMode mode, |
| 253 std::unique_ptr<LayerTree> layer_tree); | 217 std::unique_ptr<LayerTree> layer_tree); |
| 254 LayerTreeHostInProcess(InitParams* params, CompositorMode mode); | 218 LayerTreeHostInProcess(InitParams* params, CompositorMode mode); |
| 255 | 219 |
| 256 void InitializeThreaded( | 220 void InitializeThreaded( |
| 257 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 221 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 258 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 222 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 259 void InitializeSingleThreaded( | 223 void InitializeSingleThreaded( |
| 260 LayerTreeHostSingleThreadClient* single_thread_client, | 224 LayerTreeHostSingleThreadClient* single_thread_client, |
| 261 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 225 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 262 void InitializeRemoteServer( | |
| 263 RemoteProtoChannel* remote_proto_channel, | |
| 264 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | |
| 265 void InitializeRemoteClient( | |
| 266 RemoteProtoChannel* remote_proto_channel, | |
| 267 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 268 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | |
| 269 void InitializeForTesting( | 226 void InitializeForTesting( |
| 270 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 227 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
| 271 std::unique_ptr<Proxy> proxy_for_testing); | 228 std::unique_ptr<Proxy> proxy_for_testing); |
| 272 void InitializePictureCacheForTesting(); | 229 void InitializePictureCacheForTesting(); |
| 273 void SetTaskRunnerProviderForTesting( | 230 void SetTaskRunnerProviderForTesting( |
| 274 std::unique_ptr<TaskRunnerProvider> task_runner_provider); | 231 std::unique_ptr<TaskRunnerProvider> task_runner_provider); |
| 275 void SetUIResourceManagerForTesting( | 232 void SetUIResourceManagerForTesting( |
| 276 std::unique_ptr<UIResourceManager> ui_resource_manager); | 233 std::unique_ptr<UIResourceManager> ui_resource_manager); |
| 277 | 234 |
| 278 // task_graph_runner() returns a valid value only until the LayerTreeHostImpl | 235 // task_graph_runner() returns a valid value only until the LayerTreeHostImpl |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // TODO(khushalsagar): Investigate removing this after SPV2, since then we | 322 // TODO(khushalsagar): Investigate removing this after SPV2, since then we |
| 366 // should get these PropertyTrees directly from blink? | 323 // should get these PropertyTrees directly from blink? |
| 367 std::unique_ptr<ReflectedMainFrameState> reflected_main_frame_state_; | 324 std::unique_ptr<ReflectedMainFrameState> reflected_main_frame_state_; |
| 368 | 325 |
| 369 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostInProcess); | 326 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostInProcess); |
| 370 }; | 327 }; |
| 371 | 328 |
| 372 } // namespace cc | 329 } // namespace cc |
| 373 | 330 |
| 374 #endif // CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ | 331 #endif // CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ |
| OLD | NEW |