Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Unified Diff: content/browser/compositor/gpu_vsync_begin_frame_source.cc

Issue 2626413002: Route D3D VSync signal to Compositor (Closed)
Patch Set: Merged with recent BeginFrameSource changes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..f9414105a00a395fe48c3f911079387105fe2099
--- /dev/null
+++ b/content/browser/compositor/gpu_vsync_begin_frame_source.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/compositor/gpu_vsync_begin_frame_source.h"
+
+namespace content {
+
+GpuVSyncBeginFrameSource::GpuVSyncBeginFrameSource(
+ GpuVSyncControl* vsync_control)
+ : cc::ExternalBeginFrameSource(this),
+ vsync_control_(vsync_control),
+ needs_begin_frames_(false),
+ next_sequence_number_(cc::BeginFrameArgs::kStartingFrameNumber) {
+ DCHECK(vsync_control);
+}
+
+GpuVSyncBeginFrameSource::~GpuVSyncBeginFrameSource() = default;
+
+void GpuVSyncBeginFrameSource::OnVSync(base::TimeTicks timestamp,
+ base::TimeDelta interval) {
+ if (!needs_begin_frames_)
+ return;
+
+ base::TimeTicks now = base::TimeTicks::Now();
+ base::TimeTicks deadline = now.SnappedToNextTick(timestamp, interval);
+
+ TRACE_EVENT1("cc", "GpuVSyncBeginFrameSource::OnVSync", "latency",
+ (now - timestamp).ToInternalValue());
+
+ next_sequence_number_++;
+ OnBeginFrame(cc::BeginFrameArgs::Create(
+ BEGINFRAME_FROM_HERE, source_id(), next_sequence_number_, timestamp,
+ deadline, interval, cc::BeginFrameArgs::NORMAL));
+}
+
+void GpuVSyncBeginFrameSource::OnNeedsBeginFrames(bool needs_begin_frames) {
+ needs_begin_frames_ = needs_begin_frames;
+ vsync_control_->SetNeedsVSync(needs_begin_frames);
+}
+
+void GpuVSyncBeginFrameSource::OnDidFinishFrame(const cc::BeginFrameAck& ack) {}
+
+} // namespace content
« no previous file with comments | « content/browser/compositor/gpu_vsync_begin_frame_source.h ('k') | gpu/ipc/client/command_buffer_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698