ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / cc / output / begin_frame_args.cc
blob3663125715eaad0304f462087063f57e082508ec
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"
8 #include "ui/gfx/frame_time.h"
10 namespace cc {
12 const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) {
13 switch (type) {
14 case BeginFrameArgs::INVALID:
15 return "INVALID";
16 case BeginFrameArgs::NORMAL:
17 return "NORMAL";
18 case BeginFrameArgs::SYNCHRONOUS:
19 return "SYNCHRONOUS";
20 case BeginFrameArgs::MISSED:
21 return "MISSED";
22 case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX:
23 return "BEGIN_FRAME_ARGS_TYPE_MAX";
25 NOTREACHED();
26 return "???";
29 BeginFrameArgs::BeginFrameArgs()
30 : frame_time(base::TimeTicks()),
31 deadline(base::TimeTicks()),
32 interval(base::TimeDelta::FromMicroseconds(-1)),
33 type(BeginFrameArgs::INVALID) {
36 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time,
37 base::TimeTicks deadline,
38 base::TimeDelta interval,
39 BeginFrameArgs::BeginFrameArgsType type)
40 : frame_time(frame_time),
41 deadline(deadline),
42 interval(interval),
43 type(type) {
46 BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location,
47 base::TimeTicks frame_time,
48 base::TimeTicks deadline,
49 base::TimeDelta interval,
50 BeginFrameArgs::BeginFrameArgsType type) {
51 DCHECK_NE(type, BeginFrameArgs::INVALID);
52 DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX);
53 #ifdef NDEBUG
54 return BeginFrameArgs(frame_time, deadline, interval, type);
55 #else
56 BeginFrameArgs args = BeginFrameArgs(frame_time, deadline, interval, type);
57 args.created_from = location;
58 return args;
59 #endif
62 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
63 BeginFrameArgs::AsValue() const {
64 scoped_refptr<base::trace_event::TracedValue> state =
65 new base::trace_event::TracedValue();
66 AsValueInto(state.get());
67 return state;
70 void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const {
71 state->SetString("type", "BeginFrameArgs");
72 state->SetString("subtype", TypeToString(type));
73 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
74 state->SetDouble("deadline_us", deadline.ToInternalValue());
75 state->SetDouble("interval_us", interval.InMicroseconds());
76 #ifndef NDEBUG
77 state->SetString("created_from", created_from.ToString());
78 #endif
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