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_manager_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 "skia/ext/refptr.h" | 35 #include "skia/ext/refptr.h" |
33 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
34 #include "third_party/skia/include/core/SkPicture.h" | 37 #include "third_party/skia/include/core/SkPicture.h" |
35 #include "ui/base/latency_info.h" | 38 #include "ui/base/latency_info.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 bool using_partial_swap; | 78 bool using_partial_swap; |
76 bool using_set_visibility; | 79 bool using_set_visibility; |
77 bool using_egl_image; | 80 bool using_egl_image; |
78 bool allow_partial_texture_updates; | 81 bool allow_partial_texture_updates; |
79 bool using_offscreen_context3d; | 82 bool using_offscreen_context3d; |
80 int max_texture_size; | 83 int max_texture_size; |
81 bool avoid_pow2_textures; | 84 bool avoid_pow2_textures; |
82 bool using_map_image; | 85 bool using_map_image; |
83 }; | 86 }; |
84 | 87 |
88 enum UIResourceRequestType { | |
89 UIResourceCreate, | |
90 UIResourceDelete | |
91 }; | |
92 | |
93 struct UIResourceRequest { | |
94 UIResourceRequestType type; | |
95 UIResourceId id; | |
96 scoped_refptr<UIResourceBitmap> bitmap; | |
97 }; | |
98 | |
85 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { | 99 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { |
86 public: | 100 public: |
87 static scoped_ptr<LayerTreeHost> Create( | 101 static scoped_ptr<LayerTreeHost> Create( |
88 LayerTreeHostClient* client, | 102 LayerTreeHostClient* client, |
89 const LayerTreeSettings& settings, | 103 const LayerTreeSettings& settings, |
90 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 104 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
91 virtual ~LayerTreeHost(); | 105 virtual ~LayerTreeHost(); |
92 | 106 |
93 void SetLayerTreeHostClientReady(); | 107 void SetLayerTreeHostClientReady(); |
94 | 108 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 void SetVisible(bool visible); | 223 void SetVisible(bool visible); |
210 bool visible() const { return visible_; } | 224 bool visible() const { return visible_; } |
211 | 225 |
212 void StartPageScaleAnimation(gfx::Vector2d target_offset, | 226 void StartPageScaleAnimation(gfx::Vector2d target_offset, |
213 bool use_anchor, | 227 bool use_anchor, |
214 float scale, | 228 float scale, |
215 base::TimeDelta duration); | 229 base::TimeDelta duration); |
216 | 230 |
217 void ApplyScrollAndScale(const ScrollAndScaleSet& info); | 231 void ApplyScrollAndScale(const ScrollAndScaleSet& info); |
218 | 232 |
233 void UIResourceReady(UIResourceId id); | |
enne (OOO)
2013/07/22 23:09:15
Can you remove this if it isn't called anywhere?
powei
2013/07/24 02:28:29
Done.
| |
234 void UIResourceLost(UIResourceId id); | |
235 | |
219 void SetImplTransform(const gfx::Transform& transform); | 236 void SetImplTransform(const gfx::Transform& transform); |
220 void SetLatencyInfo(const ui::LatencyInfo& latency_info); | 237 void SetLatencyInfo(const ui::LatencyInfo& latency_info); |
221 | 238 |
222 void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); | 239 void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); |
223 void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); | 240 void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); |
224 | 241 |
225 // RateLimiterClient implementation. | 242 // RateLimiterClient implementation. |
226 virtual void RateLimit() OVERRIDE; | 243 virtual void RateLimit() OVERRIDE; |
227 | 244 |
228 bool buffered_updates() const { | 245 bool buffered_updates() const { |
(...skipping 19 matching lines...) Expand all Loading... | |
248 | 265 |
249 skia::RefPtr<SkPicture> CapturePicture(); | 266 skia::RefPtr<SkPicture> CapturePicture(); |
250 | 267 |
251 bool BlocksPendingCommit() const; | 268 bool BlocksPendingCommit() const; |
252 | 269 |
253 // Obtains a thorough dump of the LayerTreeHost as a value. | 270 // Obtains a thorough dump of the LayerTreeHost as a value. |
254 scoped_ptr<base::Value> AsValue() const; | 271 scoped_ptr<base::Value> AsValue() const; |
255 | 272 |
256 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 273 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
257 | 274 |
275 // UI Resource management | |
enne (OOO)
2013/07/22 23:09:15
This comment doesn't really add much. Could you i
powei
2013/07/24 02:28:29
Done.
| |
276 virtual UIResourceId CreateUIResource(const UIResourceCallback& content); | |
277 // Deletes a UI resource. May safely be called more than once. | |
278 virtual void DeleteUIResource(UIResourceId id); | |
279 | |
258 protected: | 280 protected: |
259 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); | 281 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); |
260 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 282 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
261 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); | 283 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); |
262 | 284 |
263 private: | 285 private: |
264 bool InitializeProxy(scoped_ptr<Proxy> proxy); | 286 bool InitializeProxy(scoped_ptr<Proxy> proxy); |
265 | 287 |
266 bool PaintLayerContents(const LayerList& render_surface_layer_list, | 288 bool PaintLayerContents(const LayerList& render_surface_layer_list, |
267 ResourceUpdateQueue* quue); | 289 ResourceUpdateQueue* quue); |
268 bool PaintMasksForRenderSurface(Layer* render_surface_layer, | 290 bool PaintMasksForRenderSurface(Layer* render_surface_layer, |
269 ResourceUpdateQueue* queue); | 291 ResourceUpdateQueue* queue); |
270 void UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue); | 292 void UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue); |
271 void UpdateHudLayer(); | 293 void UpdateHudLayer(); |
272 void TriggerPrepaint(); | 294 void TriggerPrepaint(); |
273 | 295 |
274 void ReduceMemoryUsage(); | 296 void ReduceMemoryUsage(); |
275 | 297 |
276 void PrioritizeTextures(const LayerList& render_surface_layer_list, | 298 void PrioritizeTextures(const LayerList& render_surface_layer_list, |
277 OverdrawMetrics* metrics); | 299 OverdrawMetrics* metrics); |
278 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); | 300 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); |
279 void SetPrioritiesForLayers(const LayerList& update_list); | 301 void SetPrioritiesForLayers(const LayerList& update_list); |
280 size_t CalculateMemoryForRenderSurfaces(const LayerList& update_list); | 302 size_t CalculateMemoryForRenderSurfaces(const LayerList& update_list); |
281 | 303 |
282 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | 304 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); |
283 | 305 |
306 // UIResourceCallback is used to retrieve the the bitmap of the resource | |
307 // request. The boolean parameter indicates whether the retrieval is due | |
308 // to lost resource (due to lost context) or not. | |
309 typedef base::hash_map<UIResourceId, UIResourceCallback> UIResourceClientMap; | |
310 UIResourceClientMap ui_resource_client_map_; | |
311 int ui_resource_id_; | |
312 | |
313 typedef std::list<UIResourceRequest> UIResourceRequestQueue; | |
314 UIResourceRequestQueue ui_resource_request_queue_; | |
315 | |
284 void CalculateLCDTextMetricsCallback(Layer* layer); | 316 void CalculateLCDTextMetricsCallback(Layer* layer); |
285 | 317 |
286 bool animating_; | 318 bool animating_; |
287 bool needs_full_tree_sync_; | 319 bool needs_full_tree_sync_; |
288 bool needs_filter_context_; | 320 bool needs_filter_context_; |
289 | 321 |
290 base::CancelableClosure prepaint_callback_; | 322 base::CancelableClosure prepaint_callback_; |
291 | 323 |
292 LayerTreeHostClient* client_; | 324 LayerTreeHostClient* client_; |
293 scoped_ptr<Proxy> proxy_; | 325 scoped_ptr<Proxy> proxy_; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 int64 total_num_cc_layers_will_use_lcd_text; | 393 int64 total_num_cc_layers_will_use_lcd_text; |
362 }; | 394 }; |
363 LCDTextMetrics lcd_text_metrics_; | 395 LCDTextMetrics lcd_text_metrics_; |
364 | 396 |
365 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 397 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
366 }; | 398 }; |
367 | 399 |
368 } // namespace cc | 400 } // namespace cc |
369 | 401 |
370 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 402 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |