Chromium Code Reviews| Index: cc/resources/ui_resource_manager.h |
| diff --git a/cc/resources/ui_resource_manager.h b/cc/resources/ui_resource_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f37606640fd276772b7349605089a779186d12da |
| --- /dev/null |
| +++ b/cc/resources/ui_resource_manager.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_RESOURCES_UI_RESOURCE_MANAGER_H_ |
| +#define CC_RESOURCES_UI_RESOURCE_MANAGER_H_ |
| + |
| +#include <unordered_map> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "cc/base/cc_export.h" |
| +#include "cc/resources/scoped_ui_resource.h" |
| +#include "cc/resources/ui_resource_request.h" |
| + |
| +namespace cc { |
| +class UIResourceRequest; |
| + |
| +class CC_EXPORT UIResourceManager { |
| + public: |
| + UIResourceManager(); |
| + ~UIResourceManager(); |
| + |
| + // CreateUIResource creates a resource given a bitmap. The bitmap is |
| + // generated via an interface function, which is called when initializing the |
| + // resource and when the resource has been lost (due to lost context). The |
| + // parameter of the interface is a single boolean, which indicates whether the |
| + // resource has been lost or not. CreateUIResource returns an Id of the |
| + // resource, which is always positive. |
| + virtual UIResourceId CreateUIResource(UIResourceClient* client); |
| + |
| + // Deletes a UI resource. May safely be called more than once. |
| + virtual void DeleteUIResource(UIResourceId id); |
| + |
| + // Put the recreation of all UI resources into the resource queue after they |
| + // were evicted on the impl thread. |
| + void RecreateUIResources(); |
| + |
| + virtual gfx::Size GetUIResourceSize(UIResourceId id) const; |
| + |
| + 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.
|
| + |
| + private: |
| + struct UIResourceClientData { |
| + UIResourceClient* client; |
| + gfx::Size size; |
| + }; |
| + |
| + using UIResourceClientMap = |
| + std::unordered_map<UIResourceId, UIResourceClientData>; |
| + UIResourceClientMap ui_resource_client_map_; |
| + int next_ui_resource_id_; |
| + |
| + using UIResourceRequestQueue = std::vector<UIResourceRequest>; |
| + UIResourceRequestQueue ui_resource_request_queue_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UIResourceManager); |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_RESOURCES_UI_RESOURCE_MANAGER_H_ |