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 | |
52 // Destroys all surfaces. | |
53 void DestroyAll(); | |
54 | |
55 // Destroys and disown all surfaces, and reset all resource references. This | 49 // Destroys and disown all surfaces, and reset all resource references. This |
56 // is useful when resources are invalid (e.g. lost context). | 50 // is useful when resources are invalid (e.g. lost context). |
57 void Reset(); | 51 void Reset(); |
58 | 52 |
59 // Set that the current frame on new_id is to be treated as the successor to | 53 // 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. | 54 // the current frame on old_id for the purposes of calculating damage. |
61 void SetPreviousFrameSurface(const LocalFrameId& new_id, | 55 void SetPreviousFrameSurface(const LocalFrameId& new_id, |
Fady Samuel
2016/11/11 19:02:20
Make this private.
| |
62 const LocalFrameId& old_id); | 56 const LocalFrameId& old_id); |
63 | 57 |
64 // A frame can only be submitted to a surface created by this factory, | 58 // A frame can only be submitted to a surface created by this factory, |
65 // although the frame may reference surfaces created by other factories. | 59 // although the frame may reference surfaces created by other factories. |
66 // The callback is called the first time this frame is used to draw, or if | 60 // The callback is called the first time this frame is used to draw, or if |
67 // the frame is discarded. | 61 // the frame is discarded. |
68 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, | 62 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
69 CompositorFrame frame, | 63 CompositorFrame frame, |
70 const DrawCallback& callback); | 64 const DrawCallback& callback); |
71 void RequestCopyOfSurface(const LocalFrameId& local_frame_id, | 65 void RequestCopyOfSurface(const LocalFrameId& local_frame_id, |
(...skipping 14 matching lines...) Expand all Loading... | |
86 // example if the Display shares a context with the creator. | 80 // example if the Display shares a context with the creator. |
87 bool needs_sync_points() const { return needs_sync_points_; } | 81 bool needs_sync_points() const { return needs_sync_points_; } |
88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } | 82 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } |
89 | 83 |
90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager | 84 // SurfaceFactory's owner can call this when it finds out that SurfaceManager |
91 // is no longer alive during destruction. | 85 // is no longer alive during destruction. |
92 void DidDestroySurfaceManager() { manager_ = nullptr; } | 86 void DidDestroySurfaceManager() { manager_ = nullptr; } |
93 | 87 |
94 private: | 88 private: |
95 FrameSinkId frame_sink_id_; | 89 FrameSinkId frame_sink_id_; |
90 LocalFrameId current_local_frame_id_; | |
96 SurfaceManager* manager_; | 91 SurfaceManager* manager_; |
97 SurfaceFactoryClient* client_; | 92 SurfaceFactoryClient* client_; |
98 SurfaceResourceHolder holder_; | 93 SurfaceResourceHolder holder_; |
99 | 94 |
100 bool needs_sync_points_; | 95 bool needs_sync_points_; |
96 void Create(const LocalFrameId& local_frame_id); | |
97 void Destroy(const LocalFrameId& local_frame_id); | |
98 void DestroyAll(); | |
101 | 99 |
102 using OwningSurfaceMap = std:: | 100 using OwningSurfaceMap = std:: |
103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; | 101 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
104 OwningSurfaceMap surface_map_; | 102 OwningSurfaceMap surface_map_; |
105 | 103 |
106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; | 104 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
107 | 105 |
108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 106 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
109 }; | 107 }; |
110 | 108 |
111 } // namespace cc | 109 } // namespace cc |
112 | 110 |
113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 111 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
OLD | NEW |