| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/compositor/compositor_observer.h" | 10 #include "ui/compositor/compositor_observer.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 struct BeginFrameArgs; | 13 struct BeginFrameArgs; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // This is the interface from the BeginFrameObserverProxy which manages sending | 18 // This is the interface from the BeginFrameObserverProxy which manages sending |
| 19 // BeginFrame messages. | 19 // BeginFrame messages. |
| 20 class BeginFrameObserverProxyClient { | 20 class BeginFrameObserverProxyClient { |
| 21 public: | 21 public: |
| 22 virtual void SendBeginFrame(const cc::BeginFrameArgs& args) = 0; | 22 virtual void SendBeginFrame(const cc::BeginFrameArgs& args) = 0; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 // This class is used to manage all of the RenderWidgetHostView state and | 25 // This class is used to manage all of the RenderWidgetHostView state and |
| 26 // functionality that is associated with BeginFrame message handling. | 26 // functionality that is associated with BeginFrame message handling. |
| 27 class CONTENT_EXPORT BeginFrameObserverProxy | 27 class CONTENT_EXPORT BeginFrameObserverProxy |
| 28 : public ui::CompositorBeginFrameObserver { | 28 : public ui::CompositorBeginFrameObserver, |
| 29 public ui::CompositorObserver { |
| 29 public: | 30 public: |
| 30 explicit BeginFrameObserverProxy(BeginFrameObserverProxyClient* client); | 31 explicit BeginFrameObserverProxy(BeginFrameObserverProxyClient* client); |
| 31 ~BeginFrameObserverProxy() override; | 32 ~BeginFrameObserverProxy() override; |
| 32 | 33 |
| 33 void SetNeedsBeginFrames(bool needs_begin_frames); | 34 void SetNeedsBeginFrames(bool needs_begin_frames); |
| 34 | 35 |
| 35 void SetCompositor(ui::Compositor* compositor); | 36 void SetCompositor(ui::Compositor* compositor); |
| 36 void ResetCompositor(); | 37 void ResetCompositor(); |
| 37 | 38 |
| 38 // Overridden from ui::CompositorBeginFrameObserver: | 39 // Overridden from ui::CompositorBeginFrameObserver: |
| 39 void OnSendBeginFrame(const cc::BeginFrameArgs& args) override; | 40 void OnSendBeginFrame(const cc::BeginFrameArgs& args) override; |
| 40 | 41 |
| 42 // Overridden from ui::CompositorObserver: |
| 43 // TODO(simonhong): Stop overriding ui::CompositorObserver. We need to make |
| 44 // sure that this class should be destroyed before ui::Compositor. |
| 45 void OnCompositingDidCommit(ui::Compositor* compositor) override {} |
| 46 void OnCompositingStarted(ui::Compositor* compositor, |
| 47 base::TimeTicks start_time) override {} |
| 48 void OnCompositingEnded(ui::Compositor* compositor) override {} |
| 49 void OnCompositingAborted(ui::Compositor* compositor) override {} |
| 50 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 51 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 52 |
| 41 private: | 53 private: |
| 42 void StartObservingBeginFrames(); | 54 void StartObservingBeginFrames(); |
| 43 void StopObservingBeginFrames(); | 55 void StopObservingBeginFrames(); |
| 44 | 56 |
| 45 // True when RenderWidget needs a BeginFrame message. | 57 // True when RenderWidget needs a BeginFrame message. |
| 46 bool needs_begin_frames_; | 58 bool needs_begin_frames_; |
| 47 | 59 |
| 48 // Used whether to send begin frame to client or not. When |args| from | 60 // Used whether to send begin frame to client or not. When |args| from |
| 49 // Compositor is different from this, send to client. | 61 // Compositor is different from this, send to client. |
| 50 cc::BeginFrameArgs last_sent_begin_frame_args_; | 62 cc::BeginFrameArgs last_sent_begin_frame_args_; |
| 51 | 63 |
| 52 BeginFrameObserverProxyClient* client_; | 64 BeginFrameObserverProxyClient* client_; |
| 53 ui::Compositor* compositor_; | 65 ui::Compositor* compositor_; |
| 54 | 66 |
| 55 DISALLOW_COPY_AND_ASSIGN(BeginFrameObserverProxy); | 67 DISALLOW_COPY_AND_ASSIGN(BeginFrameObserverProxy); |
| 56 }; | 68 }; |
| 57 | 69 |
| 58 } // namespace content | 70 } // namespace content |
| 59 | 71 |
| 60 #endif // CONTENT_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ | 72 #endif // CONTENT_BROWSER_RENDERER_HOST_BEGIN_FRAME_OBSERVER_PROXY_H_ |
| OLD | NEW |