| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_SURFACES_SURFACE_FACTORY_H_ | 5 #ifndef CC_SURFACES_SURFACE_FACTORY_H_ |
| 6 #define CC_SURFACES_SURFACE_FACTORY_H_ | 6 #define CC_SURFACES_SURFACE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class CopyOutputRequest; | 28 class CopyOutputRequest; |
| 29 class Surface; | 29 class Surface; |
| 30 class SurfaceFactoryClient; | 30 class SurfaceFactoryClient; |
| 31 class SurfaceManager; | 31 class SurfaceManager; |
| 32 | 32 |
| 33 // A SurfaceFactory is used to create surfaces that may share resources and | 33 // A SurfaceFactory is used to create surfaces that may share resources and |
| 34 // receive returned resources for frames submitted to those surfaces. Resources | 34 // receive returned resources for frames submitted to those surfaces. Resources |
| 35 // submitted to frames created by a particular factory will be returned to that | 35 // submitted to frames created by a particular factory will be returned to that |
| 36 // factory's client when they are no longer being used. This is the only class | 36 // factory's client when they are no longer being used. This is the only class |
| 37 // most users of surfaces will need to directly interact with. | 37 // most users of surfaces will need to directly interact with. |
| 38 class CC_SURFACES_EXPORT SurfaceFactory | 38 class CC_SURFACES_EXPORT SurfaceFactory { |
| 39 : public base::SupportsWeakPtr<SurfaceFactory> { | |
| 40 public: | 39 public: |
| 41 using DrawCallback = base::Callback<void()>; | 40 using DrawCallback = base::Callback<void()>; |
| 42 | 41 |
| 43 SurfaceFactory(const FrameSinkId& frame_sink_id, | 42 SurfaceFactory(const FrameSinkId& frame_sink_id, |
| 44 SurfaceManager* manager, | 43 SurfaceManager* manager, |
| 45 SurfaceFactoryClient* client); | 44 SurfaceFactoryClient* client); |
| 46 ~SurfaceFactory(); | 45 ~SurfaceFactory(); |
| 47 | 46 |
| 48 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 49 | 48 |
| 50 void Create(const LocalFrameId& local_frame_id); | 49 void Create(const LocalFrameId& local_frame_id); |
| 51 void Destroy(const LocalFrameId& local_frame_id); | 50 void Destroy(const LocalFrameId& local_frame_id); |
| 51 |
| 52 // Destroys all surfaces. |
| 52 void DestroyAll(); | 53 void DestroyAll(); |
| 53 | 54 |
| 55 // Destroys and disown all surfaces, and reset all resource references. This |
| 56 // is useful when resources are invalid (e.g. lost context). |
| 57 void Reset(); |
| 58 |
| 54 // Set that the current frame on new_id is to be treated as the successor to | 59 // Set that the current frame on new_id is to be treated as the successor to |
| 55 // the current frame on old_id for the purposes of calculating damage. | 60 // the current frame on old_id for the purposes of calculating damage. |
| 56 void SetPreviousFrameSurface(const LocalFrameId& new_id, | 61 void SetPreviousFrameSurface(const LocalFrameId& new_id, |
| 57 const LocalFrameId& old_id); | 62 const LocalFrameId& old_id); |
| 58 | 63 |
| 59 // A frame can only be submitted to a surface created by this factory, | 64 // A frame can only be submitted to a surface created by this factory, |
| 60 // although the frame may reference surfaces created by other factories. | 65 // although the frame may reference surfaces created by other factories. |
| 61 // The callback is called the first time this frame is used to draw, or if | 66 // The callback is called the first time this frame is used to draw, or if |
| 62 // the frame is discarded. | 67 // the frame is discarded. |
| 63 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, | 68 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 SurfaceManager* manager_; | 96 SurfaceManager* manager_; |
| 92 SurfaceFactoryClient* client_; | 97 SurfaceFactoryClient* client_; |
| 93 SurfaceResourceHolder holder_; | 98 SurfaceResourceHolder holder_; |
| 94 | 99 |
| 95 bool needs_sync_points_; | 100 bool needs_sync_points_; |
| 96 | 101 |
| 97 using OwningSurfaceMap = std:: | 102 using OwningSurfaceMap = std:: |
| 98 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; | 103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
| 99 OwningSurfaceMap surface_map_; | 104 OwningSurfaceMap surface_map_; |
| 100 | 105 |
| 106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
| 107 |
| 101 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
| 102 }; | 109 }; |
| 103 | 110 |
| 104 } // namespace cc | 111 } // namespace cc |
| 105 | 112 |
| 106 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
| OLD | NEW |