| 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_source.h" | 5 #include "cc/scheduler/begin_frame_source.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/debug/trace_event_argument.h" | 9 #include "base/debug/trace_event_argument.h" |
| 10 #include "base/location.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "cc/scheduler/delay_based_time_source.h" | 13 #include "cc/scheduler/delay_based_time_source.h" |
| 13 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
| 14 #include "ui/gfx/frame_time.h" | 15 #include "ui/gfx/frame_time.h" |
| 15 | 16 |
| 16 #ifdef NDEBUG | 17 #ifdef NDEBUG |
| 17 #define DEBUG_FRAMES(...) | 18 #define DEBUG_FRAMES(...) |
| 18 #else | 19 #else |
| 19 #define DEBUG_FRAMES(name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 20 #define DEBUG_FRAMES(name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 176 } |
| 176 | 177 |
| 177 void BackToBackBeginFrameSource::BeginFrame() { | 178 void BackToBackBeginFrameSource::BeginFrame() { |
| 178 send_begin_frame_posted_ = false; | 179 send_begin_frame_posted_ = false; |
| 179 | 180 |
| 180 if (!needs_begin_frames_) | 181 if (!needs_begin_frames_) |
| 181 return; | 182 return; |
| 182 | 183 |
| 183 base::TimeTicks now = Now(); | 184 base::TimeTicks now = Now(); |
| 184 BeginFrameArgs args = BeginFrameArgs::Create( | 185 BeginFrameArgs args = BeginFrameArgs::Create( |
| 185 now, now + BeginFrameArgs::DefaultInterval(), | 186 BEGINFRAME_FROM_HERE, now, now + BeginFrameArgs::DefaultInterval(), |
| 186 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); | 187 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); |
| 187 CallOnBeginFrame(args); | 188 CallOnBeginFrame(args); |
| 188 } | 189 } |
| 189 | 190 |
| 190 // BeginFrameSource support | 191 // BeginFrameSource support |
| 191 | 192 |
| 192 void BackToBackBeginFrameSource::DidFinishFrame(size_t remaining_frames) { | 193 void BackToBackBeginFrameSource::DidFinishFrame(size_t remaining_frames) { |
| 193 if (remaining_frames == 0) { | 194 if (remaining_frames == 0) { |
| 194 OnNeedsBeginFramesChange(NeedsBeginFrames()); | 195 OnNeedsBeginFramesChange(NeedsBeginFrames()); |
| 195 } | 196 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void SyntheticBeginFrameSource::OnUpdateVSyncParameters( | 236 void SyntheticBeginFrameSource::OnUpdateVSyncParameters( |
| 236 base::TimeTicks new_vsync_timebase, | 237 base::TimeTicks new_vsync_timebase, |
| 237 base::TimeDelta new_vsync_interval) { | 238 base::TimeDelta new_vsync_interval) { |
| 238 time_source_->SetTimebaseAndInterval(new_vsync_timebase, new_vsync_interval); | 239 time_source_->SetTimebaseAndInterval(new_vsync_timebase, new_vsync_interval); |
| 239 } | 240 } |
| 240 | 241 |
| 241 BeginFrameArgs SyntheticBeginFrameSource::CreateBeginFrameArgs( | 242 BeginFrameArgs SyntheticBeginFrameSource::CreateBeginFrameArgs( |
| 242 base::TimeTicks frame_time, | 243 base::TimeTicks frame_time, |
| 243 BeginFrameArgs::BeginFrameArgsType type) { | 244 BeginFrameArgs::BeginFrameArgsType type) { |
| 244 base::TimeTicks deadline = time_source_->NextTickTime(); | 245 base::TimeTicks deadline = time_source_->NextTickTime(); |
| 245 return BeginFrameArgs::Create(frame_time, deadline, time_source_->Interval(), | 246 return BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
| 246 type); | 247 time_source_->Interval(), type); |
| 247 } | 248 } |
| 248 | 249 |
| 249 // TimeSourceClient support | 250 // TimeSourceClient support |
| 250 void SyntheticBeginFrameSource::OnTimerTick() { | 251 void SyntheticBeginFrameSource::OnTimerTick() { |
| 251 CallOnBeginFrame(CreateBeginFrameArgs(time_source_->LastTickTime(), | 252 CallOnBeginFrame(CreateBeginFrameArgs(time_source_->LastTickTime(), |
| 252 BeginFrameArgs::NORMAL)); | 253 BeginFrameArgs::NORMAL)); |
| 253 } | 254 } |
| 254 | 255 |
| 255 // BeginFrameSourceMixIn support | 256 // BeginFrameSourceMixIn support |
| 256 void SyntheticBeginFrameSource::OnNeedsBeginFramesChange( | 257 void SyntheticBeginFrameSource::OnNeedsBeginFramesChange( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (!observer_->LastUsedBeginFrameArgs().IsValid()) | 483 if (!observer_->LastUsedBeginFrameArgs().IsValid()) |
| 483 return true; | 484 return true; |
| 484 | 485 |
| 485 // Only allow new args have a *strictly bigger* frame_time value and statisfy | 486 // Only allow new args have a *strictly bigger* frame_time value and statisfy |
| 486 // minimum interval requirement. | 487 // minimum interval requirement. |
| 487 return (args.frame_time >= | 488 return (args.frame_time >= |
| 488 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); | 489 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); |
| 489 } | 490 } |
| 490 | 491 |
| 491 } // namespace cc | 492 } // namespace cc |
| OLD | NEW |