| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 344 |
| 346 PropertyTrees* property_trees() { return &property_trees_; } | 345 PropertyTrees* property_trees() { return &property_trees_; } |
| 347 bool needs_meta_info_recomputation() { | 346 bool needs_meta_info_recomputation() { |
| 348 return needs_meta_info_recomputation_; | 347 return needs_meta_info_recomputation_; |
| 349 } | 348 } |
| 350 | 349 |
| 351 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); | 350 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); |
| 352 | 351 |
| 353 Layer* LayerById(int id) const; | 352 Layer* LayerById(int id) const; |
| 354 | 353 |
| 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 | 354 // 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 | 355 // protobuf message. Not all members are serialized as they are not helpful |
| 395 // for remote usage. | 356 // for remote usage. |
| 396 // The |swap_promise_list_| is transferred to the serializer in | 357 // The |swap_promise_list_| is transferred to the serializer in |
| 397 // |swap_promises|. | 358 // |swap_promises|. |
| 398 void ToProtobufForCommit( | 359 void ToProtobufForCommit( |
| 399 proto::LayerTreeHost* proto, | 360 proto::LayerTreeHost* proto, |
| 400 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | 361 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); |
| 401 | 362 |
| 402 // Deserializes the protobuf into this LayerTreeHost before a commit. The | 363 // Deserializes the protobuf into this LayerTreeHost before a commit. The |
| (...skipping 14 matching lines...) Expand all Loading... |
| 417 } | 378 } |
| 418 | 379 |
| 419 EnginePictureCache* engine_picture_cache() const { | 380 EnginePictureCache* engine_picture_cache() const { |
| 420 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 381 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
| 421 } | 382 } |
| 422 | 383 |
| 423 ClientPictureCache* client_picture_cache() const { | 384 ClientPictureCache* client_picture_cache() const { |
| 424 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 385 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
| 425 } | 386 } |
| 426 | 387 |
| 427 LayerTree* GetLayerTree() { return &layer_tree_; } | 388 LayerTree* GetLayerTree() { return layer_tree_.get(); } |
| 428 const LayerTree* GetLayerTree() const { return &layer_tree_; } | 389 const LayerTree* GetLayerTree() const { return layer_tree_.get(); } |
| 429 | 390 |
| 430 protected: | 391 protected: |
| 431 LayerTreeHost(InitParams* params, CompositorMode mode); | 392 LayerTreeHost(InitParams* params, CompositorMode mode); |
| 432 void InitializeThreaded( | 393 void InitializeThreaded( |
| 433 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 394 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 434 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 395 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 435 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 396 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 436 void InitializeSingleThreaded( | 397 void InitializeSingleThreaded( |
| 437 LayerTreeHostSingleThreadClient* single_thread_client, | 398 LayerTreeHostSingleThreadClient* single_thread_client, |
| 438 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 399 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 545 |
| 585 ImageSerializationProcessor* image_serialization_processor_; | 546 ImageSerializationProcessor* image_serialization_processor_; |
| 586 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 547 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
| 587 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 548 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
| 588 | 549 |
| 589 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; | 550 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
| 590 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 551 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
| 591 | 552 |
| 592 PropertyTrees property_trees_; | 553 PropertyTrees property_trees_; |
| 593 | 554 |
| 594 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; | |
| 595 ElementLayersMap element_layers_map_; | |
| 596 | |
| 597 uint32_t surface_client_id_; | 555 uint32_t surface_client_id_; |
| 598 uint32_t next_surface_sequence_; | 556 uint32_t next_surface_sequence_; |
| 599 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 557 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 600 | 558 |
| 601 // Layer tree that hold layers. | 559 // Layer tree that hold layers. |
| 602 LayerTree layer_tree_; | 560 std::unique_ptr<LayerTree> layer_tree_; |
| 603 | 561 |
| 604 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 562 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 605 }; | 563 }; |
| 606 | 564 |
| 607 } // namespace cc | 565 } // namespace cc |
| 608 | 566 |
| 609 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 567 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
| OLD | NEW |