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

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: fix some tests; needs rebase; Created 7 years, 5 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 skipped_begin_frame_args_ = args; 170 skipped_begin_frame_args_ = args;
171 } else { 171 } else {
172 begin_frame_pending_ = true; 172 begin_frame_pending_ = true;
173 client_->BeginFrame(args); 173 client_->BeginFrame(args);
174 // args might be an alias for skipped_begin_frame_args_. 174 // args might be an alias for skipped_begin_frame_args_.
175 // Do not reset it before calling BeginFrame! 175 // Do not reset it before calling BeginFrame!
176 skipped_begin_frame_args_ = BeginFrameArgs(); 176 skipped_begin_frame_args_ = BeginFrameArgs();
177 } 177 }
178 } 178 }
179 179
180 base::TimeDelta OutputSurface::RetroactiveBeginFramePeriod() { 180 base::TimeTicks OutputSurface::RetroactiveBeginFrameDeadline() {
181 return BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); 181 base::TimeTicks alternative_deadline =
182 skipped_begin_frame_args_.frame_time +
183 BeginFrameArgs::DefaultRetroactiveBeginFramePeriod();
184 return std::max(skipped_begin_frame_args_.deadline, alternative_deadline);
182 } 185 }
183 186
184 void OutputSurface::PostCheckForRetroactiveBeginFrame() { 187 void OutputSurface::PostCheckForRetroactiveBeginFrame() {
185 if (!skipped_begin_frame_args_.IsValid()) 188 if (!skipped_begin_frame_args_.IsValid())
186 return; 189 return;
187 190
188 base::MessageLoop::current()->PostTask( 191 base::MessageLoop::current()->PostTask(
189 FROM_HERE, 192 FROM_HERE,
190 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, 193 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame,
191 weak_ptr_factory_.GetWeakPtr())); 194 weak_ptr_factory_.GetWeakPtr()));
192 } 195 }
193 196
194 void OutputSurface::CheckForRetroactiveBeginFrame() { 197 void OutputSurface::CheckForRetroactiveBeginFrame() {
195 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); 198 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame");
196 base::TimeTicks now = base::TimeTicks::Now(); 199 if (base::TimeTicks::Now() < RetroactiveBeginFrameDeadline())
197 base::TimeTicks alternative_deadline =
198 skipped_begin_frame_args_.frame_time +
199 RetroactiveBeginFramePeriod();
200 if (now < skipped_begin_frame_args_.deadline ||
201 now < alternative_deadline) {
202 BeginFrame(skipped_begin_frame_args_); 200 BeginFrame(skipped_begin_frame_args_);
203 }
204 } 201 }
205 202
206 void OutputSurface::DidSwapBuffers() { 203 void OutputSurface::DidSwapBuffers() {
207 begin_frame_pending_ = false; 204 begin_frame_pending_ = false;
208 pending_swap_buffers_++; 205 pending_swap_buffers_++;
209 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", 206 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers",
210 "pending_swap_buffers_", pending_swap_buffers_); 207 "pending_swap_buffers_", pending_swap_buffers_);
211 if (frame_rate_controller_) 208 if (frame_rate_controller_)
212 frame_rate_controller_->DidSwapBuffers(); 209 frame_rate_controller_->DidSwapBuffers();
213 PostCheckForRetroactiveBeginFrame(); 210 PostCheckForRetroactiveBeginFrame();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 368
372 void OutputSurface::PostSwapBuffersComplete() { 369 void OutputSurface::PostSwapBuffersComplete() {
373 base::MessageLoop::current()->PostTask( 370 base::MessageLoop::current()->PostTask(
374 FROM_HERE, 371 FROM_HERE,
375 base::Bind(&OutputSurface::OnSwapBuffersComplete, 372 base::Bind(&OutputSurface::OnSwapBuffersComplete,
376 weak_ptr_factory_.GetWeakPtr(), 373 weak_ptr_factory_.GetWeakPtr(),
377 static_cast<CompositorFrameAck*>(NULL))); 374 static_cast<CompositorFrameAck*>(NULL)));
378 } 375 }
379 376
380 } // namespace cc 377 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698