Index: content/browser/compositor/gpu_vsync_begin_frame_source.cc |
diff --git a/content/browser/compositor/gpu_vsync_begin_frame_source.cc b/content/browser/compositor/gpu_vsync_begin_frame_source.cc |
index 7e43be479adc6b1ff83bc7337b8cf60b29b15855..cc1e793c528776c1b2a544e16722afac0e826434 100644 |
--- a/content/browser/compositor/gpu_vsync_begin_frame_source.cc |
+++ b/content/browser/compositor/gpu_vsync_begin_frame_source.cc |
@@ -22,7 +22,7 @@ void GpuVSyncBeginFrameSource::OnVSync(base::TimeTicks timestamp, |
if (!needs_begin_frames_) |
return; |
- base::TimeTicks now = base::TimeTicks::Now(); |
+ base::TimeTicks now = Now(); |
base::TimeTicks deadline = now.SnappedToNextTick(timestamp, interval); |
TRACE_EVENT1("cc", "GpuVSyncBeginFrameSource::OnVSync", "latency", |
@@ -39,4 +39,48 @@ void GpuVSyncBeginFrameSource::OnNeedsBeginFrames(bool needs_begin_frames) { |
vsync_control_->SetNeedsVSync(needs_begin_frames); |
} |
+base::TimeTicks GpuVSyncBeginFrameSource::Now() const { |
+ return base::TimeTicks::Now(); |
+} |
+ |
+bool GpuVSyncBeginFrameSource::GetMissedBeginFrameArgs( |
+ cc::BeginFrameObserver* obs, |
+ cc::BeginFrameArgs* missed_args) { |
+ const cc::BeginFrameArgs& last_observer_args = obs->LastUsedBeginFrameArgs(); |
+ if (!last_begin_frame_args_.IsValid()) { |
+ // This is the case when all observers were removed from this BFS. |
+ if (!last_observer_args.IsValid()) |
sunnyps
2017/05/30 22:13:17
nit: Remove this workaround after removing the "la
stanisc
2017/05/31 01:17:53
Done.
|
+ return false; |
+ |
+ last_begin_frame_args_ = last_observer_args; |
+ } |
+ |
+ base::TimeTicks now = Now(); |
+ base::TimeTicks estimated_next_timestamp = now.SnappedToNextTick( |
+ last_begin_frame_args_.frame_time, last_begin_frame_args_.interval); |
+ base::TimeTicks missed_timestamp = |
+ estimated_next_timestamp - last_begin_frame_args_.interval; |
+ |
+ if (missed_timestamp > last_begin_frame_args_.frame_time) { |
+ // The projected missed timestamp is newer than the last known timestamp. |
+ // In this case create BeginFrameArgs with a new sequence number. |
+ next_sequence_number_++; |
+ last_begin_frame_args_ = cc::BeginFrameArgs::Create( |
+ BEGINFRAME_FROM_HERE, source_id(), next_sequence_number_, |
+ missed_timestamp, estimated_next_timestamp, |
+ last_begin_frame_args_.interval, cc::BeginFrameArgs::MISSED); |
+ } else { |
+ // The last known args object is up-to-date. Skip sending notification |
+ // if the observer has already seen it. |
+ if (last_observer_args.IsValid() && |
+ last_begin_frame_args_.frame_time <= last_observer_args.frame_time) { |
+ return false; |
+ } |
+ } |
+ |
+ *missed_args = last_begin_frame_args_; |
+ missed_args->type = cc::BeginFrameArgs::MISSED; |
+ return true; |
+} |
+ |
} // namespace content |