| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // 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 |
| 56 // we decide that no further processing is necessary. | 56 // we decide that no further processing is necessary. |
| 57 enum CommitPipelineStage { | 57 enum CommitPipelineStage { |
| 58 NO_PIPELINE_STAGE, | 58 NO_PIPELINE_STAGE, |
| 59 ANIMATE_PIPELINE_STAGE, | 59 ANIMATE_PIPELINE_STAGE, |
| 60 UPDATE_LAYERS_PIPELINE_STAGE, | 60 UPDATE_LAYERS_PIPELINE_STAGE, |
| 61 COMMIT_PIPELINE_STAGE, | 61 COMMIT_PIPELINE_STAGE, |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 struct MainThreadOnly { | 64 struct MainThreadOnly { |
| 65 MainThreadOnly(ThreadProxy* proxy, int layer_tree_host_id); | 65 MainThreadOnly(ThreadProxy* proxy, LayerTreeHost* layer_tree_host); |
| 66 ~MainThreadOnly(); | 66 ~MainThreadOnly(); |
| 67 | 67 |
| 68 const int layer_tree_host_id; | 68 const int layer_tree_host_id; |
| 69 | 69 |
| 70 LayerTreeHost* layer_tree_host; |
| 71 |
| 70 // The furthest pipeline stage which has been requested for the next | 72 // The furthest pipeline stage which has been requested for the next |
| 71 // commit. | 73 // commit. |
| 72 CommitPipelineStage max_requested_pipeline_stage; | 74 CommitPipelineStage max_requested_pipeline_stage; |
| 73 // The commit pipeline stage that is currently being processed. | 75 // The commit pipeline stage that is currently being processed. |
| 74 CommitPipelineStage current_pipeline_stage; | 76 CommitPipelineStage current_pipeline_stage; |
| 75 // The commit pipeline stage at which processing for the current commit | 77 // The commit pipeline stage at which processing for the current commit |
| 76 // will stop. Only valid while we are executing the pipeline (i.e., | 78 // will stop. Only valid while we are executing the pipeline (i.e., |
| 77 // |current_pipeline_stage| is set to a pipeline stage). | 79 // |current_pipeline_stage| is set to a pipeline stage). |
| 78 CommitPipelineStage final_pipeline_stage; | 80 CommitPipelineStage final_pipeline_stage; |
| 79 | 81 |
| 82 bool commit_waits_for_activation; |
| 83 |
| 80 bool started; | 84 bool started; |
| 81 bool prepare_tiles_pending; | 85 bool prepare_tiles_pending; |
| 82 bool defer_commits; | 86 bool defer_commits; |
| 83 | 87 |
| 84 RendererCapabilities renderer_capabilities_main_thread_copy; | 88 RendererCapabilities renderer_capabilities_main_thread_copy; |
| 85 | 89 |
| 86 // TODO(khushalsagar): Make this scoped_ptr<ChannelMain> when ProxyMain | 90 // TODO(khushalsagar): Make this scoped_ptr<ChannelMain> when ProxyMain |
| 87 // and ProxyImpl are split. | 91 // and ProxyImpl are split. |
| 88 ChannelMain* channel_main; | 92 ChannelMain* channel_main; |
| 89 | 93 |
| 90 base::WeakPtrFactory<ThreadProxy> weak_factory; | 94 base::WeakPtrFactory<ThreadProxy> weak_factory; |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 // Accessed on the main thread, or when main thread is blocked. | 97 // Accessed on the impl thread when the main thread is blocked for a commit. |
| 94 struct MainThreadOrBlockedMainThread { | 98 struct BlockedMainCommitOnly { |
| 95 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host); | 99 BlockedMainCommitOnly(); |
| 96 ~MainThreadOrBlockedMainThread(); | 100 ~BlockedMainCommitOnly(); |
| 97 | |
| 98 LayerTreeHost* layer_tree_host; | 101 LayerTreeHost* layer_tree_host; |
| 99 bool commit_waits_for_activation; | |
| 100 bool main_thread_inside_commit; | |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 struct CompositorThreadOnly { | 104 struct CompositorThreadOnly { |
| 104 CompositorThreadOnly( | 105 CompositorThreadOnly( |
| 105 ThreadProxy* proxy, | 106 ThreadProxy* proxy, |
| 106 int layer_tree_host_id, | 107 int layer_tree_host_id, |
| 107 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 108 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 108 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 109 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 109 ~CompositorThreadOnly(); | 110 ~CompositorThreadOnly(); |
| 110 | 111 |
| 111 const int layer_tree_host_id; | 112 const int layer_tree_host_id; |
| 112 | 113 |
| 113 scoped_ptr<Scheduler> scheduler; | 114 scoped_ptr<Scheduler> scheduler; |
| 114 | 115 |
| 115 // Set when the main thread is waiting on a | 116 // Set when the main thread is waiting on a pending tree activation. |
| 116 // ScheduledActionSendBeginMainFrame to be issued. | 117 bool next_commit_waits_for_activation; |
| 117 CompletionEvent* begin_main_frame_sent_completion_event; | |
| 118 | 118 |
| 119 // Set when the main thread is waiting on a commit to complete. | 119 // Set when the main thread is waiting on a commit to complete or on a |
| 120 // pending tree activation. |
| 120 CompletionEvent* commit_completion_event; | 121 CompletionEvent* commit_completion_event; |
| 121 | 122 |
| 122 // Set when the main thread is waiting on a pending tree activation. | |
| 123 CompletionEvent* completion_event_for_commit_held_on_tree_activation; | |
| 124 | |
| 125 // Set when the next draw should post DidCommitAndDrawFrame to the main | 123 // Set when the next draw should post DidCommitAndDrawFrame to the main |
| 126 // thread. | 124 // thread. |
| 127 bool next_frame_is_newly_committed_frame; | 125 bool next_frame_is_newly_committed_frame; |
| 128 | 126 |
| 129 bool inside_draw; | 127 bool inside_draw; |
| 130 | 128 |
| 131 bool input_throttled_until_commit; | 129 bool input_throttled_until_commit; |
| 132 | 130 |
| 133 // Whether a commit has been completed since the last time animations were | 131 // Whether a commit has been completed since the last time animations were |
| 134 // ticked. If this happens, we need to animate again. | 132 // ticked. If this happens, we need to animate again. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 145 BeginFrameArgs last_processed_begin_main_frame_args; | 143 BeginFrameArgs last_processed_begin_main_frame_args; |
| 146 | 144 |
| 147 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; | 145 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; |
| 148 | 146 |
| 149 ChannelImpl* channel_impl; | 147 ChannelImpl* channel_impl; |
| 150 | 148 |
| 151 base::WeakPtrFactory<ThreadProxy> weak_factory; | 149 base::WeakPtrFactory<ThreadProxy> weak_factory; |
| 152 }; | 150 }; |
| 153 | 151 |
| 154 const MainThreadOnly& main() const; | 152 const MainThreadOnly& main() const; |
| 155 const MainThreadOrBlockedMainThread& blocked_main() const; | |
| 156 const CompositorThreadOnly& impl() const; | 153 const CompositorThreadOnly& impl() const; |
| 157 | 154 |
| 158 // Proxy implementation | 155 // Proxy implementation |
| 159 void FinishAllRendering() override; | 156 void FinishAllRendering() override; |
| 160 bool IsStarted() const override; | 157 bool IsStarted() const override; |
| 161 bool CommitToActiveTree() const override; | 158 bool CommitToActiveTree() const override; |
| 162 void SetOutputSurface(OutputSurface* output_surface) override; | 159 void SetOutputSurface(OutputSurface* output_surface) override; |
| 163 void SetVisible(bool visible) override; | 160 void SetVisible(bool visible) override; |
| 164 void SetThrottleFrameProduction(bool throttle) override; | 161 void SetThrottleFrameProduction(bool throttle) override; |
| 165 const RendererCapabilities& GetRendererCapabilities() const override; | 162 const RendererCapabilities& GetRendererCapabilities() const override; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 void FinishAllRenderingOnImpl(CompletionEvent* completion) override; | 269 void FinishAllRenderingOnImpl(CompletionEvent* completion) override; |
| 273 void SetVisibleOnImpl(CompletionEvent* completion, bool visible) override; | 270 void SetVisibleOnImpl(CompletionEvent* completion, bool visible) override; |
| 274 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override; | 271 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override; |
| 275 void FinishGLOnImpl(CompletionEvent* completion) override; | 272 void FinishGLOnImpl(CompletionEvent* completion) override; |
| 276 void MainFrameWillHappenOnImplForTesting( | 273 void MainFrameWillHappenOnImplForTesting( |
| 277 CompletionEvent* completion, | 274 CompletionEvent* completion, |
| 278 bool* main_frame_will_happen) override; | 275 bool* main_frame_will_happen) override; |
| 279 void SetNeedsCommitOnImpl() override; | 276 void SetNeedsCommitOnImpl() override; |
| 280 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override; | 277 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override; |
| 281 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override; | 278 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override; |
| 282 void StartCommitOnImpl(CompletionEvent* completion) override; | 279 void StartCommitOnImpl(CompletionEvent* completion, |
| 280 LayerTreeHost* layer_tree_host, |
| 281 bool hold_commit_for_activation) override; |
| 282 void InitializeImplOnImpl(CompletionEvent* completion, |
| 283 LayerTreeHost* layer_tree_host) override; |
| 284 void LayerTreeHostClosedOnImpl(CompletionEvent* completion) override; |
| 283 | 285 |
| 284 protected: | 286 protected: |
| 285 ThreadProxy( | 287 ThreadProxy( |
| 286 LayerTreeHost* layer_tree_host, | 288 LayerTreeHost* layer_tree_host, |
| 287 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 289 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 288 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 290 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 289 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 291 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 290 | 292 |
| 291 private: | 293 private: |
| 292 // Called on main thread. | 294 // Called on main thread. |
| 293 | 295 |
| 294 // 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 |
| 295 // already outstanding. | 297 // already outstanding. |
| 296 bool SendCommitRequestToImplThreadIfNeeded( | 298 bool SendCommitRequestToImplThreadIfNeeded( |
| 297 CommitPipelineStage required_stage); | 299 CommitPipelineStage required_stage); |
| 298 | 300 |
| 299 // Called on impl thread. | 301 // Called on impl thread. |
| 300 struct SchedulerStateRequest; | 302 struct SchedulerStateRequest; |
| 301 | 303 |
| 302 void InitializeImplOnImplThread(CompletionEvent* completion); | |
| 303 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | |
| 304 DrawResult DrawSwapInternal(bool forced_draw); | 304 DrawResult DrawSwapInternal(bool forced_draw); |
| 305 | 305 |
| 306 LayerTreeHost* layer_tree_host(); | 306 LayerTreeHost* layer_tree_host(); |
| 307 const LayerTreeHost* layer_tree_host() const; | 307 const LayerTreeHost* layer_tree_host() const; |
| 308 | 308 |
| 309 // Use accessors instead of this variable directly. | 309 // Use accessors instead of this variable directly. |
| 310 MainThreadOnly main_thread_only_vars_unsafe_; | 310 MainThreadOnly main_thread_only_vars_unsafe_; |
| 311 MainThreadOnly& main(); | 311 MainThreadOnly& main(); |
| 312 | 312 |
| 313 // Use accessors instead of this variable directly. | 313 // Use accessors instead of this variable directly. |
| 314 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; | 314 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_; |
| 315 MainThreadOrBlockedMainThread& blocked_main(); | 315 BlockedMainCommitOnly& blocked_main_commit(); |
| 316 | 316 |
| 317 // Use accessors instead of this variable directly. | 317 // Use accessors instead of this variable directly. |
| 318 CompositorThreadOnly compositor_thread_vars_unsafe_; | 318 CompositorThreadOnly compositor_thread_vars_unsafe_; |
| 319 CompositorThreadOnly& impl(); | 319 CompositorThreadOnly& impl(); |
| 320 | 320 |
| 321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. | 321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. |
| 322 scoped_ptr<ThreadedChannel> threaded_channel_; | 322 scoped_ptr<ThreadedChannel> threaded_channel_; |
| 323 | 323 |
| 324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
| 325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
| 326 | 326 |
| 327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 } // namespace cc | 330 } // namespace cc |
| 331 | 331 |
| 332 #endif // CC_TREES_THREAD_PROXY_H_ | 332 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |