Bump libaddressinput version
[chromium-blink-merge.git] / cc / output / begin_frame_args.cc
blob216eb52587af2c5d5e509d4b11af8aa5b4989b85
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/trace_event/trace_event_argument.h"
9 namespace cc {
11 const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) {
12 switch (type) {
13 case BeginFrameArgs::INVALID:
14 return "INVALID";
15 case BeginFrameArgs::NORMAL:
16 return "NORMAL";
17 case BeginFrameArgs::MISSED:
18 return "MISSED";
19 case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX:
20 return "BEGIN_FRAME_ARGS_TYPE_MAX";
22 NOTREACHED();
23 return "???";
26 BeginFrameArgs::BeginFrameArgs()
27 : frame_time(base::TimeTicks()),
28 deadline(base::TimeTicks()),
29 interval(base::TimeDelta::FromMicroseconds(-1)),
30 type(BeginFrameArgs::INVALID),
31 on_critical_path(true) {
34 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time,
35 base::TimeTicks deadline,
36 base::TimeDelta interval,
37 BeginFrameArgs::BeginFrameArgsType type)
38 : frame_time(frame_time),
39 deadline(deadline),
40 interval(interval),
41 type(type),
42 on_critical_path(true) {
45 BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location,
46 base::TimeTicks frame_time,
47 base::TimeTicks deadline,
48 base::TimeDelta interval,
49 BeginFrameArgs::BeginFrameArgsType type) {
50 DCHECK_NE(type, BeginFrameArgs::INVALID);
51 DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX);
52 #ifdef NDEBUG
53 return BeginFrameArgs(frame_time, deadline, interval, type);
54 #else
55 BeginFrameArgs args = BeginFrameArgs(frame_time, deadline, interval, type);
56 args.created_from = location;
57 return args;
58 #endif
61 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
62 BeginFrameArgs::AsValue() const {
63 scoped_refptr<base::trace_event::TracedValue> state =
64 new base::trace_event::TracedValue();
65 AsValueInto(state.get());
66 return state;
69 void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const {
70 state->SetString("type", "BeginFrameArgs");
71 state->SetString("subtype", TypeToString(type));
72 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
73 state->SetDouble("deadline_us", deadline.ToInternalValue());
74 state->SetDouble("interval_us", interval.InMicroseconds());
75 #ifndef NDEBUG
76 state->SetString("created_from", created_from.ToString());
77 #endif
78 state->SetBoolean("on_critical_path", on_critical_path);
81 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
82 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
83 // as the default adjustment gives the Browser the last 1/3 of a frame to
84 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
85 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
86 // output.
87 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() {
88 return base::TimeDelta::FromMicroseconds(16666 / 3);
91 base::TimeDelta BeginFrameArgs::DefaultInterval() {
92 return base::TimeDelta::FromMicroseconds(16666);
95 } // namespace cc