Chromium Code Reviews| 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_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_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 |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <unordered_map> | 15 #include <unordered_map> |
| 16 #include <vector> | 16 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 29 #include "cc/input/layer_selection_bound.h" | 29 #include "cc/input/layer_selection_bound.h" |
| 30 #include "cc/input/scrollbar.h" | 30 #include "cc/input/scrollbar.h" |
| 31 #include "cc/input/top_controls_state.h" | 31 #include "cc/input/top_controls_state.h" |
| 32 #include "cc/layers/layer_collections.h" | 32 #include "cc/layers/layer_collections.h" |
| 33 #include "cc/layers/layer_list_iterator.h" | 33 #include "cc/layers/layer_list_iterator.h" |
| 34 #include "cc/output/output_surface.h" | 34 #include "cc/output/output_surface.h" |
| 35 #include "cc/output/swap_promise.h" | 35 #include "cc/output/swap_promise.h" |
| 36 #include "cc/resources/resource_format.h" | 36 #include "cc/resources/resource_format.h" |
| 37 #include "cc/trees/compositor_mode.h" | 37 #include "cc/trees/compositor_mode.h" |
| 38 #include "cc/trees/layer_tree.h" | 38 #include "cc/trees/layer_tree.h" |
| 39 #include "cc/trees/layer_tree_host.h" | |
| 39 #include "cc/trees/layer_tree_host_client.h" | 40 #include "cc/trees/layer_tree_host_client.h" |
| 40 #include "cc/trees/layer_tree_host_interface.h" | |
| 41 #include "cc/trees/layer_tree_settings.h" | 41 #include "cc/trees/layer_tree_settings.h" |
| 42 #include "cc/trees/proxy.h" | 42 #include "cc/trees/proxy.h" |
| 43 #include "cc/trees/surface_sequence_generator.h" | 43 #include "cc/trees/surface_sequence_generator.h" |
| 44 #include "cc/trees/swap_promise_manager.h" | 44 #include "cc/trees/swap_promise_manager.h" |
| 45 #include "third_party/skia/include/core/SkColor.h" | 45 #include "third_party/skia/include/core/SkColor.h" |
| 46 #include "ui/gfx/geometry/rect.h" | 46 #include "ui/gfx/geometry/rect.h" |
| 47 | 47 |
| 48 namespace gpu { | |
| 49 class GpuMemoryBufferManager; | |
| 50 } | |
| 51 | |
| 52 namespace cc { | 48 namespace cc { |
| 53 | 49 class AnimationHost; |
| 54 class AnimationEvents; | 50 class AnimationEvents; |
| 55 class AnimationHost; | |
| 56 class BeginFrameSource; | 51 class BeginFrameSource; |
| 57 class ClientPictureCache; | 52 class ClientPictureCache; |
| 58 class EnginePictureCache; | 53 class EnginePictureCache; |
| 59 class HeadsUpDisplayLayer; | 54 class HeadsUpDisplayLayer; |
| 60 class ImageSerializationProcessor; | 55 class ImageSerializationProcessor; |
| 61 class Layer; | 56 class Layer; |
| 57 class LayerTreeHostClient; | |
| 62 class LayerTreeHostImpl; | 58 class LayerTreeHostImpl; |
| 63 class LayerTreeHostImplClient; | 59 class LayerTreeHostImplClient; |
| 64 class LayerTreeHostSingleThreadClient; | 60 class LayerTreeHostSingleThreadClient; |
| 65 class LayerTreeMutator; | 61 class LayerTreeMutator; |
| 66 class PropertyTrees; | 62 class PropertyTrees; |
| 67 class Region; | 63 class Region; |
| 68 class RemoteProtoChannel; | 64 class RemoteProtoChannel; |
| 69 class RenderingStatsInstrumentation; | 65 class RenderingStatsInstrumentation; |
| 70 class ResourceProvider; | 66 class ResourceProvider; |
| 71 class ResourceUpdateQueue; | 67 class ResourceUpdateQueue; |
| 72 class SharedBitmapManager; | 68 class SharedBitmapManager; |
| 73 class TaskGraphRunner; | 69 class TaskGraphRunner; |
| 74 class TopControlsManager; | 70 class TopControlsManager; |
| 75 struct PendingPageScaleAnimation; | 71 struct PendingPageScaleAnimation; |
| 76 struct RenderingStats; | 72 struct RenderingStats; |
| 77 struct ScrollAndScaleSet; | 73 struct ScrollAndScaleSet; |
| 78 | 74 |
| 79 namespace proto { | 75 namespace proto { |
| 80 class LayerTreeHost; | 76 class LayerTreeHost; |
| 81 } | 77 } |
| 82 | 78 |
| 83 // This class is being refactored to an interface, see LayerTreeHostInterface, | 79 class CC_EXPORT LayerTreeHostInProcess : public LayerTreeHost { |
| 84 // which is the API for the cc embedder. When adding new code to this class, | |
| 85 // consider the following: | |
| 86 // 1) If its state/data that gets pushed to the LayerTreeImpl during commit, add | |
| 87 // it to the LayerTree. | |
| 88 // 2) If it's a call from the embedder, add it to the LayerTreeHostInterface. | |
| 89 // 3) If it's a call from any of the internal cc classes, i.e., LayerTree or | |
| 90 // PropertyTreeBuilder, etc., add it to the LayerTreeHostInterface. | |
| 91 // 4) If it's a notification from the impl thread or a call from Proxy, add it | |
| 92 // to this class. | |
| 93 // This class will be renamed to LayerTreeHostInProcess and will be the | |
| 94 // LayerTreeHost implementation for when the impl thread for the compositor runs | |
| 95 // in the same process, and thus uses a Proxy. | |
| 96 class CC_EXPORT LayerTreeHost : public LayerTreeHostInterface { | |
| 97 public: | 80 public: |
| 98 // TODO(sad): InitParams should be a movable type so that it can be | 81 // TODO(sad): InitParams should be a movable type so that it can be |
| 99 // std::move()d to the Create* functions. | 82 // std::move()d to the Create* functions. |
| 100 struct CC_EXPORT InitParams { | 83 struct CC_EXPORT InitParams { |
| 101 LayerTreeHostClient* client = nullptr; | 84 LayerTreeHostClient* client = nullptr; |
| 102 SharedBitmapManager* shared_bitmap_manager = nullptr; | 85 SharedBitmapManager* shared_bitmap_manager = nullptr; |
| 103 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; | 86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; |
| 104 TaskGraphRunner* task_graph_runner = nullptr; | 87 TaskGraphRunner* task_graph_runner = nullptr; |
| 105 LayerTreeSettings const* settings = nullptr; | 88 LayerTreeSettings const* settings = nullptr; |
| 106 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; | 89 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; |
| 107 std::unique_ptr<BeginFrameSource> external_begin_frame_source; | 90 std::unique_ptr<BeginFrameSource> external_begin_frame_source; |
| 108 ImageSerializationProcessor* image_serialization_processor = nullptr; | 91 ImageSerializationProcessor* image_serialization_processor = nullptr; |
| 109 std::unique_ptr<AnimationHost> animation_host; | 92 std::unique_ptr<AnimationHost> animation_host; |
| 110 | 93 |
| 111 InitParams(); | 94 InitParams(); |
| 112 ~InitParams(); | 95 ~InitParams(); |
| 113 }; | 96 }; |
| 114 | 97 |
| 115 // The SharedBitmapManager will be used on the compositor thread. | 98 // The SharedBitmapManager will be used on the compositor thread. |
| 116 static std::unique_ptr<LayerTreeHostInterface> CreateThreaded( | 99 static std::unique_ptr<LayerTreeHostInProcess> CreateThreaded( |
|
Khushal
2016/09/15 00:56:20
I made these return the in process one itself. If
| |
| 117 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 100 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 118 InitParams* params); | 101 InitParams* params); |
| 119 | 102 |
| 120 static std::unique_ptr<LayerTreeHost> CreateSingleThreaded( | 103 static std::unique_ptr<LayerTreeHostInProcess> CreateSingleThreaded( |
| 121 LayerTreeHostSingleThreadClient* single_thread_client, | 104 LayerTreeHostSingleThreadClient* single_thread_client, |
| 122 InitParams* params); | 105 InitParams* params); |
| 123 | 106 |
| 124 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteServer( | 107 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteServer( |
| 125 RemoteProtoChannel* remote_proto_channel, | 108 RemoteProtoChannel* remote_proto_channel, |
| 126 InitParams* params); | 109 InitParams* params); |
| 127 | 110 |
| 128 // The lifetime of this LayerTreeHost is tied to the lifetime of the remote | 111 // The lifetime of this LayerTreeHostInProcess is tied to the lifetime of the |
| 129 // server LayerTreeHost. It should be created on receiving | 112 // remote server LayerTreeHostInProcess. It should be created on receiving |
| 130 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving | 113 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving |
| 131 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures | 114 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures |
| 132 // that the client will not send any compositor messages once the | 115 // that the client will not send any compositor messages once the |
| 133 // LayerTreeHost on the server is destroyed. | 116 // LayerTreeHostInProcess on the server is destroyed. |
| 134 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteClient( | 117 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteClient( |
| 135 RemoteProtoChannel* remote_proto_channel, | 118 RemoteProtoChannel* remote_proto_channel, |
| 136 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 119 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 137 InitParams* params); | 120 InitParams* params); |
| 138 | 121 |
| 139 ~LayerTreeHost() override; | 122 ~LayerTreeHostInProcess() override; |
| 140 | 123 |
| 141 // LayerTreeHostInterface implementation. | 124 // LayerTreeHost implementation. |
| 142 int GetId() const override; | 125 int GetId() const override; |
| 143 int SourceFrameNumber() const override; | 126 int SourceFrameNumber() const override; |
| 144 LayerTree* GetLayerTree() override; | 127 LayerTree* GetLayerTree() override; |
| 145 const LayerTree* GetLayerTree() const override; | 128 const LayerTree* GetLayerTree() const override; |
| 146 UIResourceManager* GetUIResourceManager() const override; | 129 UIResourceManager* GetUIResourceManager() const override; |
| 147 TaskRunnerProvider* GetTaskRunnerProvider() const override; | 130 TaskRunnerProvider* GetTaskRunnerProvider() const override; |
| 148 const LayerTreeSettings& GetSettings() const override; | 131 const LayerTreeSettings& GetSettings() const override; |
| 149 void SetSurfaceClientId(uint32_t client_id) override; | 132 void SetSurfaceClientId(uint32_t client_id) override; |
| 150 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 133 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
| 151 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; | 134 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 174 void DidStopFlinging() override; | 157 void DidStopFlinging() override; |
| 175 void SetDebugState(const LayerTreeDebugState& debug_state) override; | 158 void SetDebugState(const LayerTreeDebugState& debug_state) override; |
| 176 const LayerTreeDebugState& GetDebugState() const override; | 159 const LayerTreeDebugState& GetDebugState() const override; |
| 177 int ScheduleMicroBenchmark( | 160 int ScheduleMicroBenchmark( |
| 178 const std::string& benchmark_name, | 161 const std::string& benchmark_name, |
| 179 std::unique_ptr<base::Value> value, | 162 std::unique_ptr<base::Value> value, |
| 180 const MicroBenchmark::DoneCallback& callback) override; | 163 const MicroBenchmark::DoneCallback& callback) override; |
| 181 bool SendMessageToMicroBenchmark(int id, | 164 bool SendMessageToMicroBenchmark(int id, |
| 182 std::unique_ptr<base::Value> value) override; | 165 std::unique_ptr<base::Value> value) override; |
| 183 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override; | 166 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override; |
| 167 void SetNextCommitWaitsForActivation() override; | |
| 168 void ResetGpuRasterizationTracking() override; | |
| 184 | 169 |
| 185 // LayerTreeHost interface to Proxy. | 170 // LayerTreeHostInProcess interface to Proxy. |
| 186 void WillBeginMainFrame(); | 171 void WillBeginMainFrame(); |
| 187 void DidBeginMainFrame(); | 172 void DidBeginMainFrame(); |
| 188 void BeginMainFrame(const BeginFrameArgs& args); | 173 void BeginMainFrame(const BeginFrameArgs& args); |
| 189 void BeginMainFrameNotExpectedSoon(); | 174 void BeginMainFrameNotExpectedSoon(); |
| 190 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); | 175 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); |
| 191 void RequestMainFrameUpdate(); | 176 void RequestMainFrameUpdate(); |
| 192 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); | 177 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); |
| 193 void WillCommit(); | 178 void WillCommit(); |
| 194 void CommitComplete(); | 179 void CommitComplete(); |
| 195 void RequestNewOutputSurface(); | 180 void RequestNewOutputSurface(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 210 bool gpu_rasterization_histogram_recorded() const { | 195 bool gpu_rasterization_histogram_recorded() const { |
| 211 return gpu_rasterization_histogram_recorded_; | 196 return gpu_rasterization_histogram_recorded_; |
| 212 } | 197 } |
| 213 | 198 |
| 214 void CollectRenderingStats(RenderingStats* stats) const; | 199 void CollectRenderingStats(RenderingStats* stats) const; |
| 215 | 200 |
| 216 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { | 201 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { |
| 217 return rendering_stats_instrumentation_.get(); | 202 return rendering_stats_instrumentation_.get(); |
| 218 } | 203 } |
| 219 | 204 |
| 220 void SetNextCommitWaitsForActivation(); | |
| 221 | |
| 222 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); | 205 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); |
| 223 | 206 |
| 224 bool has_gpu_rasterization_trigger() const { | 207 bool has_gpu_rasterization_trigger() const { |
| 225 return has_gpu_rasterization_trigger_; | 208 return has_gpu_rasterization_trigger_; |
| 226 } | 209 } |
| 227 | 210 |
| 228 Proxy* proxy() const { return proxy_.get(); } | 211 Proxy* proxy() const { return proxy_.get(); } |
| 229 | 212 |
| 230 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | 213 // Serializes the parts of this LayerTreeHostInProcess that is needed for a |
| 231 // protobuf message. Not all members are serialized as they are not helpful | 214 // commit to a protobuf message. Not all members are serialized as they are |
| 232 // for remote usage. | 215 // not helpful for remote usage. |
| 233 // The |swap_promise_list_| is transferred to the serializer in | 216 // The |swap_promise_list_| is transferred to the serializer in |
| 234 // |swap_promises|. | 217 // |swap_promises|. |
| 235 void ToProtobufForCommit( | 218 void ToProtobufForCommit( |
| 236 proto::LayerTreeHost* proto, | 219 proto::LayerTreeHost* proto, |
| 237 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | 220 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); |
| 238 | 221 |
| 239 // Deserializes the protobuf into this LayerTreeHost before a commit. The | 222 // Deserializes the protobuf into this LayerTreeHostInProcess before a commit. |
| 240 // expected input is a serialized remote LayerTreeHost. After deserializing | 223 // The expected input is a serialized remote LayerTreeHost. After |
| 241 // the protobuf, the normal commit-flow should continue. | 224 // deserializing the protobuf, the normal commit-flow should continue. |
| 242 void FromProtobufForCommit(const proto::LayerTreeHost& proto); | 225 void FromProtobufForCommit(const proto::LayerTreeHost& proto); |
| 243 | 226 |
| 244 bool IsSingleThreaded() const; | 227 bool IsSingleThreaded() const; |
| 245 bool IsThreaded() const; | 228 bool IsThreaded() const; |
| 246 bool IsRemoteServer() const; | 229 bool IsRemoteServer() const; |
| 247 bool IsRemoteClient() const; | 230 bool IsRemoteClient() const; |
| 248 | 231 |
| 249 ImageSerializationProcessor* image_serialization_processor() const { | 232 ImageSerializationProcessor* image_serialization_processor() const { |
| 250 return image_serialization_processor_; | 233 return image_serialization_processor_; |
| 251 } | 234 } |
| 252 | 235 |
| 253 EnginePictureCache* engine_picture_cache() const { | 236 EnginePictureCache* engine_picture_cache() const { |
| 254 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 237 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
| 255 } | 238 } |
| 256 | 239 |
| 257 ClientPictureCache* client_picture_cache() const { | 240 ClientPictureCache* client_picture_cache() const { |
| 258 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 241 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
| 259 } | 242 } |
| 260 | 243 |
| 261 void ResetGpuRasterizationTracking(); | |
| 262 | |
| 263 protected: | 244 protected: |
| 264 // Allow tests to inject the LayerTree. | 245 // Allow tests to inject the LayerTree. |
| 265 LayerTreeHost(InitParams* params, | 246 LayerTreeHostInProcess(InitParams* params, |
| 266 CompositorMode mode, | 247 CompositorMode mode, |
| 267 std::unique_ptr<LayerTree> layer_tree); | 248 std::unique_ptr<LayerTree> layer_tree); |
| 268 LayerTreeHost(InitParams* params, CompositorMode mode); | 249 LayerTreeHostInProcess(InitParams* params, CompositorMode mode); |
| 269 | 250 |
| 270 void InitializeThreaded( | 251 void InitializeThreaded( |
| 271 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 252 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 272 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 253 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 273 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 254 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 274 void InitializeSingleThreaded( | 255 void InitializeSingleThreaded( |
| 275 LayerTreeHostSingleThreadClient* single_thread_client, | 256 LayerTreeHostSingleThreadClient* single_thread_client, |
| 276 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 257 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 277 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 258 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 278 void InitializeRemoteServer( | 259 void InitializeRemoteServer( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 358 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 378 TaskGraphRunner* task_graph_runner_; | 359 TaskGraphRunner* task_graph_runner_; |
| 379 | 360 |
| 380 ImageSerializationProcessor* image_serialization_processor_; | 361 ImageSerializationProcessor* image_serialization_processor_; |
| 381 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 362 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
| 382 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 363 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
| 383 | 364 |
| 384 SurfaceSequenceGenerator surface_sequence_generator_; | 365 SurfaceSequenceGenerator surface_sequence_generator_; |
| 385 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 366 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 386 | 367 |
| 387 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 368 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostInProcess); |
| 388 }; | 369 }; |
| 389 | 370 |
| 390 } // namespace cc | 371 } // namespace cc |
| 391 | 372 |
| 392 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 373 #endif // CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_ |
| OLD | NEW |