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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated dchecks in ui_resource_bitmap Created 7 years, 3 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 <list>
10 #include <vector> 10 #include <vector>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 bool using_egl_image; 79 bool using_egl_image;
80 bool allow_partial_texture_updates; 80 bool allow_partial_texture_updates;
81 bool using_offscreen_context3d; 81 bool using_offscreen_context3d;
82 int max_texture_size; 82 int max_texture_size;
83 bool avoid_pow2_textures; 83 bool avoid_pow2_textures;
84 bool using_map_image; 84 bool using_map_image;
85 bool using_shared_memory_resources; 85 bool using_shared_memory_resources;
86 bool using_discard_framebuffer; 86 bool using_discard_framebuffer;
87 }; 87 };
88 88
89 struct CC_EXPORT UIResourceRequest { 89 class CC_EXPORT UIResourceRequest {
90 public:
90 enum UIResourceRequestType { 91 enum UIResourceRequestType {
91 UIResourceCreate, 92 UIResourceCreate,
92 UIResourceDelete, 93 UIResourceDelete,
93 UIResourceInvalidRequest 94 UIResourceInvalidRequest
94 }; 95 };
95 96
96 UIResourceRequest(); 97 UIResourceRequest(UIResourceRequestType type, UIResourceId id);
98 UIResourceRequest(UIResourceRequestType type,
99 UIResourceId id,
100 const UIResourceBitmap& bitmap);
101 UIResourceRequest(const UIResourceRequest& request);
102
97 ~UIResourceRequest(); 103 ~UIResourceRequest();
98 UIResourceRequestType type; 104
99 UIResourceId id; 105 UIResourceRequestType GetType() const { return type_; }
100 scoped_refptr<UIResourceBitmap> bitmap; 106 UIResourceId GetId() const { return id_; }
107 UIResourceBitmap GetBitmap() const {
108 DCHECK(bitmap_);
109 return *bitmap_.get();
110 }
111
112 UIResourceRequest& operator=(const UIResourceRequest& request);
113
114 private:
115 UIResourceRequestType type_;
116 UIResourceId id_;
117 scoped_ptr<UIResourceBitmap> bitmap_;
101 }; 118 };
102 119
103 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { 120 class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
104 public: 121 public:
105 static scoped_ptr<LayerTreeHost> Create( 122 static scoped_ptr<LayerTreeHost> Create(
106 LayerTreeHostClient* client, 123 LayerTreeHostClient* client,
107 const LayerTreeSettings& settings, 124 const LayerTreeSettings& settings,
108 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 125 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
109 virtual ~LayerTreeHost(); 126 virtual ~LayerTreeHost();
110 127
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // CreateUIResource creates a resource given a bitmap. The bitmap is 297 // CreateUIResource creates a resource given a bitmap. The bitmap is
281 // generated via an interface function, which is called when initializing the 298 // generated via an interface function, which is called when initializing the
282 // resource and when the resource has been lost (due to lost context). The 299 // resource and when the resource has been lost (due to lost context). The
283 // parameter of the interface is a single boolean, which indicates whether the 300 // parameter of the interface is a single boolean, which indicates whether the
284 // resource has been lost or not. CreateUIResource returns an Id of the 301 // resource has been lost or not. CreateUIResource returns an Id of the
285 // resource, which is always positive. 302 // resource, which is always positive.
286 virtual UIResourceId CreateUIResource(UIResourceClient* client); 303 virtual UIResourceId CreateUIResource(UIResourceClient* client);
287 // Deletes a UI resource. May safely be called more than once. 304 // Deletes a UI resource. May safely be called more than once.
288 virtual void DeleteUIResource(UIResourceId id); 305 virtual void DeleteUIResource(UIResourceId id);
289 306
307 virtual gfx::Size GetUIResourceSize(UIResourceId id) const;
308
290 bool UsingSharedMemoryResources(); 309 bool UsingSharedMemoryResources();
291 int id() const { return tree_id_; } 310 int id() const { return tree_id_; }
292 311
293 protected: 312 protected:
294 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); 313 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings);
295 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 314 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
296 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); 315 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing);
297 316
298 private: 317 private:
299 bool InitializeProxy(scoped_ptr<Proxy> proxy); 318 bool InitializeProxy(scoped_ptr<Proxy> proxy);
(...skipping 18 matching lines...) Expand all
318 OverdrawMetrics* metrics); 337 OverdrawMetrics* metrics);
319 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); 338 void SetPrioritiesForSurfaces(size_t surface_memory_bytes);
320 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); 339 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list);
321 size_t CalculateMemoryForRenderSurfaces( 340 size_t CalculateMemoryForRenderSurfaces(
322 const RenderSurfaceLayerList& update_list); 341 const RenderSurfaceLayerList& update_list);
323 342
324 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); 343 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time);
325 344
326 void RecreateUIResources(bool resource_lost); 345 void RecreateUIResources(bool resource_lost);
327 346
328 typedef base::hash_map<UIResourceId, UIResourceClient*> UIResourceClientMap; 347 struct UIResourceClientData {
348 UIResourceClient* client;
349 gfx::Size size;
350 };
351
352 typedef base::hash_map<UIResourceId, UIResourceClientData>
353 UIResourceClientMap;
329 UIResourceClientMap ui_resource_client_map_; 354 UIResourceClientMap ui_resource_client_map_;
330 int next_ui_resource_id_; 355 int next_ui_resource_id_;
331 356
332 typedef std::list<UIResourceRequest> UIResourceRequestQueue; 357 typedef std::list<UIResourceRequest> UIResourceRequestQueue;
333 UIResourceRequestQueue ui_resource_request_queue_; 358 UIResourceRequestQueue ui_resource_request_queue_;
334 359
335 void CalculateLCDTextMetricsCallback(Layer* layer); 360 void CalculateLCDTextMetricsCallback(Layer* layer);
336 361
337 bool animating_; 362 bool animating_;
338 bool needs_full_tree_sync_; 363 bool needs_full_tree_sync_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 }; 442 };
418 LCDTextMetrics lcd_text_metrics_; 443 LCDTextMetrics lcd_text_metrics_;
419 int tree_id_; 444 int tree_id_;
420 445
421 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 446 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
422 }; 447 };
423 448
424 } // namespace cc 449 } // namespace cc
425 450
426 #endif // CC_TREES_LAYER_TREE_HOST_H_ 451 #endif // CC_TREES_LAYER_TREE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698