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 22 matching lines...) Expand all Loading... |
33 #include "cc/input/top_controls_state.h" | 33 #include "cc/input/top_controls_state.h" |
34 #include "cc/layers/layer_collections.h" | 34 #include "cc/layers/layer_collections.h" |
35 #include "cc/layers/layer_list_iterator.h" | 35 #include "cc/layers/layer_list_iterator.h" |
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_host_client.h" | 44 #include "cc/trees/layer_tree_host_client.h" |
44 #include "cc/trees/layer_tree_settings.h" | 45 #include "cc/trees/layer_tree_settings.h" |
45 #include "cc/trees/mutator_host_client.h" | 46 #include "cc/trees/mutator_host_client.h" |
46 #include "cc/trees/proxy.h" | 47 #include "cc/trees/proxy.h" |
47 #include "cc/trees/swap_promise_monitor.h" | 48 #include "cc/trees/swap_promise_monitor.h" |
48 #include "third_party/skia/include/core/SkColor.h" | 49 #include "third_party/skia/include/core/SkColor.h" |
49 #include "ui/gfx/geometry/rect.h" | 50 #include "ui/gfx/geometry/rect.h" |
50 | 51 |
51 namespace gpu { | 52 namespace gpu { |
52 class GpuMemoryBufferManager; | 53 class GpuMemoryBufferManager; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 void UpdateTopControlsState(TopControlsState constraints, | 289 void UpdateTopControlsState(TopControlsState constraints, |
289 TopControlsState current, | 290 TopControlsState current, |
290 bool animate); | 291 bool animate); |
291 | 292 |
292 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } | 293 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } |
293 | 294 |
294 Proxy* proxy() const { return proxy_.get(); } | 295 Proxy* proxy() const { return proxy_.get(); } |
295 TaskRunnerProvider* task_runner_provider() const { | 296 TaskRunnerProvider* task_runner_provider() const { |
296 return task_runner_provider_.get(); | 297 return task_runner_provider_.get(); |
297 } | 298 } |
298 AnimationHost* animation_host() const { return animation_host_.get(); } | 299 AnimationHost* animation_host() const; |
299 | |
300 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | |
301 | 300 |
302 // CreateUIResource creates a resource given a bitmap. The bitmap is | 301 // CreateUIResource creates a resource given a bitmap. The bitmap is |
303 // generated via an interface function, which is called when initializing the | 302 // generated via an interface function, which is called when initializing the |
304 // resource and when the resource has been lost (due to lost context). The | 303 // resource and when the resource has been lost (due to lost context). The |
305 // parameter of the interface is a single boolean, which indicates whether the | 304 // parameter of the interface is a single boolean, which indicates whether the |
306 // resource has been lost or not. CreateUIResource returns an Id of the | 305 // resource has been lost or not. CreateUIResource returns an Id of the |
307 // resource, which is always positive. | 306 // resource, which is always positive. |
308 virtual UIResourceId CreateUIResource(UIResourceClient* client); | 307 virtual UIResourceId CreateUIResource(UIResourceClient* client); |
309 // Deletes a UI resource. May safely be called more than once. | 308 // Deletes a UI resource. May safely be called more than once. |
310 virtual void DeleteUIResource(UIResourceId id); | 309 virtual void DeleteUIResource(UIResourceId id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 347 } |
349 | 348 |
350 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); | 349 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); |
351 | 350 |
352 Layer* LayerById(int id) const; | 351 Layer* LayerById(int id) const; |
353 | 352 |
354 Layer* LayerByElementId(ElementId element_id) const; | 353 Layer* LayerByElementId(ElementId element_id) const; |
355 void AddToElementMap(Layer* layer); | 354 void AddToElementMap(Layer* layer); |
356 void RemoveFromElementMap(Layer* layer); | 355 void RemoveFromElementMap(Layer* layer); |
357 | 356 |
358 void AddLayerShouldPushProperties(Layer* layer); | |
359 void RemoveLayerShouldPushProperties(Layer* layer); | |
360 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); | |
361 bool LayerNeedsPushPropertiesForTesting(Layer* layer); | 357 bool LayerNeedsPushPropertiesForTesting(Layer* layer); |
362 | 358 |
363 void RegisterLayer(Layer* layer); | |
364 void UnregisterLayer(Layer* layer); | |
365 // MutatorHostClient implementation. | 359 // MutatorHostClient implementation. |
366 bool IsElementInList(ElementId element_id, | 360 bool IsElementInList(ElementId element_id, |
367 ElementListType list_type) const override; | 361 ElementListType list_type) const override; |
368 void SetMutatorsNeedCommit() override; | 362 void SetMutatorsNeedCommit() override; |
369 void SetMutatorsNeedRebuildPropertyTrees() override; | 363 void SetMutatorsNeedRebuildPropertyTrees() override; |
370 void SetElementFilterMutated(ElementId element_id, | 364 void SetElementFilterMutated(ElementId element_id, |
371 ElementListType list_type, | 365 ElementListType list_type, |
372 const FilterOperations& filters) override; | 366 const FilterOperations& filters) override; |
373 void SetElementOpacityMutated(ElementId element_id, | 367 void SetElementOpacityMutated(ElementId element_id, |
374 ElementListType list_type, | 368 ElementListType list_type, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 413 } |
420 | 414 |
421 EnginePictureCache* engine_picture_cache() const { | 415 EnginePictureCache* engine_picture_cache() const { |
422 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | 416 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; |
423 } | 417 } |
424 | 418 |
425 ClientPictureCache* client_picture_cache() const { | 419 ClientPictureCache* client_picture_cache() const { |
426 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | 420 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; |
427 } | 421 } |
428 | 422 |
| 423 LayerTree* GetLayerTree() { return &layer_tree_; } |
| 424 const LayerTree* GetLayerTree() const { return &layer_tree_; } |
| 425 |
429 protected: | 426 protected: |
430 LayerTreeHost(InitParams* params, CompositorMode mode); | 427 LayerTreeHost(InitParams* params, CompositorMode mode); |
431 void InitializeThreaded( | 428 void InitializeThreaded( |
432 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 429 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
433 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 430 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
434 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 431 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
435 void InitializeSingleThreaded( | 432 void InitializeSingleThreaded( |
436 LayerTreeHostSingleThreadClient* single_thread_client, | 433 LayerTreeHostSingleThreadClient* single_thread_client, |
437 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 434 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
438 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 435 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 bool content_is_suitable_for_gpu_rasterization_; | 550 bool content_is_suitable_for_gpu_rasterization_; |
554 bool gpu_rasterization_histogram_recorded_; | 551 bool gpu_rasterization_histogram_recorded_; |
555 | 552 |
556 SkColor background_color_; | 553 SkColor background_color_; |
557 bool has_transparent_background_; | 554 bool has_transparent_background_; |
558 | 555 |
559 bool have_scroll_event_handlers_; | 556 bool have_scroll_event_handlers_; |
560 EventListenerProperties event_listener_properties_[static_cast<size_t>( | 557 EventListenerProperties event_listener_properties_[static_cast<size_t>( |
561 EventListenerClass::kNumClasses)]; | 558 EventListenerClass::kNumClasses)]; |
562 | 559 |
563 std::unique_ptr<AnimationHost> animation_host_; | |
564 | |
565 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 560 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
566 | 561 |
567 // If set, then page scale animation has completed, but the client hasn't been | 562 // If set, then page scale animation has completed, but the client hasn't been |
568 // notified about it yet. | 563 // notified about it yet. |
569 bool did_complete_scale_animation_; | 564 bool did_complete_scale_animation_; |
570 | 565 |
571 bool in_paint_layer_contents_; | |
572 | |
573 int id_; | 566 int id_; |
574 bool next_commit_forces_redraw_; | 567 bool next_commit_forces_redraw_; |
575 | 568 |
576 scoped_refptr<Layer> overscroll_elasticity_layer_; | 569 scoped_refptr<Layer> overscroll_elasticity_layer_; |
577 scoped_refptr<Layer> page_scale_layer_; | 570 scoped_refptr<Layer> page_scale_layer_; |
578 scoped_refptr<Layer> inner_viewport_scroll_layer_; | 571 scoped_refptr<Layer> inner_viewport_scroll_layer_; |
579 scoped_refptr<Layer> outer_viewport_scroll_layer_; | 572 scoped_refptr<Layer> outer_viewport_scroll_layer_; |
580 | 573 |
581 LayerSelection selection_; | 574 LayerSelection selection_; |
582 | 575 |
583 SharedBitmapManager* shared_bitmap_manager_; | 576 SharedBitmapManager* shared_bitmap_manager_; |
584 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 577 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
585 TaskGraphRunner* task_graph_runner_; | 578 TaskGraphRunner* task_graph_runner_; |
586 | 579 |
587 ImageSerializationProcessor* image_serialization_processor_; | 580 ImageSerializationProcessor* image_serialization_processor_; |
588 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 581 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
589 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 582 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
590 | 583 |
591 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; | 584 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
592 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 585 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
593 | 586 |
594 PropertyTrees property_trees_; | 587 PropertyTrees property_trees_; |
595 | 588 |
596 using LayerIdMap = std::unordered_map<int, Layer*>; | |
597 LayerIdMap layer_id_map_; | |
598 | |
599 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; | 589 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; |
600 ElementLayersMap element_layers_map_; | 590 ElementLayersMap element_layers_map_; |
601 | 591 |
602 // Set of layers that need to push properties. | |
603 std::unordered_set<Layer*> layers_that_should_push_properties_; | |
604 | |
605 uint32_t surface_client_id_; | 592 uint32_t surface_client_id_; |
606 uint32_t next_surface_sequence_; | 593 uint32_t next_surface_sequence_; |
607 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 594 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
608 | 595 |
| 596 // Layer tree that hold layers. |
| 597 LayerTree layer_tree_; |
| 598 |
609 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 599 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
610 }; | 600 }; |
611 | 601 |
612 } // namespace cc | 602 } // namespace cc |
613 | 603 |
614 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 604 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |