Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1340)

Side by Side Diff: cc/surfaces/surface_factory.h

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 50
52 // Destroys all surfaces. 51 // Destroys all surfaces.
53 void DestroyAll();
54
55 // Destroys and disown all surfaces, and reset all resource references. This 52 // Destroys and disown all surfaces, and reset all resource references. This
56 // is useful when resources are invalid (e.g. lost context). 53 // is useful when resources are invalid (e.g. lost context).
57 void Reset(); 54 void Reset();
58 55
59 // Set that the current frame on new_id is to be treated as the successor to 56 // 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. 57 // the current frame on old_id for the purposes of calculating damage.
61 void SetPreviousFrameSurface(const LocalFrameId& new_id, 58 void SetPreviousFrameSurface(const LocalFrameId& new_id,
62 const LocalFrameId& old_id); 59 const LocalFrameId& old_id);
63 60
64 // A frame can only be submitted to a surface created by this factory, 61 // A frame can only be submitted to a surface created by this factory,
(...skipping 21 matching lines...) Expand all
86 // example if the Display shares a context with the creator. 83 // example if the Display shares a context with the creator.
87 bool needs_sync_points() const { return needs_sync_points_; } 84 bool needs_sync_points() const { return needs_sync_points_; }
88 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } 85 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; }
89 86
90 // SurfaceFactory's owner can call this when it finds out that SurfaceManager 87 // SurfaceFactory's owner can call this when it finds out that SurfaceManager
91 // is no longer alive during destruction. 88 // is no longer alive during destruction.
92 void DidDestroySurfaceManager() { manager_ = nullptr; } 89 void DidDestroySurfaceManager() { manager_ = nullptr; }
93 90
94 private: 91 private:
95 FrameSinkId frame_sink_id_; 92 FrameSinkId frame_sink_id_;
93 base::Optional<LocalFrameId> last_local_frame_id_;
Fady Samuel 2016/11/10 23:33:36 why is this optional? If last_local_frame_id_ isn'
Saman Sami 2016/11/11 17:49:58 Done.
96 SurfaceManager* manager_; 94 SurfaceManager* manager_;
97 SurfaceFactoryClient* client_; 95 SurfaceFactoryClient* client_;
98 SurfaceResourceHolder holder_; 96 SurfaceResourceHolder holder_;
99 97
100 bool needs_sync_points_; 98 bool needs_sync_points_;
99 void Create(const LocalFrameId& local_frame_id);
100 void Destroy(const LocalFrameId& local_frame_id);
101 void DestroyAll();
101 102
102 using OwningSurfaceMap = std:: 103 using OwningSurfaceMap = std::
103 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>; 104 unordered_map<LocalFrameId, std::unique_ptr<Surface>, LocalFrameIdHash>;
104 OwningSurfaceMap surface_map_; 105 OwningSurfaceMap surface_map_;
105 106
106 base::WeakPtrFactory<SurfaceFactory> weak_factory_; 107 base::WeakPtrFactory<SurfaceFactory> weak_factory_;
107 108
108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); 109 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
109 }; 110 };
110 111
111 } // namespace cc 112 } // namespace cc
112 113
113 #endif // CC_SURFACES_SURFACE_FACTORY_H_ 114 #endif // CC_SURFACES_SURFACE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698