| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 153 |
| 155 LayerListIterator<Layer> begin() const; | |
| 156 LayerListIterator<Layer> end() const; | |
| 157 LayerListReverseIterator<Layer> rbegin(); | |
| 158 LayerListReverseIterator<Layer> rend(); | |
| 159 | |
| 160 // Called when the compositor completed page scale animation. | 154 // Called when the compositor completed page scale animation. |
| 161 void DidCompletePageScaleAnimation(); | 155 void DidCompletePageScaleAnimation(); |
| 162 | 156 |
| 163 LayerTreeHostClient* client() { return client_; } | 157 LayerTreeHostClient* client() { return client_; } |
| 164 const base::WeakPtr<InputHandler>& GetInputHandler() { | 158 const base::WeakPtr<InputHandler>& GetInputHandler() { |
| 165 return input_handler_weak_ptr_; | 159 return input_handler_weak_ptr_; |
| 166 } | 160 } |
| 167 | 161 |
| 168 void NotifyInputThrottledUntilCommit(); | 162 void NotifyInputThrottledUntilCommit(); |
| 169 | 163 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 void UpdateTopControlsState(TopControlsState constraints, | 283 void UpdateTopControlsState(TopControlsState constraints, |
| 290 TopControlsState current, | 284 TopControlsState current, |
| 291 bool animate); | 285 bool animate); |
| 292 | 286 |
| 293 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } | 287 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } |
| 294 | 288 |
| 295 Proxy* proxy() const { return proxy_.get(); } | 289 Proxy* proxy() const { return proxy_.get(); } |
| 296 TaskRunnerProvider* task_runner_provider() const { | 290 TaskRunnerProvider* task_runner_provider() const { |
| 297 return task_runner_provider_.get(); | 291 return task_runner_provider_.get(); |
| 298 } | 292 } |
| 299 AnimationHost* animation_host() const; | |
| 300 | 293 |
| 301 bool has_output_surface() const { return !!current_output_surface_; } | 294 bool has_output_surface() const { return !!current_output_surface_; } |
| 302 | 295 |
| 303 // CreateUIResource creates a resource given a bitmap. The bitmap is | 296 // CreateUIResource creates a resource given a bitmap. The bitmap is |
| 304 // generated via an interface function, which is called when initializing the | 297 // generated via an interface function, which is called when initializing the |
| 305 // resource and when the resource has been lost (due to lost context). The | 298 // resource and when the resource has been lost (due to lost context). The |
| 306 // parameter of the interface is a single boolean, which indicates whether the | 299 // parameter of the interface is a single boolean, which indicates whether the |
| 307 // resource has been lost or not. CreateUIResource returns an Id of the | 300 // resource has been lost or not. CreateUIResource returns an Id of the |
| 308 // resource, which is always positive. | 301 // resource, which is always positive. |
| 309 virtual UIResourceId CreateUIResource(UIResourceClient* client); | 302 virtual UIResourceId CreateUIResource(UIResourceClient* client); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 void set_surface_client_id(uint32_t client_id); | 336 void set_surface_client_id(uint32_t client_id); |
| 344 SurfaceSequence CreateSurfaceSequence(); | 337 SurfaceSequence CreateSurfaceSequence(); |
| 345 | 338 |
| 346 PropertyTrees* property_trees() { return &property_trees_; } | 339 PropertyTrees* property_trees() { return &property_trees_; } |
| 347 bool needs_meta_info_recomputation() { | 340 bool needs_meta_info_recomputation() { |
| 348 return needs_meta_info_recomputation_; | 341 return needs_meta_info_recomputation_; |
| 349 } | 342 } |
| 350 | 343 |
| 351 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); | 344 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); |
| 352 | 345 |
| 353 Layer* LayerById(int id) const; | |
| 354 | |
| 355 Layer* LayerByElementId(ElementId element_id) const; | |
| 356 void AddToElementMap(Layer* layer); | |
| 357 void RemoveFromElementMap(Layer* layer); | |
| 358 | |
| 359 // MutatorHostClient implementation. | |
| 360 bool IsElementInList(ElementId element_id, | |
| 361 ElementListType list_type) const override; | |
| 362 void SetMutatorsNeedCommit() override; | |
| 363 void SetMutatorsNeedRebuildPropertyTrees() override; | |
| 364 void SetElementFilterMutated(ElementId element_id, | |
| 365 ElementListType list_type, | |
| 366 const FilterOperations& filters) override; | |
| 367 void SetElementOpacityMutated(ElementId element_id, | |
| 368 ElementListType list_type, | |
| 369 float opacity) override; | |
| 370 void SetElementTransformMutated(ElementId element_id, | |
| 371 ElementListType list_type, | |
| 372 const gfx::Transform& transform) override; | |
| 373 void SetElementScrollOffsetMutated( | |
| 374 ElementId element_id, | |
| 375 ElementListType list_type, | |
| 376 const gfx::ScrollOffset& scroll_offset) override; | |
| 377 void ElementTransformIsAnimatingChanged(ElementId element_id, | |
| 378 ElementListType list_type, | |
| 379 AnimationChangeType change_type, | |
| 380 bool is_animating) override; | |
| 381 void ElementOpacityIsAnimatingChanged(ElementId element_id, | |
| 382 ElementListType list_type, | |
| 383 AnimationChangeType change_type, | |
| 384 bool is_animating) override; | |
| 385 void ElementFilterIsAnimatingChanged(ElementId element_id, | |
| 386 ElementListType list_type, | |
| 387 AnimationChangeType change_type, | |
| 388 bool is_animating) override; | |
| 389 void ScrollOffsetAnimationFinished() override {} | |
| 390 gfx::ScrollOffset GetScrollOffsetForAnimation( | |
| 391 ElementId element_id) const override; | |
| 392 | |
| 393 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | 346 // Serializes the parts of this LayerTreeHost that is needed for a commit to a |
| 394 // protobuf message. Not all members are serialized as they are not helpful | 347 // protobuf message. Not all members are serialized as they are not helpful |
| 395 // for remote usage. | 348 // for remote usage. |
| 396 // The |swap_promise_list_| is transferred to the serializer in | 349 // The |swap_promise_list_| is transferred to the serializer in |
| 397 // |swap_promises|. | 350 // |swap_promises|. |
| 398 void ToProtobufForCommit( | 351 void ToProtobufForCommit( |
| 399 proto::LayerTreeHost* proto, | 352 proto::LayerTreeHost* proto, |
| 400 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | 353 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); |
| 401 | 354 |
| 402 // Deserializes the protobuf into this LayerTreeHost before a commit. The | 355 // Deserializes the protobuf into this LayerTreeHost before a commit. The |
| (...skipping 14 matching lines...) Expand all Loading... |
| 417 } | 370 } |
| 418 | 371 |
| 419 EnginePictureCache* engine_picture_cache() const { | 372 EnginePictureCache* engine_picture_cache() const { |
| 420 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 373 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
| 421 } | 374 } |
| 422 | 375 |
| 423 ClientPictureCache* client_picture_cache() const { | 376 ClientPictureCache* client_picture_cache() const { |
| 424 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 377 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
| 425 } | 378 } |
| 426 | 379 |
| 427 LayerTree* GetLayerTree() { return &layer_tree_; } | 380 LayerTree* GetLayerTree() { return layer_tree_.get(); } |
| 428 const LayerTree* GetLayerTree() const { return &layer_tree_; } | 381 const LayerTree* GetLayerTree() const { return layer_tree_.get(); } |
| 429 | 382 |
| 430 protected: | 383 protected: |
| 431 LayerTreeHost(InitParams* params, CompositorMode mode); | 384 LayerTreeHost(InitParams* params, CompositorMode mode); |
| 432 void InitializeThreaded( | 385 void InitializeThreaded( |
| 433 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 386 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 434 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 387 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 435 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 388 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 436 void InitializeSingleThreaded( | 389 void InitializeSingleThreaded( |
| 437 LayerTreeHostSingleThreadClient* single_thread_client, | 390 LayerTreeHostSingleThreadClient* single_thread_client, |
| 438 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 391 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 537 |
| 585 ImageSerializationProcessor* image_serialization_processor_; | 538 ImageSerializationProcessor* image_serialization_processor_; |
| 586 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 539 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
| 587 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 540 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
| 588 | 541 |
| 589 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; | 542 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
| 590 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 543 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
| 591 | 544 |
| 592 PropertyTrees property_trees_; | 545 PropertyTrees property_trees_; |
| 593 | 546 |
| 594 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; | |
| 595 ElementLayersMap element_layers_map_; | |
| 596 | |
| 597 uint32_t surface_client_id_; | 547 uint32_t surface_client_id_; |
| 598 uint32_t next_surface_sequence_; | 548 uint32_t next_surface_sequence_; |
| 599 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 549 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 600 | 550 |
| 601 // Layer tree that hold layers. | 551 // Layer tree that hold layers. |
| 602 LayerTree layer_tree_; | 552 std::unique_ptr<LayerTree> layer_tree_; |
| 603 | 553 |
| 604 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 554 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 605 }; | 555 }; |
| 606 | 556 |
| 607 } // namespace cc | 557 } // namespace cc |
| 608 | 558 |
| 609 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 559 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
| OLD | NEW |