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

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: ccameron's fix for exisiting nine-patch uses 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Put the recreation of all UI resources into the resource queue after they 306 // Put the recreation of all UI resources into the resource queue after they
290 // were evicted on the impl thread. 307 // were evicted on the impl thread.
291 void RecreateUIResources(); 308 void RecreateUIResources();
292 309
310 virtual gfx::Size GetUIResourceSize(UIResourceId id) const;
311
293 bool UsingSharedMemoryResources(); 312 bool UsingSharedMemoryResources();
294 int id() const { return tree_id_; } 313 int id() const { return tree_id_; }
295 314
296 protected: 315 protected:
297 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings); 316 LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings);
298 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 317 bool Initialize(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
299 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing); 318 bool InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing);
300 319
301 private: 320 private:
302 bool InitializeProxy(scoped_ptr<Proxy> proxy); 321 bool InitializeProxy(scoped_ptr<Proxy> proxy);
(...skipping 16 matching lines...) Expand all
319 void PrioritizeTextures( 338 void PrioritizeTextures(
320 const RenderSurfaceLayerList& render_surface_layer_list, 339 const RenderSurfaceLayerList& render_surface_layer_list,
321 OverdrawMetrics* metrics); 340 OverdrawMetrics* metrics);
322 void SetPrioritiesForSurfaces(size_t surface_memory_bytes); 341 void SetPrioritiesForSurfaces(size_t surface_memory_bytes);
323 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list); 342 void SetPrioritiesForLayers(const RenderSurfaceLayerList& update_list);
324 size_t CalculateMemoryForRenderSurfaces( 343 size_t CalculateMemoryForRenderSurfaces(
325 const RenderSurfaceLayerList& update_list); 344 const RenderSurfaceLayerList& update_list);
326 345
327 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); 346 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time);
328 347
329 typedef base::hash_map<UIResourceId, UIResourceClient*> UIResourceClientMap; 348 struct UIResourceClientData {
349 UIResourceClient* client;
350 gfx::Size size;
351 };
352
353 typedef base::hash_map<UIResourceId, UIResourceClientData>
354 UIResourceClientMap;
330 UIResourceClientMap ui_resource_client_map_; 355 UIResourceClientMap ui_resource_client_map_;
331 int next_ui_resource_id_; 356 int next_ui_resource_id_;
332 357
333 typedef std::list<UIResourceRequest> UIResourceRequestQueue; 358 typedef std::list<UIResourceRequest> UIResourceRequestQueue;
334 UIResourceRequestQueue ui_resource_request_queue_; 359 UIResourceRequestQueue ui_resource_request_queue_;
335 360
336 void CalculateLCDTextMetricsCallback(Layer* layer); 361 void CalculateLCDTextMetricsCallback(Layer* layer);
337 362
338 bool animating_; 363 bool animating_;
339 bool needs_full_tree_sync_; 364 bool needs_full_tree_sync_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 }; 443 };
419 LCDTextMetrics lcd_text_metrics_; 444 LCDTextMetrics lcd_text_metrics_;
420 int tree_id_; 445 int tree_id_;
421 446
422 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 447 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
423 }; 448 };
424 449
425 } // namespace cc 450 } // namespace cc
426 451
427 #endif // CC_TREES_LAYER_TREE_HOST_H_ 452 #endif // CC_TREES_LAYER_TREE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698