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

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 tests 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 skipped_begin_frame_args_ = args; 213 skipped_begin_frame_args_ = args;
213 } else { 214 } else {
214 begin_frame_pending_ = true; 215 begin_frame_pending_ = true;
215 client_->BeginFrame(args); 216 client_->BeginFrame(args);
216 // args might be an alias for skipped_begin_frame_args_. 217 // args might be an alias for skipped_begin_frame_args_.
217 // Do not reset it before calling BeginFrame! 218 // Do not reset it before calling BeginFrame!
218 skipped_begin_frame_args_ = BeginFrameArgs(); 219 skipped_begin_frame_args_ = BeginFrameArgs();
219 } 220 }
220 } 221 }
221 222
222 base::TimeDelta OutputSurface::AlternateRetroactiveBeginFramePeriod() { 223 base::TimeTicks OutputSurface::RetroactiveBeginFrameDeadline() {
223 return BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); 224 // TODO(brianderson): Remove the alternative deadline once we have better
225 // deadline estimations.
226 base::TimeTicks alternative_deadline =
227 skipped_begin_frame_args_.frame_time +
228 BeginFrameArgs::DefaultRetroactiveBeginFramePeriod();
229 return std::max(skipped_begin_frame_args_.deadline, alternative_deadline);
224 } 230 }
225 231
226 void OutputSurface::PostCheckForRetroactiveBeginFrame() { 232 void OutputSurface::PostCheckForRetroactiveBeginFrame() {
227 if (!skipped_begin_frame_args_.IsValid() || 233 if (!skipped_begin_frame_args_.IsValid() ||
228 check_for_retroactive_begin_frame_pending_) 234 check_for_retroactive_begin_frame_pending_)
229 return; 235 return;
230 236
231 base::MessageLoop::current()->PostTask( 237 base::MessageLoop::current()->PostTask(
232 FROM_HERE, 238 FROM_HERE,
233 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, 239 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame,
234 weak_ptr_factory_.GetWeakPtr())); 240 weak_ptr_factory_.GetWeakPtr()));
235 check_for_retroactive_begin_frame_pending_ = true; 241 check_for_retroactive_begin_frame_pending_ = true;
236 } 242 }
237 243
238 void OutputSurface::CheckForRetroactiveBeginFrame() { 244 void OutputSurface::CheckForRetroactiveBeginFrame() {
239 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); 245 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame");
240 check_for_retroactive_begin_frame_pending_ = false; 246 check_for_retroactive_begin_frame_pending_ = false;
241 base::TimeTicks now = base::TimeTicks::Now(); 247 if (base::TimeTicks::Now() < RetroactiveBeginFrameDeadline())
242 // TODO(brianderson): Remove the alternative deadline once we have better
243 // deadline estimations.
244 base::TimeTicks alternative_deadline =
245 skipped_begin_frame_args_.frame_time +
246 AlternateRetroactiveBeginFramePeriod();
247 if (now < skipped_begin_frame_args_.deadline ||
248 now < alternative_deadline) {
249 BeginFrame(skipped_begin_frame_args_); 248 BeginFrame(skipped_begin_frame_args_);
250 }
251 } 249 }
252 250
253 void OutputSurface::DidSwapBuffers() { 251 void OutputSurface::DidSwapBuffers() {
254 begin_frame_pending_ = false; 252 begin_frame_pending_ = false;
255 pending_swap_buffers_++; 253 pending_swap_buffers_++;
256 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", 254 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers",
257 "pending_swap_buffers_", pending_swap_buffers_); 255 "pending_swap_buffers_", pending_swap_buffers_);
258 if (frame_rate_controller_) 256 if (frame_rate_controller_)
259 frame_rate_controller_->DidSwapBuffers(); 257 frame_rate_controller_->DidSwapBuffers();
260 PostCheckForRetroactiveBeginFrame(); 258 PostCheckForRetroactiveBeginFrame();
261 } 259 }
262 260
263 void OutputSurface::OnSwapBuffersComplete(const CompositorFrameAck* ack) { 261 void OutputSurface::OnSwapBuffersComplete(const CompositorFrameAck* ack) {
264 pending_swap_buffers_--; 262 pending_swap_buffers_--;
265 TRACE_EVENT1("cc", "OutputSurface::OnSwapBuffersComplete", 263 TRACE_EVENT1("cc", "OutputSurface::OnSwapBuffersComplete",
266 "pending_swap_buffers_", pending_swap_buffers_); 264 "pending_swap_buffers_", pending_swap_buffers_);
267 client_->OnSwapBuffersComplete(ack); 265 client_->OnSwapBuffersComplete(ack);
268 if (frame_rate_controller_) 266 if (frame_rate_controller_)
269 frame_rate_controller_->DidSwapBuffersComplete(); 267 frame_rate_controller_->DidSwapBuffersComplete();
270 PostCheckForRetroactiveBeginFrame(); 268 PostCheckForRetroactiveBeginFrame();
271 } 269 }
272 270
273 void OutputSurface::DidLoseOutputSurface() { 271 void OutputSurface::DidLoseOutputSurface() {
274 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface"); 272 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface");
275 begin_frame_pending_ = false; 273 begin_frame_pending_ = false;
276 pending_swap_buffers_ = 0; 274 pending_swap_buffers_ = 0;
275 if (frame_rate_controller_)
danakj 2013/08/19 21:54:41 This seems like it could be a separate CL?
276 frame_rate_controller_->SetActive(false);
277 client_->DidLoseOutputSurface(); 277 client_->DidLoseOutputSurface();
278 } 278 }
279 279
280 void OutputSurface::SetExternalStencilTest(bool enabled) { 280 void OutputSurface::SetExternalStencilTest(bool enabled) {
281 client_->SetExternalStencilTest(enabled); 281 client_->SetExternalStencilTest(enabled);
282 } 282 }
283 283
284 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, 284 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform,
285 gfx::Rect viewport) { 285 gfx::Rect viewport) {
286 client_->SetExternalDrawConstraints(transform, viewport); 286 client_->SetExternalDrawConstraints(transform, viewport);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 "discard_backbuffer", discard_backbuffer); 452 "discard_backbuffer", discard_backbuffer);
453 // Just ignore the memory manager when it says to set the limit to zero 453 // Just ignore the memory manager when it says to set the limit to zero
454 // bytes. This will happen when the memory manager thinks that the renderer 454 // bytes. This will happen when the memory manager thinks that the renderer
455 // is not visible (which the renderer knows better). 455 // is not visible (which the renderer knows better).
456 if (policy.bytes_limit_when_visible) 456 if (policy.bytes_limit_when_visible)
457 client_->SetMemoryPolicy(policy); 457 client_->SetMemoryPolicy(policy);
458 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); 458 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer);
459 } 459 }
460 460
461 } // namespace cc 461 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698