| 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 virtual ~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 virtual gfx::Size GetUIResourceSize(UIResourceId id) const; |
| 36 |
| 37 // Methods meant to be used only internally in cc ------------ |
| 38 |
| 39 // The current UIResourceRequestQueue is moved to the caller. |
| 40 std::vector<UIResourceRequest> TakeUIResourcesRequests(); |
| 41 |
| 42 // Put the recreation of all UI resources into the resource queue after they |
| 43 // were evicted on the impl thread. |
| 44 void RecreateUIResources(); |
| 45 |
| 46 private: |
| 47 struct UIResourceClientData { |
| 48 UIResourceClient* client; |
| 49 gfx::Size size; |
| 50 }; |
| 51 |
| 52 using UIResourceClientMap = |
| 53 std::unordered_map<UIResourceId, UIResourceClientData>; |
| 54 UIResourceClientMap ui_resource_client_map_; |
| 55 int next_ui_resource_id_; |
| 56 |
| 57 using UIResourceRequestQueue = std::vector<UIResourceRequest>; |
| 58 UIResourceRequestQueue ui_resource_request_queue_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(UIResourceManager); |
| 61 }; |
| 62 |
| 63 } // namespace cc |
| 64 |
| 65 #endif // CC_RESOURCES_UI_RESOURCE_MANAGER_H_ |
| OLD | NEW |