Index: cc/surfaces/surface_factory.h |
diff --git a/cc/surfaces/surface_factory.h b/cc/surfaces/surface_factory.h |
index 21a0c1858de34137c8eaaff31b6f8d4023571a15..3a6431596bc9cc470e8ef4fdbae1520988543e14 100644 |
--- a/cc/surfaces/surface_factory.h |
+++ b/cc/surfaces/surface_factory.h |
@@ -7,6 +7,7 @@ |
#include <memory> |
#include <set> |
+#include <unordered_map> |
#include "base/callback_forward.h" |
#include "base/macros.h" |
@@ -29,14 +30,11 @@ |
class SurfaceFactoryClient; |
class SurfaceManager; |
-// 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. |
+// 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: |
using DrawCallback = base::Callback<void()>; |
@@ -48,26 +46,30 @@ |
const FrameSinkId& frame_sink_id() const { return frame_sink_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). |
- void EvictSurface(); |
+ void Create(const LocalFrameId& local_frame_id); |
+ void Destroy(const LocalFrameId& local_frame_id); |
- // Destroys and disowns the current surface, and resets all resource |
- // references. This is useful when resources are invalid (e.g. lost context). |
+ // 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). |
void Reset(); |
- // 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. |
+ // 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. |
void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
CompositorFrame frame, |
const DrawCallback& callback); |
- void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> copy_request); |
+ void RequestCopyOfSurface(const LocalFrameId& local_frame_id, |
+ std::unique_ptr<CopyOutputRequest> copy_request); |
void WillDrawSurface(const LocalFrameId& id, const gfx::Rect& damage_rect); |
@@ -90,15 +92,17 @@ |
void DidDestroySurfaceManager() { manager_ = nullptr; } |
private: |
- std::unique_ptr<Surface> Create(const LocalFrameId& local_frame_id); |
- void Destroy(std::unique_ptr<Surface> surface); |
- |
- const FrameSinkId frame_sink_id_; |
+ FrameSinkId frame_sink_id_; |
SurfaceManager* manager_; |
SurfaceFactoryClient* client_; |
SurfaceResourceHolder holder_; |
+ |
bool needs_sync_points_; |
- std::unique_ptr<Surface> current_surface_; |
+ |
+ using OwningSurfaceMap = std:: |
+ unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
+ OwningSurfaceMap surface_map_; |
+ |
base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |