Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_ | |
| OLD | NEW |