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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/animation/animation_events.h" | 13 #include "cc/animation/animation_events.h" |
14 #include "cc/base/completion_event.h" | 14 #include "cc/base/completion_event.h" |
15 #include "cc/base/delayed_unique_notifier.h" | 15 #include "cc/base/delayed_unique_notifier.h" |
16 #include "cc/scheduler/commit_earlyout_reason.h" | 16 #include "cc/scheduler/commit_earlyout_reason.h" |
17 #include "cc/scheduler/scheduler.h" | 17 #include "cc/scheduler/scheduler.h" |
18 #include "cc/trees/layer_tree_host_impl.h" | 18 #include "cc/trees/layer_tree_host_impl.h" |
19 #include "cc/trees/proxy.h" | 19 #include "cc/trees/proxy.h" |
| 20 #include "cc/trees/threaded_channel.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
23 } | 24 } |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 | 27 |
27 class BeginFrameSource; | 28 class BeginFrameSource; |
| 29 class ChannelImpl; |
| 30 class ChannelMain; |
28 class ContextProvider; | 31 class ContextProvider; |
29 class InputHandlerClient; | 32 class InputHandlerClient; |
30 class LayerTreeHost; | 33 class LayerTreeHost; |
| 34 class ProxyImpl; |
| 35 class ProxyMain; |
31 class Scheduler; | 36 class Scheduler; |
32 class ScopedThreadProxy; | 37 class ScopedThreadProxy; |
| 38 class ThreadedChannel; |
33 | 39 |
34 class CC_EXPORT ThreadProxy : public Proxy, | 40 class CC_EXPORT ThreadProxy : public Proxy, |
| 41 public ProxyMain, |
| 42 public ProxyImpl, |
35 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 43 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
36 NON_EXPORTED_BASE(SchedulerClient) { | 44 NON_EXPORTED_BASE(SchedulerClient) { |
37 public: | 45 public: |
38 static scoped_ptr<Proxy> Create( | 46 static scoped_ptr<Proxy> Create( |
39 LayerTreeHost* layer_tree_host, | 47 LayerTreeHost* layer_tree_host, |
40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 48 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
41 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 49 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
42 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 50 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
43 | 51 |
44 ~ThreadProxy() override; | 52 ~ThreadProxy() override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // will stop. Only valid while we are executing the pipeline (i.e., | 87 // will stop. Only valid while we are executing the pipeline (i.e., |
80 // |current_pipeline_stage| is set to a pipeline stage). | 88 // |current_pipeline_stage| is set to a pipeline stage). |
81 CommitPipelineStage final_pipeline_stage; | 89 CommitPipelineStage final_pipeline_stage; |
82 | 90 |
83 bool started; | 91 bool started; |
84 bool prepare_tiles_pending; | 92 bool prepare_tiles_pending; |
85 bool defer_commits; | 93 bool defer_commits; |
86 | 94 |
87 RendererCapabilities renderer_capabilities_main_thread_copy; | 95 RendererCapabilities renderer_capabilities_main_thread_copy; |
88 | 96 |
| 97 // TODO(khushalsagar): Make this scoped_ptr<ChannelMain> when ProxyMain |
| 98 // and ProxyImpl are split. |
| 99 ChannelMain* channel_main; |
| 100 |
89 base::WeakPtrFactory<ThreadProxy> weak_factory; | 101 base::WeakPtrFactory<ThreadProxy> weak_factory; |
90 }; | 102 }; |
91 | 103 |
92 // Accessed on the main thread, or when main thread is blocked. | 104 // Accessed on the main thread, or when main thread is blocked. |
93 struct MainThreadOrBlockedMainThread { | 105 struct MainThreadOrBlockedMainThread { |
94 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host); | 106 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host); |
95 ~MainThreadOrBlockedMainThread(); | 107 ~MainThreadOrBlockedMainThread(); |
96 | 108 |
97 LayerTreeHost* layer_tree_host; | 109 LayerTreeHost* layer_tree_host; |
98 bool commit_waits_for_activation; | 110 bool commit_waits_for_activation; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 149 |
138 scoped_ptr<BeginFrameSource> external_begin_frame_source; | 150 scoped_ptr<BeginFrameSource> external_begin_frame_source; |
139 | 151 |
140 RenderingStatsInstrumentation* rendering_stats_instrumentation; | 152 RenderingStatsInstrumentation* rendering_stats_instrumentation; |
141 | 153 |
142 // Values used to keep track of frame durations. Used only in frame timing. | 154 // Values used to keep track of frame durations. Used only in frame timing. |
143 BeginFrameArgs last_begin_main_frame_args; | 155 BeginFrameArgs last_begin_main_frame_args; |
144 BeginFrameArgs last_processed_begin_main_frame_args; | 156 BeginFrameArgs last_processed_begin_main_frame_args; |
145 | 157 |
146 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; | 158 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; |
| 159 |
| 160 ChannelImpl* channel_impl; |
| 161 |
147 base::WeakPtrFactory<ThreadProxy> weak_factory; | 162 base::WeakPtrFactory<ThreadProxy> weak_factory; |
148 }; | 163 }; |
149 | 164 |
150 const MainThreadOnly& main() const; | 165 const MainThreadOnly& main() const; |
151 const MainThreadOrBlockedMainThread& blocked_main() const; | 166 const MainThreadOrBlockedMainThread& blocked_main() const; |
152 const CompositorThreadOnly& impl() const; | 167 const CompositorThreadOnly& impl() const; |
153 | 168 |
154 // Proxy implementation | 169 // Proxy implementation |
155 void FinishAllRendering() override; | 170 void FinishAllRendering() override; |
156 bool IsStarted() const override; | 171 bool IsStarted() const override; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 DrawResult ScheduledActionDrawAndSwapForced() override; | 239 DrawResult ScheduledActionDrawAndSwapForced() override; |
225 void ScheduledActionAnimate() override; | 240 void ScheduledActionAnimate() override; |
226 void ScheduledActionCommit() override; | 241 void ScheduledActionCommit() override; |
227 void ScheduledActionActivateSyncTree() override; | 242 void ScheduledActionActivateSyncTree() override; |
228 void ScheduledActionBeginOutputSurfaceCreation() override; | 243 void ScheduledActionBeginOutputSurfaceCreation() override; |
229 void ScheduledActionPrepareTiles() override; | 244 void ScheduledActionPrepareTiles() override; |
230 void ScheduledActionInvalidateOutputSurface() override; | 245 void ScheduledActionInvalidateOutputSurface() override; |
231 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 246 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
232 void SendBeginMainFrameNotExpectedSoon() override; | 247 void SendBeginMainFrameNotExpectedSoon() override; |
233 | 248 |
| 249 // ProxyMain implementation |
| 250 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; |
| 251 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; |
| 252 void DidCompleteSwapBuffers() override; |
| 253 |
| 254 // ProxyImpl implementation |
| 255 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; |
| 256 void SetThrottleFrameProductionOnImpl(bool throttle) override; |
| 257 void SetLayerTreeHostClientReadyOnImpl() override; |
| 258 |
234 protected: | 259 protected: |
235 ThreadProxy( | 260 ThreadProxy( |
236 LayerTreeHost* layer_tree_host, | 261 LayerTreeHost* layer_tree_host, |
237 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 262 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
238 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 263 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
239 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 264 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
240 | 265 |
241 private: | 266 private: |
242 // Called on main thread. | 267 // Called on main thread. |
243 void SetRendererCapabilitiesMainThreadCopy( | 268 void SetRendererCapabilitiesMainThreadCopy( |
244 const RendererCapabilities& capabilities); | 269 const RendererCapabilities& capabilities); |
245 void BeginMainFrame( | 270 void BeginMainFrame( |
246 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 271 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
247 void BeginMainFrameNotExpectedSoon(); | 272 void BeginMainFrameNotExpectedSoon(); |
248 void DidCommitAndDrawFrame(); | 273 void DidCommitAndDrawFrame(); |
249 void DidCompleteSwapBuffers(); | |
250 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 274 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
251 void DidLoseOutputSurface(); | 275 void DidLoseOutputSurface(); |
252 void RequestNewOutputSurface(); | 276 void RequestNewOutputSurface(); |
253 void DidInitializeOutputSurface(bool success, | 277 void DidInitializeOutputSurface(bool success, |
254 const RendererCapabilities& capabilities); | 278 const RendererCapabilities& capabilities); |
255 // Returns |true| if the request was actually sent, |false| if one was | 279 // Returns |true| if the request was actually sent, |false| if one was |
256 // already outstanding. | 280 // already outstanding. |
257 bool SendCommitRequestToImplThreadIfNeeded( | 281 bool SendCommitRequestToImplThreadIfNeeded( |
258 CommitPipelineStage required_stage); | 282 CommitPipelineStage required_stage); |
259 void DidCompletePageScaleAnimation(); | 283 void DidCompletePageScaleAnimation(); |
260 | 284 |
261 // Called on impl thread. | 285 // Called on impl thread. |
262 struct SchedulerStateRequest; | 286 struct SchedulerStateRequest; |
263 | 287 |
264 void StartCommitOnImplThread(CompletionEvent* completion); | 288 void StartCommitOnImplThread(CompletionEvent* completion); |
265 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | 289 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); |
266 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 290 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
267 void InitializeImplOnImplThread(CompletionEvent* completion); | 291 void InitializeImplOnImplThread(CompletionEvent* completion); |
268 void SetLayerTreeHostClientReadyOnImplThread(); | |
269 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 292 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
270 void SetThrottleFrameProductionOnImplThread(bool throttle); | |
271 void HasInitializedOutputSurfaceOnImplThread( | 293 void HasInitializedOutputSurfaceOnImplThread( |
272 CompletionEvent* completion, | 294 CompletionEvent* completion, |
273 bool* has_initialized_output_surface); | 295 bool* has_initialized_output_surface); |
274 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | 296 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); |
275 void InitializeOutputSurfaceOnImplThread(OutputSurface* output_surface); | 297 void InitializeOutputSurfaceOnImplThread(OutputSurface* output_surface); |
276 void ReleaseOutputSurfaceOnImplThread(CompletionEvent* completion); | 298 void ReleaseOutputSurfaceOnImplThread(CompletionEvent* completion); |
277 void FinishGLOnImplThread(CompletionEvent* completion); | 299 void FinishGLOnImplThread(CompletionEvent* completion); |
278 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 300 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
279 DrawResult DrawSwapInternal(bool forced_draw); | 301 DrawResult DrawSwapInternal(bool forced_draw); |
280 void MainFrameWillHappenOnImplThreadForTesting(CompletionEvent* completion, | 302 void MainFrameWillHappenOnImplThreadForTesting(CompletionEvent* completion, |
(...skipping 14 matching lines...) Expand all Loading... |
295 MainThreadOnly& main(); | 317 MainThreadOnly& main(); |
296 | 318 |
297 // Use accessors instead of this variable directly. | 319 // Use accessors instead of this variable directly. |
298 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 320 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; |
299 MainThreadOrBlockedMainThread& blocked_main(); | 321 MainThreadOrBlockedMainThread& blocked_main(); |
300 | 322 |
301 // Use accessors instead of this variable directly. | 323 // Use accessors instead of this variable directly. |
302 CompositorThreadOnly compositor_thread_vars_unsafe_; | 324 CompositorThreadOnly compositor_thread_vars_unsafe_; |
303 CompositorThreadOnly& impl(); | 325 CompositorThreadOnly& impl(); |
304 | 326 |
| 327 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
| 328 scoped_ptr<ThreadedChannel> threaded_channel_; |
| 329 |
305 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 330 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
306 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 331 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
307 | 332 |
308 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 333 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
309 }; | 334 }; |
310 | 335 |
311 } // namespace cc | 336 } // namespace cc |
312 | 337 |
313 #endif // CC_TREES_THREAD_PROXY_H_ | 338 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |