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 enum UIResourceRequestType { | |
aelias_OOO_until_Jul13
2013/07/31 21:00:30
nit: put this inside UIResourceRequest.
powei
2013/07/31 21:29:39
Done.
| |
88 UIResourceCreate, | |
89 UIResourceDelete, | |
90 UIResourceInvalidRequest | |
91 }; | |
92 | |
93 struct CC_EXPORT UIResourceRequest { | |
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 return animation_registrar_.get(); | 264 return animation_registrar_.get(); |
248 } | 265 } |
249 | 266 |
250 bool BlocksPendingCommit() const; | 267 bool BlocksPendingCommit() const; |
251 | 268 |
252 // Obtains a thorough dump of the LayerTreeHost as a value. | 269 // Obtains a thorough dump of the LayerTreeHost as a value. |
253 scoped_ptr<base::Value> AsValue() const; | 270 scoped_ptr<base::Value> AsValue() const; |
254 | 271 |
255 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 272 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
256 | 273 |
274 // CreateUIResource creates a resource given a bitmap. The bitmap is | |
275 // generated via an interface function, which is called when initializing the | |
276 // resource and when the resource has been lost (due to lost context). The | |
277 // parameter of the interface is a single boolean, which indicates whether the | |
278 // resource has been lost or not. CreateUIResource returns an Id of the | |
279 // resource, which is always positive. | |
280 virtual UIResourceId CreateUIResource(UIResourceClient* client); | |
281 // Deletes a UI resource. May safely be called more than once. | |
282 virtual void DeleteUIResource(UIResourceId id); | |
283 | |
257 bool UsingSharedMemoryResources(); | 284 bool UsingSharedMemoryResources(); |
258 int id() const { return tree_id_; } | 285 int id() const { return tree_id_; } |
259 | 286 |
260 protected: | 287 protected: |
261 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); | 288 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); |
262 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 289 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
263 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); | 290 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); |
264 | 291 |
265 private: | 292 private: |
266 bool InitializeProxy(scoped_ptr<Proxy> proxy); | 293 bool InitializeProxy(scoped_ptr<Proxy> proxy); |
(...skipping 16 matching lines...) Expand all Loading... | |
283 void PrioritizeTextures( | 310 void PrioritizeTextures( |
284 const RenderSurfaceLayerList& render_surface_layer_list, | 311 const RenderSurfaceLayerList& render_surface_layer_list, |
285 OverdrawMetrics* metrics); | 312 OverdrawMetrics* metrics); |
286 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); | 313 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); |
287 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); | 314 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); |
288 size_t CalculateMemoryForRenderSurfaces( | 315 size_t CalculateMemoryForRenderSurfaces( |
289 const RenderSurfaceLayerList& update_list); | 316 const RenderSurfaceLayerList& update_list); |
290 | 317 |
291 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | 318 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); |
292 | 319 |
320 void UIResourceLost(UIResourceId id); | |
321 | |
322 void DidLoseUIResources(); | |
323 | |
324 typedef base::hash_map<UIResourceId, UIResourceClient*> UIResourceClientMap; | |
325 UIResourceClientMap ui_resource_client_map_; | |
326 int next_ui_resource_id_; | |
327 | |
328 typedef std::list<UIResourceRequest> UIResourceRequestQueue; | |
329 UIResourceRequestQueue ui_resource_request_queue_; | |
330 | |
293 void CalculateLCDTextMetricsCallback(Layer* layer); | 331 void CalculateLCDTextMetricsCallback(Layer* layer); |
294 | 332 |
295 bool animating_; | 333 bool animating_; |
296 bool needs_full_tree_sync_; | 334 bool needs_full_tree_sync_; |
297 bool needs_filter_context_; | 335 bool needs_filter_context_; |
298 | 336 |
299 base::CancelableClosure prepaint_callback_; | 337 base::CancelableClosure prepaint_callback_; |
300 | 338 |
301 LayerTreeHostClient* client_; | 339 LayerTreeHostClient* client_; |
302 scoped_ptr<Proxy> proxy_; | 340 scoped_ptr<Proxy> proxy_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 }; | 409 }; |
372 LCDTextMetrics lcd_text_metrics_; | 410 LCDTextMetrics lcd_text_metrics_; |
373 int tree_id_; | 411 int tree_id_; |
374 | 412 |
375 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 413 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
376 }; | 414 }; |
377 | 415 |
378 } // namespace cc | 416 } // namespace cc |
379 | 417 |
380 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 418 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |