| 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_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "cc/output/output_surface.h" | 36 #include "cc/output/output_surface.h" |
| 37 #include "cc/output/renderer_capabilities.h" | 37 #include "cc/output/renderer_capabilities.h" |
| 38 #include "cc/output/swap_promise.h" | 38 #include "cc/output/swap_promise.h" |
| 39 #include "cc/resources/resource_format.h" | 39 #include "cc/resources/resource_format.h" |
| 40 #include "cc/resources/scoped_ui_resource.h" | 40 #include "cc/resources/scoped_ui_resource.h" |
| 41 #include "cc/surfaces/surface_sequence.h" | 41 #include "cc/surfaces/surface_sequence.h" |
| 42 #include "cc/trees/compositor_mode.h" | 42 #include "cc/trees/compositor_mode.h" |
| 43 #include "cc/trees/layer_tree.h" | 43 #include "cc/trees/layer_tree.h" |
| 44 #include "cc/trees/layer_tree_host_client.h" | 44 #include "cc/trees/layer_tree_host_client.h" |
| 45 #include "cc/trees/layer_tree_settings.h" | 45 #include "cc/trees/layer_tree_settings.h" |
| 46 #include "cc/trees/mutator_host_client.h" | |
| 47 #include "cc/trees/proxy.h" | 46 #include "cc/trees/proxy.h" |
| 48 #include "cc/trees/swap_promise_monitor.h" | 47 #include "cc/trees/swap_promise_monitor.h" |
| 49 #include "third_party/skia/include/core/SkColor.h" | 48 #include "third_party/skia/include/core/SkColor.h" |
| 50 #include "ui/gfx/geometry/rect.h" | 49 #include "ui/gfx/geometry/rect.h" |
| 51 | 50 |
| 52 namespace gpu { | 51 namespace gpu { |
| 53 class GpuMemoryBufferManager; | 52 class GpuMemoryBufferManager; |
| 54 } | 53 } |
| 55 | 54 |
| 56 namespace cc { | 55 namespace cc { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 class TopControlsManager; | 75 class TopControlsManager; |
| 77 class UIResourceRequest; | 76 class UIResourceRequest; |
| 78 struct PendingPageScaleAnimation; | 77 struct PendingPageScaleAnimation; |
| 79 struct RenderingStats; | 78 struct RenderingStats; |
| 80 struct ScrollAndScaleSet; | 79 struct ScrollAndScaleSet; |
| 81 | 80 |
| 82 namespace proto { | 81 namespace proto { |
| 83 class LayerTreeHost; | 82 class LayerTreeHost; |
| 84 } | 83 } |
| 85 | 84 |
| 86 class CC_EXPORT LayerTreeHost : public MutatorHostClient { | 85 class CC_EXPORT LayerTreeHost { |
| 87 public: | 86 public: |
| 88 // TODO(sad): InitParams should be a movable type so that it can be | 87 // TODO(sad): InitParams should be a movable type so that it can be |
| 89 // std::move()d to the Create* functions. | 88 // std::move()d to the Create* functions. |
| 90 struct CC_EXPORT InitParams { | 89 struct CC_EXPORT InitParams { |
| 91 LayerTreeHostClient* client = nullptr; | 90 LayerTreeHostClient* client = nullptr; |
| 92 SharedBitmapManager* shared_bitmap_manager = nullptr; | 91 SharedBitmapManager* shared_bitmap_manager = nullptr; |
| 93 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; | 92 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; |
| 94 TaskGraphRunner* task_graph_runner = nullptr; | 93 TaskGraphRunner* task_graph_runner = nullptr; |
| 95 LayerTreeSettings const* settings = nullptr; | 94 LayerTreeSettings const* settings = nullptr; |
| 96 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; | 95 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures | 120 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures |
| 122 // that the client will not send any compositor messages once the | 121 // that the client will not send any compositor messages once the |
| 123 // LayerTreeHost on the server is destroyed. | 122 // LayerTreeHost on the server is destroyed. |
| 124 static std::unique_ptr<LayerTreeHost> CreateRemoteClient( | 123 static std::unique_ptr<LayerTreeHost> CreateRemoteClient( |
| 125 RemoteProtoChannel* remote_proto_channel, | 124 RemoteProtoChannel* remote_proto_channel, |
| 126 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 125 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 127 InitParams* params); | 126 InitParams* params); |
| 128 | 127 |
| 129 virtual ~LayerTreeHost(); | 128 virtual ~LayerTreeHost(); |
| 130 | 129 |
| 131 // LayerTreeHost interface to Proxy | 130 // LayerTreeHost interface to Proxy. |
| 132 void WillBeginMainFrame(); | 131 void WillBeginMainFrame(); |
| 133 void DidBeginMainFrame(); | 132 void DidBeginMainFrame(); |
| 134 void BeginMainFrame(const BeginFrameArgs& args); | 133 void BeginMainFrame(const BeginFrameArgs& args); |
| 135 void BeginMainFrameNotExpectedSoon(); | 134 void BeginMainFrameNotExpectedSoon(); |
| 136 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); | 135 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); |
| 137 void DidStopFlinging(); | 136 void DidStopFlinging(); |
| 138 void RequestMainFrameUpdate(); | 137 void RequestMainFrameUpdate(); |
| 139 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); | 138 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); |
| 140 void WillCommit(); | 139 void WillCommit(); |
| 141 void CommitComplete(); | 140 void CommitComplete(); |
| 142 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface); | 141 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface); |
| 143 std::unique_ptr<OutputSurface> ReleaseOutputSurface(); | 142 std::unique_ptr<OutputSurface> ReleaseOutputSurface(); |
| 144 void RequestNewOutputSurface(); | 143 void RequestNewOutputSurface(); |
| 145 void DidInitializeOutputSurface(); | 144 void DidInitializeOutputSurface(); |
| 146 void DidFailToInitializeOutputSurface(); | 145 void DidFailToInitializeOutputSurface(); |
| 147 virtual std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 146 virtual std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 148 LayerTreeHostImplClient* client); | 147 LayerTreeHostImplClient* client); |
| 149 void DidLoseOutputSurface(); | 148 void DidLoseOutputSurface(); |
| 150 bool output_surface_lost() const { return output_surface_lost_; } | 149 bool output_surface_lost() const { return output_surface_lost_; } |
| 151 void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } | 150 void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } |
| 152 void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } | 151 void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } |
| 153 bool UpdateLayers(); | 152 bool UpdateLayers(); |
| 154 // Called when the compositor completed page scale animation. | 153 // Called when the compositor completed page scale animation. |
| 155 void DidCompletePageScaleAnimation(); | 154 void DidCompletePageScaleAnimation(); |
| 156 | 155 |
| 157 LayerListIterator<Layer> begin() const; | |
| 158 LayerListIterator<Layer> end() const; | |
| 159 LayerListReverseIterator<Layer> rbegin(); | |
| 160 LayerListReverseIterator<Layer> rend(); | |
| 161 | |
| 162 LayerTreeHostClient* client() { return client_; } | 156 LayerTreeHostClient* client() { return client_; } |
| 163 const base::WeakPtr<InputHandler>& GetInputHandler() { | 157 const base::WeakPtr<InputHandler>& GetInputHandler() { |
| 164 return input_handler_weak_ptr_; | 158 return input_handler_weak_ptr_; |
| 165 } | 159 } |
| 166 | 160 |
| 167 void NotifyInputThrottledUntilCommit(); | 161 void NotifyInputThrottledUntilCommit(); |
| 168 | 162 |
| 169 void LayoutAndUpdateLayers(); | 163 void LayoutAndUpdateLayers(); |
| 170 void Composite(base::TimeTicks frame_begin_time); | 164 void Composite(base::TimeTicks frame_begin_time); |
| 171 | 165 |
| 172 void SetDeferCommits(bool defer_commits); | 166 void SetDeferCommits(bool defer_commits); |
| 173 | 167 |
| 174 int source_frame_number() const { return source_frame_number_; } | 168 int source_frame_number() const { return source_frame_number_; } |
| 175 | 169 |
| 176 bool gpu_rasterization_histogram_recorded() const { | 170 bool gpu_rasterization_histogram_recorded() const { |
| 177 return gpu_rasterization_histogram_recorded_; | 171 return gpu_rasterization_histogram_recorded_; |
| 178 } | 172 } |
| 179 | 173 |
| 180 void SetNeedsDisplayOnAllLayers(); | |
| 181 | |
| 182 void CollectRenderingStats(RenderingStats* stats) const; | 174 void CollectRenderingStats(RenderingStats* stats) const; |
| 183 | 175 |
| 184 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { | 176 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { |
| 185 return rendering_stats_instrumentation_.get(); | 177 return rendering_stats_instrumentation_.get(); |
| 186 } | 178 } |
| 187 | 179 |
| 188 virtual const RendererCapabilities& GetRendererCapabilities() const; | 180 virtual const RendererCapabilities& GetRendererCapabilities() const; |
| 189 | 181 |
| 190 void SetNeedsAnimate(); | 182 void SetNeedsAnimate(); |
| 191 virtual void SetNeedsUpdateLayers(); | 183 virtual void SetNeedsUpdateLayers(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); | 260 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); |
| 269 std::vector<std::unique_ptr<SwapPromise>> TakeSwapPromises(); | 261 std::vector<std::unique_ptr<SwapPromise>> TakeSwapPromises(); |
| 270 | 262 |
| 271 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } | 263 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } |
| 272 | 264 |
| 273 void set_surface_client_id(uint32_t client_id); | 265 void set_surface_client_id(uint32_t client_id); |
| 274 SurfaceSequence CreateSurfaceSequence(); | 266 SurfaceSequence CreateSurfaceSequence(); |
| 275 | 267 |
| 276 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); | 268 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); |
| 277 | 269 |
| 278 Layer* LayerById(int id) const; | |
| 279 | |
| 280 Layer* LayerByElementId(ElementId element_id) const; | |
| 281 void AddToElementMap(Layer* layer); | |
| 282 void RemoveFromElementMap(Layer* layer); | |
| 283 | |
| 284 // MutatorHostClient implementation. | |
| 285 bool IsElementInList(ElementId element_id, | |
| 286 ElementListType list_type) const override; | |
| 287 void SetMutatorsNeedCommit() override; | |
| 288 void SetMutatorsNeedRebuildPropertyTrees() override; | |
| 289 void SetElementFilterMutated(ElementId element_id, | |
| 290 ElementListType list_type, | |
| 291 const FilterOperations& filters) override; | |
| 292 void SetElementOpacityMutated(ElementId element_id, | |
| 293 ElementListType list_type, | |
| 294 float opacity) override; | |
| 295 void SetElementTransformMutated(ElementId element_id, | |
| 296 ElementListType list_type, | |
| 297 const gfx::Transform& transform) override; | |
| 298 void SetElementScrollOffsetMutated( | |
| 299 ElementId element_id, | |
| 300 ElementListType list_type, | |
| 301 const gfx::ScrollOffset& scroll_offset) override; | |
| 302 void ElementTransformIsAnimatingChanged(ElementId element_id, | |
| 303 ElementListType list_type, | |
| 304 AnimationChangeType change_type, | |
| 305 bool is_animating) override; | |
| 306 void ElementOpacityIsAnimatingChanged(ElementId element_id, | |
| 307 ElementListType list_type, | |
| 308 AnimationChangeType change_type, | |
| 309 bool is_animating) override; | |
| 310 void ElementFilterIsAnimatingChanged(ElementId element_id, | |
| 311 ElementListType list_type, | |
| 312 AnimationChangeType change_type, | |
| 313 bool is_animating) override; | |
| 314 void ScrollOffsetAnimationFinished() override {} | |
| 315 gfx::ScrollOffset GetScrollOffsetForAnimation( | |
| 316 ElementId element_id) const override; | |
| 317 | |
| 318 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | 270 // Serializes the parts of this LayerTreeHost that is needed for a commit to a |
| 319 // protobuf message. Not all members are serialized as they are not helpful | 271 // protobuf message. Not all members are serialized as they are not helpful |
| 320 // for remote usage. | 272 // for remote usage. |
| 321 // The |swap_promise_list_| is transferred to the serializer in | 273 // The |swap_promise_list_| is transferred to the serializer in |
| 322 // |swap_promises|. | 274 // |swap_promises|. |
| 323 void ToProtobufForCommit( | 275 void ToProtobufForCommit( |
| 324 proto::LayerTreeHost* proto, | 276 proto::LayerTreeHost* proto, |
| 325 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | 277 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); |
| 326 | 278 |
| 327 // Deserializes the protobuf into this LayerTreeHost before a commit. The | 279 // Deserializes the protobuf into this LayerTreeHost before a commit. The |
| 328 // expected input is a serialized remote LayerTreeHost. After deserializing | 280 // expected input is a serialized remote LayerTreeHost. After deserializing |
| 329 // the protobuf, the normal commit-flow should continue. | 281 // the protobuf, the normal commit-flow should continue. |
| 330 void FromProtobufForCommit(const proto::LayerTreeHost& proto); | 282 void FromProtobufForCommit(const proto::LayerTreeHost& proto); |
| 331 | 283 |
| 332 bool IsSingleThreaded() const; | 284 bool IsSingleThreaded() const; |
| 333 bool IsThreaded() const; | 285 bool IsThreaded() const; |
| 334 bool IsRemoteServer() const; | 286 bool IsRemoteServer() const; |
| 335 bool IsRemoteClient() const; | 287 bool IsRemoteClient() const; |
| 336 void BuildPropertyTreesForTesting(); | 288 void BuildPropertyTreesForTesting(); |
| 337 | 289 |
| 338 void SetElementIdsForTesting(); | |
| 339 | |
| 340 ImageSerializationProcessor* image_serialization_processor() const { | 290 ImageSerializationProcessor* image_serialization_processor() const { |
| 341 return image_serialization_processor_; | 291 return image_serialization_processor_; |
| 342 } | 292 } |
| 343 | 293 |
| 344 EnginePictureCache* engine_picture_cache() const { | 294 EnginePictureCache* engine_picture_cache() const { |
| 345 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 295 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
| 346 } | 296 } |
| 347 | 297 |
| 348 ClientPictureCache* client_picture_cache() const { | 298 ClientPictureCache* client_picture_cache() const { |
| 349 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 299 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 435 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 486 TaskGraphRunner* task_graph_runner_; | 436 TaskGraphRunner* task_graph_runner_; |
| 487 | 437 |
| 488 ImageSerializationProcessor* image_serialization_processor_; | 438 ImageSerializationProcessor* image_serialization_processor_; |
| 489 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 439 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
| 490 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 440 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
| 491 | 441 |
| 492 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; | 442 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
| 493 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 443 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
| 494 | 444 |
| 495 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; | |
| 496 ElementLayersMap element_layers_map_; | |
| 497 | |
| 498 uint32_t surface_client_id_; | 445 uint32_t surface_client_id_; |
| 499 uint32_t next_surface_sequence_; | 446 uint32_t next_surface_sequence_; |
| 500 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 447 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 501 | 448 |
| 502 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 449 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 503 }; | 450 }; |
| 504 | 451 |
| 505 } // namespace cc | 452 } // namespace cc |
| 506 | 453 |
| 507 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 454 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
| OLD | NEW |