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

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

Issue 478703002: Remove cc::LayerTreeHostImpl::IsContextLost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ctx4
Patch Set: DoComposite draws even if context lost (fixed comments) Created 6 years, 4 months 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
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/single_thread_proxy.h" 5 #include "cc/trees/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/debug/benchmark_instrumentation.h" 9 #include "cc/debug/benchmark_instrumentation.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 SingleThreadProxy::SingleThreadProxy( 32 SingleThreadProxy::SingleThreadProxy(
33 LayerTreeHost* layer_tree_host, 33 LayerTreeHost* layer_tree_host,
34 LayerTreeHostSingleThreadClient* client, 34 LayerTreeHostSingleThreadClient* client,
35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner)
36 : Proxy(main_task_runner, NULL), 36 : Proxy(main_task_runner, NULL),
37 layer_tree_host_(layer_tree_host), 37 layer_tree_host_(layer_tree_host),
38 client_(client), 38 client_(client),
39 next_frame_is_newly_committed_frame_(false), 39 next_frame_is_newly_committed_frame_(false),
40 inside_draw_(false) { 40 inside_draw_(false),
41 weak_factory_(this) {
41 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 42 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
42 DCHECK(Proxy::IsMainThread()); 43 DCHECK(Proxy::IsMainThread());
43 DCHECK(layer_tree_host); 44 DCHECK(layer_tree_host);
44 45
45 // Impl-side painting not supported without threaded compositing. 46 // Impl-side painting not supported without threaded compositing.
46 CHECK(!layer_tree_host->settings().impl_side_painting) 47 CHECK(!layer_tree_host->settings().impl_side_painting)
47 << "Threaded compositing must be enabled to use impl-side painting."; 48 << "Threaded compositing must be enabled to use impl-side painting.";
48 } 49 }
49 50
50 void SingleThreadProxy::Start() { 51 void SingleThreadProxy::Start() {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 DCHECK(IsImplThread()); 310 DCHECK(IsImplThread());
310 renderer_capabilities_for_main_thread_ = 311 renderer_capabilities_for_main_thread_ =
311 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); 312 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities();
312 } 313 }
313 314
314 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { 315 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
315 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); 316 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread");
316 // Cause a commit so we can notice the lost context. 317 // Cause a commit so we can notice the lost context.
317 SetNeedsCommitOnImplThread(); 318 SetNeedsCommitOnImplThread();
318 client_->DidAbortSwapBuffers(); 319 client_->DidAbortSwapBuffers();
320 Proxy::MainThreadTaskRunner()->PostTask(
321 FROM_HERE,
322 base::Bind(&SingleThreadProxy::DidLoseOutputSurface,
323 weak_factory_.GetWeakPtr()));
324 }
325
326 void SingleThreadProxy::DidLoseOutputSurface() {
327 DCHECK(Proxy::IsMainThread());
328 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurface");
329
330 // The layer tree host will in turn schedule another commit.
331 layer_tree_host_->DidLoseOutputSurface();
319 } 332 }
320 333
321 void SingleThreadProxy::DidSwapBuffersOnImplThread() { 334 void SingleThreadProxy::DidSwapBuffersOnImplThread() {
322 client_->DidPostSwapBuffers(); 335 client_->DidPostSwapBuffers();
323 } 336 }
324 337
325 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { 338 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() {
326 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); 339 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread");
327 client_->DidCompleteSwapBuffers(); 340 client_->DidCompleteSwapBuffers();
328 } 341 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return layer_tree_host_impl_->visible() && 416 return layer_tree_host_impl_->visible() &&
404 layer_tree_host_impl_->CanDraw(); 417 layer_tree_host_impl_->CanDraw();
405 } 418 }
406 419
407 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { 420 void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
408 DCHECK(Proxy::IsImplThread()); 421 DCHECK(Proxy::IsImplThread());
409 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 422 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
410 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); 423 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
411 } 424 }
412 425
413 bool SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, 426 bool SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
dneto 2014/08/20 18:01:23 DoComposite still needs to be able to return a fal
danakj 2014/08/20 18:22:10 Ah, yes, we return false if not visible etc.
414 LayerTreeHostImpl::FrameData* frame) { 427 LayerTreeHostImpl::FrameData* frame) {
415 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); 428 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
416 DCHECK(!layer_tree_host_->output_surface_lost()); 429 DCHECK(!layer_tree_host_->output_surface_lost());
417 430
418 bool lost_output_surface = false;
419 { 431 {
420 DebugScopedSetImplThread impl(this); 432 DebugScopedSetImplThread impl(this);
421 base::AutoReset<bool> mark_inside(&inside_draw_, true); 433 base::AutoReset<bool> mark_inside(&inside_draw_, true);
422 434
423 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 435 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
424 // frame, so can only be used when such a frame is possible. Since 436 // frame, so can only be used when such a frame is possible. Since
425 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 437 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
426 // CanDraw() as well. 438 // CanDraw() as well.
427 if (!ShouldComposite()) { 439 if (!ShouldComposite()) {
428 UpdateBackgroundAnimateTicking(); 440 UpdateBackgroundAnimateTicking();
429 return false; 441 return false;
430 } 442 }
431 443
432 layer_tree_host_impl_->Animate( 444 layer_tree_host_impl_->Animate(
433 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); 445 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time);
434 UpdateBackgroundAnimateTicking(); 446 UpdateBackgroundAnimateTicking();
435 447
436 if (!layer_tree_host_impl_->IsContextLost()) { 448 (void)layer_tree_host_impl_->PrepareToDraw(frame);
danakj 2014/08/20 18:22:10 don't need (void) here
dneto 2014/08/20 19:15:20 Acknowledged.
437 layer_tree_host_impl_->PrepareToDraw(frame); 449 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
438 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); 450 layer_tree_host_impl_->DidDrawAllLayers(*frame);
439 layer_tree_host_impl_->DidDrawAllLayers(*frame);
440 }
441 lost_output_surface = layer_tree_host_impl_->IsContextLost();
442 451
443 bool start_ready_animations = true; 452 bool start_ready_animations = true;
444 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 453 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
445 454
446 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 455 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
447 } 456 }
448 457
449 if (lost_output_surface) {
450 layer_tree_host_->DidLoseOutputSurface();
451 return false;
452 }
453
454 return true; 458 return true;
455 } 459 }
456 460
457 void SingleThreadProxy::DidSwapFrame() { 461 void SingleThreadProxy::DidSwapFrame() {
458 if (next_frame_is_newly_committed_frame_) { 462 if (next_frame_is_newly_committed_frame_) {
459 next_frame_is_newly_committed_frame_ = false; 463 next_frame_is_newly_committed_frame_ = false;
460 layer_tree_host_->DidCommitAndDrawFrame(); 464 layer_tree_host_->DidCommitAndDrawFrame();
461 } 465 }
462 } 466 }
463 467
464 bool SingleThreadProxy::MainFrameWillHappenForTesting() { 468 bool SingleThreadProxy::MainFrameWillHappenForTesting() {
465 return false; 469 return false;
466 } 470 }
467 471
468 } // namespace cc 472 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_unittest_delegated.cc ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698