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

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

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Add an --enable-deadline-scheduler commandline flag. Created 7 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "cc/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include <algorithm>
7 #include <set> 8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 skipped_begin_frame_args_ = args; 155 skipped_begin_frame_args_ = args;
155 } else { 156 } else {
156 begin_frame_pending_ = true; 157 begin_frame_pending_ = true;
157 client_->BeginFrame(args); 158 client_->BeginFrame(args);
158 // args might be an alias for skipped_begin_frame_args_. 159 // args might be an alias for skipped_begin_frame_args_.
159 // Do not reset it before calling BeginFrame! 160 // Do not reset it before calling BeginFrame!
160 skipped_begin_frame_args_ = BeginFrameArgs(); 161 skipped_begin_frame_args_ = BeginFrameArgs();
161 } 162 }
162 } 163 }
163 164
164 base::TimeDelta OutputSurface::AlternateRetroactiveBeginFramePeriod() { 165 base::TimeTicks OutputSurface::RetroactiveBeginFrameDeadline() {
165 return BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); 166 // TODO(brianderson): Remove the alternative deadline once we have better
167 // deadline estimations.
168 base::TimeTicks alternative_deadline =
169 skipped_begin_frame_args_.frame_time +
170 BeginFrameArgs::DefaultRetroactiveBeginFramePeriod();
171 return std::max(skipped_begin_frame_args_.deadline, alternative_deadline);
166 } 172 }
167 173
168 void OutputSurface::PostCheckForRetroactiveBeginFrame() { 174 void OutputSurface::PostCheckForRetroactiveBeginFrame() {
169 if (!skipped_begin_frame_args_.IsValid() || 175 if (!skipped_begin_frame_args_.IsValid() ||
170 check_for_retroactive_begin_frame_pending_) 176 check_for_retroactive_begin_frame_pending_)
171 return; 177 return;
172 178
173 base::MessageLoop::current()->PostTask( 179 base::MessageLoop::current()->PostTask(
174 FROM_HERE, 180 FROM_HERE,
175 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, 181 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame,
176 weak_ptr_factory_.GetWeakPtr())); 182 weak_ptr_factory_.GetWeakPtr()));
177 check_for_retroactive_begin_frame_pending_ = true; 183 check_for_retroactive_begin_frame_pending_ = true;
178 } 184 }
179 185
180 void OutputSurface::CheckForRetroactiveBeginFrame() { 186 void OutputSurface::CheckForRetroactiveBeginFrame() {
181 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); 187 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame");
182 check_for_retroactive_begin_frame_pending_ = false; 188 check_for_retroactive_begin_frame_pending_ = false;
183 base::TimeTicks now = base::TimeTicks::Now(); 189 if (base::TimeTicks::Now() < RetroactiveBeginFrameDeadline())
184 // TODO(brianderson): Remove the alternative deadline once we have better
185 // deadline estimations.
186 base::TimeTicks alternative_deadline =
187 skipped_begin_frame_args_.frame_time +
188 AlternateRetroactiveBeginFramePeriod();
189 if (now < skipped_begin_frame_args_.deadline ||
190 now < alternative_deadline) {
191 BeginFrame(skipped_begin_frame_args_); 190 BeginFrame(skipped_begin_frame_args_);
192 }
193 } 191 }
194 192
195 void OutputSurface::DidSwapBuffers() { 193 void OutputSurface::DidSwapBuffers() {
196 begin_frame_pending_ = false; 194 begin_frame_pending_ = false;
197 pending_swap_buffers_++; 195 pending_swap_buffers_++;
198 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", 196 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers",
199 "pending_swap_buffers_", pending_swap_buffers_); 197 "pending_swap_buffers_", pending_swap_buffers_);
200 if (frame_rate_controller_) 198 if (frame_rate_controller_)
201 frame_rate_controller_->DidSwapBuffers(); 199 frame_rate_controller_->DidSwapBuffers();
202 PostCheckForRetroactiveBeginFrame(); 200 PostCheckForRetroactiveBeginFrame();
203 } 201 }
204 202
205 void OutputSurface::OnSwapBuffersComplete(const CompositorFrameAck* ack) { 203 void OutputSurface::OnSwapBuffersComplete(const CompositorFrameAck* ack) {
206 pending_swap_buffers_--; 204 pending_swap_buffers_--;
207 TRACE_EVENT1("cc", "OutputSurface::OnSwapBuffersComplete", 205 TRACE_EVENT1("cc", "OutputSurface::OnSwapBuffersComplete",
208 "pending_swap_buffers_", pending_swap_buffers_); 206 "pending_swap_buffers_", pending_swap_buffers_);
209 client_->OnSwapBuffersComplete(ack); 207 client_->OnSwapBuffersComplete(ack);
210 if (frame_rate_controller_) 208 if (frame_rate_controller_)
211 frame_rate_controller_->DidSwapBuffersComplete(); 209 frame_rate_controller_->DidSwapBuffersComplete();
212 PostCheckForRetroactiveBeginFrame(); 210 PostCheckForRetroactiveBeginFrame();
213 } 211 }
214 212
215 void OutputSurface::DidLoseOutputSurface() { 213 void OutputSurface::DidLoseOutputSurface() {
216 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface"); 214 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface");
217 begin_frame_pending_ = false; 215 begin_frame_pending_ = false;
218 pending_swap_buffers_ = 0; 216 pending_swap_buffers_ = 0;
217 if (frame_rate_controller_)
218 frame_rate_controller_->SetActive(false);
219 client_->DidLoseOutputSurface(); 219 client_->DidLoseOutputSurface();
220 } 220 }
221 221
222 void OutputSurface::SetExternalStencilTest(bool enabled) { 222 void OutputSurface::SetExternalStencilTest(bool enabled) {
223 client_->SetExternalStencilTest(enabled); 223 client_->SetExternalStencilTest(enabled);
224 } 224 }
225 225
226 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, 226 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform,
227 gfx::Rect viewport) { 227 gfx::Rect viewport) {
228 client_->SetExternalDrawConstraints(transform, viewport); 228 client_->SetExternalDrawConstraints(transform, viewport);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 "discard_backbuffer", discard_backbuffer); 403 "discard_backbuffer", discard_backbuffer);
404 // Just ignore the memory manager when it says to set the limit to zero 404 // Just ignore the memory manager when it says to set the limit to zero
405 // bytes. This will happen when the memory manager thinks that the renderer 405 // bytes. This will happen when the memory manager thinks that the renderer
406 // is not visible (which the renderer knows better). 406 // is not visible (which the renderer knows better).
407 if (policy.bytes_limit_when_visible) 407 if (policy.bytes_limit_when_visible)
408 client_->SetMemoryPolicy(policy); 408 client_->SetMemoryPolicy(policy);
409 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); 409 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer);
410 } 410 }
411 411
412 } // namespace cc 412 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698