Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: cc/trees/layer_tree_host.h

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
26 #include "cc/scheduler/rate_limiter.h" 28 #include "cc/scheduler/rate_limiter.h"
27 #include "cc/trees/layer_tree_host_client.h" 29 #include "cc/trees/layer_tree_host_client.h"
28 #include "cc/trees/layer_tree_host_common.h" 30 #include "cc/trees/layer_tree_host_common.h"
29 #include "cc/trees/layer_tree_settings.h" 31 #include "cc/trees/layer_tree_settings.h"
30 #include "cc/trees/occlusion_tracker.h" 32 #include "cc/trees/occlusion_tracker.h"
31 #include "cc/trees/proxy.h" 33 #include "cc/trees/proxy.h"
32 #include "third_party/skia/include/core/SkColor.h" 34 #include "third_party/skia/include/core/SkColor.h"
33 #include "ui/base/latency_info.h" 35 #include "ui/base/latency_info.h"
34 #include "ui/gfx/rect.h" 36 #include "ui/gfx/rect.h"
35 37
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 bool using_set_visibility; 76 bool using_set_visibility;
75 bool using_egl_image; 77 bool using_egl_image;
76 bool allow_partial_texture_updates; 78 bool allow_partial_texture_updates;
77 bool using_offscreen_context3d; 79 bool using_offscreen_context3d;
78 int max_texture_size; 80 int max_texture_size;
79 bool avoid_pow2_textures; 81 bool avoid_pow2_textures;
80 bool using_map_image; 82 bool using_map_image;
81 bool using_shared_memory_resources; 83 bool using_shared_memory_resources;
82 }; 84 };
83 85
86 typedef int UIResourceId;
87 typedef base::Callback<scoped_refptr<UIResourceBitmap>(bool resource_lost)>
88 UIResourceCallback;
89 enum UIResourceRequestType {
90 UIResourceCreate,
91 UIResourceDelete
92 };
93 struct UIResourceRequest {
94 UIResourceRequestType type;
95 UIResourceId id;
96 scoped_refptr<UIResourceBitmap> bitmap;
97 };
98
84 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { 99 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
85 public: 100 public:
86 static scoped_ptr<LayerTreeHost> Create( 101 static scoped_ptr<LayerTreeHost> Create(
87 LayerTreeHostClient* client, 102 LayerTreeHostClient* client,
88 const LayerTreeSettings& settings, 103 const LayerTreeSettings& settings,
89 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 104 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
90 virtual ~LayerTreeHost(); 105 virtual ~LayerTreeHost();
91 106
92 void SetLayerTreeHostClientReady(); 107 void SetLayerTreeHostClientReady();
93 108
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 void SetVisible(bool visible); 223 void SetVisible(bool visible);
209 bool visible() const { return visible_; } 224 bool visible() const { return visible_; }
210 225
211 void StartPageScaleAnimation(gfx::Vector2d target_offset, 226 void StartPageScaleAnimation(gfx::Vector2d target_offset,
212 bool use_anchor, 227 bool use_anchor,
213 float scale, 228 float scale,
214 base::TimeDelta duration); 229 base::TimeDelta duration);
215 230
216 void ApplyScrollAndScale(const ScrollAndScaleSet& info); 231 void ApplyScrollAndScale(const ScrollAndScaleSet& info);
217 232
233 void UIResourceLost(UIResourceId id);
234
218 void SetImplTransform(const gfx::Transform& transform); 235 void SetImplTransform(const gfx::Transform& transform);
219 void SetLatencyInfo(const ui::LatencyInfo& latency_info); 236 void SetLatencyInfo(const ui::LatencyInfo& latency_info);
220 237
221 virtual void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); 238 virtual void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d);
222 virtual void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); 239 virtual void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d);
223 240
224 // RateLimiterClient implementation. 241 // RateLimiterClient implementation.
225 virtual void RateLimit() OVERRIDE; 242 virtual void RateLimit() OVERRIDE;
226 243
227 bool buffered_updates() const { 244 bool buffered_updates() const {
(...skipping 17 matching lines...) Expand all
245 return animation_registrar_.get(); 262 return animation_registrar_.get();
246 } 263 }
247 264
248 bool BlocksPendingCommit() const; 265 bool BlocksPendingCommit() const;
249 266
250 // Obtains a thorough dump of the LayerTreeHost as a value. 267 // Obtains a thorough dump of the LayerTreeHost as a value.
251 scoped_ptr<base::Value> AsValue() const; 268 scoped_ptr<base::Value> AsValue() const;
252 269
253 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } 270 bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
254 271
272 // CreateUIResource creates a resource given a bitmap. The bitmap is
273 // generated via a callback function, which is called when initializing the
274 // resource and when the resource has been lost (due to lost context). The
275 // parameter of the callback is a single boolean, which indicates whether the
276 // resource has been lost or not. CreateUIResource returns an Id of the
277 // resource, which is always positive.
278 virtual UIResourceId CreateUIResource(const UIResourceCallback& bitmap_cb);
279 // Deletes a UI resource. May safely be called more than once.
280 virtual void DeleteUIResource(UIResourceId id);
281
255 bool UsingSharedMemoryResources(); 282 bool UsingSharedMemoryResources();
256 int id() const { return tree_id_; } 283 int id() const { return tree_id_; }
257 284
258 protected: 285 protected:
259 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); 286 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings);
260 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 287 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
261 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); 288 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing);
262 289
263 private: 290 private:
264 bool InitializeProxy(scoped_ptr<Proxy> proxy); 291 bool InitializeProxy(scoped_ptr<Proxy> proxy);
(...skipping 16 matching lines...) Expand all
281 void PrioritizeTextures( 308 void PrioritizeTextures(
282 const RenderSurfaceLayerList& render_surface_layer_list, 309 const RenderSurfaceLayerList& render_surface_layer_list,
283 OverdrawMetrics* metrics); 310 OverdrawMetrics* metrics);
284 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); 311 void SetPrioritiesForSurfaces(size_t surface_memory_bytes);
285 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); 312 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list);
286 size_t CalculateMemoryForRenderSurfaces( 313 size_t CalculateMemoryForRenderSurfaces(
287 const RenderSurfaceLayerList& update_list); 314 const RenderSurfaceLayerList& update_list);
288 315
289 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); 316 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time);
290 317
318 void DidLoseUIResources();
319
320 // UIResourceCallback is used to retrieve the the bitmap of the resource
321 // request. The boolean parameter indicates whether the retrieval is due
322 // to lost resource (due to lost context) or not.
323 typedef base::hash_map<UIResourceId, UIResourceCallback> UIResourceClientMap;
324 UIResourceClientMap ui_resource_client_map_;
325 int ui_resource_id_;
326
327 typedef std::list<UIResourceRequest> UIResourceRequestQueue;
328 UIResourceRequestQueue ui_resource_request_queue_;
329
291 void CalculateLCDTextMetricsCallback(Layer* layer); 330 void CalculateLCDTextMetricsCallback(Layer* layer);
292 331
293 bool animating_; 332 bool animating_;
294 bool needs_full_tree_sync_; 333 bool needs_full_tree_sync_;
295 bool needs_filter_context_; 334 bool needs_filter_context_;
296 335
297 base::CancelableClosure prepaint_callback_; 336 base::CancelableClosure prepaint_callback_;
298 337
299 LayerTreeHostClient* client_; 338 LayerTreeHostClient* client_;
300 scoped_ptr<Proxy> proxy_; 339 scoped_ptr<Proxy> proxy_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 }; 408 };
370 LCDTextMetrics lcd_text_metrics_; 409 LCDTextMetrics lcd_text_metrics_;
371 int tree_id_; 410 int tree_id_;
372 411
373 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 412 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
374 }; 413 };
375 414
376 } // namespace cc 415 } // namespace cc
377 416
378 #endif // CC_TREES_LAYER_TREE_HOST_H_ 417 #endif // CC_TREES_LAYER_TREE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698