| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/begin_frame_args.h" | 5 #include "cc/output/begin_frame_args.h" |
| 6 | |
| 7 #include "base/debug/trace_event_argument.h" | |
| 8 #include "ui/gfx/frame_time.h" | 6 #include "ui/gfx/frame_time.h" |
| 9 | 7 |
| 10 namespace cc { | 8 namespace cc { |
| 11 | 9 |
| 12 BeginFrameArgs::BeginFrameArgs() | 10 BeginFrameArgs::BeginFrameArgs() |
| 13 : frame_time(base::TimeTicks()), | 11 : frame_time(base::TimeTicks()), |
| 14 deadline(base::TimeTicks()), | 12 deadline(base::TimeTicks()), |
| 15 interval(base::TimeDelta::FromMicroseconds(-1)) { | 13 interval(base::TimeDelta::FromMicroseconds(-1)) { |
| 16 } | 14 } |
| 17 | 15 |
| 18 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, | 16 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, |
| 19 base::TimeTicks deadline, | 17 base::TimeTicks deadline, |
| 20 base::TimeDelta interval) | 18 base::TimeDelta interval) |
| 21 : frame_time(frame_time), | 19 : frame_time(frame_time), |
| 22 deadline(deadline), | 20 deadline(deadline), |
| 23 interval(interval) | 21 interval(interval) |
| 24 {} | 22 {} |
| 25 | 23 |
| 26 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time, | 24 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time, |
| 27 base::TimeTicks deadline, | 25 base::TimeTicks deadline, |
| 28 base::TimeDelta interval) { | 26 base::TimeDelta interval) { |
| 29 return BeginFrameArgs(frame_time, deadline, interval); | 27 return BeginFrameArgs(frame_time, deadline, interval); |
| 30 } | 28 } |
| 31 | 29 |
| 32 scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsValue() | 30 scoped_ptr<base::Value> BeginFrameArgs::AsValue() const { |
| 33 const { | 31 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); |
| 34 scoped_refptr<base::debug::TracedValue> state = | |
| 35 new base::debug::TracedValue(); | |
| 36 AsValueInto(state.get()); | |
| 37 return state; | |
| 38 } | |
| 39 | |
| 40 void BeginFrameArgs::AsValueInto(base::debug::TracedValue* state) const { | |
| 41 state->SetString("type", "BeginFrameArgs"); | 32 state->SetString("type", "BeginFrameArgs"); |
| 42 state->SetDouble("frame_time_us", frame_time.ToInternalValue()); | 33 state->SetDouble("frame_time_us", frame_time.ToInternalValue()); |
| 43 state->SetDouble("deadline_us", deadline.ToInternalValue()); | 34 state->SetDouble("deadline_us", deadline.ToInternalValue()); |
| 44 state->SetDouble("interval_us", interval.InMicroseconds()); | 35 state->SetDouble("interval_us", interval.InMicroseconds()); |
| 36 return state.PassAs<base::Value>(); |
| 45 } | 37 } |
| 46 | 38 |
| 47 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor( | 39 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor( |
| 48 base::TimeTicks now) { | 40 base::TimeTicks now) { |
| 49 // For WebView/SynchronousCompositor, we always want to draw immediately, | 41 // For WebView/SynchronousCompositor, we always want to draw immediately, |
| 50 // so we set the deadline to 0 and guess that the interval is 16 milliseconds. | 42 // so we set the deadline to 0 and guess that the interval is 16 milliseconds. |
| 51 if (now.is_null()) | 43 if (now.is_null()) |
| 52 now = gfx::FrameTime::Now(); | 44 now = gfx::FrameTime::Now(); |
| 53 return BeginFrameArgs(now, base::TimeTicks(), DefaultInterval()); | 45 return BeginFrameArgs(now, base::TimeTicks(), DefaultInterval()); |
| 54 } | 46 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 | 57 |
| 66 base::TimeDelta BeginFrameArgs::DefaultInterval() { | 58 base::TimeDelta BeginFrameArgs::DefaultInterval() { |
| 67 return base::TimeDelta::FromMicroseconds(16666); | 59 return base::TimeDelta::FromMicroseconds(16666); |
| 68 } | 60 } |
| 69 | 61 |
| 70 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() { | 62 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() { |
| 71 return base::TimeDelta::FromMicroseconds(4444); | 63 return base::TimeDelta::FromMicroseconds(4444); |
| 72 } | 64 } |
| 73 | 65 |
| 74 } // namespace cc | 66 } // namespace cc |
| OLD | NEW |