OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_THREAD_PROXY_H_ | 5 #ifndef CC_TREES_THREAD_PROXY_H_ |
6 #define CC_TREES_THREAD_PROXY_H_ | 6 #define CC_TREES_THREAD_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 class ThreadedChannel; | 38 class ThreadedChannel; |
39 | 39 |
40 class CC_EXPORT ThreadProxy : public Proxy, | 40 class CC_EXPORT ThreadProxy : public Proxy, |
41 public ProxyMain, | 41 public ProxyMain, |
42 public ProxyImpl, | 42 public ProxyImpl, |
43 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 43 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
44 NON_EXPORTED_BASE(SchedulerClient) { | 44 NON_EXPORTED_BASE(SchedulerClient) { |
45 public: | 45 public: |
46 static scoped_ptr<Proxy> Create( | 46 static scoped_ptr<Proxy> Create( |
47 LayerTreeHost* layer_tree_host, | 47 LayerTreeHost* layer_tree_host, |
48 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 48 TaskRunnerProvider* task_runner_provider, |
49 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
50 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 49 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
51 | 50 |
52 ~ThreadProxy() override; | 51 ~ThreadProxy() override; |
53 | 52 |
54 // Commits between the main and impl threads are processed through a pipeline | 53 // Commits between the main and impl threads are processed through a pipeline |
55 // with the following stages. For efficiency we can early out at any stage if | 54 // with the following stages. For efficiency we can early out at any stage if |
56 // we decide that no further processing is necessary. | 55 // we decide that no further processing is necessary. |
57 enum CommitPipelineStage { | 56 enum CommitPipelineStage { |
58 NO_PIPELINE_STAGE, | 57 NO_PIPELINE_STAGE, |
59 ANIMATE_PIPELINE_STAGE, | 58 ANIMATE_PIPELINE_STAGE, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 143 |
145 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; | 144 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; |
146 | 145 |
147 ChannelImpl* channel_impl; | 146 ChannelImpl* channel_impl; |
148 | 147 |
149 base::WeakPtrFactory<ThreadProxy> weak_factory; | 148 base::WeakPtrFactory<ThreadProxy> weak_factory; |
150 }; | 149 }; |
151 | 150 |
152 const MainThreadOnly& main() const; | 151 const MainThreadOnly& main() const; |
153 const CompositorThreadOnly& impl() const; | 152 const CompositorThreadOnly& impl() const; |
| 153 TaskRunnerProvider* task_runner_provider() { return task_runner_provider_; } |
154 | 154 |
155 // Proxy implementation | 155 // Proxy implementation |
156 void FinishAllRendering() override; | 156 void FinishAllRendering() override; |
157 bool IsStarted() const override; | 157 bool IsStarted() const override; |
158 bool CommitToActiveTree() const override; | 158 bool CommitToActiveTree() const override; |
159 void SetOutputSurface(OutputSurface* output_surface) override; | 159 void SetOutputSurface(OutputSurface* output_surface) override; |
160 void SetVisible(bool visible) override; | 160 void SetVisible(bool visible) override; |
161 void SetThrottleFrameProduction(bool throttle) override; | 161 void SetThrottleFrameProduction(bool throttle) override; |
162 const RendererCapabilities& GetRendererCapabilities() const override; | 162 const RendererCapabilities& GetRendererCapabilities() const override; |
163 void SetNeedsAnimate() override; | 163 void SetNeedsAnimate() override; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void ScheduledActionBeginOutputSurfaceCreation() override; | 232 void ScheduledActionBeginOutputSurfaceCreation() override; |
233 void ScheduledActionPrepareTiles() override; | 233 void ScheduledActionPrepareTiles() override; |
234 void ScheduledActionInvalidateOutputSurface() override; | 234 void ScheduledActionInvalidateOutputSurface() override; |
235 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 235 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
236 void SendBeginMainFrameNotExpectedSoon() override; | 236 void SendBeginMainFrameNotExpectedSoon() override; |
237 | 237 |
238 // ProxyMain implementation | 238 // ProxyMain implementation |
239 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; | 239 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; |
240 | 240 |
241 protected: | 241 protected: |
242 ThreadProxy( | 242 ThreadProxy(LayerTreeHost* layer_tree_host, |
243 LayerTreeHost* layer_tree_host, | 243 TaskRunnerProvider* task_runner_provider, |
244 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 244 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
245 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
246 scoped_ptr<BeginFrameSource> external_begin_frame_source); | |
247 | 245 |
248 private: | 246 private: |
249 friend class ThreadProxyForTest; | 247 friend class ThreadProxyForTest; |
250 | 248 |
251 // ProxyMain implementation. | 249 // ProxyMain implementation. |
252 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; | 250 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; |
253 void DidCompleteSwapBuffers() override; | 251 void DidCompleteSwapBuffers() override; |
254 void SetRendererCapabilitiesMainCopy( | 252 void SetRendererCapabilitiesMainCopy( |
255 const RendererCapabilities& capabilities) override; | 253 const RendererCapabilities& capabilities) override; |
256 void BeginMainFrameNotExpectedSoon() override; | 254 void BeginMainFrameNotExpectedSoon() override; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // Returns |true| if the request was actually sent, |false| if one was | 297 // Returns |true| if the request was actually sent, |false| if one was |
300 // already outstanding. | 298 // already outstanding. |
301 bool SendCommitRequestToImplThreadIfNeeded( | 299 bool SendCommitRequestToImplThreadIfNeeded( |
302 CommitPipelineStage required_stage); | 300 CommitPipelineStage required_stage); |
303 | 301 |
304 // Called on impl thread. | 302 // Called on impl thread. |
305 struct SchedulerStateRequest; | 303 struct SchedulerStateRequest; |
306 | 304 |
307 DrawResult DrawSwapInternal(bool forced_draw); | 305 DrawResult DrawSwapInternal(bool forced_draw); |
308 | 306 |
| 307 TaskRunnerProvider* task_runner_provider_; |
| 308 |
309 // Use accessors instead of this variable directly. | 309 // Use accessors instead of this variable directly. |
310 MainThreadOnly main_thread_only_vars_unsafe_; | 310 MainThreadOnly main_thread_only_vars_unsafe_; |
311 MainThreadOnly& main(); | 311 MainThreadOnly& main(); |
312 | 312 |
313 // Use accessors instead of this variable directly. | 313 // Use accessors instead of this variable directly. |
314 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_; | 314 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_; |
315 BlockedMainCommitOnly& blocked_main_commit(); | 315 BlockedMainCommitOnly& blocked_main_commit(); |
316 | 316 |
317 // Use accessors instead of this variable directly. | 317 // Use accessors instead of this variable directly. |
318 CompositorThreadOnly compositor_thread_vars_unsafe_; | 318 CompositorThreadOnly compositor_thread_vars_unsafe_; |
319 CompositorThreadOnly& impl(); | 319 CompositorThreadOnly& impl(); |
320 | 320 |
321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | 321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
322 scoped_ptr<ThreadedChannel> threaded_channel_; | 322 scoped_ptr<ThreadedChannel> threaded_channel_; |
323 | 323 |
324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
326 | 326 |
327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
328 }; | 328 }; |
329 | 329 |
330 } // namespace cc | 330 } // namespace cc |
331 | 331 |
332 #endif // CC_TREES_THREAD_PROXY_H_ | 332 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |