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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
49 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 49 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
50 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 50 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
51 | 51 |
52 ~ThreadProxy() override; | 52 ~ThreadProxy() override; |
53 | 53 |
54 struct BeginMainFrameAndCommitState { | |
55 BeginMainFrameAndCommitState(); | |
56 ~BeginMainFrameAndCommitState(); | |
57 | |
58 unsigned int begin_frame_id; | |
59 BeginFrameArgs begin_frame_args; | |
60 scoped_ptr<ScrollAndScaleSet> scroll_info; | |
61 size_t memory_allocation_limit_bytes; | |
62 bool evicted_ui_resources; | |
63 }; | |
64 | |
65 // Commits between the main and impl threads are processed through a pipeline | 54 // Commits between the main and impl threads are processed through a pipeline |
66 // with the following stages. For efficiency we can early out at any stage if | 55 // with the following stages. For efficiency we can early out at any stage if |
67 // we decide that no further processing is necessary. | 56 // we decide that no further processing is necessary. |
68 enum CommitPipelineStage { | 57 enum CommitPipelineStage { |
69 NO_PIPELINE_STAGE, | 58 NO_PIPELINE_STAGE, |
70 ANIMATE_PIPELINE_STAGE, | 59 ANIMATE_PIPELINE_STAGE, |
71 UPDATE_LAYERS_PIPELINE_STAGE, | 60 UPDATE_LAYERS_PIPELINE_STAGE, |
72 COMMIT_PIPELINE_STAGE, | 61 COMMIT_PIPELINE_STAGE, |
73 }; | 62 }; |
74 | 63 |
(...skipping 10 matching lines...) Expand all Loading... |
85 CommitPipelineStage current_pipeline_stage; | 74 CommitPipelineStage current_pipeline_stage; |
86 // The commit pipeline stage at which processing for the current commit | 75 // The commit pipeline stage at which processing for the current commit |
87 // will stop. Only valid while we are executing the pipeline (i.e., | 76 // will stop. Only valid while we are executing the pipeline (i.e., |
88 // |current_pipeline_stage| is set to a pipeline stage). | 77 // |current_pipeline_stage| is set to a pipeline stage). |
89 CommitPipelineStage final_pipeline_stage; | 78 CommitPipelineStage final_pipeline_stage; |
90 | 79 |
91 bool started; | 80 bool started; |
92 bool prepare_tiles_pending; | 81 bool prepare_tiles_pending; |
93 bool defer_commits; | 82 bool defer_commits; |
94 | 83 |
| 84 bool commit_waits_for_activation; |
| 85 |
95 RendererCapabilities renderer_capabilities_main_thread_copy; | 86 RendererCapabilities renderer_capabilities_main_thread_copy; |
96 | 87 |
97 // TODO(khushalsagar): Make this scoped_ptr<ChannelMain> when ProxyMain | 88 // TODO(khushalsagar): Make this scoped_ptr<ChannelMain> when ProxyMain |
98 // and ProxyImpl are split. | 89 // and ProxyImpl are split. |
99 ChannelMain* channel_main; | 90 ChannelMain* channel_main; |
100 | 91 |
101 base::WeakPtrFactory<ThreadProxy> weak_factory; | 92 base::WeakPtrFactory<ThreadProxy> weak_factory; |
102 }; | 93 }; |
103 | 94 |
104 // Accessed on the main thread, or when main thread is blocked. | 95 // Accessed on the main thread, or when main thread is blocked. |
105 struct MainThreadOrBlockedMainThread { | 96 struct MainThreadOrBlockedMainThread { |
106 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host); | 97 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host); |
107 ~MainThreadOrBlockedMainThread(); | 98 ~MainThreadOrBlockedMainThread(); |
108 | 99 |
109 LayerTreeHost* layer_tree_host; | 100 LayerTreeHost* layer_tree_host; |
110 bool commit_waits_for_activation; | |
111 bool main_thread_inside_commit; | |
112 }; | 101 }; |
113 | 102 |
114 struct CompositorThreadOnly { | 103 struct CompositorThreadOnly { |
115 CompositorThreadOnly( | 104 CompositorThreadOnly( |
116 ThreadProxy* proxy, | 105 ThreadProxy* proxy, |
117 int layer_tree_host_id, | 106 int layer_tree_host_id, |
118 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 107 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
119 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 108 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
120 ~CompositorThreadOnly(); | 109 ~CompositorThreadOnly(); |
121 | 110 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 void ScheduledActionBeginOutputSurfaceCreation() override; | 234 void ScheduledActionBeginOutputSurfaceCreation() override; |
246 void ScheduledActionPrepareTiles() override; | 235 void ScheduledActionPrepareTiles() override; |
247 void ScheduledActionInvalidateOutputSurface() override; | 236 void ScheduledActionInvalidateOutputSurface() override; |
248 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 237 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
249 void SendBeginMainFrameNotExpectedSoon() override; | 238 void SendBeginMainFrameNotExpectedSoon() override; |
250 | 239 |
251 // ProxyMain implementation | 240 // ProxyMain implementation |
252 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; | 241 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; |
253 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; | 242 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; |
254 void DidCompleteSwapBuffers() override; | 243 void DidCompleteSwapBuffers() override; |
| 244 void SetRendererCapabilitiesMainCopy( |
| 245 const RendererCapabilities& capabilities) override; |
| 246 void BeginMainFrameNotExpectedSoon() override; |
| 247 void DidCommitAndDrawFrame() override; |
| 248 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue) override; |
| 249 void DidLoseOutputSurface() override; |
| 250 void RequestNewOutputSurface() override; |
| 251 void DidInitializeOutputSurface( |
| 252 bool success, |
| 253 const RendererCapabilities& capabilities) override; |
| 254 void DidCompletePageScaleAnimation() override; |
| 255 void PostFrameTimingEventsOnMain( |
| 256 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 257 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| 258 override; |
| 259 void BeginMainFrame( |
| 260 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) override; |
255 | 261 |
256 // ProxyImpl implementation | 262 // ProxyImpl implementation |
257 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; | 263 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; |
258 void SetThrottleFrameProductionOnImpl(bool throttle) override; | 264 void SetThrottleFrameProductionOnImpl(bool throttle) override; |
259 void UpdateTopControlsStateOnImpl(TopControlsState constraints, | 265 void UpdateTopControlsStateOnImpl(TopControlsState constraints, |
260 TopControlsState current, | 266 TopControlsState current, |
261 bool animate) override; | 267 bool animate) override; |
| 268 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override; |
| 269 void MainThreadHasStoppedFlingingOnImpl() override; |
| 270 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override; |
| 271 void SetDeferCommitsOnImpl(bool defer_commits) override; |
| 272 void FinishAllRenderingOnImpl(CompletionEvent* completion) override; |
| 273 void SetVisibleOnImpl(CompletionEvent* completion, bool visible) override; |
| 274 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override; |
| 275 void FinishGLOnImpl(CompletionEvent* completion) override; |
| 276 void MainFrameWillHappenOnImplForTesting( |
| 277 CompletionEvent* completion, |
| 278 bool* main_frame_will_happen) override; |
| 279 void SetNeedsCommitOnImpl() override; |
| 280 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override; |
| 281 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override; |
| 282 void StartCommitOnImpl( |
| 283 CompletionEvent* completion, |
| 284 BlockedMainCommitState* blocked_main_commit_state) override; |
262 | 285 |
263 protected: | 286 protected: |
264 ThreadProxy( | 287 ThreadProxy( |
265 LayerTreeHost* layer_tree_host, | 288 LayerTreeHost* layer_tree_host, |
266 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 289 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
267 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 290 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
268 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 291 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
269 | 292 |
270 private: | 293 private: |
271 // Called on main thread. | 294 // Called on main thread. |
272 void SetRendererCapabilitiesMainThreadCopy( | 295 |
273 const RendererCapabilities& capabilities); | |
274 void BeginMainFrame( | |
275 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | |
276 void BeginMainFrameNotExpectedSoon(); | |
277 void DidCommitAndDrawFrame(); | |
278 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | |
279 void DidLoseOutputSurface(); | |
280 void RequestNewOutputSurface(); | |
281 void DidInitializeOutputSurface(bool success, | |
282 const RendererCapabilities& capabilities); | |
283 // Returns |true| if the request was actually sent, |false| if one was | 296 // Returns |true| if the request was actually sent, |false| if one was |
284 // already outstanding. | 297 // already outstanding. |
285 bool SendCommitRequestToImplThreadIfNeeded( | 298 bool SendCommitRequestToImplThreadIfNeeded( |
286 CommitPipelineStage required_stage); | 299 CommitPipelineStage required_stage); |
287 void DidCompletePageScaleAnimation(); | |
288 | 300 |
289 // Called on impl thread. | 301 // Called on impl thread. |
290 struct SchedulerStateRequest; | 302 struct SchedulerStateRequest; |
291 | 303 |
292 void StartCommitOnImplThread(CompletionEvent* completion); | |
293 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | |
294 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | |
295 void InitializeImplOnImplThread(CompletionEvent* completion); | 304 void InitializeImplOnImplThread(CompletionEvent* completion); |
296 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | |
297 void HasInitializedOutputSurfaceOnImplThread( | |
298 CompletionEvent* completion, | |
299 bool* has_initialized_output_surface); | |
300 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | |
301 void InitializeOutputSurfaceOnImplThread(OutputSurface* output_surface); | |
302 void ReleaseOutputSurfaceOnImplThread(CompletionEvent* completion); | |
303 void FinishGLOnImplThread(CompletionEvent* completion); | |
304 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 305 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
305 DrawResult DrawSwapInternal(bool forced_draw); | 306 DrawResult DrawSwapInternal(bool forced_draw); |
306 void MainFrameWillHappenOnImplThreadForTesting(CompletionEvent* completion, | |
307 bool* main_frame_will_happen); | |
308 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile); | |
309 void MainThreadHasStoppedFlingingOnImplThread(); | |
310 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); | |
311 void SetDeferCommitsOnImplThread(bool defer_commits) const; | |
312 void PostFrameTimingEvents( | |
313 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
314 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | |
315 | 307 |
316 LayerTreeHost* layer_tree_host(); | 308 LayerTreeHost* layer_tree_host(); |
317 const LayerTreeHost* layer_tree_host() const; | 309 const LayerTreeHost* layer_tree_host() const; |
318 | 310 |
319 // Use accessors instead of this variable directly. | 311 // Use accessors instead of this variable directly. |
320 MainThreadOnly main_thread_only_vars_unsafe_; | 312 MainThreadOnly main_thread_only_vars_unsafe_; |
321 MainThreadOnly& main(); | 313 MainThreadOnly& main(); |
322 | 314 |
323 // Use accessors instead of this variable directly. | 315 // Use accessors instead of this variable directly. |
324 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 316 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; |
325 MainThreadOrBlockedMainThread& blocked_main(); | 317 MainThreadOrBlockedMainThread& blocked_main(); |
326 | 318 |
327 // Use accessors instead of this variable directly. | 319 // Use accessors instead of this variable directly. |
328 CompositorThreadOnly compositor_thread_vars_unsafe_; | 320 CompositorThreadOnly compositor_thread_vars_unsafe_; |
329 CompositorThreadOnly& impl(); | 321 CompositorThreadOnly& impl(); |
330 | 322 |
| 323 // Set when the main thread is waiting on a commit to finish. |
| 324 // Use accessors instead of this variable directly. |
| 325 // TODO(khushalsagar) : Move to ProxyImpl once ThreadProxy is split. |
| 326 BlockedMainCommitState* blocked_main_commit_state_vars_unsafe_; |
| 327 const BlockedMainCommitState* blocked_commit_state() const; |
| 328 void set_blocked_commit_state( |
| 329 BlockedMainCommitState* blocked_main_commit_state); |
| 330 |
331 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | 331 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
332 scoped_ptr<ThreadedChannel> threaded_channel_; | 332 scoped_ptr<ThreadedChannel> threaded_channel_; |
333 | 333 |
334 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 334 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
335 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 335 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
336 | 336 |
337 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 337 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
338 }; | 338 }; |
339 | 339 |
340 } // namespace cc | 340 } // namespace cc |
341 | 341 |
342 #endif // CC_TREES_THREAD_PROXY_H_ | 342 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |