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

Unified Diff: cc/resources/ui_resource_manager.h

Issue 2322943003: cc: Move UI Resource management out of LayerTreeHost. (Closed)
Patch Set: virtual dtor 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..551a285a544221129141d5a72c886d06e8d4d07a
--- /dev/null
+++ b/cc/resources/ui_resource_manager.h
@@ -0,0 +1,65 @@
+// 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();
+ virtual ~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);
+
+ virtual gfx::Size GetUIResourceSize(UIResourceId id) const;
+
+ // Methods meant to be used only internally in cc ------------
+
+ // The current UIResourceRequestQueue is moved to the caller.
+ std::vector<UIResourceRequest> TakeUIResourcesRequests();
+
+ // Put the recreation of all UI resources into the resource queue after they
+ // were evicted on the impl thread.
+ void RecreateUIResources();
+
+ 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_
« 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