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 28 matching lines...) Expand all Loading... |
39 public: | 39 public: |
40 using DrawCallback = base::Callback<void()>; | 40 using DrawCallback = base::Callback<void()>; |
41 | 41 |
42 SurfaceFactory(const FrameSinkId& frame_sink_id, | 42 SurfaceFactory(const FrameSinkId& frame_sink_id, |
43 SurfaceManager* manager, | 43 SurfaceManager* manager, |
44 SurfaceFactoryClient* client); | 44 SurfaceFactoryClient* client); |
45 ~SurfaceFactory(); | 45 ~SurfaceFactory(); |
46 | 46 |
47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
48 | 48 |
49 void Create(const LocalFrameId& local_frame_id); | |
50 void Destroy(const LocalFrameId& local_frame_id); | |
51 | 49 |
52 // Destroys all surfaces. | 50 // Destroys all surfaces. |
53 void DestroyAll(); | |
54 | |
55 // Destroys and disown all surfaces, and reset all resource references. This | 51 // Destroys and disown all surfaces, and reset all resource references. This |
56 // is useful when resources are invalid (e.g. lost context). | 52 // is useful when resources are invalid (e.g. lost context). |
57 void Reset(); | 53 void Reset(); |
58 | 54 |
59 // Set that the current frame on new_id is to be treated as the successor to | 55 // Set that the current frame on new_id is to be treated as the successor to |
60 // the current frame on old_id for the purposes of calculating damage. | 56 // the current frame on old_id for the purposes of calculating damage. |
61 void SetPreviousFrameSurface(const LocalFrameId& new_id, | 57 void SetPreviousFrameSurface(const LocalFrameId& new_id, |
62 const LocalFrameId& old_id); | 58 const LocalFrameId& old_id); |
63 | 59 |
64 // A frame can only be submitted to a surface created by this factory, | 60 // A frame can only be submitted to a surface created by this factory, |
(...skipping 21 matching lines...) Expand all Loading... |
86 // example if the Display shares a context with the creator. | 82 // example if the Display shares a context with the creator. |
87 bool needs_sync_points() const { return needs_sync_points_; } | 83 bool needs_sync_points() const { return needs_sync_points_; } |
88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } | 84 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } |
89 | 85 |
90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager | 86 // SurfaceFactory's owner can call this when it finds out that SurfaceManager |
91 // is no longer alive during destruction. | 87 // is no longer alive during destruction. |
92 void DidDestroySurfaceManager() { manager_ = nullptr; } | 88 void DidDestroySurfaceManager() { manager_ = nullptr; } |
93 | 89 |
94 private: | 90 private: |
95 FrameSinkId frame_sink_id_; | 91 FrameSinkId frame_sink_id_; |
| 92 LocalFrameId last_local_frame_id_; |
96 SurfaceManager* manager_; | 93 SurfaceManager* manager_; |
97 SurfaceFactoryClient* client_; | 94 SurfaceFactoryClient* client_; |
98 SurfaceResourceHolder holder_; | 95 SurfaceResourceHolder holder_; |
99 | 96 |
100 bool needs_sync_points_; | 97 bool needs_sync_points_; |
| 98 void Create(const LocalFrameId& local_frame_id); |
| 99 void Destroy(const LocalFrameId& local_frame_id); |
| 100 void DestroyAll(); |
101 | 101 |
102 using OwningSurfaceMap = std:: | 102 using OwningSurfaceMap = std:: |
103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; | 103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
104 OwningSurfaceMap surface_map_; | 104 OwningSurfaceMap surface_map_; |
105 | 105 |
106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; | 106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace cc | 111 } // namespace cc |
112 | 112 |
113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
OLD | NEW |