Chromium Code Reviews| 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 | |
| 60 // the current frame on old_id for the purposes of calculating damage. | |
| 61 void SetPreviousFrameSurface(const LocalFrameId& new_id, | |
| 62 const LocalFrameId& old_id); | |
| 63 | |
| 64 // A frame can only be submitted to a surface created by this factory, | 53 // A frame can only be submitted to a surface created by this factory, |
| 65 // although the frame may reference surfaces created by other factories. | 54 // 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 | 55 // The callback is called the first time this frame is used to draw, or if |
| 67 // the frame is discarded. | 56 // the frame is discarded. |
| 68 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, | 57 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
| 69 CompositorFrame frame, | 58 CompositorFrame frame, |
| 70 const DrawCallback& callback); | 59 const DrawCallback& callback); |
| 71 void RequestCopyOfSurface(const LocalFrameId& local_frame_id, | 60 void RequestCopyOfSurface(const LocalFrameId& local_frame_id, |
| 72 std::unique_ptr<CopyOutputRequest> copy_request); | 61 std::unique_ptr<CopyOutputRequest> copy_request); |
| 73 | 62 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 85 // to have sync points set on them when returned from the Display, for | 74 // to have sync points set on them when returned from the Display, for |
| 86 // example if the Display shares a context with the creator. | 75 // example if the Display shares a context with the creator. |
| 87 bool needs_sync_points() const { return needs_sync_points_; } | 76 bool needs_sync_points() const { return needs_sync_points_; } |
| 88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } | 77 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } |
| 89 | 78 |
| 90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager | 79 // SurfaceFactory's owner can call this when it finds out that SurfaceManager |
| 91 // is no longer alive during destruction. | 80 // is no longer alive during destruction. |
| 92 void DidDestroySurfaceManager() { manager_ = nullptr; } | 81 void DidDestroySurfaceManager() { manager_ = nullptr; } |
| 93 | 82 |
| 94 private: | 83 private: |
| 95 FrameSinkId frame_sink_id_; | 84 FrameSinkId frame_sink_id_; |
|
Fady Samuel
2016/11/11 19:47:56
nit make const.
| |
| 85 LocalFrameId current_local_frame_id_; | |
| 96 SurfaceManager* manager_; | 86 SurfaceManager* manager_; |
| 97 SurfaceFactoryClient* client_; | 87 SurfaceFactoryClient* client_; |
| 98 SurfaceResourceHolder holder_; | 88 SurfaceResourceHolder holder_; |
| 99 | 89 |
| 100 bool needs_sync_points_; | 90 bool needs_sync_points_; |
| 91 void Create(const LocalFrameId& local_frame_id); | |
|
Fady Samuel
2016/11/11 19:47:57
nit: style, we usually put methods above class var
| |
| 92 void Destroy(const LocalFrameId& local_frame_id); | |
| 93 void DestroyAll(); | |
|
Fady Samuel
2016/11/11 19:47:57
Rename DestroyAll() => EvictFrame() and make publi
| |
| 94 | |
| 95 // Set that the current frame on new_id is to be treated as the successor to | |
| 96 // the current frame on old_id for the purposes of calculating damage. | |
| 97 void SetPreviousFrameSurface(const LocalFrameId& new_id, | |
|
Fady Samuel
2016/11/11 19:47:57
Try to make method order in the cc file match the
| |
| 98 const LocalFrameId& old_id); | |
| 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_; |
|
Fady Samuel
2016/11/11 19:49:03
Replace this with:
std::unique_ptr<Surface> activ
| |
| 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 |