Chromium Code Reviews| 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 170 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( | |
|
vmpstr
2015/10/26 17:57:36
I'm a bit hesitant about these becoming public. Ca
Khushal
2015/10/26 20:56:02
Done. Added ThreadProxyForTest as a friend class a
| |
| 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) const 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(CompletionEvent* completion) override; | |
| 262 | 283 |
| 263 protected: | 284 protected: |
| 264 ThreadProxy( | 285 ThreadProxy( |
| 265 LayerTreeHost* layer_tree_host, | 286 LayerTreeHost* layer_tree_host, |
| 266 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 287 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 267 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 288 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 268 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 289 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 269 | 290 |
| 270 private: | 291 private: |
| 271 // Called on main thread. | 292 // Called on main thread. |
| 272 void SetRendererCapabilitiesMainThreadCopy( | 293 |
| 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 | 294 // Returns |true| if the request was actually sent, |false| if one was |
| 284 // already outstanding. | 295 // already outstanding. |
| 285 bool SendCommitRequestToImplThreadIfNeeded( | 296 bool SendCommitRequestToImplThreadIfNeeded( |
| 286 CommitPipelineStage required_stage); | 297 CommitPipelineStage required_stage); |
| 287 void DidCompletePageScaleAnimation(); | |
| 288 | 298 |
| 289 // Called on impl thread. | 299 // Called on impl thread. |
| 290 struct SchedulerStateRequest; | 300 struct SchedulerStateRequest; |
| 291 | 301 |
| 292 void StartCommitOnImplThread(CompletionEvent* completion); | |
| 293 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | |
| 294 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | |
| 295 void InitializeImplOnImplThread(CompletionEvent* completion); | 302 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); | 303 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
| 305 DrawResult DrawSwapInternal(bool forced_draw); | 304 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 | 305 |
| 316 LayerTreeHost* layer_tree_host(); | 306 LayerTreeHost* layer_tree_host(); |
| 317 const LayerTreeHost* layer_tree_host() const; | 307 const LayerTreeHost* layer_tree_host() const; |
| 318 | 308 |
| 319 // Use accessors instead of this variable directly. | 309 // Use accessors instead of this variable directly. |
| 320 MainThreadOnly main_thread_only_vars_unsafe_; | 310 MainThreadOnly main_thread_only_vars_unsafe_; |
| 321 MainThreadOnly& main(); | 311 MainThreadOnly& main(); |
| 322 | 312 |
| 323 // Use accessors instead of this variable directly. | 313 // Use accessors instead of this variable directly. |
| 324 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 314 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; |
| 325 MainThreadOrBlockedMainThread& blocked_main(); | 315 MainThreadOrBlockedMainThread& blocked_main(); |
| 326 | 316 |
| 327 // Use accessors instead of this variable directly. | 317 // Use accessors instead of this variable directly. |
| 328 CompositorThreadOnly compositor_thread_vars_unsafe_; | 318 CompositorThreadOnly compositor_thread_vars_unsafe_; |
| 329 CompositorThreadOnly& impl(); | 319 CompositorThreadOnly& impl(); |
| 330 | 320 |
| 331 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | 321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
| 332 scoped_ptr<ThreadedChannel> threaded_channel_; | 322 scoped_ptr<ThreadedChannel> threaded_channel_; |
| 333 | 323 |
| 334 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
| 335 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
| 336 | 326 |
| 337 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 338 }; | 328 }; |
| 339 | 329 |
| 340 } // namespace cc | 330 } // namespace cc |
| 341 | 331 |
| 342 #endif // CC_TREES_THREAD_PROXY_H_ | 332 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |