diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 01:17:34 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 01:17:34 +0000 |
commit | 387b59dfaa6e4d21cf106b212763eda19a6bf6bb (patch) | |
tree | db15559e1081e6e0c32ea4e734d2667ca52b75d6 /cc/surfaces/surface_factory.h | |
parent | 48d2b7c54479f23c092bbaf923fd47db3b8e2f91 (diff) | |
download | chromium_src-387b59dfaa6e4d21cf106b212763eda19a6bf6bb.zip chromium_src-387b59dfaa6e4d21cf106b212763eda19a6bf6bb.tar.gz chromium_src-387b59dfaa6e4d21cf106b212763eda19a6bf6bb.tar.bz2 |
Use a SurfaceFactory and manage resources for that group of surfaces
This adds a SurfaceFactory by which a client (normally a compositor
instance) can create and destroy surfaces that may want to reuse
resources. All frames must be submitted through the factory, although
a frame may reference surfaces from different factories.
BUG=339257
Review URL: https://codereview.chromium.org/332293003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/surfaces/surface_factory.h')
-rw-r--r-- | cc/surfaces/surface_factory.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cc/surfaces/surface_factory.h b/cc/surfaces/surface_factory.h new file mode 100644 index 0000000..5ea85d4 --- /dev/null +++ b/cc/surfaces/surface_factory.h @@ -0,0 +1,61 @@ +// Copyright 2014 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_SURFACES_SURFACE_FACTORY_H_ +#define CC_SURFACES_SURFACE_FACTORY_H_ + +#include "base/containers/scoped_ptr_hash_map.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "cc/surfaces/surface_id.h" +#include "cc/surfaces/surface_resource_holder.h" +#include "cc/surfaces/surfaces_export.h" + +namespace gfx { +class Size; +} + +namespace cc { +class CompositorFrame; +class Surface; +class SurfaceFactoryClient; +class SurfaceManager; + +// A SurfaceFactory is used to create surfaces that may share resources and +// receive returned resources for frames submitted to those surfaces. Resources +// submitted to frames created by a particular factory will be returned to that +// factory's client when they are no longer being used. This is the only class +// most users of surfaces will need to directly interact with. +class CC_SURFACES_EXPORT SurfaceFactory + : public base::SupportsWeakPtr<SurfaceFactory> { + public: + SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); + ~SurfaceFactory(); + + SurfaceId Create(const gfx::Size& size); + void Destroy(SurfaceId surface_id); + // A frame can only be submitted to a surface created by this factory, + // although the frame may reference surfaces created by other factories. + void SubmitFrame(SurfaceId surface_id, scoped_ptr<CompositorFrame> frame); + + SurfaceFactoryClient* client() { return client_; } + + void ReceiveFromChild(const TransferableResourceArray& resources); + void RefResources(const TransferableResourceArray& resources); + void UnrefResources(const ReturnedResourceArray& resources); + + private: + SurfaceManager* manager_; + SurfaceFactoryClient* client_; + typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; + base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; + + SurfaceResourceHolder holder_; + + DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); +}; + +} // namespace cc + +#endif // CC_SURFACES_SURFACE_FACTORY_H_ |