OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "cc/scheduler/begin_frame_source.h" |
| 12 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" |
| 13 |
| 14 namespace IPC { |
| 15 class Message; |
| 16 class SyncMessageFilter; |
| 17 } |
| 18 |
| 19 namespace content { |
| 20 |
| 21 // This class can be created only on the main thread, but then becomes pinned |
| 22 // to a fixed thread where cc::Scheduler is running. |
| 23 class CompositorExternalBeginFrameSource |
| 24 : public cc::BeginFrameSourceMixIn, |
| 25 public NON_EXPORTED_BASE(base::NonThreadSafe) { |
| 26 public: |
| 27 explicit CompositorExternalBeginFrameSource(int routing_id); |
| 28 virtual ~CompositorExternalBeginFrameSource(); |
| 29 |
| 30 // cc::BeginFrameSourceMixIn implementation. |
| 31 virtual void OnNeedsBeginFramesChange(bool needs_begin_frames) override; |
| 32 virtual void SetClientReady() override; |
| 33 |
| 34 private: |
| 35 class CompositorExternalBeginFrameSourceProxy |
| 36 : public base::RefCountedThreadSafe< |
| 37 CompositorExternalBeginFrameSourceProxy> { |
| 38 public: |
| 39 explicit CompositorExternalBeginFrameSourceProxy( |
| 40 CompositorExternalBeginFrameSource* begin_frame_source) |
| 41 : begin_frame_source_(begin_frame_source) {} |
| 42 void ClearBeginFrameSource() { begin_frame_source_ = NULL; } |
| 43 void OnMessageReceived(const IPC::Message& message) { |
| 44 if (begin_frame_source_) |
| 45 begin_frame_source_->OnMessageReceived(message); |
| 46 } |
| 47 |
| 48 private: |
| 49 friend class base::RefCountedThreadSafe< |
| 50 CompositorExternalBeginFrameSourceProxy>; |
| 51 virtual ~CompositorExternalBeginFrameSourceProxy() {} |
| 52 |
| 53 CompositorExternalBeginFrameSource* begin_frame_source_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSourceProxy); |
| 56 }; |
| 57 |
| 58 void OnMessageReceived(const IPC::Message& message); |
| 59 |
| 60 void OnBeginFrame(const cc::BeginFrameArgs& args); |
| 61 bool Send(IPC::Message* message); |
| 62 |
| 63 scoped_refptr<CompositorForwardingMessageFilter> begin_frame_source_filter_; |
| 64 scoped_refptr<CompositorExternalBeginFrameSourceProxy> |
| 65 begin_frame_source_proxy_; |
| 66 scoped_refptr<IPC::SyncMessageFilter> message_sender_; |
| 67 int routing_id_; |
| 68 CompositorForwardingMessageFilter::Handler begin_frame_source_filter_handler_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSource); |
| 71 }; |
| 72 |
| 73 } // namespace content |
| 74 |
| 75 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
OLD | NEW |