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

Unified Diff: content/renderer/gpu/compositor_external_begin_frame_source.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/renderer/gpu/compositor_external_begin_frame_source.cc
diff --git a/content/renderer/gpu/compositor_external_begin_frame_source.cc b/content/renderer/gpu/compositor_external_begin_frame_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4fa9312d181a62c37b68bf29178273d07ecabe45
--- /dev/null
+++ b/content/renderer/gpu/compositor_external_begin_frame_source.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 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/renderer/gpu/compositor_external_begin_frame_source.h"
+
+#include "content/common/view_messages.h"
+#include "content/renderer/render_thread_impl.h"
+#include "ipc/ipc_sync_channel.h"
+#include "ipc/ipc_sync_message_filter.h"
+
+namespace content {
+
+CompositorExternalBeginFrameSource::CompositorExternalBeginFrameSource(
+ int routing_id)
+ : begin_frame_source_filter_(
+ RenderThreadImpl::current()->compositor_message_filter()),
+ message_sender_(RenderThreadImpl::current()->sync_message_filter()),
+ routing_id_(routing_id) {
+ DCHECK(begin_frame_source_filter_.get());
+ DCHECK(message_sender_.get());
+ DetachFromThread();
+}
+
+CompositorExternalBeginFrameSource::~CompositorExternalBeginFrameSource() {
+ DCHECK(CalledOnValidThread());
+ if (begin_frame_source_proxy_.get()) {
+ begin_frame_source_proxy_->ClearBeginFrameSource();
+ begin_frame_source_filter_->RemoveHandlerOnCompositorThread(
+ routing_id_,
+ begin_frame_source_filter_handler_);
+ }
+}
+
+void CompositorExternalBeginFrameSource::OnNeedsBeginFramesChange(
+ bool needs_begin_frames) {
+ DCHECK(CalledOnValidThread());
+ Send(new ViewHostMsg_SetNeedsBeginFrames(routing_id_, needs_begin_frames));
+}
+
+void CompositorExternalBeginFrameSource::SetClientReady() {
+ DCHECK(CalledOnValidThread());
+ DCHECK(!begin_frame_source_proxy_.get());
+ begin_frame_source_proxy_ =
+ new CompositorExternalBeginFrameSourceProxy(this);
+ begin_frame_source_filter_handler_ = base::Bind(
+ &CompositorExternalBeginFrameSourceProxy::OnMessageReceived,
+ begin_frame_source_proxy_);
+ begin_frame_source_filter_->AddHandlerOnCompositorThread(
+ routing_id_,
+ begin_frame_source_filter_handler_);
+}
+
+void CompositorExternalBeginFrameSource::OnMessageReceived(
+ const IPC::Message& message) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(begin_frame_source_proxy_.get());
+ IPC_BEGIN_MESSAGE_MAP(CompositorExternalBeginFrameSource, message)
+ IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame)
+ IPC_END_MESSAGE_MAP();
+}
+
+void CompositorExternalBeginFrameSource::OnBeginFrame(
+ const cc::BeginFrameArgs& args) {
+ DCHECK(CalledOnValidThread());
+ CallOnBeginFrame(args);
+}
+
+bool CompositorExternalBeginFrameSource::Send(IPC::Message* message) {
+ return message_sender_->Send(message);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698