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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 void ScheduledActionAnimate() override; | 232 void ScheduledActionAnimate() override; |
244 void ScheduledActionCommit() override; | 233 void ScheduledActionCommit() override; |
245 void ScheduledActionActivateSyncTree() override; | 234 void ScheduledActionActivateSyncTree() override; |
246 void ScheduledActionBeginOutputSurfaceCreation() override; | 235 void ScheduledActionBeginOutputSurfaceCreation() override; |
247 void ScheduledActionPrepareTiles() override; | 236 void ScheduledActionPrepareTiles() override; |
248 void ScheduledActionInvalidateOutputSurface() override; | 237 void ScheduledActionInvalidateOutputSurface() override; |
249 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 238 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
250 void SendBeginMainFrameNotExpectedSoon() override; | 239 void SendBeginMainFrameNotExpectedSoon() override; |
251 | 240 |
252 // ProxyMain implementation | 241 // ProxyMain implementation |
253 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; | |
254 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; | 242 void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) override; |
255 void DidCompleteSwapBuffers() override; | |
256 | |
257 // ProxyImpl implementation | |
258 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; | |
259 void SetThrottleFrameProductionOnImpl(bool throttle) override; | |
260 void UpdateTopControlsStateOnImpl(TopControlsState constraints, | |
261 TopControlsState current, | |
262 bool animate) override; | |
263 | 243 |
264 protected: | 244 protected: |
265 ThreadProxy( | 245 ThreadProxy( |
266 LayerTreeHost* layer_tree_host, | 246 LayerTreeHost* layer_tree_host, |
267 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 247 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
268 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 248 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
269 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 249 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
270 | 250 |
271 private: | 251 private: |
272 // Called on main thread. | 252 friend class ThreadProxyForTest; |
273 void SetRendererCapabilitiesMainThreadCopy( | 253 |
274 const RendererCapabilities& capabilities); | 254 // ProxyMain implementation. |
| 255 base::WeakPtr<ProxyMain> GetMainWeakPtr() override; |
| 256 void DidCompleteSwapBuffers() override; |
| 257 void SetRendererCapabilitiesMainCopy( |
| 258 const RendererCapabilities& capabilities) override; |
| 259 void BeginMainFrameNotExpectedSoon() override; |
| 260 void DidCommitAndDrawFrame() override; |
| 261 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue) override; |
| 262 void DidLoseOutputSurface() override; |
| 263 void RequestNewOutputSurface() override; |
| 264 void DidInitializeOutputSurface( |
| 265 bool success, |
| 266 const RendererCapabilities& capabilities) override; |
| 267 void DidCompletePageScaleAnimation() override; |
| 268 void PostFrameTimingEventsOnMain( |
| 269 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 270 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| 271 override; |
275 void BeginMainFrame( | 272 void BeginMainFrame( |
276 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 273 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) override; |
277 void BeginMainFrameNotExpectedSoon(); | 274 |
278 void DidCommitAndDrawFrame(); | 275 // ProxyImpl implementation |
279 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 276 base::WeakPtr<ProxyImpl> GetImplWeakPtr() override; |
280 void DidLoseOutputSurface(); | 277 void SetThrottleFrameProductionOnImpl(bool throttle) override; |
281 void RequestNewOutputSurface(); | 278 void UpdateTopControlsStateOnImpl(TopControlsState constraints, |
282 void DidInitializeOutputSurface(bool success, | 279 TopControlsState current, |
283 const RendererCapabilities& capabilities); | 280 bool animate) override; |
| 281 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override; |
| 282 void MainThreadHasStoppedFlingingOnImpl() override; |
| 283 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override; |
| 284 void SetDeferCommitsOnImpl(bool defer_commits) const override; |
| 285 void FinishAllRenderingOnImpl(CompletionEvent* completion) override; |
| 286 void SetVisibleOnImpl(CompletionEvent* completion, bool visible) override; |
| 287 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override; |
| 288 void FinishGLOnImpl(CompletionEvent* completion) override; |
| 289 void MainFrameWillHappenOnImplForTesting( |
| 290 CompletionEvent* completion, |
| 291 bool* main_frame_will_happen) override; |
| 292 void SetNeedsCommitOnImpl() override; |
| 293 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override; |
| 294 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override; |
| 295 void StartCommitOnImpl(CompletionEvent* completion) override; |
| 296 |
284 // 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 |
285 // already outstanding. | 298 // already outstanding. |
286 bool SendCommitRequestToImplThreadIfNeeded( | 299 bool SendCommitRequestToImplThreadIfNeeded( |
287 CommitPipelineStage required_stage); | 300 CommitPipelineStage required_stage); |
288 void DidCompletePageScaleAnimation(); | |
289 | 301 |
290 // Called on impl thread. | 302 // Called on impl thread. |
291 struct SchedulerStateRequest; | 303 struct SchedulerStateRequest; |
292 | 304 |
293 void StartCommitOnImplThread(CompletionEvent* completion); | |
294 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | |
295 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | |
296 void InitializeImplOnImplThread(CompletionEvent* completion); | 305 void InitializeImplOnImplThread(CompletionEvent* completion); |
297 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | |
298 void HasInitializedOutputSurfaceOnImplThread( | |
299 CompletionEvent* completion, | |
300 bool* has_initialized_output_surface); | |
301 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | |
302 void InitializeOutputSurfaceOnImplThread(OutputSurface* output_surface); | |
303 void ReleaseOutputSurfaceOnImplThread(CompletionEvent* completion); | |
304 void FinishGLOnImplThread(CompletionEvent* completion); | |
305 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 306 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
306 DrawResult DrawSwapInternal(bool forced_draw); | 307 DrawResult DrawSwapInternal(bool forced_draw); |
307 void MainFrameWillHappenOnImplThreadForTesting(CompletionEvent* completion, | |
308 bool* main_frame_will_happen); | |
309 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile); | |
310 void MainThreadHasStoppedFlingingOnImplThread(); | |
311 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); | |
312 void SetDeferCommitsOnImplThread(bool defer_commits) const; | |
313 void PostFrameTimingEvents( | |
314 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
315 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | |
316 | 308 |
317 LayerTreeHost* layer_tree_host(); | 309 LayerTreeHost* layer_tree_host(); |
318 const LayerTreeHost* layer_tree_host() const; | 310 const LayerTreeHost* layer_tree_host() const; |
319 | 311 |
320 // Use accessors instead of this variable directly. | 312 // Use accessors instead of this variable directly. |
321 MainThreadOnly main_thread_only_vars_unsafe_; | 313 MainThreadOnly main_thread_only_vars_unsafe_; |
322 MainThreadOnly& main(); | 314 MainThreadOnly& main(); |
323 | 315 |
324 // Use accessors instead of this variable directly. | 316 // Use accessors instead of this variable directly. |
325 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 317 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; |
326 MainThreadOrBlockedMainThread& blocked_main(); | 318 MainThreadOrBlockedMainThread& blocked_main(); |
327 | 319 |
328 // Use accessors instead of this variable directly. | 320 // Use accessors instead of this variable directly. |
329 CompositorThreadOnly compositor_thread_vars_unsafe_; | 321 CompositorThreadOnly compositor_thread_vars_unsafe_; |
330 CompositorThreadOnly& impl(); | 322 CompositorThreadOnly& impl(); |
331 | 323 |
332 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | 324 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
333 scoped_ptr<ThreadedChannel> threaded_channel_; | 325 scoped_ptr<ThreadedChannel> threaded_channel_; |
334 | 326 |
335 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 327 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
336 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 328 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
337 | 329 |
338 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 330 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
339 }; | 331 }; |
340 | 332 |
341 } // namespace cc | 333 } // namespace cc |
342 | 334 |
343 #endif // CC_TREES_THREAD_PROXY_H_ | 335 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |