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 18 matching lines...) Expand all Loading... |
29 #include "cc/input/layer_selection_bound.h" | 29 #include "cc/input/layer_selection_bound.h" |
30 #include "cc/input/scrollbar.h" | 30 #include "cc/input/scrollbar.h" |
31 #include "cc/input/top_controls_state.h" | 31 #include "cc/input/top_controls_state.h" |
32 #include "cc/layers/layer_lists.h" | 32 #include "cc/layers/layer_lists.h" |
33 #include "cc/output/output_surface.h" | 33 #include "cc/output/output_surface.h" |
34 #include "cc/resources/resource_format.h" | 34 #include "cc/resources/resource_format.h" |
35 #include "cc/resources/scoped_ui_resource.h" | 35 #include "cc/resources/scoped_ui_resource.h" |
36 #include "cc/surfaces/surface_sequence.h" | 36 #include "cc/surfaces/surface_sequence.h" |
37 #include "cc/trees/layer_tree_host_client.h" | 37 #include "cc/trees/layer_tree_host_client.h" |
38 #include "cc/trees/layer_tree_host_common.h" | 38 #include "cc/trees/layer_tree_host_common.h" |
| 39 #include "cc/trees/layer_tree_mutators_client.h" |
39 #include "cc/trees/layer_tree_settings.h" | 40 #include "cc/trees/layer_tree_settings.h" |
40 #include "cc/trees/proxy.h" | 41 #include "cc/trees/proxy.h" |
41 #include "third_party/skia/include/core/SkColor.h" | 42 #include "third_party/skia/include/core/SkColor.h" |
42 #include "ui/gfx/geometry/rect.h" | 43 #include "ui/gfx/geometry/rect.h" |
43 | 44 |
44 namespace gpu { | 45 namespace gpu { |
45 class GpuMemoryBufferManager; | 46 class GpuMemoryBufferManager; |
46 } | 47 } |
47 | 48 |
48 namespace cc { | 49 namespace cc { |
49 class AnimationRegistrar; | 50 class AnimationRegistrar; |
| 51 class AnimationTimeline; |
50 class BeginFrameSource; | 52 class BeginFrameSource; |
51 class HeadsUpDisplayLayer; | 53 class HeadsUpDisplayLayer; |
52 class Layer; | 54 class Layer; |
53 class LayerTreeHostImpl; | 55 class LayerTreeHostImpl; |
54 class LayerTreeHostImplClient; | 56 class LayerTreeHostImplClient; |
55 class LayerTreeHostSingleThreadClient; | 57 class LayerTreeHostSingleThreadClient; |
56 class PrioritizedResource; | 58 class PrioritizedResource; |
57 class PrioritizedResourceManager; | 59 class PrioritizedResourceManager; |
58 class Region; | 60 class Region; |
59 class RenderingStatsInstrumentation; | 61 class RenderingStatsInstrumentation; |
(...skipping 18 matching lines...) Expand all Loading... |
78 RendererCapabilities(); | 80 RendererCapabilities(); |
79 ~RendererCapabilities(); | 81 ~RendererCapabilities(); |
80 | 82 |
81 // Duplicate any modification to this list to RendererCapabilitiesImpl. | 83 // Duplicate any modification to this list to RendererCapabilitiesImpl. |
82 ResourceFormat best_texture_format; | 84 ResourceFormat best_texture_format; |
83 bool allow_partial_texture_updates; | 85 bool allow_partial_texture_updates; |
84 int max_texture_size; | 86 int max_texture_size; |
85 bool using_shared_memory_resources; | 87 bool using_shared_memory_resources; |
86 }; | 88 }; |
87 | 89 |
88 class CC_EXPORT LayerTreeHost { | 90 class CC_EXPORT LayerTreeHost : public LayerTreeMutatorsClient { |
89 public: | 91 public: |
90 // The SharedBitmapManager will be used on the compositor thread. | 92 // The SharedBitmapManager will be used on the compositor thread. |
91 static scoped_ptr<LayerTreeHost> CreateThreaded( | 93 static scoped_ptr<LayerTreeHost> CreateThreaded( |
92 LayerTreeHostClient* client, | 94 LayerTreeHostClient* client, |
93 SharedBitmapManager* shared_bitmap_manager, | 95 SharedBitmapManager* shared_bitmap_manager, |
94 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 96 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
95 const LayerTreeSettings& settings, | 97 const LayerTreeSettings& settings, |
96 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 98 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
97 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 99 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
98 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 100 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void SetNeedsRedraw(); | 170 void SetNeedsRedraw(); |
169 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); | 171 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); |
170 bool CommitRequested() const; | 172 bool CommitRequested() const; |
171 bool BeginMainFrameRequested() const; | 173 bool BeginMainFrameRequested() const; |
172 | 174 |
173 void SetNextCommitWaitsForActivation(); | 175 void SetNextCommitWaitsForActivation(); |
174 | 176 |
175 void SetNextCommitForcesRedraw(); | 177 void SetNextCommitForcesRedraw(); |
176 | 178 |
177 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events); | 179 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events); |
| 180 void SetAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
178 | 181 |
179 void SetRootLayer(scoped_refptr<Layer> root_layer); | 182 void SetRootLayer(scoped_refptr<Layer> root_layer); |
180 Layer* root_layer() { return root_layer_.get(); } | 183 Layer* root_layer() { return root_layer_.get(); } |
181 const Layer* root_layer() const { return root_layer_.get(); } | 184 const Layer* root_layer() const { return root_layer_.get(); } |
182 const Layer* overscroll_elasticity_layer() const { | 185 const Layer* overscroll_elasticity_layer() const { |
183 return overscroll_elasticity_layer_.get(); | 186 return overscroll_elasticity_layer_.get(); |
184 } | 187 } |
185 const Layer* page_scale_layer() const { return page_scale_layer_.get(); } | 188 const Layer* page_scale_layer() const { return page_scale_layer_.get(); } |
186 void RegisterViewportLayers(scoped_refptr<Layer> overscroll_elasticity_layer, | 189 void RegisterViewportLayers(scoped_refptr<Layer> overscroll_elasticity_layer, |
187 scoped_refptr<Layer> page_scale_layer, | 190 scoped_refptr<Layer> page_scale_layer, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 TopControlsState current, | 267 TopControlsState current, |
265 bool animate); | 268 bool animate); |
266 | 269 |
267 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } | 270 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } |
268 | 271 |
269 Proxy* proxy() const { return proxy_.get(); } | 272 Proxy* proxy() const { return proxy_.get(); } |
270 | 273 |
271 AnimationRegistrar* animation_registrar() const { | 274 AnimationRegistrar* animation_registrar() const { |
272 return animation_registrar_.get(); | 275 return animation_registrar_.get(); |
273 } | 276 } |
| 277 AnimationTimeline* animation_timeline() const { |
| 278 return animation_timeline_.get(); |
| 279 } |
274 | 280 |
275 // Obtains a thorough dump of the LayerTreeHost as a value. | 281 // Obtains a thorough dump of the LayerTreeHost as a value. |
276 void AsValueInto(base::trace_event::TracedValue* value) const; | 282 void AsValueInto(base::trace_event::TracedValue* value) const; |
277 | 283 |
278 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 284 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
279 | 285 |
280 // CreateUIResource creates a resource given a bitmap. The bitmap is | 286 // CreateUIResource creates a resource given a bitmap. The bitmap is |
281 // generated via an interface function, which is called when initializing the | 287 // generated via an interface function, which is called when initializing the |
282 // resource and when the resource has been lost (due to lost context). The | 288 // resource and when the resource has been lost (due to lost context). The |
283 // parameter of the interface is a single boolean, which indicates whether the | 289 // parameter of the interface is a single boolean, which indicates whether the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); | 322 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); |
317 | 323 |
318 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } | 324 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } |
319 | 325 |
320 void set_surface_id_namespace(uint32_t id_namespace); | 326 void set_surface_id_namespace(uint32_t id_namespace); |
321 SurfaceSequence CreateSurfaceSequence(); | 327 SurfaceSequence CreateSurfaceSequence(); |
322 | 328 |
323 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) const; | 329 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) const; |
324 void SendBeginFramesToChildren(const BeginFrameArgs& args) const; | 330 void SendBeginFramesToChildren(const BeginFrameArgs& args) const; |
325 | 331 |
| 332 Layer* LayerById(int id) const; |
| 333 void RegisterLayer(Layer* layer); |
| 334 void UnregisterLayer(Layer* layer); |
| 335 // LayerTreeMutatorsClient implementation. |
| 336 AnimationRegistrar* GetAnimationRegistrar() const override; |
| 337 void SetMutatorsNeedCommit() override; |
| 338 void SetLayerFilterMutated(int layer_id, |
| 339 bool active_tree, |
| 340 const FilterOperations& filters) override; |
| 341 void SetLayerOpacityMutated(int layer_id, |
| 342 bool active_tree, |
| 343 float opacity) override; |
| 344 void SetLayerTransformMutated(int layer_id, |
| 345 bool active_tree, |
| 346 const gfx::Transform& transform) override; |
| 347 |
326 protected: | 348 protected: |
327 LayerTreeHost(LayerTreeHostClient* client, | 349 LayerTreeHost(LayerTreeHostClient* client, |
328 SharedBitmapManager* shared_bitmap_manager, | 350 SharedBitmapManager* shared_bitmap_manager, |
329 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 351 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
330 const LayerTreeSettings& settings); | 352 const LayerTreeSettings& settings); |
331 void InitializeThreaded( | 353 void InitializeThreaded( |
332 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 354 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
333 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 355 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
334 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 356 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
335 void InitializeSingleThreaded( | 357 void InitializeSingleThreaded( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 bool content_is_suitable_for_gpu_rasterization_; | 453 bool content_is_suitable_for_gpu_rasterization_; |
432 bool gpu_rasterization_histogram_recorded_; | 454 bool gpu_rasterization_histogram_recorded_; |
433 | 455 |
434 SkColor background_color_; | 456 SkColor background_color_; |
435 bool has_transparent_background_; | 457 bool has_transparent_background_; |
436 | 458 |
437 typedef ScopedPtrVector<PrioritizedResource> TextureList; | 459 typedef ScopedPtrVector<PrioritizedResource> TextureList; |
438 size_t partial_texture_update_requests_; | 460 size_t partial_texture_update_requests_; |
439 | 461 |
440 scoped_ptr<AnimationRegistrar> animation_registrar_; | 462 scoped_ptr<AnimationRegistrar> animation_registrar_; |
| 463 scoped_refptr<AnimationTimeline> animation_timeline_; |
441 | 464 |
442 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 465 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
443 | 466 |
444 // If set, then page scale animation has completed, but the client hasn't been | 467 // If set, then page scale animation has completed, but the client hasn't been |
445 // notified about it yet. | 468 // notified about it yet. |
446 bool did_complete_scale_animation_; | 469 bool did_complete_scale_animation_; |
447 | 470 |
448 bool in_paint_layer_contents_; | 471 bool in_paint_layer_contents_; |
449 | 472 |
450 static const int kTotalFramesToUseForLCDTextMetrics = 50; | 473 static const int kTotalFramesToUseForLCDTextMetrics = 50; |
(...skipping 20 matching lines...) Expand all Loading... |
471 | 494 |
472 LayerSelectionBound selection_start_; | 495 LayerSelectionBound selection_start_; |
473 LayerSelectionBound selection_end_; | 496 LayerSelectionBound selection_end_; |
474 | 497 |
475 SharedBitmapManager* shared_bitmap_manager_; | 498 SharedBitmapManager* shared_bitmap_manager_; |
476 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 499 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
477 | 500 |
478 ScopedPtrVector<SwapPromise> swap_promise_list_; | 501 ScopedPtrVector<SwapPromise> swap_promise_list_; |
479 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 502 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
480 | 503 |
| 504 typedef base::hash_map<int, Layer*> LayerIdMap; |
| 505 LayerIdMap layer_id_map_; |
| 506 |
481 uint32_t surface_id_namespace_; | 507 uint32_t surface_id_namespace_; |
482 uint32_t next_surface_sequence_; | 508 uint32_t next_surface_sequence_; |
483 | 509 |
484 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 510 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
485 }; | 511 }; |
486 | 512 |
487 } // namespace cc | 513 } // namespace cc |
488 | 514 |
489 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 515 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |