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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Change Ref/UnrefResources to public Created 3 years, 7 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
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_H_ 5 #ifndef CC_SURFACES_SURFACE_H_
6 #define CC_SURFACES_SURFACE_H_ 6 #define CC_SURFACES_SURFACE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <unordered_set> 14 #include <unordered_set>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/optional.h" 20 #include "base/optional.h"
21 #include "cc/output/copy_output_request.h" 21 #include "cc/output/copy_output_request.h"
22 #include "cc/surfaces/compositor_frame_sink_support.h"
22 #include "cc/surfaces/frame_sink_id.h" 23 #include "cc/surfaces/frame_sink_id.h"
23 #include "cc/surfaces/pending_frame_observer.h" 24 #include "cc/surfaces/pending_frame_observer.h"
24 #include "cc/surfaces/surface_factory.h"
25 #include "cc/surfaces/surface_id.h" 25 #include "cc/surfaces/surface_id.h"
26 #include "cc/surfaces/surface_sequence.h" 26 #include "cc/surfaces/surface_sequence.h"
27 #include "cc/surfaces/surfaces_export.h" 27 #include "cc/surfaces/surfaces_export.h"
28 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
29 29
30 namespace ui { 30 namespace ui {
31 class LatencyInfo; 31 class LatencyInfo;
32 } 32 }
33 33
34 namespace cc { 34 namespace cc {
35 35
36 class CompositorFrame; 36 class CompositorFrame;
37 class CopyOutputRequest; 37 class CopyOutputRequest;
38 class SurfaceFactory;
39 38
40 class CC_SURFACES_EXPORT Surface { 39 class CC_SURFACES_EXPORT Surface {
41 public: 40 public:
42 using DrawCallback = SurfaceFactory::DrawCallback; 41 using DrawCallback = base::Callback<void()>;
danakj 2017/05/03 16:08:39 this is written base::Closure
Alex Z. 2017/05/03 18:07:37 Done.
danakj 2017/05/05 16:04:19 FWIW I was okay with the typedef, but I mean Callb
43 using WillDrawCallback = SurfaceFactory::WillDrawCallback; 42 using WillDrawCallback =
43 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>;
44 44
45 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory); 45 Surface(
46 const SurfaceId& id,
47 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support);
46 ~Surface(); 48 ~Surface();
47 49
48 const SurfaceId& surface_id() const { return surface_id_; } 50 const SurfaceId& surface_id() const { return surface_id_; }
49 const SurfaceId& previous_frame_surface_id() const { 51 const SurfaceId& previous_frame_surface_id() const {
50 return previous_frame_surface_id_; 52 return previous_frame_surface_id_;
51 } 53 }
52 54
53 void SetPreviousFrameSurface(Surface* surface); 55 void SetPreviousFrameSurface(Surface* surface);
54 56
55 // |draw_callback| is called once to notify the client that the previously 57 // |draw_callback| is called once to notify the client that the previously
(...skipping 30 matching lines...) Expand all
86 // returns true before calling this method. 88 // returns true before calling this method.
87 const CompositorFrame& GetPendingFrame(); 89 const CompositorFrame& GetPendingFrame();
88 90
89 // Returns a number that increments by 1 every time a new frame is enqueued. 91 // Returns a number that increments by 1 every time a new frame is enqueued.
90 int frame_index() const { return frame_index_; } 92 int frame_index() const { return frame_index_; }
91 93
92 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 94 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
93 void RunDrawCallback(); 95 void RunDrawCallback();
94 void RunWillDrawCallback(const gfx::Rect& damage_rect); 96 void RunWillDrawCallback(const gfx::Rect& damage_rect);
95 97
96 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 98 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support() {
99 return compositor_frame_sink_support_;
100 }
97 101
98 // Add a SurfaceSequence that must be satisfied before the Surface is 102 // Add a SurfaceSequence that must be satisfied before the Surface is
99 // destroyed. 103 // destroyed.
100 void AddDestructionDependency(SurfaceSequence sequence); 104 void AddDestructionDependency(SurfaceSequence sequence);
101 105
102 // Satisfy all destruction dependencies that are contained in sequences, and 106 // Satisfy all destruction dependencies that are contained in sequences, and
103 // remove them from sequences. 107 // remove them from sequences.
104 void SatisfyDestructionDependencies( 108 void SatisfyDestructionDependencies(
105 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, 109 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences,
106 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); 110 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void ClearCopyRequests(); 152 void ClearCopyRequests();
149 153
150 void TakeLatencyInfoFromPendingFrame( 154 void TakeLatencyInfoFromPendingFrame(
151 std::vector<ui::LatencyInfo>* latency_info); 155 std::vector<ui::LatencyInfo>* latency_info);
152 static void TakeLatencyInfoFromFrame( 156 static void TakeLatencyInfoFromFrame(
153 CompositorFrame* frame, 157 CompositorFrame* frame,
154 std::vector<ui::LatencyInfo>* latency_info); 158 std::vector<ui::LatencyInfo>* latency_info);
155 159
156 SurfaceId surface_id_; 160 SurfaceId surface_id_;
157 SurfaceId previous_frame_surface_id_; 161 SurfaceId previous_frame_surface_id_;
158 base::WeakPtr<SurfaceFactory> factory_; 162 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support_;
159 163
160 base::Optional<FrameData> pending_frame_data_; 164 base::Optional<FrameData> pending_frame_data_;
161 base::Optional<FrameData> active_frame_data_; 165 base::Optional<FrameData> active_frame_data_;
162 int frame_index_; 166 int frame_index_;
163 bool destroyed_; 167 bool destroyed_;
164 std::vector<SurfaceSequence> destruction_dependencies_; 168 std::vector<SurfaceSequence> destruction_dependencies_;
165 169
166 SurfaceDependencies blocking_surfaces_; 170 SurfaceDependencies blocking_surfaces_;
167 base::ObserverList<PendingFrameObserver, true> observers_; 171 base::ObserverList<PendingFrameObserver, true> observers_;
168 172
169 DISALLOW_COPY_AND_ASSIGN(Surface); 173 DISALLOW_COPY_AND_ASSIGN(Surface);
170 }; 174 };
171 175
172 } // namespace cc 176 } // namespace cc
173 177
174 #endif // CC_SURFACES_SURFACE_H_ 178 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698