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 "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; | |
David Trainor- moved to gerrit
2015/09/23 17:54:12
Can we comment on the fact that ProxyImpl doesn't
Khushal
2015/09/23 20:50:28
Done. ProxyImpl only holds a reference to ChannelI
| |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 DrawResult ScheduledActionDrawAndSwapForced() override; | 240 DrawResult ScheduledActionDrawAndSwapForced() override; |
226 void ScheduledActionAnimate() override; | 241 void ScheduledActionAnimate() override; |
227 void ScheduledActionCommit() override; | 242 void ScheduledActionCommit() override; |
228 void ScheduledActionActivateSyncTree() override; | 243 void ScheduledActionActivateSyncTree() override; |
229 void ScheduledActionBeginOutputSurfaceCreation() override; | 244 void ScheduledActionBeginOutputSurfaceCreation() override; |
230 void ScheduledActionPrepareTiles() override; | 245 void ScheduledActionPrepareTiles() override; |
231 void ScheduledActionInvalidateOutputSurface() override; | 246 void ScheduledActionInvalidateOutputSurface() override; |
232 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 247 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
233 void SendBeginMainFrameNotExpectedSoon() override; | 248 void SendBeginMainFrameNotExpectedSoon() override; |
234 | 249 |
250 // ProxyMain implementation | |
251 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; | |
252 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; | |
253 void DidCompleteSwapBuffers() override; | |
254 | |
255 // ProxyImpl implementation | |
256 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; | |
257 void SetThrottleFrameProductionOnImpl(bool throttle) override; | |
258 void SetLayerTreeHostClientReadyOnImpl() override; | |
259 | |
235 protected: | 260 protected: |
236 ThreadProxy( | 261 ThreadProxy( |
237 LayerTreeHost* layer_tree_host, | 262 LayerTreeHost* layer_tree_host, |
238 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 263 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
239 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 264 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
240 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 265 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
241 | 266 |
242 private: | 267 private: |
243 // Called on main thread. | 268 // Called on main thread. |
244 void SetRendererCapabilitiesMainThreadCopy( | 269 void SetRendererCapabilitiesMainThreadCopy( |
245 const RendererCapabilities& capabilities); | 270 const RendererCapabilities& capabilities); |
246 void BeginMainFrame( | 271 void BeginMainFrame( |
247 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 272 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
248 void BeginMainFrameNotExpectedSoon(); | 273 void BeginMainFrameNotExpectedSoon(); |
249 void DidCommitAndDrawFrame(); | 274 void DidCommitAndDrawFrame(); |
250 void DidCompleteSwapBuffers(); | |
251 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 275 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
252 void DidLoseOutputSurface(); | 276 void DidLoseOutputSurface(); |
253 void RequestNewOutputSurface(); | 277 void RequestNewOutputSurface(); |
254 void DidInitializeOutputSurface(bool success, | 278 void DidInitializeOutputSurface(bool success, |
255 const RendererCapabilities& capabilities); | 279 const RendererCapabilities& capabilities); |
256 // Returns |true| if the request was actually sent, |false| if one was | 280 // Returns |true| if the request was actually sent, |false| if one was |
257 // already outstanding. | 281 // already outstanding. |
258 bool SendCommitRequestToImplThreadIfNeeded( | 282 bool SendCommitRequestToImplThreadIfNeeded( |
259 CommitPipelineStage required_stage); | 283 CommitPipelineStage required_stage); |
260 void DidCompletePageScaleAnimation(); | 284 void DidCompletePageScaleAnimation(); |
261 | 285 |
262 // Called on impl thread. | 286 // Called on impl thread. |
263 struct SchedulerStateRequest; | 287 struct SchedulerStateRequest; |
264 | 288 |
265 void StartCommitOnImplThread(CompletionEvent* completion); | 289 void StartCommitOnImplThread(CompletionEvent* completion); |
266 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | 290 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); |
267 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 291 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
268 void InitializeImplOnImplThread(CompletionEvent* completion); | 292 void InitializeImplOnImplThread(CompletionEvent* completion); |
269 void SetLayerTreeHostClientReadyOnImplThread(); | |
270 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 293 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
271 void SetThrottleFrameProductionOnImplThread(bool throttle); | |
272 void HasInitializedOutputSurfaceOnImplThread( | 294 void HasInitializedOutputSurfaceOnImplThread( |
273 CompletionEvent* completion, | 295 CompletionEvent* completion, |
274 bool* has_initialized_output_surface); | 296 bool* has_initialized_output_surface); |
275 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | 297 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); |
276 void InitializeOutputSurfaceOnImplThread( | 298 void InitializeOutputSurfaceOnImplThread( |
277 scoped_ptr<OutputSurface> output_surface); | 299 scoped_ptr<OutputSurface> output_surface); |
278 void ReleaseOutputSurfaceOnImplThread( | 300 void ReleaseOutputSurfaceOnImplThread( |
279 CompletionEvent* completion, | 301 CompletionEvent* completion, |
280 scoped_ptr<OutputSurface>* output_surface); | 302 scoped_ptr<OutputSurface>* output_surface); |
281 void FinishGLOnImplThread(CompletionEvent* completion); | 303 void FinishGLOnImplThread(CompletionEvent* completion); |
(...skipping 18 matching lines...) Expand all Loading... | |
300 MainThreadOnly& main(); | 322 MainThreadOnly& main(); |
301 | 323 |
302 // Use accessors instead of this variable directly. | 324 // Use accessors instead of this variable directly. |
303 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 325 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; |
304 MainThreadOrBlockedMainThread& blocked_main(); | 326 MainThreadOrBlockedMainThread& blocked_main(); |
305 | 327 |
306 // Use accessors instead of this variable directly. | 328 // Use accessors instead of this variable directly. |
307 CompositorThreadOnly compositor_thread_vars_unsafe_; | 329 CompositorThreadOnly compositor_thread_vars_unsafe_; |
308 CompositorThreadOnly& impl(); | 330 CompositorThreadOnly& impl(); |
309 | 331 |
332 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | |
333 scoped_ptr<ThreadedChannel> threaded_channel_; | |
334 | |
310 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 335 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
311 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 336 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
312 | 337 |
313 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 338 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
314 }; | 339 }; |
315 | 340 |
316 } // namespace cc | 341 } // namespace cc |
317 | 342 |
318 #endif // CC_TREES_THREAD_PROXY_H_ | 343 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |