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

Unified Diff: content/browser/android/in_process/synchronous_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, 2 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/android/in_process/synchronous_compositor_external_begin_frame_source.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.cc b/content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5437d59588cbed1ba9a3f4865ea1ac3f9ba201af
--- /dev/null
+++ b/content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.cc
@@ -0,0 +1,68 @@
+// 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/browser/android/in_process/synchronous_compositor_external_begin_frame_source.h"
+
+#include "cc/output/begin_frame_args.h"
+#include "content/browser/android/in_process/synchronous_compositor_impl.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+SynchronousCompositorExternalBeginFrameSource::
+ SynchronousCompositorExternalBeginFrameSource(int routing_id)
+ : routing_id_(routing_id),
+ compositor_(nullptr) {
+}
+
+SynchronousCompositorExternalBeginFrameSource::
+ ~SynchronousCompositorExternalBeginFrameSource() {
+ DCHECK(CalledOnValidThread());
+ if (compositor_)
+ compositor_->SetExternalBeginFrameSource(nullptr);
+}
+
+void SynchronousCompositorExternalBeginFrameSource::BeginFrame() {
+ DCHECK(CalledOnValidThread());
+ CallOnBeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor());
+}
+
+void SynchronousCompositorExternalBeginFrameSource::SetCompositor(
+ SynchronousCompositorImpl* compositor) {
+ DCHECK(CalledOnValidThread());
+ compositor_ = compositor;
+}
+
+void SynchronousCompositorExternalBeginFrameSource::OnNeedsBeginFramesChange(
+ bool needs_begin_frames) {
+ DCHECK(CalledOnValidThread());
+
+ if (compositor_)
+ compositor_->SetContinuousInvalidate(needs_begin_frames);
+}
+
+void SynchronousCompositorExternalBeginFrameSource::SetClientReady() {
+ DCHECK(CalledOnValidThread());
+
+ SynchronousCompositorImpl* compositor = GetCompositor();
boliu 2014/10/30 16:21:32 Just put the code for GetCompositor here, since th
simonhong 2014/10/31 00:22:08 Done.
+ if (compositor) {
+ compositor->SetExternalBeginFrameSource(this);
+ SetCompositor(compositor);
boliu 2014/10/30 16:21:32 nit: I think it's awkward SetCompositor is called
simonhong 2014/10/31 00:22:08 Done.
+ }
+}
+
+SynchronousCompositorImpl*
+SynchronousCompositorExternalBeginFrameSource::GetCompositor() const {
+ return SynchronousCompositorImpl::FromRoutingID(routing_id_);
+}
+
+// Not using base::NonThreadSafe as we want to enforce a more exacting threading
+// requirement: SynchronousCompositorExternalBeginFrameSource() must only be
+// used on the UI thread.
+bool
+SynchronousCompositorExternalBeginFrameSource::CalledOnValidThread() const {
+ return BrowserThread::CurrentlyOn(BrowserThread::UI);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698