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 CC_TREES_PROXY_IMPL_H_ | 5 #ifndef CC_TREES_PROXY_IMPL_H_ |
6 #define CC_TREES_PROXY_IMPL_H_ | 6 #define CC_TREES_PROXY_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/base/completion_event.h" | 11 #include "cc/base/completion_event.h" |
12 #include "cc/base/delayed_unique_notifier.h" | 12 #include "cc/base/delayed_unique_notifier.h" |
13 #include "cc/input/top_controls_state.h" | 13 #include "cc/input/top_controls_state.h" |
14 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
15 #include "cc/trees/channel_impl.h" | 15 #include "cc/trees/channel_impl.h" |
16 #include "cc/trees/layer_tree_host_impl.h" | 16 #include "cc/trees/layer_tree_host_impl.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 // This class aggregates all the interactions that the main side of the | 20 // This class aggregates all the interactions that the main side of the |
21 // compositor needs to have with the impl side. It is created and owned by the | 21 // compositor needs to have with the impl side. It is created and owned by the |
22 // ChannelImpl implementation. The class lives entirely on the impl thread. | 22 // ChannelImpl implementation. The class lives entirely on the impl thread. |
23 class CC_EXPORT ProxyImpl : public NON_EXPORTED_BASE(LayerTreeHostImplClient), | 23 class CC_EXPORT ProxyImpl : public NON_EXPORTED_BASE(LayerTreeHostImplClient), |
24 public NON_EXPORTED_BASE(SchedulerClient) { | 24 public NON_EXPORTED_BASE(SchedulerClient) { |
25 public: | 25 public: |
26 static std::unique_ptr<ProxyImpl> Create( | 26 ProxyImpl(ChannelImpl* channel_impl, |
27 ChannelImpl* channel_impl, | 27 LayerTreeHost* layer_tree_host, |
28 LayerTreeHost* layer_tree_host, | 28 TaskRunnerProvider* task_runner_provider, |
29 TaskRunnerProvider* task_runner_provider, | 29 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
30 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
31 | |
32 ~ProxyImpl() override; | 30 ~ProxyImpl() override; |
33 | 31 |
34 // Virtual for testing. | 32 // Virtual for testing. |
35 virtual void UpdateTopControlsStateOnImpl(TopControlsState constraints, | 33 void UpdateTopControlsStateOnImpl(TopControlsState constraints, |
36 TopControlsState current, | 34 TopControlsState current, |
37 bool animate); | 35 bool animate); |
38 virtual void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface); | 36 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface); |
39 virtual void InitializeMutatorOnImpl( | 37 void InitializeMutatorOnImpl(std::unique_ptr<LayerTreeMutator> mutator); |
40 std::unique_ptr<LayerTreeMutator> mutator); | 38 void MainThreadHasStoppedFlingingOnImpl(); |
41 virtual void MainThreadHasStoppedFlingingOnImpl(); | 39 void SetInputThrottledUntilCommitOnImpl(bool is_throttled); |
42 virtual void SetInputThrottledUntilCommitOnImpl(bool is_throttled); | 40 void SetDeferCommitsOnImpl(bool defer_commits) const; |
43 virtual void SetDeferCommitsOnImpl(bool defer_commits) const; | 41 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect); |
44 virtual void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect); | 42 void SetNeedsCommitOnImpl(); |
45 virtual void SetNeedsCommitOnImpl(); | 43 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason, |
46 virtual void BeginMainFrameAbortedOnImpl( | 44 base::TimeTicks main_thread_start_time); |
47 CommitEarlyOutReason reason, | 45 void FinishAllRenderingOnImpl(CompletionEvent* completion); |
48 base::TimeTicks main_thread_start_time); | 46 void SetVisibleOnImpl(bool visible); |
49 virtual void FinishAllRenderingOnImpl(CompletionEvent* completion); | 47 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion); |
50 virtual void SetVisibleOnImpl(bool visible); | 48 void FinishGLOnImpl(CompletionEvent* completion); |
51 virtual void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion); | 49 void NotifyReadyToCommitOnImpl(CompletionEvent* completion, |
52 virtual void FinishGLOnImpl(CompletionEvent* completion); | |
53 virtual void StartCommitOnImpl(CompletionEvent* completion, | |
54 LayerTreeHost* layer_tree_host, | 50 LayerTreeHost* layer_tree_host, |
55 base::TimeTicks main_thread_start_time, | 51 base::TimeTicks main_thread_start_time, |
56 bool hold_commit_for_activation); | 52 bool hold_commit_for_activation); |
57 | 53 |
58 void MainFrameWillHappenOnImplForTesting(CompletionEvent* completion, | 54 void MainFrameWillHappenOnImplForTesting(CompletionEvent* completion, |
59 bool* main_frame_will_happen); | 55 bool* main_frame_will_happen); |
60 void BlockNotifyReadyToActivateForTesting(bool block); | |
61 CompletionEvent* ActivationCompletionEventForTesting(); | |
62 | |
63 protected: | |
64 // protected for testing. | |
65 ProxyImpl(ChannelImpl* channel_impl, | |
66 LayerTreeHost* layer_tree_host, | |
67 TaskRunnerProvider* task_runner_provider, | |
68 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
69 | 56 |
70 private: | 57 private: |
71 // The members of this struct should be accessed on the impl thread only when | 58 // The members of this struct should be accessed on the impl thread only when |
72 // the main thread is blocked for a commit. | 59 // the main thread is blocked for a commit. |
73 struct BlockedMainCommitOnly { | 60 struct BlockedMainCommitOnly { |
74 BlockedMainCommitOnly(); | 61 BlockedMainCommitOnly(); |
75 ~BlockedMainCommitOnly(); | 62 ~BlockedMainCommitOnly(); |
76 LayerTreeHost* layer_tree_host; | 63 LayerTreeHost* layer_tree_host; |
77 }; | 64 }; |
78 | 65 |
79 friend class ProxyImplForTest; | |
80 | |
81 // LayerTreeHostImplClient implementation | 66 // LayerTreeHostImplClient implementation |
82 void UpdateRendererCapabilitiesOnImplThread() override; | 67 void UpdateRendererCapabilitiesOnImplThread() override; |
83 void DidLoseOutputSurfaceOnImplThread() override; | 68 void DidLoseOutputSurfaceOnImplThread() override; |
84 void CommitVSyncParameters(base::TimeTicks timebase, | 69 void CommitVSyncParameters(base::TimeTicks timebase, |
85 base::TimeDelta interval) override; | 70 base::TimeDelta interval) override; |
86 void SetBeginFrameSource(BeginFrameSource* source) override; | 71 void SetBeginFrameSource(BeginFrameSource* source) override; |
87 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; | 72 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; |
88 void DidSwapBuffersCompleteOnImplThread() override; | 73 void DidSwapBuffersCompleteOnImplThread() override; |
89 void OnCanDrawStateChanged(bool can_draw) override; | 74 void OnCanDrawStateChanged(bool can_draw) override; |
90 void NotifyReadyToActivate() override; | 75 void NotifyReadyToActivate() override; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Use accessors instead of this variable directly. | 150 // Use accessors instead of this variable directly. |
166 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_; | 151 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_; |
167 BlockedMainCommitOnly& blocked_main_commit(); | 152 BlockedMainCommitOnly& blocked_main_commit(); |
168 | 153 |
169 DISALLOW_COPY_AND_ASSIGN(ProxyImpl); | 154 DISALLOW_COPY_AND_ASSIGN(ProxyImpl); |
170 }; | 155 }; |
171 | 156 |
172 } // namespace cc | 157 } // namespace cc |
173 | 158 |
174 #endif // CC_TREES_PROXY_IMPL_H_ | 159 #endif // CC_TREES_PROXY_IMPL_H_ |
OLD | NEW |