Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/compositor/gpu_vsync_begin_frame_source.h" | |
| 6 | |
| 7 namespace content { | |
| 8 | |
| 9 GpuVSyncBeginFrameSource::GpuVSyncBeginFrameSource( | |
| 10 GpuVSyncControl* vsync_control) | |
| 11 : cc::ExternalBeginFrameSource(this), | |
| 12 vsync_control_(vsync_control), | |
| 13 needs_begin_frames_(false), | |
| 14 next_sequence_number_(cc::BeginFrameArgs::kStartingFrameNumber) { | |
| 15 DCHECK(vsync_control); | |
| 16 } | |
| 17 | |
| 18 GpuVSyncBeginFrameSource::~GpuVSyncBeginFrameSource() = default; | |
| 19 | |
| 20 void GpuVSyncBeginFrameSource::OnVSync( | |
| 21 base::TimeTicks timestamp, base::TimeDelta interval) { | |
| 22 if (!needs_begin_frames_) | |
| 23 return; | |
| 24 | |
| 25 base::TimeTicks now = base::TimeTicks::Now(); | |
| 26 base::TimeTicks deadline = now.SnappedToNextTick(timestamp, interval); | |
| 27 | |
| 28 TRACE_EVENT1("cc", "GpuVSyncBeginFrameSource::OnVSync", | |
| 29 "latency", (now - timestamp).ToInternalValue()); | |
| 30 | |
| 31 next_sequence_number_++; | |
|
sunnyps
2017/01/25 01:36:41
I think you want to increment seq num after begin
| |
| 32 OnBeginFrame(cc::BeginFrameArgs::Create( | |
| 33 BEGINFRAME_FROM_HERE, source_id(), next_sequence_number_, timestamp, | |
| 34 deadline, interval, cc::BeginFrameArgs::NORMAL)); | |
| 35 } | |
| 36 | |
| 37 void GpuVSyncBeginFrameSource::OnNeedsBeginFrames(bool needs_begin_frames) { | |
| 38 needs_begin_frames_ = needs_begin_frames; | |
| 39 vsync_control_->SetNeedsVSync(needs_begin_frames); | |
| 40 } | |
| 41 | |
| 42 } // namespace content | |
| OLD | NEW |