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

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

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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_display_output_surface_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 24 matching lines...) Expand all
35 // A SurfaceFactory is used to create surfaces that may share resources and 35 // A SurfaceFactory is used to create surfaces that may share resources and
36 // receive returned resources for frames submitted to those surfaces. Resources 36 // receive returned resources for frames submitted to those surfaces. Resources
37 // submitted to frames created by a particular factory will be returned to that 37 // submitted to frames created by a particular factory will be returned to that
38 // factory's client when they are no longer being used. This is the only class 38 // factory's client when they are no longer being used. This is the only class
39 // most users of surfaces will need to directly interact with. 39 // most users of surfaces will need to directly interact with.
40 class CC_SURFACES_EXPORT SurfaceFactory 40 class CC_SURFACES_EXPORT SurfaceFactory
41 : public base::SupportsWeakPtr<SurfaceFactory> { 41 : public base::SupportsWeakPtr<SurfaceFactory> {
42 public: 42 public:
43 using DrawCallback = base::Callback<void(SurfaceDrawStatus)>; 43 using DrawCallback = base::Callback<void(SurfaceDrawStatus)>;
44 44
45 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); 45 SurfaceFactory(uint32_t client_id,
46 SurfaceManager* manager,
47 SurfaceFactoryClient* client);
46 ~SurfaceFactory(); 48 ~SurfaceFactory();
47 49
50 void SetParent(uint32_t client_id);
51
48 void Create(const SurfaceId& surface_id); 52 void Create(const SurfaceId& surface_id);
49 void Destroy(const SurfaceId& surface_id); 53 void Destroy(const SurfaceId& surface_id);
50 void DestroyAll(); 54 void DestroyAll();
51 55
52 // 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
53 // 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.
54 void SetPreviousFrameSurface(const SurfaceId& new_id, 58 void SetPreviousFrameSurface(const SurfaceId& new_id,
55 const SurfaceId& old_id); 59 const SurfaceId& old_id);
56 60
57 // 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,
58 // although the frame may reference surfaces created by other factories. 62 // although the frame may reference surfaces created by other factories.
59 // The callback is called the first time this frame is used to draw, or if 63 // The callback is called the first time this frame is used to draw, or if
60 // the frame is discarded. 64 // the frame is discarded.
61 void SubmitCompositorFrame(const SurfaceId& surface_id, 65 void SubmitCompositorFrame(const SurfaceId& surface_id,
62 CompositorFrame frame, 66 CompositorFrame frame,
63 const DrawCallback& callback); 67 const DrawCallback& callback);
64 void RequestCopyOfSurface(const SurfaceId& surface_id, 68 void RequestCopyOfSurface(const SurfaceId& surface_id,
65 std::unique_ptr<CopyOutputRequest> copy_request); 69 std::unique_ptr<CopyOutputRequest> copy_request);
66 70
67 void WillDrawSurface(const SurfaceId& id, const gfx::Rect& damage_rect); 71 void WillDrawSurface(const SurfaceId& id, const gfx::Rect& damage_rect);
68 72
69 SurfaceFactoryClient* client() { return client_; } 73 SurfaceFactoryClient* client() { return client_; }
70 74
71 void ReceiveFromChild(const TransferableResourceArray& resources); 75 void ReceiveFromChild(const TransferableResourceArray& resources);
72 void RefResources(const TransferableResourceArray& resources); 76 void RefResources(const TransferableResourceArray& resources);
73 void UnrefResources(const ReturnedResourceArray& resources); 77 void UnrefResources(const ReturnedResourceArray& resources);
74 78
75 SurfaceManager* manager() { return manager_; } 79 SurfaceManager* manager() { return manager_; }
76 80
81 uint32_t client_id() const { return client_id_; }
82
83 uint32_t parent_client_id() const { return parent_client_id_; }
84
77 // This can be set to false if resources from this SurfaceFactory don't need 85 // This can be set to false if resources from this SurfaceFactory don't need
78 // to have sync points set on them when returned from the Display, for 86 // to have sync points set on them when returned from the Display, for
79 // example if the Display shares a context with the creator. 87 // example if the Display shares a context with the creator.
80 bool needs_sync_points() const { return needs_sync_points_; } 88 bool needs_sync_points() const { return needs_sync_points_; }
81 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; } 89 void set_needs_sync_points(bool needs) { needs_sync_points_ = needs; }
82 90
83 // SurfaceFactory's owner can call this when it finds out that SurfaceManager 91 // SurfaceFactory's owner can call this when it finds out that SurfaceManager
84 // is no longer alive during destruction. 92 // is no longer alive during destruction.
85 void DidDestroySurfaceManager() { manager_ = nullptr; } 93 void DidDestroySurfaceManager() { manager_ = nullptr; }
86 94
87 private: 95 private:
96 const uint32_t client_id_;
97 uint32_t parent_client_id_;
88 SurfaceManager* manager_; 98 SurfaceManager* manager_;
89 SurfaceFactoryClient* client_; 99 SurfaceFactoryClient* client_;
90 SurfaceResourceHolder holder_; 100 SurfaceResourceHolder holder_;
91 101
92 bool needs_sync_points_; 102 bool needs_sync_points_;
93 103
94 using OwningSurfaceMap = 104 using OwningSurfaceMap =
95 std::unordered_map<SurfaceId, std::unique_ptr<Surface>, SurfaceIdHash>; 105 std::unordered_map<SurfaceId, std::unique_ptr<Surface>, SurfaceIdHash>;
96 OwningSurfaceMap surface_map_; 106 OwningSurfaceMap surface_map_;
97 107
98 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); 108 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
99 }; 109 };
100 110
101 } // namespace cc 111 } // namespace cc
102 112
103 #endif // CC_SURFACES_SURFACE_FACTORY_H_ 113 #endif // CC_SURFACES_SURFACE_FACTORY_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_display_output_surface_unittest.cc ('k') | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698