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

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

Issue 1377063003: Split ThreadProxy methods to ProxyMain and ProxyImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep ProxyMain and ProxyImpl methods private. 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/thread_proxy.h ('k') | cc/trees/threaded_channel.h » ('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 #include "cc/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 main_thread_inside_commit(false) {} 98 main_thread_inside_commit(false) {}
99 99
100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} 100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {}
101 101
102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( 102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
103 ThreadProxy* proxy, 103 ThreadProxy* proxy,
104 int layer_tree_host_id, 104 int layer_tree_host_id,
105 RenderingStatsInstrumentation* rendering_stats_instrumentation, 105 RenderingStatsInstrumentation* rendering_stats_instrumentation,
106 scoped_ptr<BeginFrameSource> external_begin_frame_source) 106 scoped_ptr<BeginFrameSource> external_begin_frame_source)
107 : layer_tree_host_id(layer_tree_host_id), 107 : layer_tree_host_id(layer_tree_host_id),
108 commit_completion_event(NULL), 108 commit_completion_event(nullptr),
109 completion_event_for_commit_held_on_tree_activation(NULL), 109 completion_event_for_commit_held_on_tree_activation(nullptr),
110 next_frame_is_newly_committed_frame(false), 110 next_frame_is_newly_committed_frame(false),
111 inside_draw(false), 111 inside_draw(false),
112 input_throttled_until_commit(false), 112 input_throttled_until_commit(false),
113 smoothness_priority_expiration_notifier( 113 smoothness_priority_expiration_notifier(
114 proxy->ImplThreadTaskRunner(), 114 proxy->ImplThreadTaskRunner(),
115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), 115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
116 base::TimeDelta::FromMilliseconds( 116 base::TimeDelta::FromMilliseconds(
117 kSmoothnessTakesPriorityExpirationDelay * 1000)), 117 kSmoothnessTakesPriorityExpirationDelay * 1000)),
118 external_begin_frame_source(external_begin_frame_source.Pass()), 118 external_begin_frame_source(external_begin_frame_source.Pass()),
119 rendering_stats_instrumentation(rendering_stats_instrumentation), 119 rendering_stats_instrumentation(rendering_stats_instrumentation),
120 weak_factory(proxy) { 120 weak_factory(proxy) {}
121 }
122 121
123 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 122 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
124 123
125 ThreadProxy::~ThreadProxy() { 124 ThreadProxy::~ThreadProxy() {
126 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 125 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
127 DCHECK(IsMainThread()); 126 DCHECK(IsMainThread());
128 DCHECK(!main().started); 127 DCHECK(!main().started);
129 } 128 }
130 129
131 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { 130 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) {
132 threaded_channel_ = threaded_channel.Pass(); 131 threaded_channel_ = threaded_channel.Pass();
133 main().channel_main = threaded_channel_.get(); 132 main().channel_main = threaded_channel_.get();
134 } 133 }
135 134
136 void ThreadProxy::FinishAllRendering() { 135 void ThreadProxy::FinishAllRendering() {
137 DCHECK(Proxy::IsMainThread()); 136 DCHECK(Proxy::IsMainThread());
138 DCHECK(!main().defer_commits); 137 DCHECK(!main().defer_commits);
139 138
140 // Make sure all GL drawing is finished on the impl thread. 139 // Make sure all GL drawing is finished on the impl thread.
141 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 140 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
142 CompletionEvent completion; 141 CompletionEvent completion;
143 Proxy::ImplThreadTaskRunner()->PostTask( 142 main().channel_main->FinishAllRenderingOnImpl(&completion);
144 FROM_HERE,
145 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread,
146 impl_thread_weak_ptr_,
147 &completion));
148 completion.Wait(); 143 completion.Wait();
149 } 144 }
150 145
151 bool ThreadProxy::IsStarted() const { 146 bool ThreadProxy::IsStarted() const {
152 DCHECK(Proxy::IsMainThread()); 147 DCHECK(Proxy::IsMainThread());
153 return main().started; 148 return main().started;
154 } 149 }
155 150
156 bool ThreadProxy::CommitToActiveTree() const { 151 bool ThreadProxy::CommitToActiveTree() const {
157 // With ThreadProxy, we use a pending tree and activate it once it's ready to 152 // With ThreadProxy, we use a pending tree and activate it once it's ready to
158 // draw to allow input to modify the active tree and draw during raster. 153 // draw to allow input to modify the active tree and draw during raster.
159 return false; 154 return false;
160 } 155 }
161 156
162 void ThreadProxy::SetVisible(bool visible) { 157 void ThreadProxy::SetVisible(bool visible) {
163 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); 158 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible);
164 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 159 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
165 160
166 CompletionEvent completion; 161 CompletionEvent completion;
167 Proxy::ImplThreadTaskRunner()->PostTask( 162 main().channel_main->SetVisibleOnImpl(&completion, visible);
168 FROM_HERE,
169 base::Bind(&ThreadProxy::SetVisibleOnImplThread,
170 impl_thread_weak_ptr_,
171 &completion,
172 visible));
173 completion.Wait(); 163 completion.Wait();
174 } 164 }
175 165
176 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, 166 void ThreadProxy::SetVisibleOnImpl(CompletionEvent* completion, bool visible) {
177 bool visible) {
178 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); 167 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible);
179 impl().layer_tree_host_impl->SetVisible(visible); 168 impl().layer_tree_host_impl->SetVisible(visible);
180 impl().scheduler->SetVisible(visible); 169 impl().scheduler->SetVisible(visible);
181 completion->Signal(); 170 completion->Signal();
182 } 171 }
183 172
184 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { 173 void ThreadProxy::SetThrottleFrameProduction(bool throttle) {
185 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", 174 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle",
186 throttle); 175 throttle);
187 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); 176 main().channel_main->SetThrottleFrameProductionOnImpl(throttle);
(...skipping 10 matching lines...) Expand all
198 DCHECK(IsMainThread()); 187 DCHECK(IsMainThread());
199 layer_tree_host()->DidLoseOutputSurface(); 188 layer_tree_host()->DidLoseOutputSurface();
200 } 189 }
201 190
202 void ThreadProxy::RequestNewOutputSurface() { 191 void ThreadProxy::RequestNewOutputSurface() {
203 DCHECK(IsMainThread()); 192 DCHECK(IsMainThread());
204 layer_tree_host()->RequestNewOutputSurface(); 193 layer_tree_host()->RequestNewOutputSurface();
205 } 194 }
206 195
207 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { 196 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) {
208 Proxy::ImplThreadTaskRunner()->PostTask( 197 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface);
209 FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread,
210 impl_thread_weak_ptr_, output_surface));
211 } 198 }
212 199
213 void ThreadProxy::ReleaseOutputSurface() { 200 void ThreadProxy::ReleaseOutputSurface() {
214 DCHECK(IsMainThread()); 201 DCHECK(IsMainThread());
215 DCHECK(layer_tree_host()->output_surface_lost()); 202 DCHECK(layer_tree_host()->output_surface_lost());
216 203
217 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 204 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
218 CompletionEvent completion; 205 CompletionEvent completion;
219 Proxy::ImplThreadTaskRunner()->PostTask( 206 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion);
220 FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread,
221 impl_thread_weak_ptr_, &completion));
222 completion.Wait(); 207 completion.Wait();
223 } 208 }
224 209
225 void ThreadProxy::DidInitializeOutputSurface( 210 void ThreadProxy::DidInitializeOutputSurface(
226 bool success, 211 bool success,
227 const RendererCapabilities& capabilities) { 212 const RendererCapabilities& capabilities) {
228 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); 213 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface");
229 DCHECK(IsMainThread()); 214 DCHECK(IsMainThread());
230 215
231 if (!success) { 216 if (!success) {
232 layer_tree_host()->DidFailToInitializeOutputSurface(); 217 layer_tree_host()->DidFailToInitializeOutputSurface();
233 return; 218 return;
234 } 219 }
235 main().renderer_capabilities_main_thread_copy = capabilities; 220 main().renderer_capabilities_main_thread_copy = capabilities;
236 layer_tree_host()->DidInitializeOutputSurface(); 221 layer_tree_host()->DidInitializeOutputSurface();
237 } 222 }
238 223
239 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( 224 void ThreadProxy::SetRendererCapabilitiesMainCopy(
240 const RendererCapabilities& capabilities) { 225 const RendererCapabilities& capabilities) {
241 main().renderer_capabilities_main_thread_copy = capabilities; 226 main().renderer_capabilities_main_thread_copy = capabilities;
242 } 227 }
243 228
244 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( 229 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded(
245 CommitPipelineStage required_stage) { 230 CommitPipelineStage required_stage) {
246 DCHECK(IsMainThread()); 231 DCHECK(IsMainThread());
247 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); 232 DCHECK_NE(NO_PIPELINE_STAGE, required_stage);
248 bool already_posted = 233 bool already_posted =
249 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; 234 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE;
250 main().max_requested_pipeline_stage = 235 main().max_requested_pipeline_stage =
251 std::max(main().max_requested_pipeline_stage, required_stage); 236 std::max(main().max_requested_pipeline_stage, required_stage);
252 if (already_posted) 237 if (already_posted)
253 return false; 238 return false;
254 Proxy::ImplThreadTaskRunner()->PostTask( 239 main().channel_main->SetNeedsCommitOnImpl();
255 FROM_HERE,
256 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread,
257 impl_thread_weak_ptr_));
258 return true; 240 return true;
259 } 241 }
260 242
243 void ThreadProxy::SetNeedsCommitOnImpl() {
244 SetNeedsCommitOnImplThread();
245 }
246
261 void ThreadProxy::DidCompletePageScaleAnimation() { 247 void ThreadProxy::DidCompletePageScaleAnimation() {
262 DCHECK(IsMainThread()); 248 DCHECK(IsMainThread());
263 layer_tree_host()->DidCompletePageScaleAnimation(); 249 layer_tree_host()->DidCompletePageScaleAnimation();
264 } 250 }
265 251
266 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { 252 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const {
267 DCHECK(IsMainThread()); 253 DCHECK(IsMainThread());
268 DCHECK(!layer_tree_host()->output_surface_lost()); 254 DCHECK(!layer_tree_host()->output_surface_lost());
269 return main().renderer_capabilities_main_thread_copy; 255 return main().renderer_capabilities_main_thread_copy;
270 } 256 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return; 288 return;
303 } 289 }
304 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { 290 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) {
305 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", 291 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit",
306 TRACE_EVENT_SCOPE_THREAD); 292 TRACE_EVENT_SCOPE_THREAD);
307 } 293 }
308 } 294 }
309 295
310 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { 296 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() {
311 DCHECK(IsImplThread()); 297 DCHECK(IsImplThread());
312 Proxy::MainThreadTaskRunner()->PostTask( 298 impl().channel_impl->SetRendererCapabilitiesMainCopy(
313 FROM_HERE, 299 impl()
314 base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, 300 .layer_tree_host_impl->GetRendererCapabilities()
315 main_thread_weak_ptr_, 301 .MainThreadCapabilities());
316 impl()
317 .layer_tree_host_impl->GetRendererCapabilities()
318 .MainThreadCapabilities()));
319 } 302 }
320 303
321 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { 304 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() {
322 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); 305 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread");
323 DCHECK(IsImplThread()); 306 DCHECK(IsImplThread());
324 Proxy::MainThreadTaskRunner()->PostTask( 307 impl().channel_impl->DidLoseOutputSurface();
325 FROM_HERE,
326 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_));
327 impl().scheduler->DidLoseOutputSurface(); 308 impl().scheduler->DidLoseOutputSurface();
328 } 309 }
329 310
330 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, 311 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase,
331 base::TimeDelta interval) { 312 base::TimeDelta interval) {
332 impl().scheduler->CommitVSyncParameters(timebase, interval); 313 impl().scheduler->CommitVSyncParameters(timebase, interval);
333 } 314 }
334 315
335 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 316 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
336 impl().scheduler->SetEstimatedParentDrawTime(draw_time); 317 impl().scheduler->SetEstimatedParentDrawTime(draw_time);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // In tests the layer tree is destroyed after the scheduler is. 383 // In tests the layer tree is destroyed after the scheduler is.
403 if (impl().scheduler) 384 if (impl().scheduler)
404 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); 385 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames);
405 } 386 }
406 387
407 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( 388 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
408 scoped_ptr<AnimationEventsVector> events) { 389 scoped_ptr<AnimationEventsVector> events) {
409 TRACE_EVENT0("cc", 390 TRACE_EVENT0("cc",
410 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); 391 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread");
411 DCHECK(IsImplThread()); 392 DCHECK(IsImplThread());
412 Proxy::MainThreadTaskRunner()->PostTask( 393 impl().channel_impl->SetAnimationEvents(events.Pass());
413 FROM_HERE,
414 base::Bind(&ThreadProxy::SetAnimationEvents,
415 main_thread_weak_ptr_,
416 base::Passed(&events)));
417 } 394 }
418 395
419 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } 396 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; }
420 397
421 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { 398 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
422 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); 399 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw");
423 DCHECK(IsMainThread()); 400 DCHECK(IsMainThread());
424 Proxy::ImplThreadTaskRunner()->PostTask( 401 main().channel_main->SetNeedsRedrawOnImpl(damage_rect);
425 FROM_HERE, 402 }
426 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, 403
427 impl_thread_weak_ptr_, 404 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {
428 damage_rect)); 405 DCHECK(IsImplThread());
406 SetNeedsRedrawRectOnImplThread(damage_rect);
429 } 407 }
430 408
431 void ThreadProxy::SetNextCommitWaitsForActivation() { 409 void ThreadProxy::SetNextCommitWaitsForActivation() {
432 DCHECK(IsMainThread()); 410 DCHECK(IsMainThread());
433 DCHECK(!blocked_main().main_thread_inside_commit); 411 DCHECK(!blocked_main().main_thread_inside_commit);
434 blocked_main().commit_waits_for_activation = true; 412 blocked_main().commit_waits_for_activation = true;
435 } 413 }
436 414
437 void ThreadProxy::SetDeferCommits(bool defer_commits) { 415 void ThreadProxy::SetDeferCommits(bool defer_commits) {
438 DCHECK(IsMainThread()); 416 DCHECK(IsMainThread());
439 if (main().defer_commits == defer_commits) 417 if (main().defer_commits == defer_commits)
440 return; 418 return;
441 419
442 main().defer_commits = defer_commits; 420 main().defer_commits = defer_commits;
443 if (main().defer_commits) 421 if (main().defer_commits)
444 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 422 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
445 else 423 else
446 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 424 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
447 425
448 Proxy::ImplThreadTaskRunner()->PostTask( 426 main().channel_main->SetDeferCommitsOnImpl(defer_commits);
449 FROM_HERE,
450 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread,
451 impl_thread_weak_ptr_,
452 defer_commits));
453 } 427 }
454 428
455 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { 429 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) const {
456 DCHECK(IsImplThread()); 430 DCHECK(IsImplThread());
457 impl().scheduler->SetDeferCommits(defer_commits); 431 impl().scheduler->SetDeferCommits(defer_commits);
458 } 432 }
459 433
460 bool ThreadProxy::CommitRequested() const { 434 bool ThreadProxy::CommitRequested() const {
461 DCHECK(IsMainThread()); 435 DCHECK(IsMainThread());
462 // TODO(skyostil): Split this into something like CommitRequested() and 436 // TODO(skyostil): Split this into something like CommitRequested() and
463 // CommitInProgress(). 437 // CommitInProgress().
464 return main().current_pipeline_stage != NO_PIPELINE_STAGE || 438 return main().current_pipeline_stage != NO_PIPELINE_STAGE ||
465 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; 439 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE;
(...skipping 22 matching lines...) Expand all
488 } 462 }
489 463
490 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { 464 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) {
491 DCHECK(IsImplThread()); 465 DCHECK(IsImplThread());
492 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); 466 impl().layer_tree_host_impl->SetViewportDamage(damage_rect);
493 SetNeedsRedrawOnImplThread(); 467 SetNeedsRedrawOnImplThread();
494 } 468 }
495 469
496 void ThreadProxy::MainThreadHasStoppedFlinging() { 470 void ThreadProxy::MainThreadHasStoppedFlinging() {
497 DCHECK(IsMainThread()); 471 DCHECK(IsMainThread());
498 Proxy::ImplThreadTaskRunner()->PostTask( 472 main().channel_main->MainThreadHasStoppedFlingingOnImpl();
499 FROM_HERE,
500 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread,
501 impl_thread_weak_ptr_));
502 } 473 }
503 474
504 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { 475 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() {
505 DCHECK(IsImplThread()); 476 DCHECK(IsImplThread());
506 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); 477 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging();
507 } 478 }
508 479
509 void ThreadProxy::NotifyInputThrottledUntilCommit() { 480 void ThreadProxy::NotifyInputThrottledUntilCommit() {
510 DCHECK(IsMainThread()); 481 DCHECK(IsMainThread());
511 Proxy::ImplThreadTaskRunner()->PostTask( 482 main().channel_main->SetInputThrottledUntilCommitOnImpl(true);
512 FROM_HERE,
513 base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread,
514 impl_thread_weak_ptr_,
515 true));
516 } 483 }
517 484
518 void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { 485 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {
519 DCHECK(IsImplThread()); 486 DCHECK(IsImplThread());
520 if (is_throttled == impl().input_throttled_until_commit) 487 if (is_throttled == impl().input_throttled_until_commit)
521 return; 488 return;
522 impl().input_throttled_until_commit = is_throttled; 489 impl().input_throttled_until_commit = is_throttled;
523 RenewTreePriority(); 490 RenewTreePriority();
524 } 491 }
525 492
526 LayerTreeHost* ThreadProxy::layer_tree_host() { 493 LayerTreeHost* ThreadProxy::layer_tree_host() {
527 return blocked_main().layer_tree_host; 494 return blocked_main().layer_tree_host;
528 } 495 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 TRACE_EVENT0("cc", "ThreadProxy::Stop"); 551 TRACE_EVENT0("cc", "ThreadProxy::Stop");
585 DCHECK(IsMainThread()); 552 DCHECK(IsMainThread());
586 DCHECK(main().started); 553 DCHECK(main().started);
587 554
588 // Synchronously finishes pending GL operations and deletes the impl. 555 // Synchronously finishes pending GL operations and deletes the impl.
589 // The two steps are done as separate post tasks, so that tasks posted 556 // The two steps are done as separate post tasks, so that tasks posted
590 // by the GL implementation due to the Finish can be executed by the 557 // by the GL implementation due to the Finish can be executed by the
591 // renderer before shutting it down. 558 // renderer before shutting it down.
592 { 559 {
593 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 560 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
594
595 CompletionEvent completion; 561 CompletionEvent completion;
596 Proxy::ImplThreadTaskRunner()->PostTask( 562 main().channel_main->FinishGLOnImpl(&completion);
597 FROM_HERE,
598 base::Bind(&ThreadProxy::FinishGLOnImplThread,
599 impl_thread_weak_ptr_,
600 &completion));
601 completion.Wait(); 563 completion.Wait();
602 } 564 }
603 { 565 {
604 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 566 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
605 567
606 CompletionEvent completion; 568 CompletionEvent completion;
607 Proxy::ImplThreadTaskRunner()->PostTask( 569 Proxy::ImplThreadTaskRunner()->PostTask(
608 FROM_HERE, 570 FROM_HERE,
609 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, 571 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread,
610 impl_thread_weak_ptr_, 572 impl_thread_weak_ptr_,
611 &completion)); 573 &completion));
612 completion.Wait(); 574 completion.Wait();
613 } 575 }
614 576
615 main().weak_factory.InvalidateWeakPtrs(); 577 main().weak_factory.InvalidateWeakPtrs();
616 blocked_main().layer_tree_host = NULL; 578 blocked_main().layer_tree_host = NULL;
617 main().started = false; 579 main().started = false;
618 } 580 }
619 581
620 bool ThreadProxy::SupportsImplScrolling() const { 582 bool ThreadProxy::SupportsImplScrolling() const {
621 return true; 583 return true;
622 } 584 }
623 585
624 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { 586 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) {
625 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); 587 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread");
626 DCHECK(IsImplThread()); 588 DCHECK(IsImplThread());
627 impl().layer_tree_host_impl->FinishAllRendering(); 589 impl().layer_tree_host_impl->FinishAllRendering();
628 completion->Signal(); 590 completion->Signal();
629 } 591 }
630 592
631 void ThreadProxy::ScheduledActionSendBeginMainFrame() { 593 void ThreadProxy::ScheduledActionSendBeginMainFrame() {
632 unsigned int begin_frame_id = nextBeginFrameId++; 594 unsigned int begin_frame_id = nextBeginFrameId++;
633 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( 595 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task(
634 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); 596 benchmark_instrumentation::kSendBeginFrame, begin_frame_id);
635 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( 597 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state(
636 new BeginMainFrameAndCommitState); 598 new BeginMainFrameAndCommitState);
637 begin_main_frame_state->begin_frame_id = begin_frame_id; 599 begin_main_frame_state->begin_frame_id = begin_frame_id;
638 begin_main_frame_state->begin_frame_args = 600 begin_main_frame_state->begin_frame_args =
639 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); 601 impl().layer_tree_host_impl->CurrentBeginFrameArgs();
640 begin_main_frame_state->scroll_info = 602 begin_main_frame_state->scroll_info =
641 impl().layer_tree_host_impl->ProcessScrollDeltas(); 603 impl().layer_tree_host_impl->ProcessScrollDeltas();
642 begin_main_frame_state->memory_allocation_limit_bytes = 604 begin_main_frame_state->memory_allocation_limit_bytes =
643 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); 605 impl().layer_tree_host_impl->memory_allocation_limit_bytes();
644 begin_main_frame_state->evicted_ui_resources = 606 begin_main_frame_state->evicted_ui_resources =
645 impl().layer_tree_host_impl->EvictedUIResourcesExist(); 607 impl().layer_tree_host_impl->EvictedUIResourcesExist();
646 // TODO(vmpstr): This needs to be fixed if 608 // TODO(vmpstr): This needs to be fixed if
647 // main_frame_before_activation_enabled is set, since we might run this code 609 // main_frame_before_activation_enabled is set, since we might run this code
648 // twice before recording a duration. crbug.com/469824 610 // twice before recording a duration. crbug.com/469824
649 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; 611 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args;
650 Proxy::MainThreadTaskRunner()->PostTask( 612 impl().channel_impl->BeginMainFrame(begin_main_frame_state.Pass());
651 FROM_HERE,
652 base::Bind(&ThreadProxy::BeginMainFrame,
653 main_thread_weak_ptr_,
654 base::Passed(&begin_main_frame_state)));
655 devtools_instrumentation::DidRequestMainThreadFrame( 613 devtools_instrumentation::DidRequestMainThreadFrame(
656 impl().layer_tree_host_id); 614 impl().layer_tree_host_id);
657 } 615 }
658 616
659 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { 617 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() {
660 Proxy::MainThreadTaskRunner()->PostTask( 618 impl().channel_impl->BeginMainFrameNotExpectedSoon();
661 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon,
662 main_thread_weak_ptr_));
663 } 619 }
664 620
665 void ThreadProxy::BeginMainFrame( 621 void ThreadProxy::BeginMainFrame(
666 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 622 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
667 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( 623 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task(
668 benchmark_instrumentation::kDoBeginFrame, 624 benchmark_instrumentation::kDoBeginFrame,
669 begin_main_frame_state->begin_frame_id); 625 begin_main_frame_state->begin_frame_id);
670 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); 626 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame");
671 DCHECK(IsMainThread()); 627 DCHECK(IsMainThread());
672 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); 628 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage);
673 629
674 if (main().defer_commits) { 630 if (main().defer_commits) {
675 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", 631 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit",
676 TRACE_EVENT_SCOPE_THREAD); 632 TRACE_EVENT_SCOPE_THREAD);
677 Proxy::ImplThreadTaskRunner()->PostTask( 633 main().channel_main->BeginMainFrameAbortedOnImpl(
678 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 634 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT);
679 impl_thread_weak_ptr_,
680 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT));
681 return; 635 return;
682 } 636 }
683 637
684 // If the commit finishes, LayerTreeHost will transfer its swap promises to 638 // If the commit finishes, LayerTreeHost will transfer its swap promises to
685 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the 639 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the
686 // remaining swap promises. 640 // remaining swap promises.
687 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); 641 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host());
688 642
689 main().final_pipeline_stage = main().max_requested_pipeline_stage; 643 main().final_pipeline_stage = main().max_requested_pipeline_stage;
690 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; 644 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE;
691 645
692 if (!layer_tree_host()->visible()) { 646 if (!layer_tree_host()->visible()) {
693 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 647 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
694 Proxy::ImplThreadTaskRunner()->PostTask( 648 main().channel_main->BeginMainFrameAbortedOnImpl(
695 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 649 CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
696 impl_thread_weak_ptr_,
697 CommitEarlyOutReason::ABORTED_NOT_VISIBLE));
698 return; 650 return;
699 } 651 }
700 652
701 if (layer_tree_host()->output_surface_lost()) { 653 if (layer_tree_host()->output_surface_lost()) {
702 TRACE_EVENT_INSTANT0( 654 TRACE_EVENT_INSTANT0(
703 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); 655 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
704 Proxy::ImplThreadTaskRunner()->PostTask( 656 main().channel_main->BeginMainFrameAbortedOnImpl(
705 FROM_HERE, 657 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
706 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
707 impl_thread_weak_ptr_,
708 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST));
709 return; 658 return;
710 } 659 }
711 660
712 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; 661 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE;
713 662
714 layer_tree_host()->ApplyScrollAndScale( 663 layer_tree_host()->ApplyScrollAndScale(
715 begin_main_frame_state->scroll_info.get()); 664 begin_main_frame_state->scroll_info.get());
716 665
717 layer_tree_host()->WillBeginMainFrame(); 666 layer_tree_host()->WillBeginMainFrame();
718 667
(...skipping 18 matching lines...) Expand all
737 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; 686 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE;
738 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); 687 bool updated = should_update_layers && layer_tree_host()->UpdateLayers();
739 688
740 layer_tree_host()->WillCommit(); 689 layer_tree_host()->WillCommit();
741 devtools_instrumentation::ScopedCommitTrace commit_task( 690 devtools_instrumentation::ScopedCommitTrace commit_task(
742 layer_tree_host()->id()); 691 layer_tree_host()->id());
743 692
744 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; 693 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE;
745 if (!updated && can_cancel_this_commit) { 694 if (!updated && can_cancel_this_commit) {
746 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); 695 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD);
747 Proxy::ImplThreadTaskRunner()->PostTask( 696 main().channel_main->BeginMainFrameAbortedOnImpl(
748 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 697 CommitEarlyOutReason::FINISHED_NO_UPDATES);
749 impl_thread_weak_ptr_,
750 CommitEarlyOutReason::FINISHED_NO_UPDATES));
751 698
752 // Although the commit is internally aborted, this is because it has been 699 // Although the commit is internally aborted, this is because it has been
753 // detected to be a no-op. From the perspective of an embedder, this commit 700 // detected to be a no-op. From the perspective of an embedder, this commit
754 // went through, and input should no longer be throttled, etc. 701 // went through, and input should no longer be throttled, etc.
755 main().current_pipeline_stage = NO_PIPELINE_STAGE; 702 main().current_pipeline_stage = NO_PIPELINE_STAGE;
756 layer_tree_host()->CommitComplete(); 703 layer_tree_host()->CommitComplete();
757 layer_tree_host()->DidBeginMainFrame(); 704 layer_tree_host()->DidBeginMainFrame();
758 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); 705 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE);
759 return; 706 return;
760 } 707 }
761 708
762 // Notify the impl thread that the main thread is ready to commit. This will 709 // Notify the impl thread that the main thread is ready to commit. This will
763 // begin the commit process, which is blocking from the main thread's 710 // begin the commit process, which is blocking from the main thread's
764 // point of view, but asynchronously performed on the impl thread, 711 // point of view, but asynchronously performed on the impl thread,
765 // coordinated by the Scheduler. 712 // coordinated by the Scheduler.
766 { 713 {
767 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); 714 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit");
768 715
769 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 716 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
770 717
771 // This CapturePostTasks should be destroyed before CommitComplete() is 718 // This CapturePostTasks should be destroyed before CommitComplete() is
772 // called since that goes out to the embedder, and we want the embedder 719 // called since that goes out to the embedder, and we want the embedder
773 // to receive its callbacks before that. 720 // to receive its callbacks before that.
774 BlockingTaskRunner::CapturePostTasks blocked( 721 BlockingTaskRunner::CapturePostTasks blocked(
775 blocking_main_thread_task_runner()); 722 blocking_main_thread_task_runner());
776 723
777 CompletionEvent completion; 724 CompletionEvent completion;
778 Proxy::ImplThreadTaskRunner()->PostTask( 725 main().channel_main->StartCommitOnImpl(&completion);
779 FROM_HERE, base::Bind(&ThreadProxy::StartCommitOnImplThread,
780 impl_thread_weak_ptr_, &completion));
781 completion.Wait(); 726 completion.Wait();
782 } 727 }
783 728
784 main().current_pipeline_stage = NO_PIPELINE_STAGE; 729 main().current_pipeline_stage = NO_PIPELINE_STAGE;
785 layer_tree_host()->CommitComplete(); 730 layer_tree_host()->CommitComplete();
786 layer_tree_host()->DidBeginMainFrame(); 731 layer_tree_host()->DidBeginMainFrame();
787 } 732 }
788 733
789 void ThreadProxy::BeginMainFrameNotExpectedSoon() { 734 void ThreadProxy::BeginMainFrameNotExpectedSoon() {
790 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); 735 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon");
791 DCHECK(IsMainThread()); 736 DCHECK(IsMainThread());
792 layer_tree_host()->BeginMainFrameNotExpectedSoon(); 737 layer_tree_host()->BeginMainFrameNotExpectedSoon();
793 } 738 }
794 739
795 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion) { 740 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion) {
796 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); 741 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread");
797 DCHECK(!impl().commit_completion_event); 742 DCHECK(!impl().commit_completion_event);
798 DCHECK(IsImplThread() && IsMainThreadBlocked()); 743 DCHECK(IsImplThread() && IsMainThreadBlocked());
799 DCHECK(impl().scheduler); 744 DCHECK(impl().scheduler);
800 DCHECK(impl().scheduler->CommitPending()); 745 DCHECK(impl().scheduler->CommitPending());
801 746
802 if (!impl().layer_tree_host_impl) { 747 if (!impl().layer_tree_host_impl) {
803 TRACE_EVENT_INSTANT0( 748 TRACE_EVENT_INSTANT0(
804 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); 749 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD);
805 completion->Signal(); 750 completion->Signal();
806 return; 751 return;
807 } 752 }
808 753
809 // Ideally, we should inform to impl thread when BeginMainFrame is started. 754 // Ideally, we should inform to impl thread when BeginMainFrame is started.
810 // But, we can avoid a PostTask in here. 755 // But, we can avoid a PostTask in here.
811 impl().scheduler->NotifyBeginMainFrameStarted(); 756 impl().scheduler->NotifyBeginMainFrameStarted();
812 impl().commit_completion_event = completion; 757 impl().commit_completion_event = completion;
813 impl().scheduler->NotifyReadyToCommit(); 758 impl().scheduler->NotifyReadyToCommit();
814 } 759 }
815 760
816 void ThreadProxy::BeginMainFrameAbortedOnImplThread( 761 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) {
817 CommitEarlyOutReason reason) {
818 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", 762 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason",
819 CommitEarlyOutReasonToString(reason)); 763 CommitEarlyOutReasonToString(reason));
820 DCHECK(IsImplThread()); 764 DCHECK(IsImplThread());
821 DCHECK(impl().scheduler); 765 DCHECK(impl().scheduler);
822 DCHECK(impl().scheduler->CommitPending()); 766 DCHECK(impl().scheduler->CommitPending());
823 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 767 DCHECK(!impl().layer_tree_host_impl->pending_tree());
824 768
825 if (CommitEarlyOutHandledCommit(reason)) { 769 if (CommitEarlyOutHandledCommit(reason)) {
826 SetInputThrottledUntilCommitOnImplThread(false); 770 SetInputThrottledUntilCommitOnImpl(false);
827 impl().last_processed_begin_main_frame_args = 771 impl().last_processed_begin_main_frame_args =
828 impl().last_begin_main_frame_args; 772 impl().last_begin_main_frame_args;
829 } 773 }
830 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); 774 impl().layer_tree_host_impl->BeginMainFrameAborted(reason);
831 impl().scheduler->BeginMainFrameAborted(reason); 775 impl().scheduler->BeginMainFrameAborted(reason);
832 } 776 }
833 777
834 void ThreadProxy::ScheduledActionAnimate() { 778 void ThreadProxy::ScheduledActionAnimate() {
835 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); 779 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
836 DCHECK(IsImplThread()); 780 DCHECK(IsImplThread());
(...skipping 16 matching lines...) Expand all
853 bool hold_commit = blocked_main().commit_waits_for_activation; 797 bool hold_commit = blocked_main().commit_waits_for_activation;
854 blocked_main().commit_waits_for_activation = false; 798 blocked_main().commit_waits_for_activation = false;
855 799
856 if (hold_commit) { 800 if (hold_commit) {
857 // For some layer types in impl-side painting, the commit is held until 801 // For some layer types in impl-side painting, the commit is held until
858 // the sync tree is activated. It's also possible that the 802 // the sync tree is activated. It's also possible that the
859 // sync tree has already activated if there was no work to be done. 803 // sync tree has already activated if there was no work to be done.
860 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 804 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
861 impl().completion_event_for_commit_held_on_tree_activation = 805 impl().completion_event_for_commit_held_on_tree_activation =
862 impl().commit_completion_event; 806 impl().commit_completion_event;
863 impl().commit_completion_event = NULL; 807 impl().commit_completion_event = nullptr;
864 } else { 808 } else {
865 impl().commit_completion_event->Signal(); 809 impl().commit_completion_event->Signal();
866 impl().commit_completion_event = NULL; 810 impl().commit_completion_event = nullptr;
867 } 811 }
868 812
869 impl().scheduler->DidCommit(); 813 impl().scheduler->DidCommit();
870 814
871 // Delay this step until afer the main thread has been released as it's 815 // Delay this step until afer the main thread has been released as it's
872 // often a good bit of work to update the tree and prepare the new frame. 816 // often a good bit of work to update the tree and prepare the new frame.
873 impl().layer_tree_host_impl->CommitComplete(); 817 impl().layer_tree_host_impl->CommitComplete();
874 818
875 SetInputThrottledUntilCommitOnImplThread(false); 819 SetInputThrottledUntilCommitOnImpl(false);
876 820
877 impl().next_frame_is_newly_committed_frame = true; 821 impl().next_frame_is_newly_committed_frame = true;
878 } 822 }
879 823
880 void ThreadProxy::ScheduledActionActivateSyncTree() { 824 void ThreadProxy::ScheduledActionActivateSyncTree() {
881 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); 825 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree");
882 DCHECK(IsImplThread()); 826 DCHECK(IsImplThread());
883 impl().layer_tree_host_impl->ActivateSyncTree(); 827 impl().layer_tree_host_impl->ActivateSyncTree();
884 } 828 }
885 829
886 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { 830 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
887 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); 831 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation");
888 DCHECK(IsImplThread()); 832 DCHECK(IsImplThread());
889 Proxy::MainThreadTaskRunner()->PostTask( 833 impl().channel_impl->RequestNewOutputSurface();
890 FROM_HERE,
891 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_));
892 } 834 }
893 835
894 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { 836 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) {
895 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 837 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
896 DrawResult result; 838 DrawResult result;
897 839
898 DCHECK(IsImplThread()); 840 DCHECK(IsImplThread());
899 DCHECK(impl().layer_tree_host_impl.get()); 841 DCHECK(impl().layer_tree_host_impl.get());
900 842
901 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 843 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 879
938 bool start_ready_animations = draw_frame; 880 bool start_ready_animations = draw_frame;
939 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); 881 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations);
940 882
941 if (draw_frame) 883 if (draw_frame)
942 impl().layer_tree_host_impl->SwapBuffers(frame); 884 impl().layer_tree_host_impl->SwapBuffers(frame);
943 885
944 // Tell the main thread that the the newly-commited frame was drawn. 886 // Tell the main thread that the the newly-commited frame was drawn.
945 if (impl().next_frame_is_newly_committed_frame) { 887 if (impl().next_frame_is_newly_committed_frame) {
946 impl().next_frame_is_newly_committed_frame = false; 888 impl().next_frame_is_newly_committed_frame = false;
947 Proxy::MainThreadTaskRunner()->PostTask( 889 impl().channel_impl->DidCommitAndDrawFrame();
948 FROM_HERE,
949 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
950 } 890 }
951 891
952 DCHECK_NE(INVALID_RESULT, result); 892 DCHECK_NE(INVALID_RESULT, result);
953 return result; 893 return result;
954 } 894 }
955 895
956 void ThreadProxy::ScheduledActionPrepareTiles() { 896 void ThreadProxy::ScheduledActionPrepareTiles() {
957 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); 897 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles");
958 impl().layer_tree_host_impl->PrepareTiles(); 898 impl().layer_tree_host_impl->PrepareTiles();
959 } 899 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 this, scheduler_settings, impl().layer_tree_host_id, 973 this, scheduler_settings, impl().layer_tree_host_id,
1034 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), 974 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(),
1035 compositor_timing_history.Pass()); 975 compositor_timing_history.Pass());
1036 976
1037 DCHECK_EQ(impl().scheduler->visible(), 977 DCHECK_EQ(impl().scheduler->visible(),
1038 impl().layer_tree_host_impl->visible()); 978 impl().layer_tree_host_impl->visible());
1039 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 979 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1040 completion->Signal(); 980 completion->Signal();
1041 } 981 }
1042 982
1043 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 983 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) {
1044 OutputSurface* output_surface) {
1045 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); 984 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
1046 DCHECK(IsImplThread()); 985 DCHECK(IsImplThread());
1047 986
1048 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); 987 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get();
1049 bool success = host_impl->InitializeRenderer(output_surface); 988 bool success = host_impl->InitializeRenderer(output_surface);
1050 RendererCapabilities capabilities; 989 RendererCapabilities capabilities;
1051 if (success) { 990 if (success) {
1052 capabilities = 991 capabilities =
1053 host_impl->GetRendererCapabilities().MainThreadCapabilities(); 992 host_impl->GetRendererCapabilities().MainThreadCapabilities();
1054 } 993 }
1055 994
1056 Proxy::MainThreadTaskRunner()->PostTask( 995 impl().channel_impl->DidInitializeOutputSurface(success, capabilities);
1057 FROM_HERE,
1058 base::Bind(&ThreadProxy::DidInitializeOutputSurface,
1059 main_thread_weak_ptr_,
1060 success,
1061 capabilities));
1062 996
1063 if (success) 997 if (success)
1064 impl().scheduler->DidCreateAndInitializeOutputSurface(); 998 impl().scheduler->DidCreateAndInitializeOutputSurface();
1065 } 999 }
1066 1000
1067 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( 1001 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) {
1068 CompletionEvent* completion) {
1069 DCHECK(IsImplThread()); 1002 DCHECK(IsImplThread());
1070 1003
1071 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call 1004 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call
1072 // LayerTreeHost::DidLoseOutputSurface since it already knows. 1005 // LayerTreeHost::DidLoseOutputSurface since it already knows.
1073 impl().scheduler->DidLoseOutputSurface(); 1006 impl().scheduler->DidLoseOutputSurface();
1074 impl().layer_tree_host_impl->ReleaseOutputSurface(); 1007 impl().layer_tree_host_impl->ReleaseOutputSurface();
1075 completion->Signal(); 1008 completion->Signal();
1076 } 1009 }
1077 1010
1078 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { 1011 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) {
1079 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); 1012 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread");
1080 DCHECK(IsImplThread()); 1013 DCHECK(IsImplThread());
1081 if (impl().layer_tree_host_impl->output_surface()) { 1014 if (impl().layer_tree_host_impl->output_surface()) {
1082 ContextProvider* context_provider = 1015 ContextProvider* context_provider =
1083 impl().layer_tree_host_impl->output_surface()->context_provider(); 1016 impl().layer_tree_host_impl->output_surface()->context_provider();
1084 if (context_provider) 1017 if (context_provider)
1085 context_provider->ContextGL()->Finish(); 1018 context_provider->ContextGL()->Finish();
1086 } 1019 }
1087 completion->Signal(); 1020 completion->Signal();
1088 } 1021 }
1089 1022
1090 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1023 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1091 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1024 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1092 DCHECK(IsImplThread()); 1025 DCHECK(IsImplThread());
1093 DCHECK(IsMainThreadBlocked()); 1026 DCHECK(IsMainThreadBlocked());
1094 impl().scheduler = nullptr; 1027 impl().scheduler = nullptr;
1095 impl().external_begin_frame_source = nullptr; 1028 impl().external_begin_frame_source = nullptr;
1096 impl().layer_tree_host_impl = nullptr; 1029 impl().layer_tree_host_impl = nullptr;
1097 impl().weak_factory.InvalidateWeakPtrs(); 1030 impl().weak_factory.InvalidateWeakPtrs();
1098 // We need to explicitly shutdown the notifier to destroy any weakptrs it is 1031 // We need to explicitly shutdown the notifier to destroy any weakptrs it is
1099 // holding while still on the compositor thread. This also ensures any 1032 // holding while still on the compositor thread. This also ensures any
1100 // callbacks holding a ThreadProxy pointer are cancelled. 1033 // callbacks holding a ThreadProxy pointer are cancelled.
1101 impl().smoothness_priority_expiration_notifier.Shutdown(); 1034 impl().smoothness_priority_expiration_notifier.Shutdown();
1102 completion->Signal(); 1035 completion->Signal();
1103 } 1036 }
1104 1037
1105 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState()
1106 : memory_allocation_limit_bytes(0),
1107 evicted_ui_resources(false) {}
1108
1109 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {}
1110
1111 bool ThreadProxy::MainFrameWillHappenForTesting() { 1038 bool ThreadProxy::MainFrameWillHappenForTesting() {
1112 DCHECK(IsMainThread()); 1039 DCHECK(IsMainThread());
1113 CompletionEvent completion;
1114 bool main_frame_will_happen = false; 1040 bool main_frame_will_happen = false;
1115 { 1041 {
1116 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 1042 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
1117 Proxy::ImplThreadTaskRunner()->PostTask( 1043 CompletionEvent completion;
1118 FROM_HERE, 1044 main().channel_main->MainFrameWillHappenOnImplForTesting(
1119 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, 1045 &completion, &main_frame_will_happen);
1120 impl_thread_weak_ptr_,
1121 &completion,
1122 &main_frame_will_happen));
1123 completion.Wait(); 1046 completion.Wait();
1124 } 1047 }
1125 return main_frame_will_happen; 1048 return main_frame_will_happen;
1126 } 1049 }
1127 1050
1128 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { 1051 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) {
1129 NOTREACHED() << "Only used by SingleThreadProxy"; 1052 NOTREACHED() << "Only used by SingleThreadProxy";
1130 } 1053 }
1131 1054
1132 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( 1055 void ThreadProxy::MainFrameWillHappenOnImplForTesting(
1133 CompletionEvent* completion, 1056 CompletionEvent* completion,
1134 bool* main_frame_will_happen) { 1057 bool* main_frame_will_happen) {
1135 DCHECK(IsImplThread()); 1058 DCHECK(IsImplThread());
1136 if (impl().layer_tree_host_impl->output_surface()) { 1059 if (impl().layer_tree_host_impl->output_surface()) {
1137 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); 1060 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen();
1138 } else { 1061 } else {
1139 *main_frame_will_happen = false; 1062 *main_frame_will_happen = false;
1140 } 1063 }
1141 completion->Signal(); 1064 completion->Signal();
1142 } 1065 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 } 1121 }
1199 1122
1200 void ThreadProxy::DidActivateSyncTree() { 1123 void ThreadProxy::DidActivateSyncTree() {
1201 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); 1124 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread");
1202 DCHECK(IsImplThread()); 1125 DCHECK(IsImplThread());
1203 1126
1204 if (impl().completion_event_for_commit_held_on_tree_activation) { 1127 if (impl().completion_event_for_commit_held_on_tree_activation) {
1205 TRACE_EVENT_INSTANT0( 1128 TRACE_EVENT_INSTANT0(
1206 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); 1129 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
1207 impl().completion_event_for_commit_held_on_tree_activation->Signal(); 1130 impl().completion_event_for_commit_held_on_tree_activation->Signal();
1208 impl().completion_event_for_commit_held_on_tree_activation = NULL; 1131 impl().completion_event_for_commit_held_on_tree_activation = nullptr;
1209 } 1132 }
1210 1133
1211 impl().last_processed_begin_main_frame_args = 1134 impl().last_processed_begin_main_frame_args =
1212 impl().last_begin_main_frame_args; 1135 impl().last_begin_main_frame_args;
1213 } 1136 }
1214 1137
1215 void ThreadProxy::WillPrepareTiles() { 1138 void ThreadProxy::WillPrepareTiles() {
1216 DCHECK(IsImplThread()); 1139 DCHECK(IsImplThread());
1217 impl().scheduler->WillPrepareTiles(); 1140 impl().scheduler->WillPrepareTiles();
1218 } 1141 }
1219 1142
1220 void ThreadProxy::DidPrepareTiles() { 1143 void ThreadProxy::DidPrepareTiles() {
1221 DCHECK(IsImplThread()); 1144 DCHECK(IsImplThread());
1222 impl().scheduler->DidPrepareTiles(); 1145 impl().scheduler->DidPrepareTiles();
1223 } 1146 }
1224 1147
1225 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 1148 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
1226 DCHECK(IsImplThread()); 1149 DCHECK(IsImplThread());
1227 Proxy::MainThreadTaskRunner()->PostTask( 1150 impl().channel_impl->DidCompletePageScaleAnimation();
1228 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation,
1229 main_thread_weak_ptr_));
1230 } 1151 }
1231 1152
1232 void ThreadProxy::OnDrawForOutputSurface() { 1153 void ThreadProxy::OnDrawForOutputSurface() {
1233 DCHECK(IsImplThread()); 1154 DCHECK(IsImplThread());
1234 impl().scheduler->OnDrawForOutputSurface(); 1155 impl().scheduler->OnDrawForOutputSurface();
1235 } 1156 }
1236 1157
1237 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, 1158 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints,
1238 TopControlsState current, 1159 TopControlsState current,
1239 bool animate) { 1160 bool animate) {
1240 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, 1161 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current,
1241 animate); 1162 animate);
1242 } 1163 }
1243 1164
1244 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, 1165 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints,
1245 TopControlsState current, 1166 TopControlsState current,
1246 bool animate) { 1167 bool animate) {
1247 DCHECK(IsImplThread()); 1168 DCHECK(IsImplThread());
1248 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( 1169 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState(
1249 constraints, current, animate); 1170 constraints, current, animate);
1250 } 1171 }
1251 1172
1252 void ThreadProxy::PostFrameTimingEventsOnImplThread( 1173 void ThreadProxy::PostFrameTimingEventsOnImplThread(
1253 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1174 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1254 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1175 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1255 DCHECK(IsImplThread()); 1176 DCHECK(IsImplThread());
1256 Proxy::MainThreadTaskRunner()->PostTask( 1177 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(),
1257 FROM_HERE, 1178 main_frame_events.Pass());
1258 base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_,
1259 base::Passed(composite_events.Pass()),
1260 base::Passed(main_frame_events.Pass())));
1261 } 1179 }
1262 1180
1263 void ThreadProxy::PostFrameTimingEvents( 1181 void ThreadProxy::PostFrameTimingEventsOnMain(
1264 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1182 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1265 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1183 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1266 DCHECK(IsMainThread()); 1184 DCHECK(IsMainThread());
1267 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1185 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
1268 main_frame_events.Pass()); 1186 main_frame_events.Pass());
1269 } 1187 }
1270 1188
1271 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { 1189 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() {
1272 return main_thread_weak_ptr_; 1190 return main_thread_weak_ptr_;
1273 } 1191 }
1274 1192
1275 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { 1193 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() {
1276 return impl_thread_weak_ptr_; 1194 return impl_thread_weak_ptr_;
1277 } 1195 }
1278 1196
1279 } // namespace cc 1197 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | cc/trees/threaded_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698