| 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), |
| 11 location_string_(location.ToString()), | 11 location_string_(location.ToString()), |
| 12 current_updated_at_(), | 12 current_updated_at_(), |
| 13 current_args_(), | 13 current_args_(), |
| 14 current_finished_at_(base::TimeTicks::FromInternalValue(-1)) {} | 14 current_finished_at_(base::TimeTicks::FromInternalValue(-1)) {} |
| 15 | 15 |
| 16 BeginFrameTracker::~BeginFrameTracker() { | 16 BeginFrameTracker::~BeginFrameTracker() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 void BeginFrameTracker::Start(BeginFrameArgs new_args) { | 19 void BeginFrameTracker::Start(BeginFrameArgs new_args) { |
| 20 // Trace the frame time being passed between BeginFrameTrackers. | 20 // Trace the frame time being passed between BeginFrameTrackers. |
| 21 TRACE_EVENT_FLOW_STEP0( | 21 TRACE_EVENT_FLOW_STEP0( |
| 22 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", | 22 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", |
| 23 new_args.frame_time.ToInternalValue(), location_string_); | 23 new_args.frame_time.ToInternalValue(), location_string_); |
| 24 | 24 |
| 25 // Trace this specific begin frame tracker Start/Finish times. | 25 // Trace this specific begin frame tracker Start/Finish times. |
| 26 TRACE_EVENT_ASYNC_BEGIN2( | 26 TRACE_EVENT_COPY_ASYNC_BEGIN2( |
| 27 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), | 27 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), |
| 28 location_string_.c_str(), new_args.frame_time.ToInternalValue(), | 28 location_string_.c_str(), new_args.frame_time.ToInternalValue(), |
| 29 "new args", new_args.AsValue(), "current args", current_args_.AsValue()); | 29 "new args", new_args.AsValue(), "current args", current_args_.AsValue()); |
| 30 | 30 |
| 31 // Check the new BeginFrameArgs are valid and monotonically increasing. | 31 // Check the new BeginFrameArgs are valid and monotonically increasing. |
| 32 DCHECK(new_args.IsValid()); | 32 DCHECK(new_args.IsValid()); |
| 33 DCHECK_LE(current_args_.frame_time, new_args.frame_time); | 33 DCHECK_LE(current_args_.frame_time, new_args.frame_time); |
| 34 | 34 |
| 35 DCHECK(HasFinished()) | 35 DCHECK(HasFinished()) |
| 36 << "Tried to start a new frame before finishing an existing frame."; | 36 << "Tried to start a new frame before finishing an existing frame."; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 47 DCHECK(!HasFinished()) | 47 DCHECK(!HasFinished()) |
| 48 << "Tried to use BeginFrameArgs after marking the frame finished."; | 48 << "Tried to use BeginFrameArgs after marking the frame finished."; |
| 49 DCHECK(current_args_.IsValid()) | 49 DCHECK(current_args_.IsValid()) |
| 50 << "Tried to use BeginFrameArgs before starting a frame!"; | 50 << "Tried to use BeginFrameArgs before starting a frame!"; |
| 51 return current_args_; | 51 return current_args_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void BeginFrameTracker::Finish() { | 54 void BeginFrameTracker::Finish() { |
| 55 DCHECK(!HasFinished()) << "Tried to finish an already finished frame"; | 55 DCHECK(!HasFinished()) << "Tried to finish an already finished frame"; |
| 56 current_finished_at_ = base::TimeTicks::Now(); | 56 current_finished_at_ = base::TimeTicks::Now(); |
| 57 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), | 57 TRACE_EVENT_COPY_ASYNC_END0( |
| 58 location_string_.c_str(), | 58 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), |
| 59 current_args_.frame_time.ToInternalValue()); | 59 location_string_.c_str(), current_args_.frame_time.ToInternalValue()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 const BeginFrameArgs& BeginFrameTracker::Last() const { | 62 const BeginFrameArgs& BeginFrameTracker::Last() const { |
| 63 DCHECK(current_args_.IsValid()) | 63 DCHECK(current_args_.IsValid()) |
| 64 << "Tried to use last BeginFrameArgs before starting a frame!"; | 64 << "Tried to use last BeginFrameArgs before starting a frame!"; |
| 65 DCHECK(HasFinished()) | 65 DCHECK(HasFinished()) |
| 66 << "Tried to use last BeginFrameArgs before the frame is finished."; | 66 << "Tried to use last BeginFrameArgs before the frame is finished."; |
| 67 return current_args_; | 67 return current_args_; |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { | 114 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { |
| 115 if (!HasFinished()) { | 115 if (!HasFinished()) { |
| 116 return Current(); | 116 return Current(); |
| 117 } else { | 117 } else { |
| 118 return Last(); | 118 return Last(); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace cc | 122 } // namespace cc |
| OLD | NEW |