| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class SurfaceManager; | 28 class SurfaceManager; |
| 29 | 29 |
| 30 // A SurfaceFactory is used to create surfaces that may share resources and | 30 // A SurfaceFactory is used to create surfaces that may share resources and |
| 31 // receive returned resources for frames submitted to those surfaces. Resources | 31 // receive returned resources for frames submitted to those surfaces. Resources |
| 32 // submitted to frames created by a particular factory will be returned to that | 32 // submitted to frames created by a particular factory will be returned to that |
| 33 // factory's client when they are no longer being used. This is the only class | 33 // factory's client when they are no longer being used. This is the only class |
| 34 // most users of surfaces will need to directly interact with. | 34 // most users of surfaces will need to directly interact with. |
| 35 class CC_SURFACES_EXPORT SurfaceFactory | 35 class CC_SURFACES_EXPORT SurfaceFactory |
| 36 : public base::SupportsWeakPtr<SurfaceFactory> { | 36 : public base::SupportsWeakPtr<SurfaceFactory> { |
| 37 public: | 37 public: |
| 38 // This callback is called with true if the frame was drawn, or false if it |
| 39 // was discarded. |
| 40 using DrawCallback = base::Callback<void(bool)>; |
| 41 |
| 38 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); | 42 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); |
| 39 ~SurfaceFactory(); | 43 ~SurfaceFactory(); |
| 40 | 44 |
| 41 void Create(SurfaceId surface_id); | 45 void Create(SurfaceId surface_id); |
| 42 void Destroy(SurfaceId surface_id); | 46 void Destroy(SurfaceId surface_id); |
| 43 void DestroyAll(); | 47 void DestroyAll(); |
| 44 // A frame can only be submitted to a surface created by this factory, | 48 // A frame can only be submitted to a surface created by this factory, |
| 45 // although the frame may reference surfaces created by other factories. | 49 // although the frame may reference surfaces created by other factories. |
| 46 // The callback is called the first time this frame is used to draw. | 50 // The callback is called the first time this frame is used to draw, or if |
| 51 // the frame is discarded. |
| 47 void SubmitFrame(SurfaceId surface_id, | 52 void SubmitFrame(SurfaceId surface_id, |
| 48 scoped_ptr<CompositorFrame> frame, | 53 scoped_ptr<CompositorFrame> frame, |
| 49 const base::Closure& callback); | 54 const DrawCallback& callback); |
| 50 void RequestCopyOfSurface(SurfaceId surface_id, | 55 void RequestCopyOfSurface(SurfaceId surface_id, |
| 51 scoped_ptr<CopyOutputRequest> copy_request); | 56 scoped_ptr<CopyOutputRequest> copy_request); |
| 52 | 57 |
| 53 SurfaceFactoryClient* client() { return client_; } | 58 SurfaceFactoryClient* client() { return client_; } |
| 54 | 59 |
| 55 void ReceiveFromChild(const TransferableResourceArray& resources); | 60 void ReceiveFromChild(const TransferableResourceArray& resources); |
| 56 void RefResources(const TransferableResourceArray& resources); | 61 void RefResources(const TransferableResourceArray& resources); |
| 57 void UnrefResources(const ReturnedResourceArray& resources); | 62 void UnrefResources(const ReturnedResourceArray& resources); |
| 58 | 63 |
| 59 SurfaceManager* manager() { return manager_; } | 64 SurfaceManager* manager() { return manager_; } |
| 60 | 65 |
| 61 private: | 66 private: |
| 62 SurfaceManager* manager_; | 67 SurfaceManager* manager_; |
| 63 SurfaceFactoryClient* client_; | 68 SurfaceFactoryClient* client_; |
| 64 SurfaceResourceHolder holder_; | 69 SurfaceResourceHolder holder_; |
| 65 | 70 |
| 66 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; | 71 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; |
| 67 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; | 72 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; |
| 68 | 73 |
| 69 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 74 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
| 70 }; | 75 }; |
| 71 | 76 |
| 72 } // namespace cc | 77 } // namespace cc |
| 73 | 78 |
| 74 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 79 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
| OLD | NEW |