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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Merge unit tests Created 3 years, 8 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()>;
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // returns true before calling this method. 89 // returns true before calling this method.
88 const CompositorFrame& GetPendingFrame(); 90 const CompositorFrame& GetPendingFrame();
89 91
90 // Returns a number that increments by 1 every time a new frame is enqueued. 92 // Returns a number that increments by 1 every time a new frame is enqueued.
91 int frame_index() const { return frame_index_; } 93 int frame_index() const { return frame_index_; }
92 94
93 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 95 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
94 void RunDrawCallback(); 96 void RunDrawCallback();
95 void RunWillDrawCallback(const gfx::Rect& damage_rect); 97 void RunWillDrawCallback(const gfx::Rect& damage_rect);
96 98
97 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 99 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support() {
100 return compositor_frame_sink_support_;
101 }
98 102
99 // Add a SurfaceSequence that must be satisfied before the Surface is 103 // Add a SurfaceSequence that must be satisfied before the Surface is
100 // destroyed. 104 // destroyed.
101 void AddDestructionDependency(SurfaceSequence sequence); 105 void AddDestructionDependency(SurfaceSequence sequence);
102 106
103 // Satisfy all destruction dependencies that are contained in sequences, and 107 // Satisfy all destruction dependencies that are contained in sequences, and
104 // remove them from sequences. 108 // remove them from sequences.
105 void SatisfyDestructionDependencies( 109 void SatisfyDestructionDependencies(
106 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, 110 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences,
107 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); 111 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void ClearCopyRequests(); 153 void ClearCopyRequests();
150 154
151 void TakeLatencyInfoFromPendingFrame( 155 void TakeLatencyInfoFromPendingFrame(
152 std::vector<ui::LatencyInfo>* latency_info); 156 std::vector<ui::LatencyInfo>* latency_info);
153 static void TakeLatencyInfoFromFrame( 157 static void TakeLatencyInfoFromFrame(
154 CompositorFrame* frame, 158 CompositorFrame* frame,
155 std::vector<ui::LatencyInfo>* latency_info); 159 std::vector<ui::LatencyInfo>* latency_info);
156 160
157 SurfaceId surface_id_; 161 SurfaceId surface_id_;
158 SurfaceId previous_frame_surface_id_; 162 SurfaceId previous_frame_surface_id_;
159 base::WeakPtr<SurfaceFactory> factory_; 163 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support_;
160 164
161 base::Optional<FrameData> pending_frame_data_; 165 base::Optional<FrameData> pending_frame_data_;
162 base::Optional<FrameData> active_frame_data_; 166 base::Optional<FrameData> active_frame_data_;
163 int frame_index_; 167 int frame_index_;
164 bool destroyed_; 168 bool destroyed_;
165 std::vector<SurfaceSequence> destruction_dependencies_; 169 std::vector<SurfaceSequence> destruction_dependencies_;
166 170
167 SurfaceDependencies blocking_surfaces_; 171 SurfaceDependencies blocking_surfaces_;
168 base::ObserverList<PendingFrameObserver, true> observers_; 172 base::ObserverList<PendingFrameObserver, true> observers_;
169 173
170 DISALLOW_COPY_AND_ASSIGN(Surface); 174 DISALLOW_COPY_AND_ASSIGN(Surface);
171 }; 175 };
172 176
173 } // namespace cc 177 } // namespace cc
174 178
175 #endif // CC_SURFACES_SURFACE_H_ 179 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698