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 { | |
88 UIResourceCreate, | |
89 UIResourceDelete | |
90 }; | |
91 struct UIResourceRequest { | |
92 UIResourceRequestType type; | |
93 UIResourceId id; | |
94 scoped_refptr<UIResourceBitmap> bitmap; | |
95 }; | |
96 | |
84 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { | 97 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { |
85 public: | 98 public: |
86 static scoped_ptr<LayerTreeHost> Create( | 99 static scoped_ptr<LayerTreeHost> Create( |
87 LayerTreeHostClient* client, | 100 LayerTreeHostClient* client, |
88 const LayerTreeSettings& settings, | 101 const LayerTreeSettings& settings, |
89 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 102 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
90 virtual ~LayerTreeHost(); | 103 virtual ~LayerTreeHost(); |
91 | 104 |
92 void SetLayerTreeHostClientReady(); | 105 void SetLayerTreeHostClientReady(); |
93 | 106 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 void SetVisible(bool visible); | 221 void SetVisible(bool visible); |
209 bool visible() const { return visible_; } | 222 bool visible() const { return visible_; } |
210 | 223 |
211 void StartPageScaleAnimation(gfx::Vector2d target_offset, | 224 void StartPageScaleAnimation(gfx::Vector2d target_offset, |
212 bool use_anchor, | 225 bool use_anchor, |
213 float scale, | 226 float scale, |
214 base::TimeDelta duration); | 227 base::TimeDelta duration); |
215 | 228 |
216 void ApplyScrollAndScale(const ScrollAndScaleSet& info); | 229 void ApplyScrollAndScale(const ScrollAndScaleSet& info); |
217 | 230 |
231 void UIResourceLost(UIResourceId id); | |
aelias_OOO_until_Jul13
2013/07/26 23:57:31
Make this private.
powei
2013/07/30 21:47:00
Done.
| |
232 | |
218 void SetImplTransform(const gfx::Transform& transform); | 233 void SetImplTransform(const gfx::Transform& transform); |
219 void SetLatencyInfo(const ui::LatencyInfo& latency_info); | 234 void SetLatencyInfo(const ui::LatencyInfo& latency_info); |
220 | 235 |
221 virtual void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); | 236 virtual void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); |
222 virtual void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); | 237 virtual void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); |
223 | 238 |
224 // RateLimiterClient implementation. | 239 // RateLimiterClient implementation. |
225 virtual void RateLimit() OVERRIDE; | 240 virtual void RateLimit() OVERRIDE; |
226 | 241 |
227 bool buffered_updates() const { | 242 bool buffered_updates() const { |
(...skipping 17 matching lines...) Expand all Loading... | |
245 return animation_registrar_.get(); | 260 return animation_registrar_.get(); |
246 } | 261 } |
247 | 262 |
248 bool BlocksPendingCommit() const; | 263 bool BlocksPendingCommit() const; |
249 | 264 |
250 // Obtains a thorough dump of the LayerTreeHost as a value. | 265 // Obtains a thorough dump of the LayerTreeHost as a value. |
251 scoped_ptr<base::Value> AsValue() const; | 266 scoped_ptr<base::Value> AsValue() const; |
252 | 267 |
253 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 268 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
254 | 269 |
270 // CreateUIResource creates a resource given a bitmap. The bitmap is | |
271 // generated via an interface function, which is called when initializing the | |
272 // resource and when the resource has been lost (due to lost context). The | |
273 // parameter of the interface is a single boolean, which indicates whether the | |
274 // resource has been lost or not. CreateUIResource returns an Id of the | |
275 // resource, which is always positive. | |
276 virtual UIResourceId CreateUIResource(UIResourceClient* client); | |
277 // Deletes a UI resource. May safely be called more than once. | |
278 virtual void DeleteUIResource(UIResourceId id); | |
279 | |
255 bool UsingSharedMemoryResources(); | 280 bool UsingSharedMemoryResources(); |
256 int id() const { return tree_id_; } | 281 int id() const { return tree_id_; } |
257 | 282 |
258 protected: | 283 protected: |
259 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); | 284 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); |
260 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 285 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
261 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); | 286 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); |
262 | 287 |
263 private: | 288 private: |
264 bool InitializeProxy(scoped_ptr<Proxy> proxy); | 289 bool InitializeProxy(scoped_ptr<Proxy> proxy); |
(...skipping 16 matching lines...) Expand all Loading... | |
281 void PrioritizeTextures( | 306 void PrioritizeTextures( |
282 const RenderSurfaceLayerList& render_surface_layer_list, | 307 const RenderSurfaceLayerList& render_surface_layer_list, |
283 OverdrawMetrics* metrics); | 308 OverdrawMetrics* metrics); |
284 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); | 309 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); |
285 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); | 310 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); |
286 size_t CalculateMemoryForRenderSurfaces( | 311 size_t CalculateMemoryForRenderSurfaces( |
287 const RenderSurfaceLayerList& update_list); | 312 const RenderSurfaceLayerList& update_list); |
288 | 313 |
289 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | 314 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); |
290 | 315 |
316 void DidLoseUIResources(); | |
317 | |
318 // UIResourceCallback is used to retrieve the the bitmap of the resource | |
319 // request. The boolean parameter indicates whether the retrieval is due | |
320 // to lost resource (due to lost context) or not. | |
321 typedef base::hash_map<UIResourceId, UIResourceClient*> UIResourceClientMap; | |
322 UIResourceClientMap ui_resource_client_map_; | |
323 int ui_resource_id_; | |
aelias_OOO_until_Jul13
2013/07/26 23:57:31
Rename to next_ui_resource_id_
powei
2013/07/30 21:47:00
Done.
| |
324 | |
325 typedef std::list<UIResourceRequest> UIResourceRequestQueue; | |
326 UIResourceRequestQueue ui_resource_request_queue_; | |
327 | |
291 void CalculateLCDTextMetricsCallback(Layer* layer); | 328 void CalculateLCDTextMetricsCallback(Layer* layer); |
292 | 329 |
293 bool animating_; | 330 bool animating_; |
294 bool needs_full_tree_sync_; | 331 bool needs_full_tree_sync_; |
295 bool needs_filter_context_; | 332 bool needs_filter_context_; |
296 | 333 |
297 base::CancelableClosure prepaint_callback_; | 334 base::CancelableClosure prepaint_callback_; |
298 | 335 |
299 LayerTreeHostClient* client_; | 336 LayerTreeHostClient* client_; |
300 scoped_ptr<Proxy> proxy_; | 337 scoped_ptr<Proxy> proxy_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 }; | 406 }; |
370 LCDTextMetrics lcd_text_metrics_; | 407 LCDTextMetrics lcd_text_metrics_; |
371 int tree_id_; | 408 int tree_id_; |
372 | 409 |
373 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 410 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
374 }; | 411 }; |
375 | 412 |
376 } // namespace cc | 413 } // namespace cc |
377 | 414 |
378 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 415 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |