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

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

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 months 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
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 22 matching lines...) Expand all
33 // A SurfaceFactory is used to create surfaces that may share resources and 33 // A SurfaceFactory is used to create surfaces that may share resources and
34 // receive returned resources for frames submitted to those surfaces. Resources 34 // receive returned resources for frames submitted to those surfaces. Resources
35 // submitted to frames created by a particular factory will be returned to that 35 // submitted to frames created by a particular factory will be returned to that
36 // factory's client when they are no longer being used. This is the only class 36 // factory's client when they are no longer being used. This is the only class
37 // most users of surfaces will need to directly interact with. 37 // most users of surfaces will need to directly interact with.
38 class CC_SURFACES_EXPORT SurfaceFactory 38 class CC_SURFACES_EXPORT SurfaceFactory
39 : public base::SupportsWeakPtr<SurfaceFactory> { 39 : public base::SupportsWeakPtr<SurfaceFactory> {
40 public: 40 public:
41 using DrawCallback = base::Callback<void()>; 41 using DrawCallback = base::Callback<void()>;
42 42
43 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); 43 SurfaceFactory(const FrameSinkId& frame_sink_id,
44 SurfaceManager* manager,
45 SurfaceFactoryClient* client);
44 ~SurfaceFactory(); 46 ~SurfaceFactory();
45 47
48 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
49
46 void Create(const SurfaceId& surface_id); 50 void Create(const SurfaceId& surface_id);
47 void Destroy(const SurfaceId& surface_id); 51 void Destroy(const SurfaceId& surface_id);
48 void DestroyAll(); 52 void DestroyAll();
49 53
50 // 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
51 // 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.
52 void SetPreviousFrameSurface(const SurfaceId& new_id, 56 void SetPreviousFrameSurface(const SurfaceId& new_id,
53 const SurfaceId& old_id); 57 const SurfaceId& old_id);
54 58
55 // 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 20 matching lines...) Expand all
76 // to have sync points set on them when returned from the Display, for 80 // to have sync points set on them when returned from the Display, for
77 // example if the Display shares a context with the creator. 81 // example if the Display shares a context with the creator.
78 bool needs_sync_points() const { return needs_sync_points_; } 82 bool needs_sync_points() const { return needs_sync_points_; }
79 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } 83 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; }
80 84
81 // 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
82 // is no longer alive during destruction. 86 // is no longer alive during destruction.
83 void DidDestroySurfaceManager() { manager_ = nullptr; } 87 void DidDestroySurfaceManager() { manager_ = nullptr; }
84 88
85 private: 89 private:
90 FrameSinkId frame_sink_id_;
86 SurfaceManager* manager_; 91 SurfaceManager* manager_;
87 SurfaceFactoryClient* client_; 92 SurfaceFactoryClient* client_;
88 SurfaceResourceHolder holder_; 93 SurfaceResourceHolder holder_;
89 94
90 bool needs_sync_points_; 95 bool needs_sync_points_;
91 96
92 using OwningSurfaceMap = 97 using OwningSurfaceMap =
93 std::unordered_map<SurfaceId, std::unique_ptr<Surface>, SurfaceIdHash>; 98 std::unordered_map<SurfaceId, std::unique_ptr<Surface>, SurfaceIdHash>;
94 OwningSurfaceMap surface_map_; 99 OwningSurfaceMap surface_map_;
95 100
96 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); 101 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
97 }; 102 };
98 103
99 } // namespace cc 104 } // namespace cc
100 105
101 #endif // CC_SURFACES_SURFACE_FACTORY_H_ 106 #endif // CC_SURFACES_SURFACE_FACTORY_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698