diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 02:14:23 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 02:14:23 +0000 |
commit | 65d540fca58712c931316119ea6db4825260423d (patch) | |
tree | 59f765ae903215cb22c1949685784ebe4a36ac77 /cc/surfaces/surface.h | |
parent | 64f537d8537a86f816a518413f96099a15f752b2 (diff) | |
download | chromium_src-65d540fca58712c931316119ea6db4825260423d.zip chromium_src-65d540fca58712c931316119ea6db4825260423d.tar.gz chromium_src-65d540fca58712c931316119ea6db4825260423d.tar.bz2 |
Manage resource lifetimes in frames submitted to Surfaces
This keeps track of the use of resources in frames sumbmitted to
surfaces as well as refs grabbed by ResourceProviders that want to draw
the submitted frames.
BUG=339257
Review URL: https://codereview.chromium.org/195993006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/surfaces/surface.h')
-rw-r--r-- | cc/surfaces/surface.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h index 60c992c..007f33d 100644 --- a/cc/surfaces/surface.h +++ b/cc/surfaces/surface.h @@ -5,8 +5,12 @@ #ifndef CC_SURFACES_SURFACE_H_ #define CC_SURFACES_SURFACE_H_ +#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" +#include "cc/resources/resource_provider.h" +#include "cc/resources/return_callback.h" +#include "cc/surfaces/surface_client.h" #include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" #include "ui/gfx/size.h" @@ -14,7 +18,6 @@ namespace cc { class CompositorFrame; class SurfaceManager; -class SurfaceClient; class CC_SURFACES_EXPORT Surface { public: @@ -30,7 +33,18 @@ class CC_SURFACES_EXPORT Surface { // Returns the most recent frame that is eligible to be rendered. CompositorFrame* GetEligibleFrame(); + // Takes a reference to all of the current frame's resources for an external + // consumer (e.g. a ResourceProvider). The caller to this should call + // UnrefResources() when they are done with the resources. + void RefCurrentFrameResources(); + void UnrefResources(const ReturnedResourceArray& resources); + + // Returns all resources that are currently not in use to the client. + void ReturnUnusedResourcesToClient(); + private: + void ReceiveResourcesFromClient(const TransferableResourceArray& resources); + SurfaceManager* manager_; SurfaceClient* client_; gfx::Size size_; @@ -38,6 +52,21 @@ class CC_SURFACES_EXPORT Surface { // TODO(jamesr): Support multiple frames in flight. scoped_ptr<CompositorFrame> current_frame_; + struct ResourceRefs { + ResourceRefs(); + + int refs_received_from_child; + int refs_holding_resource_alive; + }; + // Keeps track of the number of users currently in flight for each resource + // ID we've received from the client. When this counter hits zero for a + // particular resource, that ID is available to return to the client. + typedef base::hash_map<ResourceProvider::ResourceId, ResourceRefs> + ResourceIdCountMap; + ResourceIdCountMap resource_id_use_count_map_; + + ReturnedResourceArray resources_available_to_return_; + DISALLOW_COPY_AND_ASSIGN(Surface); }; |