Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1292)

Side by Side Diff: cc/trees/thread_proxy.h

Issue 1418953002: cc: Send shared variables between main and impl side using the channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/proxy_impl.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void FinishAllRenderingOnImpl(CompletionEvent* completion) override; 282 void FinishAllRenderingOnImpl(CompletionEvent* completion) override;
286 void SetVisibleOnImpl(bool visible) override; 283 void SetVisibleOnImpl(bool visible) override;
287 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override; 284 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override;
288 void FinishGLOnImpl(CompletionEvent* completion) override; 285 void FinishGLOnImpl(CompletionEvent* completion) override;
289 void MainFrameWillHappenOnImplForTesting( 286 void MainFrameWillHappenOnImplForTesting(
290 CompletionEvent* completion, 287 CompletionEvent* completion,
291 bool* main_frame_will_happen) override; 288 bool* main_frame_will_happen) override;
292 void SetNeedsCommitOnImpl() override; 289 void SetNeedsCommitOnImpl() override;
293 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override; 290 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override;
294 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override; 291 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override;
295 void StartCommitOnImpl(CompletionEvent* completion) override; 292 void StartCommitOnImpl(CompletionEvent* completion,
293 LayerTreeHost* layer_tree_host,
294 bool hold_commit_for_activation) override;
295 void InitializeImplOnImpl(CompletionEvent* completion,
296 LayerTreeHost* layer_tree_host) override;
297 void LayerTreeHostClosedOnImpl(CompletionEvent* completion) override;
296 298
297 // Returns |true| if the request was actually sent, |false| if one was 299 // Returns |true| if the request was actually sent, |false| if one was
298 // already outstanding. 300 // already outstanding.
299 bool SendCommitRequestToImplThreadIfNeeded( 301 bool SendCommitRequestToImplThreadIfNeeded(
300 CommitPipelineStage required_stage); 302 CommitPipelineStage required_stage);
301 303
302 // Called on impl thread. 304 // Called on impl thread.
303 struct SchedulerStateRequest; 305 struct SchedulerStateRequest;
304 306
305 void InitializeImplOnImplThread(CompletionEvent* completion);
306 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion);
307 DrawResult DrawSwapInternal(bool forced_draw); 307 DrawResult DrawSwapInternal(bool forced_draw);
308 308
309 LayerTreeHost* layer_tree_host();
310 const LayerTreeHost* layer_tree_host() const;
311
312 // Use accessors instead of this variable directly. 309 // Use accessors instead of this variable directly.
313 MainThreadOnly main_thread_only_vars_unsafe_; 310 MainThreadOnly main_thread_only_vars_unsafe_;
314 MainThreadOnly& main(); 311 MainThreadOnly& main();
315 312
316 // Use accessors instead of this variable directly. 313 // Use accessors instead of this variable directly.
317 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; 314 BlockedMainCommitOnly main_thread_blocked_commit_vars_unsafe_;
318 MainThreadOrBlockedMainThread& blocked_main(); 315 BlockedMainCommitOnly& blocked_main_commit();
319 316
320 // Use accessors instead of this variable directly. 317 // Use accessors instead of this variable directly.
321 CompositorThreadOnly compositor_thread_vars_unsafe_; 318 CompositorThreadOnly compositor_thread_vars_unsafe_;
322 CompositorThreadOnly& impl(); 319 CompositorThreadOnly& impl();
323 320
324 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel. 321 // TODO(khushalsagar): Remove this. Temporary variable to hold the channel.
325 scoped_ptr<ThreadedChannel> threaded_channel_; 322 scoped_ptr<ThreadedChannel> threaded_channel_;
326 323
327 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; 324 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_;
328 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; 325 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_;
329 326
330 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); 327 DISALLOW_COPY_AND_ASSIGN(ThreadProxy);
331 }; 328 };
332 329
333 } // namespace cc 330 } // namespace cc
334 331
335 #endif // CC_TREES_THREAD_PROXY_H_ 332 #endif // CC_TREES_THREAD_PROXY_H_
OLDNEW
« no previous file with comments | « cc/trees/proxy_impl.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698