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

Side by Side Diff: cc/output/output_surface.h

Issue 218633010: cc: Handle retroactive BeginFrames in the Scheduler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@compositorVsyncDisable
Patch Set: Created 6 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 | « no previous file | cc/output/output_surface.cc » ('j') | cc/output/output_surface.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_OUTPUT_OUTPUT_SURFACE_H_ 5 #ifndef CC_OUTPUT_OUTPUT_SURFACE_H_
6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ 6 #define CC_OUTPUT_OUTPUT_SURFACE_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 : delegated_rendering(false), 62 : delegated_rendering(false),
63 max_frames_pending(0), 63 max_frames_pending(0),
64 deferred_gl_initialization(false), 64 deferred_gl_initialization(false),
65 draw_and_swap_full_viewport_every_frame(false), 65 draw_and_swap_full_viewport_every_frame(false),
66 adjust_deadline_for_parent(true), 66 adjust_deadline_for_parent(true),
67 uses_default_gl_framebuffer(true) {} 67 uses_default_gl_framebuffer(true) {}
68 bool delegated_rendering; 68 bool delegated_rendering;
69 int max_frames_pending; 69 int max_frames_pending;
70 bool deferred_gl_initialization; 70 bool deferred_gl_initialization;
71 bool draw_and_swap_full_viewport_every_frame; 71 bool draw_and_swap_full_viewport_every_frame;
72 // This doesn't handle the <webview> case, but once BeginImplFrame is 72 // This doesn't handle the <webview> case, but once BeginFrame is
73 // supported natively, we shouldn't need adjust_deadline_for_parent. 73 // supported natively, we shouldn't need adjust_deadline_for_parent.
74 bool adjust_deadline_for_parent; 74 bool adjust_deadline_for_parent;
75 // Whether this output surface renders to the default OpenGL zero 75 // Whether this output surface renders to the default OpenGL zero
76 // framebuffer or to an offscreen framebuffer. 76 // framebuffer or to an offscreen framebuffer.
77 bool uses_default_gl_framebuffer; 77 bool uses_default_gl_framebuffer;
78 }; 78 };
79 79
80 const Capabilities& capabilities() const { 80 const Capabilities& capabilities() const {
81 return capabilities_; 81 return capabilities_;
82 } 82 }
(...skipping 15 matching lines...) Expand all
98 // (namely Android WebView), this is called to determine whether the software 98 // (namely Android WebView), this is called to determine whether the software
99 // device should be used on the current frame. 99 // device should be used on the current frame.
100 virtual bool ForcedDrawToSoftwareDevice() const; 100 virtual bool ForcedDrawToSoftwareDevice() const;
101 101
102 // Called by the compositor on the compositor thread. This is a place where 102 // Called by the compositor on the compositor thread. This is a place where
103 // thread-specific data for the output surface can be initialized, since from 103 // thread-specific data for the output surface can be initialized, since from
104 // this point on the output surface will only be used on the compositor 104 // this point on the output surface will only be used on the compositor
105 // thread. 105 // thread.
106 virtual bool BindToClient(OutputSurfaceClient* client); 106 virtual bool BindToClient(OutputSurfaceClient* client);
107 107
108 void InitializeBeginImplFrameEmulation( 108 void InitializeBeginFrameEmulation(base::SingleThreadTaskRunner* task_runner,
109 base::SingleThreadTaskRunner* task_runner, 109 bool throttle_frame_production,
110 bool throttle_frame_production, 110 base::TimeDelta interval);
111 base::TimeDelta interval);
112 111
113 void SetMaxFramesPending(int max_frames_pending); 112 void SetMaxFramesPending(int max_frames_pending);
114 113
115 virtual void EnsureBackbuffer(); 114 virtual void EnsureBackbuffer();
116 virtual void DiscardBackbuffer(); 115 virtual void DiscardBackbuffer();
117 116
118 virtual void Reshape(const gfx::Size& size, float scale_factor); 117 virtual void Reshape(const gfx::Size& size, float scale_factor);
119 virtual gfx::Size SurfaceSize() const; 118 virtual gfx::Size SurfaceSize() const;
120 119
121 virtual void BindFramebuffer(); 120 virtual void BindFramebuffer();
122 121
123 // The implementation may destroy or steal the contents of the CompositorFrame 122 // The implementation may destroy or steal the contents of the CompositorFrame
124 // passed in (though it will not take ownership of the CompositorFrame 123 // passed in (though it will not take ownership of the CompositorFrame
125 // itself). 124 // itself).
126 virtual void SwapBuffers(CompositorFrame* frame); 125 virtual void SwapBuffers(CompositorFrame* frame);
127 126
128 // Notifies frame-rate smoothness preference. If true, all non-critical 127 // Notifies frame-rate smoothness preference. If true, all non-critical
129 // processing should be stopped, or lowered in priority. 128 // processing should be stopped, or lowered in priority.
130 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} 129 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {}
131 130
132 // Requests a BeginImplFrame notification from the output surface. The 131 // Requests a BeginFrame notification from the output surface. The
133 // notification will be delivered by calling 132 // notification will be delivered by calling
134 // OutputSurfaceClient::BeginImplFrame until the callback is disabled. 133 // OutputSurfaceClient::BeginFrame until the callback is disabled.
135 virtual void SetNeedsBeginImplFrame(bool enable); 134 virtual void SetNeedsBeginFrame(bool enable);
136 135
137 bool HasClient() { return !!client_; } 136 bool HasClient() { return !!client_; }
138 137
139 // Returns an estimate of the current GPU latency. When only a software 138 // Returns an estimate of the current GPU latency. When only a software
140 // device is present, returns 0. 139 // device is present, returns 0.
141 base::TimeDelta GpuLatencyEstimate(); 140 base::TimeDelta GpuLatencyEstimate();
142 141
143 // Get the class capable of informing cc of hardware overlay capability. 142 // Get the class capable of informing cc of hardware overlay capability.
144 OverlayCandidateValidator* overlay_candidate_validator() const { 143 OverlayCandidateValidator* overlay_candidate_validator() const {
145 return overlay_candidate_validator_.get(); 144 return overlay_candidate_validator_.get();
(...skipping 12 matching lines...) Expand all
158 void PostSwapBuffersComplete(); 157 void PostSwapBuffersComplete();
159 158
160 struct OutputSurface::Capabilities capabilities_; 159 struct OutputSurface::Capabilities capabilities_;
161 scoped_refptr<ContextProvider> context_provider_; 160 scoped_refptr<ContextProvider> context_provider_;
162 scoped_ptr<SoftwareOutputDevice> software_device_; 161 scoped_ptr<SoftwareOutputDevice> software_device_;
163 scoped_ptr<OverlayCandidateValidator> overlay_candidate_validator_; 162 scoped_ptr<OverlayCandidateValidator> overlay_candidate_validator_;
164 gfx::Size surface_size_; 163 gfx::Size surface_size_;
165 float device_scale_factor_; 164 float device_scale_factor_;
166 165
167 // The FrameRateController is deprecated. 166 // The FrameRateController is deprecated.
168 // Platforms should move to native BeginImplFrames instead. 167 // Platforms should move to native BeginFrames instead.
169 void CommitVSyncParameters(base::TimeTicks timebase, 168 void CommitVSyncParameters(base::TimeTicks timebase,
170 base::TimeDelta interval); 169 base::TimeDelta interval);
171 virtual void FrameRateControllerTick(bool throttled, 170 virtual void FrameRateControllerTick(bool throttled,
172 const BeginFrameArgs& args) OVERRIDE; 171 const BeginFrameArgs& args) OVERRIDE;
173 scoped_ptr<FrameRateController> frame_rate_controller_; 172 scoped_ptr<FrameRateController> frame_rate_controller_;
174 int max_frames_pending_; 173 int max_frames_pending_;
175 int pending_swap_buffers_; 174 int pending_swap_buffers_;
176 bool needs_begin_impl_frame_; 175 bool needs_begin_impl_frame_;
177 bool client_ready_for_begin_impl_frame_;
178 176
179 // This stores a BeginImplFrame that we couldn't process immediately, 177 // This stores a BeginFrame that we couldn't process immediately,
180 // but might process retroactively in the near future. 178 // but might process retroactively in the near future.
181 BeginFrameArgs skipped_begin_impl_frame_args_; 179 BeginFrameArgs skipped_begin_impl_frame_args_;
Sami 2014/04/01 13:09:10 skipped_begin_frame_args_?
182 180
183 // Forwarded to OutputSurfaceClient but threaded through OutputSurface 181 // Forwarded to OutputSurfaceClient but threaded through OutputSurface
184 // first so OutputSurface has a chance to update the FrameRateController 182 // first so OutputSurface has a chance to update the FrameRateController
185 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); 183 void SetNeedsRedrawRect(const gfx::Rect& damage_rect);
186 void BeginImplFrame(const BeginFrameArgs& args); 184 void BeginFrame(const BeginFrameArgs& args);
187 void DidSwapBuffers(); 185 void DidSwapBuffers();
188 void OnSwapBuffersComplete(); 186 void OnSwapBuffersComplete();
189 void ReclaimResources(const CompositorFrameAck* ack); 187 void ReclaimResources(const CompositorFrameAck* ack);
190 void DidLoseOutputSurface(); 188 void DidLoseOutputSurface();
191 void SetExternalStencilTest(bool enabled); 189 void SetExternalStencilTest(bool enabled);
192 void SetExternalDrawConstraints(const gfx::Transform& transform, 190 void SetExternalDrawConstraints(const gfx::Transform& transform,
193 const gfx::Rect& viewport, 191 const gfx::Rect& viewport,
194 const gfx::Rect& clip, 192 const gfx::Rect& clip,
195 bool valid_for_tile_management); 193 bool valid_for_tile_management);
196 194
197 // virtual for testing. 195 // virtual for testing.
198 virtual base::TimeTicks RetroactiveBeginImplFrameDeadline(); 196 virtual base::TimeTicks RetroactiveBeginFrameDeadline();
199 virtual void PostCheckForRetroactiveBeginImplFrame(); 197 virtual void PostCheckForRetroactiveBeginFrame();
200 void CheckForRetroactiveBeginImplFrame(); 198 void CheckForRetroactiveBeginFrame();
201 199
202 private: 200 private:
203 OutputSurfaceClient* client_; 201 OutputSurfaceClient* client_;
204 202
205 void SetUpContext3d(); 203 void SetUpContext3d();
206 void ResetContext3d(); 204 void ResetContext3d();
207 void SetMemoryPolicy(const ManagedMemoryPolicy& policy); 205 void SetMemoryPolicy(const ManagedMemoryPolicy& policy);
208 void UpdateAndMeasureGpuLatency(); 206 void UpdateAndMeasureGpuLatency();
209 207
210 // check_for_retroactive_begin_impl_frame_pending_ is used to avoid posting 208 // check_for_retroactive_begin_impl_frame_pending_ is used to avoid posting
211 // redundant checks for a retroactive BeginImplFrame. 209 // redundant checks for a retroactive BeginFrame.
212 bool check_for_retroactive_begin_impl_frame_pending_; 210 bool check_for_retroactive_begin_impl_frame_pending_;
213 211
214 bool external_stencil_test_enabled_; 212 bool external_stencil_test_enabled_;
215 213
216 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; 214 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_;
217 215
218 std::deque<unsigned> available_gpu_latency_query_ids_; 216 std::deque<unsigned> available_gpu_latency_query_ids_;
219 std::deque<unsigned> pending_gpu_latency_query_ids_; 217 std::deque<unsigned> pending_gpu_latency_query_ids_;
220 RollingTimeDeltaHistory gpu_latency_history_; 218 RollingTimeDeltaHistory gpu_latency_history_;
221 219
222 DISALLOW_COPY_AND_ASSIGN(OutputSurface); 220 DISALLOW_COPY_AND_ASSIGN(OutputSurface);
223 }; 221 };
224 222
225 } // namespace cc 223 } // namespace cc
226 224
227 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ 225 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/output/output_surface.cc » ('j') | cc/output/output_surface.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698