Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
| 7 | 7 |
| 8 #include <unordered_set> | 8 #include <unordered_set> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "cc/scheduler/begin_frame_source.h" | 13 #include "cc/scheduler/begin_frame_source.h" |
| 14 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" | 14 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" |
| 15 | 15 |
| 16 namespace IPC { | 16 namespace IPC { |
| 17 class Message; | 17 class Message; |
| 18 class SyncMessageFilter; | 18 class SyncMessageFilter; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 // This class can be created only on the main thread, but then becomes pinned | 23 // This class can be created only on the main thread, but then becomes pinned |
| 24 // to a fixed thread where cc::Scheduler is running. | 24 // to a fixed thread where cc::Scheduler is running. |
| 25 class CompositorExternalBeginFrameSource | 25 class CompositorExternalBeginFrameSource |
| 26 : public cc::BeginFrameSource, | 26 : public cc::BeginFrameSource, |
|
danakj
2016/08/26 22:39:13
Can we TODO to remove this as a subclass and expla
| |
| 27 public cc::ExternalBeginFrameSourceClient, | |
| 27 public NON_EXPORTED_BASE(base::NonThreadSafe) { | 28 public NON_EXPORTED_BASE(base::NonThreadSafe) { |
| 28 public: | 29 public: |
| 29 explicit CompositorExternalBeginFrameSource( | 30 explicit CompositorExternalBeginFrameSource( |
| 30 CompositorForwardingMessageFilter* filter, | 31 CompositorForwardingMessageFilter* filter, |
| 31 IPC::SyncMessageFilter* sync_message_filter, | 32 IPC::SyncMessageFilter* sync_message_filter, |
| 32 int routing_id); | 33 int routing_id); |
| 33 ~CompositorExternalBeginFrameSource() override; | 34 ~CompositorExternalBeginFrameSource() override; |
| 34 | 35 |
| 35 // cc::BeginFrameSource implementation. | 36 // cc::BeginFrameSource implementation. |
| 36 void AddObserver(cc::BeginFrameObserver* obs) override; | 37 void AddObserver(cc::BeginFrameObserver* obs) override; |
| 37 void RemoveObserver(cc::BeginFrameObserver* obs) override; | 38 void RemoveObserver(cc::BeginFrameObserver* obs) override; |
| 38 void DidFinishFrame(cc::BeginFrameObserver* obs, | 39 void DidFinishFrame(cc::BeginFrameObserver* obs, |
| 39 size_t remaining_frames) override {} | 40 size_t remaining_frames) override {} |
| 40 | 41 |
| 42 // cc::ExternalBeginFrameSourceClient implementation | |
|
danakj
2016/08/26 22:39:13
.
| |
| 43 void OnNeedsBeginFrames(bool need_begin_frames) override; | |
| 44 | |
| 41 private: | 45 private: |
| 42 class CompositorExternalBeginFrameSourceProxy | 46 class CompositorExternalBeginFrameSourceProxy |
| 43 : public base::RefCountedThreadSafe< | 47 : public base::RefCountedThreadSafe< |
| 44 CompositorExternalBeginFrameSourceProxy> { | 48 CompositorExternalBeginFrameSourceProxy> { |
| 45 public: | 49 public: |
| 46 explicit CompositorExternalBeginFrameSourceProxy( | 50 explicit CompositorExternalBeginFrameSourceProxy( |
| 47 CompositorExternalBeginFrameSource* begin_frame_source) | 51 CompositorExternalBeginFrameSource* begin_frame_source) |
| 48 : begin_frame_source_(begin_frame_source) {} | 52 : begin_frame_source_(begin_frame_source) {} |
| 49 void ClearBeginFrameSource() { begin_frame_source_ = NULL; } | 53 void ClearBeginFrameSource() { begin_frame_source_ = NULL; } |
| 50 void OnMessageReceived(const IPC::Message& message) { | 54 void OnMessageReceived(const IPC::Message& message) { |
| 51 if (begin_frame_source_) | 55 if (begin_frame_source_) |
| 52 begin_frame_source_->OnMessageReceived(message); | 56 begin_frame_source_->OnMessageReceived(message); |
| 53 } | 57 } |
| 54 | 58 |
| 55 private: | 59 private: |
| 56 friend class base::RefCountedThreadSafe< | 60 friend class base::RefCountedThreadSafe< |
| 57 CompositorExternalBeginFrameSourceProxy>; | 61 CompositorExternalBeginFrameSourceProxy>; |
| 58 virtual ~CompositorExternalBeginFrameSourceProxy() {} | 62 virtual ~CompositorExternalBeginFrameSourceProxy() {} |
| 59 | 63 |
| 60 CompositorExternalBeginFrameSource* begin_frame_source_; | 64 CompositorExternalBeginFrameSource* begin_frame_source_; |
| 61 | 65 |
| 62 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSourceProxy); | 66 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSourceProxy); |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 void SetClientReady(); | |
| 66 void OnMessageReceived(const IPC::Message& message); | 69 void OnMessageReceived(const IPC::Message& message); |
| 67 | |
| 68 void OnSetBeginFrameSourcePaused(bool paused); | 70 void OnSetBeginFrameSourcePaused(bool paused); |
| 69 void OnBeginFrame(const cc::BeginFrameArgs& args); | 71 void OnBeginFrame(const cc::BeginFrameArgs& args); |
| 70 bool Send(IPC::Message* message); | 72 bool Send(IPC::Message* message); |
| 71 | 73 |
| 74 // Shared helper implementation. | |
| 75 cc::ExternalBeginFrameSource external_begin_frame_source_; | |
| 76 | |
| 72 scoped_refptr<CompositorForwardingMessageFilter> begin_frame_source_filter_; | 77 scoped_refptr<CompositorForwardingMessageFilter> begin_frame_source_filter_; |
| 73 scoped_refptr<CompositorExternalBeginFrameSourceProxy> | 78 scoped_refptr<CompositorExternalBeginFrameSourceProxy> |
| 74 begin_frame_source_proxy_; | 79 begin_frame_source_proxy_; |
| 75 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | 80 scoped_refptr<IPC::SyncMessageFilter> message_sender_; |
| 76 int routing_id_; | 81 int routing_id_; |
| 77 CompositorForwardingMessageFilter::Handler begin_frame_source_filter_handler_; | 82 CompositorForwardingMessageFilter::Handler begin_frame_source_filter_handler_; |
| 78 cc::BeginFrameArgs missed_begin_frame_args_; | |
| 79 std::unordered_set<cc::BeginFrameObserver*> observers_; | |
| 80 bool paused_ = false; | |
| 81 | 83 |
| 82 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSource); | 84 DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSource); |
| 83 }; | 85 }; |
| 84 | 86 |
| 85 } // namespace content | 87 } // namespace content |
| 86 | 88 |
| 87 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 89 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
| OLD | NEW |