Chromium Code Reviews| Index: cc/surfaces/surface_factory.h |
| diff --git a/cc/surfaces/surface_factory.h b/cc/surfaces/surface_factory.h |
| index 3a6431596bc9cc470e8ef4fdbae1520988543e14..59043be6ea7a7796609b4df6b06bff3a11eb8957 100644 |
| --- a/cc/surfaces/surface_factory.h |
| +++ b/cc/surfaces/surface_factory.h |
| @@ -7,7 +7,6 @@ |
| #include <memory> |
| #include <set> |
| -#include <unordered_map> |
| #include "base/callback_forward.h" |
| #include "base/macros.h" |
| @@ -30,11 +29,14 @@ 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. |
| +// This class is used for creating surfaces and submitting compositor frames to |
| +// them. Surfaces are created lazily each time SubmitCompositorFrame is |
| +// called with a local frame id that is different from the last call. Only one |
| +// surface is owned by this class at a time, and upon constructing a new surface |
| +// the old one will be destructed. Resources submitted to surfaces 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: |
| using DrawCallback = base::Callback<void()>; |
| @@ -46,30 +48,26 @@ class CC_SURFACES_EXPORT SurfaceFactory { |
| const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| - void Create(const LocalFrameId& local_frame_id); |
| - void Destroy(const LocalFrameId& local_frame_id); |
| + // Destroys the current surface. You need to call this method before the |
| + // factory is destroyed, or when you would like to get rid of the surface as |
| + // soon as possible (otherwise, the next time you call SubmitCompositorFrame |
| + // the old surface will be dealt with) |
|
danakj
2016/11/15 00:43:41
nit: period
Saman Sami
2016/11/15 21:12:19
Done.
|
| + void EvictSurface(); |
| - // Destroys all surfaces. |
| - void DestroyAll(); |
| - |
| - // Destroys and disown all surfaces, and reset all resource references. This |
| - // is useful when resources are invalid (e.g. lost context). |
| + // Destroys and disowns the current surface, and resets all resource |
| + // references. This is useful when resources are invalid (e.g. lost context). |
| void Reset(); |
| - // Set that the current frame on new_id is to be treated as the successor to |
| - // the current frame on old_id for the purposes of calculating damage. |
| - void SetPreviousFrameSurface(const LocalFrameId& new_id, |
| - const LocalFrameId& old_id); |
| - |
| - // A frame can only be submitted to a surface created by this factory, |
| - // although the frame may reference surfaces created by other factories. |
| - // The callback is called the first time this frame is used to draw, or if |
| - // the frame is discarded. |
| + // Submits the frame to the current surface being managed by the factory if |
| + // the local frame ids match, or creates a new surface with the given local |
| + // frame id, destroys the old one, and submits the frame to this new surface. |
| + // The frame can contain references to any surface, regardless of which |
| + // factory owns it. The callback is called the first time this frame is used |
| + // to draw, or if the frame is discarded. |
| void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
| CompositorFrame frame, |
| const DrawCallback& callback); |
| - void RequestCopyOfSurface(const LocalFrameId& local_frame_id, |
| - std::unique_ptr<CopyOutputRequest> copy_request); |
| + void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> copy_request); |
| void WillDrawSurface(const LocalFrameId& id, const gfx::Rect& damage_rect); |
| @@ -92,17 +90,15 @@ class CC_SURFACES_EXPORT SurfaceFactory { |
| void DidDestroySurfaceManager() { manager_ = nullptr; } |
| private: |
| - FrameSinkId frame_sink_id_; |
| + std::unique_ptr<Surface> Create(const LocalFrameId& local_frame_id); |
| + void Destroy(std::unique_ptr<Surface> surface); |
| + |
| + const FrameSinkId frame_sink_id_; |
| SurfaceManager* manager_; |
| SurfaceFactoryClient* client_; |
| SurfaceResourceHolder holder_; |
| - |
| bool needs_sync_points_; |
| - |
| - using OwningSurfaceMap = std:: |
| - unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
| - OwningSurfaceMap surface_map_; |
| - |
| + std::unique_ptr<Surface> current_surface_; |
| base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |