Revert of Reland: Make WindowState::CanMinimize() take into account WidgetDelegate...
[chromium-blink-merge.git] / cc / output / begin_frame_args.cc
blobfc7098f4798cb1aefbf763f583da487f0fb5572f
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"
7 #include "base/debug/trace_event_argument.h"
8 #include "ui/gfx/frame_time.h"
10 namespace cc {
12 BeginFrameArgs::BeginFrameArgs()
13 : frame_time(base::TimeTicks()),
14 deadline(base::TimeTicks()),
15 interval(base::TimeDelta::FromMicroseconds(-1)),
16 type(BeginFrameArgs::INVALID) {
19 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time,
20 base::TimeTicks deadline,
21 base::TimeDelta interval,
22 BeginFrameArgs::BeginFrameArgsType type)
23 : frame_time(frame_time),
24 deadline(deadline),
25 interval(interval),
26 type(type) {
29 BeginFrameArgs BeginFrameArgs::CreateTyped(
30 base::TimeTicks frame_time,
31 base::TimeTicks deadline,
32 base::TimeDelta interval,
33 BeginFrameArgs::BeginFrameArgsType type) {
34 DCHECK_NE(type, BeginFrameArgs::INVALID);
35 return BeginFrameArgs(frame_time, deadline, interval, type);
38 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
39 base::TimeTicks deadline,
40 base::TimeDelta interval) {
41 return CreateTyped(frame_time, deadline, interval, BeginFrameArgs::NORMAL);
44 scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsValue()
45 const {
46 scoped_refptr<base::debug::TracedValue> state =
47 new base::debug::TracedValue();
48 AsValueInto(state.get());
49 return state;
52 void BeginFrameArgs::AsValueInto(base::debug::TracedValue* state) const {
53 state->SetString("type", "BeginFrameArgs");
54 switch (type) {
55 case BeginFrameArgs::INVALID:
56 state->SetString("subtype", "INVALID");
57 break;
58 case BeginFrameArgs::NORMAL:
59 state->SetString("subtype", "NORMAL");
60 break;
61 case BeginFrameArgs::SYNCHRONOUS:
62 state->SetString("subtype", "SYNCHRONOUS");
63 break;
64 case BeginFrameArgs::MISSED:
65 state->SetString("subtype", "MISSED");
66 break;
68 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
69 state->SetDouble("deadline_us", deadline.ToInternalValue());
70 state->SetDouble("interval_us", interval.InMicroseconds());
73 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor(
74 base::TimeTicks now) {
75 // For WebView/SynchronousCompositor, we always want to draw immediately,
76 // so we set the deadline to 0 and guess that the interval is 16 milliseconds.
77 if (now.is_null())
78 now = gfx::FrameTime::Now();
79 return CreateTyped(
80 now, base::TimeTicks(), DefaultInterval(), BeginFrameArgs::SYNCHRONOUS);
83 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
84 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
85 // as the default adjustment gives the Browser the last 1/3 of a frame to
86 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
87 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
88 // output.
89 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() {
90 return base::TimeDelta::FromMicroseconds(16666 / 3);
93 base::TimeDelta BeginFrameArgs::DefaultInterval() {
94 return base::TimeDelta::FromMicroseconds(16666);
97 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() {
98 return base::TimeDelta::FromMicroseconds(4444);
101 } // namespace cc