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