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..0e7e35c4edccbb63f3e69f5448c9318b28e7b952 |
--- /dev/null |
+++ b/content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.cc |
@@ -0,0 +1,59 @@ |
+// 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) |
brianderson
2014/10/24 20:46:58
Why does this need to take in a routing_id rather
simonhong
2014/10/29 14:47:13
I think using GetCompositor() is more better than
danakj
2014/10/29 15:12:24
If an owner of BeginFrameSource will guarantee the
boliu
2014/10/29 15:41:57
Answering Brian's original question:
I requested
|
+ : routing_id_(routing_id) { |
+} |
+ |
+SynchronousCompositorExternalBeginFrameSource:: |
+ ~SynchronousCompositorExternalBeginFrameSource() { |
+ DCHECK(CalledOnValidThread()); |
+ SynchronousCompositorImpl* compositor = |
+ SynchronousCompositorImpl::FromRoutingID(routing_id_); |
boliu
2014/10/24 17:42:40
nit suggestions: Factor this out into a GetComposi
simonhong
2014/10/29 14:47:13
Done.
|
+ if (compositor) |
+ compositor->SetExternalBeginFrameSource(nullptr); |
+} |
+ |
+void SynchronousCompositorExternalBeginFrameSource::BeginFrame() { |
+ DCHECK(CalledOnValidThread()); |
+ CallOnBeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |
+} |
+ |
+void SynchronousCompositorExternalBeginFrameSource::OnNeedsBeginFramesChange( |
+ bool needs_begin_frames) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ SynchronousCompositorImpl* compositor = |
+ SynchronousCompositorImpl::FromRoutingID(routing_id_); |
+ if (compositor && !compositor->invoking_composite()) |
boliu
2014/10/24 17:42:40
You can do the invoking_composite check in Composi
simonhong
2014/10/29 14:47:13
Done.
|
+ compositor->SetContinuousInvalidate(needs_begin_frames); |
+} |
+ |
+void SynchronousCompositorExternalBeginFrameSource::SetClientReady() { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ SynchronousCompositorImpl* compositor = |
+ SynchronousCompositorImpl::FromRoutingID(routing_id_); |
+ if (compositor) |
+ compositor->SetExternalBeginFrameSource(this); |
+} |
+ |
+// 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 |