Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / cc / output / begin_frame_args.cc
blob7a77be2bd52411b2848d2b5343bf0c86b3a0b673
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::MISSED:
19 return "MISSED";
20 case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX:
21 return "BEGIN_FRAME_ARGS_TYPE_MAX";
23 NOTREACHED();
24 return "???";
27 BeginFrameArgs::BeginFrameArgs()
28 : frame_time(base::TimeTicks()),
29 deadline(base::TimeTicks()),
30 interval(base::TimeDelta::FromMicroseconds(-1)),
31 type(BeginFrameArgs::INVALID) {
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) {
44 BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location,
45 base::TimeTicks frame_time,
46 base::TimeTicks deadline,
47 base::TimeDelta interval,
48 BeginFrameArgs::BeginFrameArgsType type) {
49 DCHECK_NE(type, BeginFrameArgs::INVALID);
50 DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX);
51 #ifdef NDEBUG
52 return BeginFrameArgs(frame_time, deadline, interval, type);
53 #else
54 BeginFrameArgs args = BeginFrameArgs(frame_time, deadline, interval, type);
55 args.created_from = location;
56 return args;
57 #endif
60 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
61 BeginFrameArgs::AsValue() const {
62 scoped_refptr<base::trace_event::TracedValue> state =
63 new base::trace_event::TracedValue();
64 AsValueInto(state.get());
65 return state;
68 void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const {
69 state->SetString("type", "BeginFrameArgs");
70 state->SetString("subtype", TypeToString(type));
71 state->SetDouble("frame_time_us", frame_time.ToInternalValue());
72 state->SetDouble("deadline_us", deadline.ToInternalValue());
73 state->SetDouble("interval_us", interval.InMicroseconds());
74 #ifndef NDEBUG
75 state->SetString("created_from", created_from.ToString());
76 #endif
79 // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
80 // cases where a good estimated draw time is not known. Using 1/3 of the vsync
81 // as the default adjustment gives the Browser the last 1/3 of a frame to
82 // produce output, the Renderer Impl thread the middle 1/3 of a frame to produce
83 // ouput, and the Renderer Main thread the first 1/3 of a frame to produce
84 // output.
85 base::TimeDelta BeginFrameArgs::DefaultEstimatedParentDrawTime() {
86 return base::TimeDelta::FromMicroseconds(16666 / 3);
89 base::TimeDelta BeginFrameArgs::DefaultInterval() {
90 return base::TimeDelta::FromMicroseconds(16666);
93 } // namespace cc