Index: content/renderer/gpu/compositor_external_begin_frame_source.h |
diff --git a/content/renderer/gpu/compositor_external_begin_frame_source.h b/content/renderer/gpu/compositor_external_begin_frame_source.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..439431bfa3ae736e8cd1059cf354803af2e0d424 |
--- /dev/null |
+++ b/content/renderer/gpu/compositor_external_begin_frame_source.h |
@@ -0,0 +1,83 @@ |
+// 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. |
+ |
+#ifndef CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
+#define CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/threading/non_thread_safe.h" |
+#include "cc/scheduler/begin_frame_source.h" |
+ |
+namespace base { |
+class TaskRunner; |
+} |
+ |
+namespace IPC { |
+class ForwardingMessageFilter; |
+class Message; |
+class SyncMessageFilter; |
+} |
+ |
+namespace content { |
+ |
+// This class can be created only on the main thread, but then becomes pinned |
+// to a fixed thread where cc::Scheduler is running. |
+class CompositorExternalBeginFrameSource |
+ : public cc::ExternalBeginFrameSource, |
danakj
2014/10/10 16:03:36
This would inherit from the BFSMixin and also the
simonhong
2014/10/15 01:04:22
ditto.
|
+ NON_EXPORTED_BASE(public base::NonThreadSafe) { |
+ public: |
+ static IPC::ForwardingMessageFilter* CreateFilter( |
+ base::TaskRunner* target_task_runner); |
+ |
+ explicit CompositorExternalBeginFrameSource(int routing_id); |
+ virtual ~CompositorExternalBeginFrameSource(); |
+ |
+ // cc::ExternalBeginFrameSource implementation. |
+ virtual void OnNeedsBeginFramesChange(bool needs_begin_frames) OVERRIDE; |
Sami
2014/10/10 13:32:33
nit: I think we can now write just
virtual void
danakj
2014/10/10 16:03:36
+1
simonhong
2014/10/15 01:04:22
Done.
|
+ virtual void SetClientReady() OVERRIDE; |
+ |
+ private: |
+ class CompositorExternalBeginFrameSourceProxy |
+ : public base::RefCountedThreadSafe< |
+ CompositorExternalBeginFrameSourceProxy> { |
+ public: |
+ explicit CompositorExternalBeginFrameSourceProxy( |
+ CompositorExternalBeginFrameSource* begin_frame_source) |
+ : begin_frame_source_(begin_frame_source) {} |
+ void ClearBeginFrameSource() { begin_frame_source_ = NULL; } |
+ void OnMessageReceived(const IPC::Message& message) { |
+ if (begin_frame_source_) |
+ begin_frame_source_->OnMessageReceived(message); |
+ } |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe< |
+ CompositorExternalBeginFrameSourceProxy>; |
+ ~CompositorExternalBeginFrameSourceProxy() {} |
+ |
+ CompositorExternalBeginFrameSource* begin_frame_source_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSourceProxy); |
+ }; |
+ |
+ void OnMessageReceived(const IPC::Message& message); |
+ |
+ void OnBeginFrame(const cc::BeginFrameArgs& args); |
+ bool Send(IPC::Message* message); |
+ |
+ scoped_refptr<IPC::ForwardingMessageFilter> begin_frame_source_filter_; |
+ scoped_refptr<CompositorExternalBeginFrameSourceProxy> |
+ begin_frame_source_proxy_; |
+ scoped_refptr<IPC::SyncMessageFilter> message_sender_; |
+ bool is_client_ready_; |
+ int routing_id_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSource); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |