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

Side by Side Diff: cc/resources/ui_resource_manager.h

Issue 2322943003: cc: Move UI Resource management out of LayerTreeHost. (Closed)
Patch Set: Rebase Created 4 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
« no previous file with comments | « cc/resources/scoped_ui_resource.cc ('k') | cc/resources/ui_resource_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_RESOURCES_UI_RESOURCE_MANAGER_H_
6 #define CC_RESOURCES_UI_RESOURCE_MANAGER_H_
7
8 #include <unordered_map>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/resources/scoped_ui_resource.h"
14 #include "cc/resources/ui_resource_request.h"
15
16 namespace cc {
17 class UIResourceRequest;
18
19 class CC_EXPORT UIResourceManager {
20 public:
21 UIResourceManager();
22 ~UIResourceManager();
23
24 // CreateUIResource creates a resource given a bitmap. The bitmap is
25 // generated via an interface function, which is called when initializing the
26 // resource and when the resource has been lost (due to lost context). The
27 // parameter of the interface is a single boolean, which indicates whether the
28 // resource has been lost or not. CreateUIResource returns an Id of the
29 // resource, which is always positive.
30 virtual UIResourceId CreateUIResource(UIResourceClient* client);
31
32 // Deletes a UI resource. May safely be called more than once.
33 virtual void DeleteUIResource(UIResourceId id);
34
35 // Put the recreation of all UI resources into the resource queue after they
36 // were evicted on the impl thread.
37 void RecreateUIResources();
38
39 virtual gfx::Size GetUIResourceSize(UIResourceId id) const;
40
41 std::vector<UIResourceRequest> TakeUIResourcesRequests();
aelias_OOO_until_Jul13 2016/09/09 23:53:34 This new method is CC-facing so it should be demar
Khushal 2016/09/10 00:11:22 Done.
42
43 private:
44 struct UIResourceClientData {
45 UIResourceClient* client;
46 gfx::Size size;
47 };
48
49 using UIResourceClientMap =
50 std::unordered_map<UIResourceId, UIResourceClientData>;
51 UIResourceClientMap ui_resource_client_map_;
52 int next_ui_resource_id_;
53
54 using UIResourceRequestQueue = std::vector<UIResourceRequest>;
55 UIResourceRequestQueue ui_resource_request_queue_;
56
57 DISALLOW_COPY_AND_ASSIGN(UIResourceManager);
58 };
59
60 } // namespace cc
61
62 #endif // CC_RESOURCES_UI_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/scoped_ui_resource.cc ('k') | cc/resources/ui_resource_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698