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> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/optional.h" | |
| 16 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 17 #include "cc/surfaces/surface_id.h" | 18 #include "cc/surfaces/surface_id.h" |
| 18 #include "cc/surfaces/surface_resource_holder.h" | 19 #include "cc/surfaces/surface_resource_holder.h" |
| 19 #include "cc/surfaces/surface_sequence.h" | 20 #include "cc/surfaces/surface_sequence.h" |
| 20 #include "cc/surfaces/surfaces_export.h" | 21 #include "cc/surfaces/surfaces_export.h" |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 class Size; | 24 class Size; |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 39 public: | 40 public: |
| 40 using DrawCallback = base::Callback<void()>; | 41 using DrawCallback = base::Callback<void()>; |
| 41 | 42 |
| 42 SurfaceFactory(const FrameSinkId& frame_sink_id, | 43 SurfaceFactory(const FrameSinkId& frame_sink_id, |
| 43 SurfaceManager* manager, | 44 SurfaceManager* manager, |
| 44 SurfaceFactoryClient* client); | 45 SurfaceFactoryClient* client); |
| 45 ~SurfaceFactory(); | 46 ~SurfaceFactory(); |
| 46 | 47 |
| 47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 48 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 48 | 49 |
| 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 | 50 // Destroys and disown all surfaces, and reset all resource references. This |
| 56 // is useful when resources are invalid (e.g. lost context). | 51 // is useful when resources are invalid (e.g. lost context). |
| 57 void Reset(); | 52 void Reset(); |
| 58 | 53 |
| 59 // Set that the current frame on new_id is to be treated as the successor to | 54 // 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. | 55 // the current frame on old_id for the purposes of calculating damage. |
| 61 void SetPreviousFrameSurface(const LocalFrameId& new_id, | 56 void SetPreviousFrameSurface(const LocalFrameId& new_id, |
| 62 const LocalFrameId& old_id); | 57 const LocalFrameId& old_id); |
| 63 | 58 |
| 64 // A frame can only be submitted to a surface created by this factory, | 59 // 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. | 81 // example if the Display shares a context with the creator. |
| 87 bool needs_sync_points() const { return needs_sync_points_; } | 82 bool needs_sync_points() const { return needs_sync_points_; } |
| 88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } | 83 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } |
| 89 | 84 |
| 90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager | 85 // SurfaceFactory's owner can call this when it finds out that SurfaceManager |
| 91 // is no longer alive during destruction. | 86 // is no longer alive during destruction. |
| 92 void DidDestroySurfaceManager() { manager_ = nullptr; } | 87 void DidDestroySurfaceManager() { manager_ = nullptr; } |
| 93 | 88 |
| 94 private: | 89 private: |
| 95 FrameSinkId frame_sink_id_; | 90 FrameSinkId frame_sink_id_; |
| 91 base::Optional<LocalFrameId> last_local_frame_id_; | |
|
Fady Samuel
2016/11/10 23:33:37
Why is this optional? I don't think this needs to
danakj
2016/11/10 23:57:58
Same, just have an empty/default id?
Saman Sami
2016/11/11 17:49:59
Done.
| |
| 96 SurfaceManager* manager_; | 92 SurfaceManager* manager_; |
| 97 SurfaceFactoryClient* client_; | 93 SurfaceFactoryClient* client_; |
| 98 SurfaceResourceHolder holder_; | 94 SurfaceResourceHolder holder_; |
| 99 | 95 |
| 100 bool needs_sync_points_; | 96 bool needs_sync_points_; |
| 97 void Create(const LocalFrameId& local_frame_id); | |
| 98 void Destroy(const LocalFrameId& local_frame_id); | |
| 99 void DestroyAll(); | |
| 101 | 100 |
| 102 using OwningSurfaceMap = std:: | 101 using OwningSurfaceMap = std:: |
| 103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; | 102 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; |
| 104 OwningSurfaceMap surface_map_; | 103 OwningSurfaceMap surface_map_; |
| 105 | 104 |
| 106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; | 105 base::WeakPtrFactory<SurfaceFactory> weak_factory_; |
| 107 | 106 |
| 108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); | 107 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); |
| 109 }; | 108 }; |
| 110 | 109 |
| 111 } // namespace cc | 110 } // namespace cc |
| 112 | 111 |
| 113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ | 112 #endif // CC_SURFACES_SURFACE_FACTORY_H_ |
| OLD | NEW |