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

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

Issue 279013002: Remove CompositeAndReadback from LayerTreeHost(Impl) and the Proxys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-cnr-lth-proxy-renderer: rebase-on-drawresult Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.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/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 48 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
49 } 49 }
50 50
51 SingleThreadProxy::~SingleThreadProxy() { 51 SingleThreadProxy::~SingleThreadProxy() {
52 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); 52 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy");
53 DCHECK(Proxy::IsMainThread()); 53 DCHECK(Proxy::IsMainThread());
54 // Make sure Stop() got called or never Started. 54 // Make sure Stop() got called or never Started.
55 DCHECK(!layer_tree_host_impl_); 55 DCHECK(!layer_tree_host_impl_);
56 } 56 }
57 57
58 bool SingleThreadProxy::CompositeAndReadback(void* pixels,
59 const gfx::Rect& rect) {
60 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback");
61 DCHECK(Proxy::IsMainThread());
62
63 gfx::Rect device_viewport_damage_rect = rect;
64
65 LayerTreeHostImpl::FrameData frame;
66 if (!CommitAndComposite(gfx::FrameTime::Now(),
67 device_viewport_damage_rect,
68 true, // for_readback
69 &frame))
70 return false;
71
72 {
73 DebugScopedSetImplThread impl(this);
74 layer_tree_host_impl_->Readback(pixels, rect);
75
76 if (layer_tree_host_impl_->IsContextLost())
77 return false;
78 }
79
80 return true;
81 }
82
83 void SingleThreadProxy::FinishAllRendering() { 58 void SingleThreadProxy::FinishAllRendering() {
84 TRACE_EVENT0("cc", "SingleThreadProxy::FinishAllRendering"); 59 TRACE_EVENT0("cc", "SingleThreadProxy::FinishAllRendering");
85 DCHECK(Proxy::IsMainThread()); 60 DCHECK(Proxy::IsMainThread());
86 { 61 {
87 DebugScopedSetImplThread impl(this); 62 DebugScopedSetImplThread impl(this);
88 layer_tree_host_impl_->FinishAllRendering(); 63 layer_tree_host_impl_->FinishAllRendering();
89 } 64 }
90 } 65 }
91 66
92 bool SingleThreadProxy::IsStarted() const { 67 bool SingleThreadProxy::IsStarted() const {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 331
357 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { 332 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() {
358 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); 333 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread");
359 client_->DidCompleteSwapBuffers(); 334 client_->DidCompleteSwapBuffers();
360 } 335 }
361 336
362 // Called by the legacy scheduling path (e.g. where render_widget does the 337 // Called by the legacy scheduling path (e.g. where render_widget does the
363 // scheduling) 338 // scheduling)
364 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { 339 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
365 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); 340 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately");
366 gfx::Rect device_viewport_damage_rect;
367 341
368 LayerTreeHostImpl::FrameData frame; 342 LayerTreeHostImpl::FrameData frame;
369 if (CommitAndComposite(frame_begin_time, 343 if (CommitAndComposite(frame_begin_time, &frame)) {
370 device_viewport_damage_rect,
371 false, // for_readback
372 &frame)) {
373 { 344 {
374 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 345 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
375 DebugScopedSetImplThread impl(this); 346 DebugScopedSetImplThread impl(this);
376 347
377 // This CapturePostTasks should be destroyed before 348 // This CapturePostTasks should be destroyed before
378 // DidCommitAndDrawFrame() is called since that goes out to the embedder, 349 // DidCommitAndDrawFrame() is called since that goes out to the embedder,
379 // and we want the embedder to receive its callbacks before that. 350 // and we want the embedder to receive its callbacks before that.
380 // NOTE: This maintains consistent ordering with the ThreadProxy since 351 // NOTE: This maintains consistent ordering with the ThreadProxy since
381 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread 352 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
382 // there as the main thread is not blocked, so any posted tasks inside 353 // there as the main thread is not blocked, so any posted tasks inside
(...skipping 25 matching lines...) Expand all
408 DebugScopedSetImplThread impl(this); 379 DebugScopedSetImplThread impl(this);
409 if (layer_tree_host_impl_->renderer()) { 380 if (layer_tree_host_impl_->renderer()) {
410 DCHECK(!layer_tree_host_->output_surface_lost()); 381 DCHECK(!layer_tree_host_->output_surface_lost());
411 layer_tree_host_impl_->renderer()->DoNoOp(); 382 layer_tree_host_impl_->renderer()->DoNoOp();
412 } 383 }
413 } 384 }
414 } 385 }
415 386
416 bool SingleThreadProxy::CommitAndComposite( 387 bool SingleThreadProxy::CommitAndComposite(
417 base::TimeTicks frame_begin_time, 388 base::TimeTicks frame_begin_time,
418 const gfx::Rect& device_viewport_damage_rect,
419 bool for_readback,
420 LayerTreeHostImpl::FrameData* frame) { 389 LayerTreeHostImpl::FrameData* frame) {
421 TRACE_EVENT0("cc", "SingleThreadProxy::CommitAndComposite"); 390 TRACE_EVENT0("cc", "SingleThreadProxy::CommitAndComposite");
422 DCHECK(Proxy::IsMainThread()); 391 DCHECK(Proxy::IsMainThread());
423 392
424 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) 393 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded())
425 return false; 394 return false;
426 395
427 layer_tree_host_->AnimateLayers(frame_begin_time); 396 layer_tree_host_->AnimateLayers(frame_begin_time);
428 397
429 if (PrioritizedResourceManager* contents_texture_manager = 398 if (PrioritizedResourceManager* contents_texture_manager =
430 layer_tree_host_->contents_texture_manager()) { 399 layer_tree_host_->contents_texture_manager()) {
431 contents_texture_manager->UnlinkAndClearEvictedBackings(); 400 contents_texture_manager->UnlinkAndClearEvictedBackings();
432 contents_texture_manager->SetMaxMemoryLimitBytes( 401 contents_texture_manager->SetMaxMemoryLimitBytes(
433 layer_tree_host_impl_->memory_allocation_limit_bytes()); 402 layer_tree_host_impl_->memory_allocation_limit_bytes());
434 contents_texture_manager->SetExternalPriorityCutoff( 403 contents_texture_manager->SetExternalPriorityCutoff(
435 layer_tree_host_impl_->memory_allocation_priority_cutoff()); 404 layer_tree_host_impl_->memory_allocation_priority_cutoff());
436 } 405 }
437 406
438 scoped_ptr<ResourceUpdateQueue> queue = 407 scoped_ptr<ResourceUpdateQueue> queue =
439 make_scoped_ptr(new ResourceUpdateQueue); 408 make_scoped_ptr(new ResourceUpdateQueue);
440 layer_tree_host_->UpdateLayers(queue.get()); 409 layer_tree_host_->UpdateLayers(queue.get());
441 410
442 layer_tree_host_->WillCommit(); 411 layer_tree_host_->WillCommit();
443 412
444 DoCommit(queue.Pass()); 413 DoCommit(queue.Pass());
445 bool result = DoComposite( 414 bool result = DoComposite(frame_begin_time, frame);
446 frame_begin_time, device_viewport_damage_rect, for_readback, frame);
447 layer_tree_host_->DidBeginMainFrame(); 415 layer_tree_host_->DidBeginMainFrame();
448 return result; 416 return result;
449 } 417 }
450 418
451 bool SingleThreadProxy::ShouldComposite() const { 419 bool SingleThreadProxy::ShouldComposite() const {
452 DCHECK(Proxy::IsImplThread()); 420 DCHECK(Proxy::IsImplThread());
453 return layer_tree_host_impl_->visible() && 421 return layer_tree_host_impl_->visible() &&
454 layer_tree_host_impl_->CanDraw(); 422 layer_tree_host_impl_->CanDraw();
455 } 423 }
456 424
457 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { 425 void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
458 DCHECK(Proxy::IsImplThread()); 426 DCHECK(Proxy::IsImplThread());
459 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 427 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
460 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); 428 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
461 } 429 }
462 430
463 bool SingleThreadProxy::DoComposite( 431 bool SingleThreadProxy::DoComposite(
464 base::TimeTicks frame_begin_time, 432 base::TimeTicks frame_begin_time,
465 const gfx::Rect& device_viewport_damage_rect,
466 bool for_readback,
467 LayerTreeHostImpl::FrameData* frame) { 433 LayerTreeHostImpl::FrameData* frame) {
468 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); 434 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
469 DCHECK(!layer_tree_host_->output_surface_lost()); 435 DCHECK(!layer_tree_host_->output_surface_lost());
470 436
471 bool lost_output_surface = false; 437 bool lost_output_surface = false;
472 { 438 {
473 DebugScopedSetImplThread impl(this); 439 DebugScopedSetImplThread impl(this);
474 base::AutoReset<bool> mark_inside(&inside_draw_, true); 440 base::AutoReset<bool> mark_inside(&inside_draw_, true);
475 441
476 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
477
478 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 442 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
479 // frame, so can only be used when such a frame is possible. Since 443 // frame, so can only be used when such a frame is possible. Since
480 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 444 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
481 // CanDraw() as well. 445 // CanDraw() as well.
482 if (!ShouldComposite() || (for_readback && !can_do_readback)) { 446 if (!ShouldComposite()) {
483 UpdateBackgroundAnimateTicking(); 447 UpdateBackgroundAnimateTicking();
484 return false; 448 return false;
485 } 449 }
486 450
487 layer_tree_host_impl_->Animate( 451 layer_tree_host_impl_->Animate(
488 layer_tree_host_impl_->CurrentFrameTimeTicks()); 452 layer_tree_host_impl_->CurrentFrameTimeTicks());
489 UpdateBackgroundAnimateTicking(); 453 UpdateBackgroundAnimateTicking();
490 454
491 if (!layer_tree_host_impl_->IsContextLost()) { 455 if (!layer_tree_host_impl_->IsContextLost()) {
492 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); 456 layer_tree_host_impl_->PrepareToDraw(frame);
493 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); 457 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
494 layer_tree_host_impl_->DidDrawAllLayers(*frame); 458 layer_tree_host_impl_->DidDrawAllLayers(*frame);
495 } 459 }
496 lost_output_surface = layer_tree_host_impl_->IsContextLost(); 460 lost_output_surface = layer_tree_host_impl_->IsContextLost();
497 461
498 bool start_ready_animations = true; 462 bool start_ready_animations = true;
499 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 463 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
500 464
501 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 465 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
502 } 466 }
503 467
504 if (lost_output_surface) { 468 if (lost_output_surface) {
505 layer_tree_host_->DidLoseOutputSurface(); 469 layer_tree_host_->DidLoseOutputSurface();
506 return false; 470 return false;
507 } 471 }
508 472
509 return true; 473 return true;
510 } 474 }
511 475
512 void SingleThreadProxy::DidSwapFrame() { 476 void SingleThreadProxy::DidSwapFrame() {
513 if (next_frame_is_newly_committed_frame_) { 477 if (next_frame_is_newly_committed_frame_) {
514 next_frame_is_newly_committed_frame_ = false; 478 next_frame_is_newly_committed_frame_ = false;
515 layer_tree_host_->DidCommitAndDrawFrame(); 479 layer_tree_host_->DidCommitAndDrawFrame();
516 } 480 }
517 } 481 }
518 482
519 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 483 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
520 484
521 } // namespace cc 485 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698