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