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 <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "cc/layers/layer_lists.h" | 31 #include "cc/layers/layer_lists.h" |
32 #include "cc/output/output_surface.h" | 32 #include "cc/output/output_surface.h" |
33 #include "cc/output/renderer_capabilities.h" | 33 #include "cc/output/renderer_capabilities.h" |
34 #include "cc/output/swap_promise.h" | 34 #include "cc/output/swap_promise.h" |
35 #include "cc/resources/resource_format.h" | 35 #include "cc/resources/resource_format.h" |
36 #include "cc/resources/scoped_ui_resource.h" | 36 #include "cc/resources/scoped_ui_resource.h" |
37 #include "cc/surfaces/surface_sequence.h" | 37 #include "cc/surfaces/surface_sequence.h" |
38 #include "cc/trees/layer_tree_host_client.h" | 38 #include "cc/trees/layer_tree_host_client.h" |
39 #include "cc/trees/layer_tree_host_common.h" | 39 #include "cc/trees/layer_tree_host_common.h" |
40 #include "cc/trees/layer_tree_settings.h" | 40 #include "cc/trees/layer_tree_settings.h" |
| 41 #include "cc/trees/mutator_host_client.h" |
41 #include "cc/trees/proxy.h" | 42 #include "cc/trees/proxy.h" |
42 #include "cc/trees/swap_promise_monitor.h" | 43 #include "cc/trees/swap_promise_monitor.h" |
43 #include "third_party/skia/include/core/SkColor.h" | 44 #include "third_party/skia/include/core/SkColor.h" |
44 #include "ui/gfx/geometry/rect.h" | 45 #include "ui/gfx/geometry/rect.h" |
45 | 46 |
46 namespace gpu { | 47 namespace gpu { |
47 class GpuMemoryBufferManager; | 48 class GpuMemoryBufferManager; |
48 } | 49 } |
49 | 50 |
50 namespace cc { | 51 namespace cc { |
51 class AnimationRegistrar; | 52 class AnimationRegistrar; |
| 53 class AnimationHost; |
52 class BeginFrameSource; | 54 class BeginFrameSource; |
53 class HeadsUpDisplayLayer; | 55 class HeadsUpDisplayLayer; |
54 class Layer; | 56 class Layer; |
55 class LayerTreeHostImpl; | 57 class LayerTreeHostImpl; |
56 class LayerTreeHostImplClient; | 58 class LayerTreeHostImplClient; |
57 class LayerTreeHostSingleThreadClient; | 59 class LayerTreeHostSingleThreadClient; |
58 class PropertyTrees; | 60 class PropertyTrees; |
59 class Region; | 61 class Region; |
60 class RenderingStatsInstrumentation; | 62 class RenderingStatsInstrumentation; |
61 class ResourceProvider; | 63 class ResourceProvider; |
62 class ResourceUpdateQueue; | 64 class ResourceUpdateQueue; |
63 class SharedBitmapManager; | 65 class SharedBitmapManager; |
64 class TaskGraphRunner; | 66 class TaskGraphRunner; |
65 class TopControlsManager; | 67 class TopControlsManager; |
66 class UIResourceRequest; | 68 class UIResourceRequest; |
67 struct PendingPageScaleAnimation; | 69 struct PendingPageScaleAnimation; |
68 struct RenderingStats; | 70 struct RenderingStats; |
69 struct ScrollAndScaleSet; | 71 struct ScrollAndScaleSet; |
70 | 72 |
71 class CC_EXPORT LayerTreeHost { | 73 class CC_EXPORT LayerTreeHost : public MutatorHostClient { |
72 public: | 74 public: |
73 // TODO(sad): InitParams should be a movable type so that it can be | 75 // TODO(sad): InitParams should be a movable type so that it can be |
74 // std::move()d to the Create* functions. | 76 // std::move()d to the Create* functions. |
75 struct CC_EXPORT InitParams { | 77 struct CC_EXPORT InitParams { |
76 LayerTreeHostClient* client = nullptr; | 78 LayerTreeHostClient* client = nullptr; |
77 SharedBitmapManager* shared_bitmap_manager = nullptr; | 79 SharedBitmapManager* shared_bitmap_manager = nullptr; |
78 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; | 80 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; |
79 TaskGraphRunner* task_graph_runner = nullptr; | 81 TaskGraphRunner* task_graph_runner = nullptr; |
80 LayerTreeSettings const* settings = nullptr; | 82 LayerTreeSettings const* settings = nullptr; |
81 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; | 83 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 TopControlsState current, | 253 TopControlsState current, |
252 bool animate); | 254 bool animate); |
253 | 255 |
254 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } | 256 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } |
255 | 257 |
256 Proxy* proxy() const { return proxy_.get(); } | 258 Proxy* proxy() const { return proxy_.get(); } |
257 | 259 |
258 AnimationRegistrar* animation_registrar() const { | 260 AnimationRegistrar* animation_registrar() const { |
259 return animation_registrar_.get(); | 261 return animation_registrar_.get(); |
260 } | 262 } |
| 263 AnimationHost* animation_host() const { return animation_host_.get(); } |
261 | 264 |
262 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 265 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
263 | 266 |
264 // CreateUIResource creates a resource given a bitmap. The bitmap is | 267 // CreateUIResource creates a resource given a bitmap. The bitmap is |
265 // generated via an interface function, which is called when initializing the | 268 // generated via an interface function, which is called when initializing the |
266 // resource and when the resource has been lost (due to lost context). The | 269 // resource and when the resource has been lost (due to lost context). The |
267 // parameter of the interface is a single boolean, which indicates whether the | 270 // parameter of the interface is a single boolean, which indicates whether the |
268 // resource has been lost or not. CreateUIResource returns an Id of the | 271 // resource has been lost or not. CreateUIResource returns an Id of the |
269 // resource, which is always positive. | 272 // resource, which is always positive. |
270 virtual UIResourceId CreateUIResource(UIResourceClient* client); | 273 virtual UIResourceId CreateUIResource(UIResourceClient* client); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 314 |
312 PropertyTrees* property_trees() { return &property_trees_; } | 315 PropertyTrees* property_trees() { return &property_trees_; } |
313 bool needs_meta_info_recomputation() { | 316 bool needs_meta_info_recomputation() { |
314 return needs_meta_info_recomputation_; | 317 return needs_meta_info_recomputation_; |
315 } | 318 } |
316 | 319 |
317 void RecordFrameTimingEvents( | 320 void RecordFrameTimingEvents( |
318 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 321 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
319 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | 322 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); |
320 | 323 |
| 324 Layer* LayerById(int id) const; |
| 325 void RegisterLayer(Layer* layer); |
| 326 void UnregisterLayer(Layer* layer); |
| 327 // LayerTreeMutatorsClient implementation. |
| 328 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; |
| 329 void SetMutatorsNeedCommit() override; |
| 330 void SetLayerFilterMutated(int layer_id, |
| 331 LayerTreeType tree_type, |
| 332 const FilterOperations& filters) override; |
| 333 void SetLayerOpacityMutated(int layer_id, |
| 334 LayerTreeType tree_type, |
| 335 float opacity) override; |
| 336 void SetLayerTransformMutated(int layer_id, |
| 337 LayerTreeType tree_type, |
| 338 const gfx::Transform& transform) override; |
| 339 void SetLayerScrollOffsetMutated( |
| 340 int layer_id, |
| 341 LayerTreeType tree_type, |
| 342 const gfx::ScrollOffset& scroll_offset) override; |
| 343 |
321 protected: | 344 protected: |
322 explicit LayerTreeHost(InitParams* params); | 345 explicit LayerTreeHost(InitParams* params); |
323 void InitializeThreaded( | 346 void InitializeThreaded( |
324 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 347 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
325 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 348 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
326 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 349 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
327 void InitializeSingleThreaded( | 350 void InitializeSingleThreaded( |
328 LayerTreeHostSingleThreadClient* single_thread_client, | 351 LayerTreeHostSingleThreadClient* single_thread_client, |
329 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 352 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
330 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 353 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 float max_page_scale_factor_; | 436 float max_page_scale_factor_; |
414 gfx::Vector2dF elastic_overscroll_; | 437 gfx::Vector2dF elastic_overscroll_; |
415 bool has_gpu_rasterization_trigger_; | 438 bool has_gpu_rasterization_trigger_; |
416 bool content_is_suitable_for_gpu_rasterization_; | 439 bool content_is_suitable_for_gpu_rasterization_; |
417 bool gpu_rasterization_histogram_recorded_; | 440 bool gpu_rasterization_histogram_recorded_; |
418 | 441 |
419 SkColor background_color_; | 442 SkColor background_color_; |
420 bool has_transparent_background_; | 443 bool has_transparent_background_; |
421 | 444 |
422 scoped_ptr<AnimationRegistrar> animation_registrar_; | 445 scoped_ptr<AnimationRegistrar> animation_registrar_; |
| 446 scoped_ptr<AnimationHost> animation_host_; |
423 | 447 |
424 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 448 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
425 | 449 |
426 // If set, then page scale animation has completed, but the client hasn't been | 450 // If set, then page scale animation has completed, but the client hasn't been |
427 // notified about it yet. | 451 // notified about it yet. |
428 bool did_complete_scale_animation_; | 452 bool did_complete_scale_animation_; |
429 | 453 |
430 bool in_paint_layer_contents_; | 454 bool in_paint_layer_contents_; |
431 | 455 |
432 int id_; | 456 int id_; |
433 bool next_commit_forces_redraw_; | 457 bool next_commit_forces_redraw_; |
434 | 458 |
435 scoped_refptr<Layer> overscroll_elasticity_layer_; | 459 scoped_refptr<Layer> overscroll_elasticity_layer_; |
436 scoped_refptr<Layer> page_scale_layer_; | 460 scoped_refptr<Layer> page_scale_layer_; |
437 scoped_refptr<Layer> inner_viewport_scroll_layer_; | 461 scoped_refptr<Layer> inner_viewport_scroll_layer_; |
438 scoped_refptr<Layer> outer_viewport_scroll_layer_; | 462 scoped_refptr<Layer> outer_viewport_scroll_layer_; |
439 | 463 |
440 LayerSelection selection_; | 464 LayerSelection selection_; |
441 | 465 |
442 SharedBitmapManager* shared_bitmap_manager_; | 466 SharedBitmapManager* shared_bitmap_manager_; |
443 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 467 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
444 TaskGraphRunner* task_graph_runner_; | 468 TaskGraphRunner* task_graph_runner_; |
445 | 469 |
446 ScopedPtrVector<SwapPromise> swap_promise_list_; | 470 ScopedPtrVector<SwapPromise> swap_promise_list_; |
447 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 471 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
448 | 472 |
449 PropertyTrees property_trees_; | 473 PropertyTrees property_trees_; |
450 | 474 |
| 475 typedef base::hash_map<int, Layer*> LayerIdMap; |
| 476 LayerIdMap layer_id_map_; |
| 477 |
451 uint32_t surface_id_namespace_; | 478 uint32_t surface_id_namespace_; |
452 uint32_t next_surface_sequence_; | 479 uint32_t next_surface_sequence_; |
453 | 480 |
454 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 481 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
455 }; | 482 }; |
456 | 483 |
457 } // namespace cc | 484 } // namespace cc |
458 | 485 |
459 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 486 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |