| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/scheduler/begin_frame_tracker.h" | 5 #include "cc/scheduler/begin_frame_tracker.h" |
| 6 | 6 |
| 7 namespace cc { | 7 namespace cc { |
| 8 | 8 |
| 9 BeginFrameTracker::BeginFrameTracker(const tracked_objects::Location& location) | 9 BeginFrameTracker::BeginFrameTracker(const tracked_objects::Location& location) |
| 10 : location_(location), | 10 : location_(location), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::TimeDelta interval = current_args_.interval; | 71 base::TimeDelta interval = current_args_.interval; |
| 72 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest | 72 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest |
| 73 // easily available so anything less than that is likely an error. | 73 // easily available so anything less than that is likely an error. |
| 74 if (interval < base::TimeDelta::FromMilliseconds(1)) { | 74 if (interval < base::TimeDelta::FromMilliseconds(1)) { |
| 75 interval = BeginFrameArgs::DefaultInterval(); | 75 interval = BeginFrameArgs::DefaultInterval(); |
| 76 } | 76 } |
| 77 return interval; | 77 return interval; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void BeginFrameTracker::AsValueInto( | 80 void BeginFrameTracker::AsValueInto( |
| 81 base::TimeTicks now, |
| 81 base::trace_event::TracedValue* state) const { | 82 base::trace_event::TracedValue* state) const { |
| 82 state->SetDouble("updated_at_ms", | 83 state->SetDouble("updated_at_ms", |
| 83 (current_updated_at_ - base::TimeTicks()).InMillisecondsF()); | 84 (current_updated_at_ - base::TimeTicks()).InMillisecondsF()); |
| 84 state->SetDouble( | 85 state->SetDouble( |
| 85 "finished_at_ms", | 86 "finished_at_ms", |
| 86 (current_finished_at_ - base::TimeTicks()).InMillisecondsF()); | 87 (current_finished_at_ - base::TimeTicks()).InMillisecondsF()); |
| 87 if (HasFinished()) { | 88 if (HasFinished()) { |
| 88 state->SetString("state", "FINISHED"); | 89 state->SetString("state", "FINISHED"); |
| 89 state->BeginDictionary("current_args_"); | 90 state->BeginDictionary("current_args_"); |
| 90 } else { | 91 } else { |
| 91 state->SetString("state", "USING"); | 92 state->SetString("state", "USING"); |
| 92 state->BeginDictionary("last_args_"); | 93 state->BeginDictionary("last_args_"); |
| 93 } | 94 } |
| 94 current_args_.AsValueInto(state); | 95 current_args_.AsValueInto(state); |
| 95 state->EndDictionary(); | 96 state->EndDictionary(); |
| 96 | 97 |
| 97 base::TimeTicks now = base::TimeTicks::Now(); | |
| 98 base::TimeTicks frame_time = current_args_.frame_time; | 98 base::TimeTicks frame_time = current_args_.frame_time; |
| 99 base::TimeTicks deadline = current_args_.deadline; | 99 base::TimeTicks deadline = current_args_.deadline; |
| 100 base::TimeDelta interval = current_args_.interval; | 100 base::TimeDelta interval = current_args_.interval; |
| 101 state->BeginDictionary("major_timestamps_in_ms"); | 101 state->BeginDictionary("major_timestamps_in_ms"); |
| 102 state->SetDouble("0_interval", interval.InMillisecondsF()); | 102 state->SetDouble("0_interval", interval.InMillisecondsF()); |
| 103 state->SetDouble("1_now_to_deadline", (deadline - now).InMillisecondsF()); | 103 state->SetDouble("1_now_to_deadline", (deadline - now).InMillisecondsF()); |
| 104 state->SetDouble("2_frame_time_to_now", (now - frame_time).InMillisecondsF()); | 104 state->SetDouble("2_frame_time_to_now", (now - frame_time).InMillisecondsF()); |
| 105 state->SetDouble("3_frame_time_to_deadline", | 105 state->SetDouble("3_frame_time_to_deadline", |
| 106 (deadline - frame_time).InMillisecondsF()); | 106 (deadline - frame_time).InMillisecondsF()); |
| 107 state->SetDouble("4_now", (now - base::TimeTicks()).InMillisecondsF()); | 107 state->SetDouble("4_now", (now - base::TimeTicks()).InMillisecondsF()); |
| 108 state->SetDouble("5_frame_time", | 108 state->SetDouble("5_frame_time", |
| 109 (frame_time - base::TimeTicks()).InMillisecondsF()); | 109 (frame_time - base::TimeTicks()).InMillisecondsF()); |
| 110 state->SetDouble("6_deadline", | 110 state->SetDouble("6_deadline", |
| 111 (deadline - base::TimeTicks()).InMillisecondsF()); | 111 (deadline - base::TimeTicks()).InMillisecondsF()); |
| 112 state->EndDictionary(); | 112 state->EndDictionary(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { | 115 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { |
| 116 if (!HasFinished()) { | 116 if (!HasFinished()) { |
| 117 return Current(); | 117 return Current(); |
| 118 } else { | 118 } else { |
| 119 return Last(); | 119 return Last(); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace cc | 123 } // namespace cc |
| OLD | NEW |