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

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

Issue 2834553002: Replace CompositorFrameSinkSupport::WillDrawSurface With RepeatingCallback (Closed)
Patch Set: Address Comments On Documentation 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
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface.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_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
(...skipping 23 matching lines...) Expand all
34 namespace cc { 34 namespace cc {
35 35
36 class BeginFrameSource; 36 class BeginFrameSource;
37 class CompositorFrame; 37 class CompositorFrame;
38 class CopyOutputRequest; 38 class CopyOutputRequest;
39 class SurfaceFactory; 39 class SurfaceFactory;
40 40
41 class CC_SURFACES_EXPORT Surface { 41 class CC_SURFACES_EXPORT Surface {
42 public: 42 public:
43 using DrawCallback = SurfaceFactory::DrawCallback; 43 using DrawCallback = SurfaceFactory::DrawCallback;
44 using WillDrawCallback = SurfaceFactory::WillDrawCallback;
44 45
45 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory); 46 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory);
46 ~Surface(); 47 ~Surface();
47 48
48 const SurfaceId& surface_id() const { return surface_id_; } 49 const SurfaceId& surface_id() const { return surface_id_; }
49 const SurfaceId& previous_frame_surface_id() const { 50 const SurfaceId& previous_frame_surface_id() const {
50 return previous_frame_surface_id_; 51 return previous_frame_surface_id_;
51 } 52 }
52 53
53 void SetPreviousFrameSurface(Surface* surface); 54 void SetPreviousFrameSurface(Surface* surface);
54 55
55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); 56 // |draw_callback| is called once to notify the client that the previously
57 // submitted CompositorFrame is processed and that another frame can be
58 // submitted.
59 // |will_draw_callback| is called when |surface| is scheduled for a draw and
60 // there is visible damage.
61 void QueueFrame(CompositorFrame frame,
62 const DrawCallback& draw_callback,
63 const WillDrawCallback& will_draw_callback);
56 void EvictFrame(); 64 void EvictFrame();
57 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); 65 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
58 66
59 // Notifies the Surface that a blocking SurfaceId now has an active frame. 67 // Notifies the Surface that a blocking SurfaceId now has an active frame.
60 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); 68 void NotifySurfaceIdAvailable(const SurfaceId& surface_id);
61 69
62 void AddObserver(PendingFrameObserver* observer); 70 void AddObserver(PendingFrameObserver* observer);
63 void RemoveObserver(PendingFrameObserver* observer); 71 void RemoveObserver(PendingFrameObserver* observer);
64 72
65 // Called if a deadline has been hit and this surface is not yet active but 73 // Called if a deadline has been hit and this surface is not yet active but
(...skipping 11 matching lines...) Expand all
77 const CompositorFrame& GetActiveFrame() const; 85 const CompositorFrame& GetActiveFrame() const;
78 86
79 // Returns the currently pending frame. You must check where HasPendingFrame() 87 // Returns the currently pending frame. You must check where HasPendingFrame()
80 // returns true before calling this method. 88 // returns true before calling this method.
81 const CompositorFrame& GetPendingFrame(); 89 const CompositorFrame& GetPendingFrame();
82 90
83 // 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.
84 int frame_index() const { return frame_index_; } 92 int frame_index() const { return frame_index_; }
85 93
86 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 94 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
87 void RunDrawCallbacks(); 95 void RunDrawCallback();
96 void RunWillDrawCallback(const gfx::Rect& damage_rect);
88 97
89 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 98 base::WeakPtr<SurfaceFactory> factory() { return factory_; }
90 99
91 // Add a SurfaceSequence that must be satisfied before the Surface is 100 // Add a SurfaceSequence that must be satisfied before the Surface is
92 // destroyed. 101 // destroyed.
93 void AddDestructionDependency(SurfaceSequence sequence); 102 void AddDestructionDependency(SurfaceSequence sequence);
94 103
95 // Satisfy all destruction dependencies that are contained in sequences, and 104 // Satisfy all destruction dependencies that are contained in sequences, and
96 // remove them from sequences. 105 // remove them from sequences.
97 void SatisfyDestructionDependencies( 106 void SatisfyDestructionDependencies(
(...skipping 14 matching lines...) Expand all
112 } 121 }
113 122
114 bool HasActiveFrame() const { return active_frame_data_.has_value(); } 123 bool HasActiveFrame() const { return active_frame_data_.has_value(); }
115 bool HasPendingFrame() const { return pending_frame_data_.has_value(); } 124 bool HasPendingFrame() const { return pending_frame_data_.has_value(); }
116 125
117 bool destroyed() const { return destroyed_; } 126 bool destroyed() const { return destroyed_; }
118 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } 127 void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
119 128
120 private: 129 private:
121 struct FrameData { 130 struct FrameData {
122 FrameData(CompositorFrame&& frame, const DrawCallback& draw_callback); 131 FrameData(CompositorFrame&& frame,
132 const DrawCallback& draw_callback,
133 const WillDrawCallback& will_draw_callback);
123 FrameData(FrameData&& other); 134 FrameData(FrameData&& other);
124 ~FrameData(); 135 ~FrameData();
125 FrameData& operator=(FrameData&& other); 136 FrameData& operator=(FrameData&& other);
126 CompositorFrame frame; 137 CompositorFrame frame;
127 DrawCallback draw_callback; 138 DrawCallback draw_callback;
139 WillDrawCallback will_draw_callback;
128 }; 140 };
129 141
130 void ActivatePendingFrame(); 142 void ActivatePendingFrame();
131 // Called when all of the surface's dependencies have been resolved. 143 // Called when all of the surface's dependencies have been resolved.
132 void ActivateFrame(FrameData frame_data); 144 void ActivateFrame(FrameData frame_data);
133 void UpdateBlockingSurfaces(bool has_previous_pending_frame, 145 void UpdateBlockingSurfaces(bool has_previous_pending_frame,
134 const CompositorFrame& current_frame); 146 const CompositorFrame& current_frame);
135 147
136 void UnrefFrameResourcesAndRunDrawCallback( 148 void UnrefFrameResourcesAndRunDrawCallback(
137 base::Optional<FrameData> frame_data); 149 base::Optional<FrameData> frame_data);
(...skipping 21 matching lines...) Expand all
159 171
160 SurfaceDependencies blocking_surfaces_; 172 SurfaceDependencies blocking_surfaces_;
161 base::ObserverList<PendingFrameObserver, true> observers_; 173 base::ObserverList<PendingFrameObserver, true> observers_;
162 174
163 DISALLOW_COPY_AND_ASSIGN(Surface); 175 DISALLOW_COPY_AND_ASSIGN(Surface);
164 }; 176 };
165 177
166 } // namespace cc 178 } // namespace cc
167 179
168 #endif // CC_SURFACES_SURFACE_H_ 180 #endif // CC_SURFACES_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698