1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/output/begin_frame_args.h"
9 BeginFrameArgs::BeginFrameArgs()
10 : frame_time(base::TimeTicks()),
11 deadline(base::TimeTicks()),
12 interval(base::TimeDelta::FromMicroseconds(-1)) {
15 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time
,
16 base::TimeTicks deadline
,
17 base::TimeDelta interval
)
18 : frame_time(frame_time
),
23 BeginFrameArgs
BeginFrameArgs::Create(base::TimeTicks frame_time
,
24 base::TimeTicks deadline
,
25 base::TimeDelta interval
) {
26 return BeginFrameArgs(frame_time
, deadline
, interval
);
29 BeginFrameArgs
BeginFrameArgs::CreateForSynchronousCompositor() {
30 // For WebView/SynchronousCompositor, we always want to draw immediately,
31 // so we set the deadline to 0 and guess that the interval is 16 milliseconds.
32 return BeginFrameArgs(base::TimeTicks::Now(),
37 BeginFrameArgs
BeginFrameArgs::CreateForTesting() {
38 base::TimeTicks now
= base::TimeTicks::Now();
39 return BeginFrameArgs(now
,
40 now
+ (DefaultInterval() / 2),
44 BeginFrameArgs
BeginFrameArgs::CreateExpiredForTesting() {
45 base::TimeTicks now
= base::TimeTicks::Now();
46 return BeginFrameArgs(now
,
47 now
- DefaultInterval(),
51 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
52 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
53 // as the default adjustment gives the Browser the last 1/3 of a frame to
54 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
55 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
57 base::TimeDelta
BeginFrameArgs::DefaultDeadlineAdjustment() {
58 return base::TimeDelta::FromMicroseconds(-16666 / 3);
61 base::TimeDelta
BeginFrameArgs::DefaultInterval() {
62 return base::TimeDelta::FromMicroseconds(16666);
65 base::TimeDelta
BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() {
66 return base::TimeDelta::FromMicroseconds(4444);