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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "cc/surfaces/surface_id.h" | 12 #include "cc/surfaces/surface_id.h" |
13 #include "cc/surfaces/surface_resource_holder.h" | 13 #include "cc/surfaces/surface_resource_holder.h" |
| 14 #include "cc/surfaces/surface_sequence.h" |
14 #include "cc/surfaces/surfaces_export.h" | 15 #include "cc/surfaces/surfaces_export.h" |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Size; | 18 class Size; |
18 } | 19 } |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
21 class CompositorFrame; | 22 class CompositorFrame; |
22 class CopyOutputRequest; | 23 class CopyOutputRequest; |
23 class Surface; | 24 class Surface; |
24 class SurfaceFactoryClient; | 25 class SurfaceFactoryClient; |
25 class SurfaceManager; | 26 class SurfaceManager; |
26 | 27 |
27 // A SurfaceFactory is used to create surfaces that may share resources and | 28 // A SurfaceFactory is used to create surfaces that may share resources and |
28 // receive returned resources for frames submitted to those surfaces. Resources | 29 // receive returned resources for frames submitted to those surfaces. Resources |
29 // submitted to frames created by a particular factory will be returned to that | 30 // submitted to frames created by a particular factory will be returned to that |
30 // factory's client when they are no longer being used. This is the only class | 31 // factory's client when they are no longer being used. This is the only class |
31 // most users of surfaces will need to directly interact with. | 32 // most users of surfaces will need to directly interact with. |
32 class CC_SURFACES_EXPORT SurfaceFactory | 33 class CC_SURFACES_EXPORT SurfaceFactory |
33 : public base::SupportsWeakPtr<SurfaceFactory> { | 34 : public base::SupportsWeakPtr<SurfaceFactory> { |
34 public: | 35 public: |
35 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); | 36 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); |
36 ~SurfaceFactory(); | 37 ~SurfaceFactory(); |
37 | 38 |
38 void Create(SurfaceId surface_id, const gfx::Size& size); | 39 void Create(SurfaceId surface_id, const gfx::Size& size); |
39 void Destroy(SurfaceId surface_id); | 40 void Destroy(SurfaceId surface_id); |
| 41 void DestroyOnSequence(SurfaceId surface_id, |
| 42 const std::set<SurfaceSequence>& dependency_set); |
40 // A frame can only be submitted to a surface created by this factory, | 43 // A frame can only be submitted to a surface created by this factory, |
41 // although the frame may reference surfaces created by other factories. | 44 // although the frame may reference surfaces created by other factories. |
42 // The callback is called the first time this frame is used to draw. | 45 // The callback is called the first time this frame is used to draw. |
43 void SubmitFrame(SurfaceId surface_id, | 46 void SubmitFrame(SurfaceId surface_id, |
44 scoped_ptr<CompositorFrame> frame, | 47 scoped_ptr<CompositorFrame> frame, |
45 const base::Closure& callback); | 48 const base::Closure& callback); |
46 void RequestCopyOfSurface(SurfaceId surface_id, | 49 void RequestCopyOfSurface(SurfaceId surface_id, |
47 scoped_ptr<CopyOutputRequest> copy_request); | 50 scoped_ptr<CopyOutputRequest> copy_request); |
48 | 51 |
49 SurfaceFactoryClient* client() { return client_; } | 52 SurfaceFactoryClient* client() { return client_; } |
50 | 53 |
51 void ReceiveFromChild(const TransferableResourceArray& resources); | 54 void ReceiveFromChild(const TransferableResourceArray& resources); |
52 void RefResources(const TransferableResourceArray& resources); | 55 void RefResources(const TransferableResourceArray& resources); |
53 void UnrefResources(const ReturnedResourceArray& resources); | 56 void UnrefResources(const ReturnedResourceArray& resources); |
54 | 57 |
| 58 SurfaceManager* manager() { return manager_; } |
| 59 |
55 private: | 60 private: |
56 SurfaceManager* manager_; | 61 SurfaceManager* manager_; |
57 SurfaceFactoryClient* client_; | 62 SurfaceFactoryClient* client_; |
58 SurfaceResourceHolder holder_; | 63 SurfaceResourceHolder holder_; |
59 | 64 |
60 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; | 65 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; |
61 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; | 66 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; |
62 | 67 |
63 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 68 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
64 }; | 69 }; |
65 | 70 |
66 } // namespace cc | 71 } // namespace cc |
67 | 72 |
68 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 73 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
OLD | NEW |