| 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 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // them. Surfaces are created lazily each time SubmitCompositorFrame is | 29 // them. Surfaces are created lazily each time SubmitCompositorFrame is |
| 30 // called with a local frame id that is different from the last call. Only one | 30 // called with a local frame id that is different from the last call. Only one |
| 31 // surface is owned by this class at a time, and upon constructing a new surface | 31 // surface is owned by this class at a time, and upon constructing a new surface |
| 32 // the old one will be destructed. Resources submitted to surfaces created by a | 32 // the old one will be destructed. Resources submitted to surfaces created by a |
| 33 // particular factory will be returned to that factory's client when they are no | 33 // particular factory will be returned to that factory's client when they are no |
| 34 // longer being used. This is the only class most users of surfaces will need to | 34 // longer being used. This is the only class most users of surfaces will need to |
| 35 // directly interact with. | 35 // directly interact with. |
| 36 class CC_SURFACES_EXPORT SurfaceFactory : public PendingFrameObserver { | 36 class CC_SURFACES_EXPORT SurfaceFactory : public PendingFrameObserver { |
| 37 public: | 37 public: |
| 38 using DrawCallback = base::Callback<void()>; | 38 using DrawCallback = base::Callback<void()>; |
| 39 using WillDrawCallback = |
| 40 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>; |
| 39 | 41 |
| 40 SurfaceFactory(const FrameSinkId& frame_sink_id, | 42 SurfaceFactory(const FrameSinkId& frame_sink_id, |
| 41 SurfaceManager* manager, | 43 SurfaceManager* manager, |
| 42 SurfaceFactoryClient* client); | 44 SurfaceFactoryClient* client); |
| 43 ~SurfaceFactory() override; | 45 ~SurfaceFactory() override; |
| 44 | 46 |
| 45 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 46 | 48 |
| 47 // Destroys the current surface. You need to call this method before the | 49 // Destroys the current surface. You need to call this method before the |
| 48 // factory is destroyed, or when you would like to get rid of the surface as | 50 // factory is destroyed, or when you would like to get rid of the surface as |
| 49 // soon as possible (otherwise, the next time you call SubmitCompositorFrame | 51 // soon as possible (otherwise, the next time you call SubmitCompositorFrame |
| 50 // the old surface will be dealt with). | 52 // the old surface will be dealt with). |
| 51 void EvictSurface(); | 53 void EvictSurface(); |
| 52 | 54 |
| 53 // Submits the frame to the current surface being managed by the factory if | 55 // Submits the frame to the current surface being managed by the factory if |
| 54 // the local frame ids match, or creates a new surface with the given local | 56 // the local frame ids match, or creates a new surface with the given local |
| 55 // frame id, destroys the old one, and submits the frame to this new surface. | 57 // frame id, destroys the old one, and submits the frame to this new surface. |
| 56 // The frame can contain references to any surface, regardless of which | 58 // The frame can contain references to any surface, regardless of which |
| 57 // factory owns it. The callback is called the first time this frame is used | 59 // factory owns it. The callback is called the first time this frame is used |
| 58 // to draw, or if the frame is discarded. | 60 // to draw, or if the frame is discarded. |
| 59 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, | 61 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, |
| 60 CompositorFrame frame, | 62 CompositorFrame frame, |
| 61 const DrawCallback& callback); | 63 const DrawCallback& callback, |
| 64 const WillDrawCallback& will_draw_callback); |
| 62 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> copy_request); | 65 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> copy_request); |
| 63 | 66 |
| 64 // Evicts the current frame on the surface. All the resources | 67 // Evicts the current frame on the surface. All the resources |
| 65 // will be released and Surface::HasFrame will return false. | 68 // will be released and Surface::HasFrame will return false. |
| 66 void ClearSurface(); | 69 void ClearSurface(); |
| 67 | 70 |
| 68 void WillDrawSurface(const LocalSurfaceId& id, const gfx::Rect& damage_rect); | |
| 69 | |
| 70 SurfaceFactoryClient* client() { return client_; } | 71 SurfaceFactoryClient* client() { return client_; } |
| 71 | 72 |
| 72 void ReceiveFromChild(const TransferableResourceArray& resources); | 73 void ReceiveFromChild(const TransferableResourceArray& resources); |
| 73 void RefResources(const TransferableResourceArray& resources); | 74 void RefResources(const TransferableResourceArray& resources); |
| 74 void UnrefResources(const ReturnedResourceArray& resources); | 75 void UnrefResources(const ReturnedResourceArray& resources); |
| 75 | 76 |
| 76 SurfaceManager* manager() { return manager_; } | 77 SurfaceManager* manager() { return manager_; } |
| 77 | 78 |
| 78 Surface* current_surface_for_testing() { return current_surface_.get(); } | 79 Surface* current_surface_for_testing() { return current_surface_.get(); } |
| 79 | 80 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 bool seen_first_frame_activation_ = false; | 104 bool seen_first_frame_activation_ = false; |
| 104 std::unique_ptr<Surface> current_surface_; | 105 std::unique_ptr<Surface> current_surface_; |
| 105 base::WeakPtrFactory<SurfaceFactory> weak_factory_; | 106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
| 106 | 107 |
| 107 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 } // namespace cc | 111 } // namespace cc |
| 111 | 112 |
| 112 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
| OLD | NEW |