OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_REMOTE_CHANNEL_IMPL_H_ | 5 #ifndef CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
6 #define CC_TREES_REMOTE_CHANNEL_IMPL_H_ | 6 #define CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool started; | 98 bool started; |
99 | 99 |
100 // This is set to true if we lost the output surface and can not push any | 100 // This is set to true if we lost the output surface and can not push any |
101 // commits to the impl thread. | 101 // commits to the impl thread. |
102 bool waiting_for_output_surface_initialization; | 102 bool waiting_for_output_surface_initialization; |
103 | 103 |
104 // The queue of messages received from the server. The messages are added to | 104 // The queue of messages received from the server. The messages are added to |
105 // this queue if we are waiting for a new output surface to be initialized. | 105 // this queue if we are waiting for a new output surface to be initialized. |
106 std::queue<proto::CompositorMessageToImpl> pending_messages; | 106 std::queue<proto::CompositorMessageToImpl> pending_messages; |
107 | 107 |
108 RendererCapabilities renderer_capabilities; | |
109 | |
110 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; | 108 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; |
111 | 109 |
112 MainThreadOnly(RemoteChannelImpl*, | 110 MainThreadOnly(RemoteChannelImpl*, |
113 LayerTreeHost* layer_tree_host, | 111 LayerTreeHost* layer_tree_host, |
114 RemoteProtoChannel* remote_proto_channel); | 112 RemoteProtoChannel* remote_proto_channel); |
115 ~MainThreadOnly(); | 113 ~MainThreadOnly(); |
116 }; | 114 }; |
117 | 115 |
118 struct CompositorThreadOnly { | 116 struct CompositorThreadOnly { |
119 std::unique_ptr<ProxyImpl> proxy_impl; | 117 std::unique_ptr<ProxyImpl> proxy_impl; |
120 std::unique_ptr<base::WeakPtrFactory<ProxyImpl>> proxy_impl_weak_factory; | 118 std::unique_ptr<base::WeakPtrFactory<ProxyImpl>> proxy_impl_weak_factory; |
121 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr; | 119 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr; |
122 | 120 |
123 CompositorThreadOnly( | 121 CompositorThreadOnly( |
124 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr); | 122 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr); |
125 ~CompositorThreadOnly(); | 123 ~CompositorThreadOnly(); |
126 }; | 124 }; |
127 | 125 |
128 // called on main thread. | 126 // called on main thread. |
129 // RemoteProtoChannel::ProtoReceiver implementation. | 127 // RemoteProtoChannel::ProtoReceiver implementation. |
130 void OnProtoReceived( | 128 void OnProtoReceived( |
131 std::unique_ptr<proto::CompositorMessage> proto) override; | 129 std::unique_ptr<proto::CompositorMessage> proto) override; |
132 | 130 |
133 // Proxy implementation | 131 // Proxy implementation |
134 bool IsStarted() const override; | 132 bool IsStarted() const override; |
135 bool CommitToActiveTree() const override; | 133 bool CommitToActiveTree() const override; |
136 void SetOutputSurface(OutputSurface* output_surface) override; | 134 void SetOutputSurface(OutputSurface* output_surface) override; |
137 void ReleaseOutputSurface() override; | 135 void ReleaseOutputSurface() override; |
138 void SetVisible(bool visible) override; | 136 void SetVisible(bool visible) override; |
139 const RendererCapabilities& GetRendererCapabilities() const override; | |
140 void SetNeedsAnimate() override; | 137 void SetNeedsAnimate() override; |
141 void SetNeedsUpdateLayers() override; | 138 void SetNeedsUpdateLayers() override; |
142 void SetNeedsCommit() override; | 139 void SetNeedsCommit() override; |
143 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 140 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
144 void SetNextCommitWaitsForActivation() override; | 141 void SetNextCommitWaitsForActivation() override; |
145 void NotifyInputThrottledUntilCommit() override; | 142 void NotifyInputThrottledUntilCommit() override; |
146 void SetDeferCommits(bool defer_commits) override; | 143 void SetDeferCommits(bool defer_commits) override; |
147 void MainThreadHasStoppedFlinging() override; | 144 void MainThreadHasStoppedFlinging() override; |
148 bool CommitRequested() const override; | 145 bool CommitRequested() const override; |
149 bool BeginMainFrameRequested() const override; | 146 bool BeginMainFrameRequested() const override; |
150 void Start( | 147 void Start( |
151 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; | 148 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; |
152 void Stop() override; | 149 void Stop() override; |
153 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 150 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
154 bool SupportsImplScrolling() const override; | 151 bool SupportsImplScrolling() const override; |
155 void UpdateTopControlsState(TopControlsState constraints, | 152 void UpdateTopControlsState(TopControlsState constraints, |
156 TopControlsState current, | 153 TopControlsState current, |
157 bool animate) override; | 154 bool animate) override; |
158 bool MainFrameWillHappenForTesting() override; | 155 bool MainFrameWillHappenForTesting() override; |
159 | 156 |
160 // Called on impl thread. | 157 // Called on impl thread. |
161 // ChannelImpl implementation | 158 // ChannelImpl implementation |
162 void DidCompleteSwapBuffers() override; | 159 void DidCompleteSwapBuffers() override; |
163 void SetRendererCapabilitiesMainCopy( | |
164 const RendererCapabilities& capabilities) override; | |
165 void BeginMainFrameNotExpectedSoon() override; | 160 void BeginMainFrameNotExpectedSoon() override; |
166 void DidCommitAndDrawFrame() override; | 161 void DidCommitAndDrawFrame() override; |
167 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; | 162 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; |
168 void DidLoseOutputSurface() override; | 163 void DidLoseOutputSurface() override; |
169 void RequestNewOutputSurface() override; | 164 void RequestNewOutputSurface() override; |
170 void DidInitializeOutputSurface( | 165 void DidInitializeOutputSurface(bool success) override; |
171 bool success, | |
172 const RendererCapabilities& capabilities) override; | |
173 void DidCompletePageScaleAnimation() override; | 166 void DidCompletePageScaleAnimation() override; |
174 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> | 167 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> |
175 begin_main_frame_state) override; | 168 begin_main_frame_state) override; |
176 | 169 |
177 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); | 170 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); |
178 | 171 |
179 // called on main thread. | 172 // called on main thread. |
180 void HandleProto(const proto::CompositorMessageToImpl& proto); | 173 void HandleProto(const proto::CompositorMessageToImpl& proto); |
181 void DidCompleteSwapBuffersOnMain(); | 174 void DidCompleteSwapBuffersOnMain(); |
182 void DidCommitAndDrawFrameOnMain(); | 175 void DidCommitAndDrawFrameOnMain(); |
183 void DidLoseOutputSurfaceOnMain(); | 176 void DidLoseOutputSurfaceOnMain(); |
184 void RequestNewOutputSurfaceOnMain(); | 177 void RequestNewOutputSurfaceOnMain(); |
185 void DidInitializeOutputSurfaceOnMain( | 178 void DidInitializeOutputSurfaceOnMain(bool success); |
186 bool success, | |
187 const RendererCapabilities& capabilities); | |
188 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); | 179 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); |
189 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); | 180 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); |
190 | 181 |
191 void InitializeImplOnImpl(CompletionEvent* completion, | 182 void InitializeImplOnImpl(CompletionEvent* completion, |
192 LayerTreeHost* layer_tree_host); | 183 LayerTreeHost* layer_tree_host); |
193 void ShutdownImplOnImpl(CompletionEvent* completion); | 184 void ShutdownImplOnImpl(CompletionEvent* completion); |
194 | 185 |
195 MainThreadOnly& main(); | 186 MainThreadOnly& main(); |
196 const MainThreadOnly& main() const; | 187 const MainThreadOnly& main() const; |
197 CompositorThreadOnly& impl(); | 188 CompositorThreadOnly& impl(); |
198 const CompositorThreadOnly& impl() const; | 189 const CompositorThreadOnly& impl() const; |
199 | 190 |
200 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 191 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
201 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | 192 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
202 | 193 |
203 TaskRunnerProvider* task_runner_provider_; | 194 TaskRunnerProvider* task_runner_provider_; |
204 | 195 |
205 // use accessors instead of these variables directly | 196 // use accessors instead of these variables directly |
206 MainThreadOnly main_thread_vars_unsafe_; | 197 MainThreadOnly main_thread_vars_unsafe_; |
207 CompositorThreadOnly compositor_thread_vars_unsafe_; | 198 CompositorThreadOnly compositor_thread_vars_unsafe_; |
208 | 199 |
209 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; | 200 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; |
210 | 201 |
211 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); | 202 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); |
212 }; | 203 }; |
213 | 204 |
214 } // namespace cc | 205 } // namespace cc |
215 | 206 |
216 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ | 207 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
OLD | NEW |