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 <list> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "cc/animation/animation_events.h" | 19 #include "cc/animation/animation_events.h" |
19 #include "cc/base/cc_export.h" | 20 #include "cc/base/cc_export.h" |
20 #include "cc/base/scoped_ptr_vector.h" | 21 #include "cc/base/scoped_ptr_vector.h" |
21 #include "cc/input/input_handler.h" | 22 #include "cc/input/input_handler.h" |
22 #include "cc/input/scrollbar.h" | 23 #include "cc/input/scrollbar.h" |
23 #include "cc/input/top_controls_state.h" | 24 #include "cc/input/top_controls_state.h" |
24 #include "cc/layers/layer_lists.h" | 25 #include "cc/layers/layer_lists.h" |
25 #include "cc/output/output_surface.h" | 26 #include "cc/output/output_surface.h" |
| 27 #include "cc/resources/ui_resource_bitmap.h" |
| 28 #include "cc/resources/ui_resource_client.h" |
26 #include "cc/scheduler/rate_limiter.h" | 29 #include "cc/scheduler/rate_limiter.h" |
27 #include "cc/trees/layer_tree_host_client.h" | 30 #include "cc/trees/layer_tree_host_client.h" |
28 #include "cc/trees/layer_tree_host_common.h" | 31 #include "cc/trees/layer_tree_host_common.h" |
29 #include "cc/trees/layer_tree_settings.h" | 32 #include "cc/trees/layer_tree_settings.h" |
30 #include "cc/trees/occlusion_tracker.h" | 33 #include "cc/trees/occlusion_tracker.h" |
31 #include "cc/trees/proxy.h" | 34 #include "cc/trees/proxy.h" |
32 #include "third_party/skia/include/core/SkColor.h" | 35 #include "third_party/skia/include/core/SkColor.h" |
33 #include "ui/base/latency_info.h" | 36 #include "ui/base/latency_info.h" |
34 #include "ui/gfx/rect.h" | 37 #include "ui/gfx/rect.h" |
35 | 38 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 bool using_set_visibility; | 77 bool using_set_visibility; |
75 bool using_egl_image; | 78 bool using_egl_image; |
76 bool allow_partial_texture_updates; | 79 bool allow_partial_texture_updates; |
77 bool using_offscreen_context3d; | 80 bool using_offscreen_context3d; |
78 int max_texture_size; | 81 int max_texture_size; |
79 bool avoid_pow2_textures; | 82 bool avoid_pow2_textures; |
80 bool using_map_image; | 83 bool using_map_image; |
81 bool using_shared_memory_resources; | 84 bool using_shared_memory_resources; |
82 }; | 85 }; |
83 | 86 |
| 87 struct CC_EXPORT UIResourceRequest { |
| 88 enum UIResourceRequestType { |
| 89 UIResourceCreate, |
| 90 UIResourceDelete, |
| 91 UIResourceInvalidRequest |
| 92 }; |
| 93 |
| 94 UIResourceRequest(); |
| 95 ~UIResourceRequest(); |
| 96 UIResourceRequestType type; |
| 97 UIResourceId id; |
| 98 scoped_refptr<UIResourceBitmap> bitmap; |
| 99 }; |
| 100 |
84 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { | 101 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { |
85 public: | 102 public: |
86 static scoped_ptr<LayerTreeHost> Create( | 103 static scoped_ptr<LayerTreeHost> Create( |
87 LayerTreeHostClient* client, | 104 LayerTreeHostClient* client, |
88 const LayerTreeSettings& settings, | 105 const LayerTreeSettings& settings, |
89 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 106 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
90 virtual ~LayerTreeHost(); | 107 virtual ~LayerTreeHost(); |
91 | 108 |
92 void SetLayerTreeHostClientReady(); | 109 void SetLayerTreeHostClientReady(); |
93 | 110 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return animation_registrar_.get(); | 266 return animation_registrar_.get(); |
250 } | 267 } |
251 | 268 |
252 bool BlocksPendingCommit() const; | 269 bool BlocksPendingCommit() const; |
253 | 270 |
254 // Obtains a thorough dump of the LayerTreeHost as a value. | 271 // Obtains a thorough dump of the LayerTreeHost as a value. |
255 scoped_ptr<base::Value> AsValue() const; | 272 scoped_ptr<base::Value> AsValue() const; |
256 | 273 |
257 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 274 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
258 | 275 |
| 276 // CreateUIResource creates a resource given a bitmap. The bitmap is |
| 277 // generated via an interface function, which is called when initializing the |
| 278 // resource and when the resource has been lost (due to lost context). The |
| 279 // parameter of the interface is a single boolean, which indicates whether the |
| 280 // resource has been lost or not. CreateUIResource returns an Id of the |
| 281 // resource, which is always positive. |
| 282 virtual UIResourceId CreateUIResource(UIResourceClient* client); |
| 283 // Deletes a UI resource. May safely be called more than once. |
| 284 virtual void DeleteUIResource(UIResourceId id); |
| 285 |
259 bool UsingSharedMemoryResources(); | 286 bool UsingSharedMemoryResources(); |
260 int id() const { return tree_id_; } | 287 int id() const { return tree_id_; } |
261 | 288 |
262 protected: | 289 protected: |
263 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); | 290 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); |
264 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 291 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
265 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); | 292 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); |
266 | 293 |
267 private: | 294 private: |
268 bool InitializeProxy(scoped_ptr<Proxy> proxy); | 295 bool InitializeProxy(scoped_ptr<Proxy> proxy); |
(...skipping 16 matching lines...) Expand all Loading... |
285 void PrioritizeTextures( | 312 void PrioritizeTextures( |
286 const RenderSurfaceLayerList& render_surface_layer_list, | 313 const RenderSurfaceLayerList& render_surface_layer_list, |
287 OverdrawMetrics* metrics); | 314 OverdrawMetrics* metrics); |
288 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); | 315 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); |
289 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); | 316 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); |
290 size_t CalculateMemoryForRenderSurfaces( | 317 size_t CalculateMemoryForRenderSurfaces( |
291 const RenderSurfaceLayerList& update_list); | 318 const RenderSurfaceLayerList& update_list); |
292 | 319 |
293 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | 320 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); |
294 | 321 |
| 322 void UIResourceLost(UIResourceId id); |
| 323 |
| 324 void DidLoseUIResources(); |
| 325 |
| 326 typedef base::hash_map<UIResourceId, UIResourceClient*> UIResourceClientMap; |
| 327 UIResourceClientMap ui_resource_client_map_; |
| 328 int next_ui_resource_id_; |
| 329 |
| 330 typedef std::list<UIResourceRequest> UIResourceRequestQueue; |
| 331 UIResourceRequestQueue ui_resource_request_queue_; |
| 332 |
295 void CalculateLCDTextMetricsCallback(Layer* layer); | 333 void CalculateLCDTextMetricsCallback(Layer* layer); |
296 | 334 |
297 bool animating_; | 335 bool animating_; |
298 bool needs_full_tree_sync_; | 336 bool needs_full_tree_sync_; |
299 bool needs_filter_context_; | 337 bool needs_filter_context_; |
300 | 338 |
301 base::CancelableClosure prepaint_callback_; | 339 base::CancelableClosure prepaint_callback_; |
302 | 340 |
303 LayerTreeHostClient* client_; | 341 LayerTreeHostClient* client_; |
304 scoped_ptr<Proxy> proxy_; | 342 scoped_ptr<Proxy> proxy_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 }; | 411 }; |
374 LCDTextMetrics lcd_text_metrics_; | 412 LCDTextMetrics lcd_text_metrics_; |
375 int tree_id_; | 413 int tree_id_; |
376 | 414 |
377 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 415 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
378 }; | 416 }; |
379 | 417 |
380 } // namespace cc | 418 } // namespace cc |
381 | 419 |
382 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 420 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |