OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 commit_requested_(false), | 45 commit_requested_(false), |
46 commit_request_sent_to_impl_thread_(false), | 46 commit_request_sent_to_impl_thread_(false), |
47 created_offscreen_context_provider_(false), | 47 created_offscreen_context_provider_(false), |
48 layer_tree_host_(layer_tree_host), | 48 layer_tree_host_(layer_tree_host), |
49 started_(false), | 49 started_(false), |
50 textures_acquired_(true), | 50 textures_acquired_(true), |
51 in_composite_and_readback_(false), | 51 in_composite_and_readback_(false), |
52 manage_tiles_pending_(false), | 52 manage_tiles_pending_(false), |
53 weak_factory_on_impl_thread_(this), | 53 weak_factory_on_impl_thread_(this), |
54 weak_factory_(this), | 54 weak_factory_(this), |
55 begin_frame_completion_event_on_impl_thread_(NULL), | 55 begin_main_frame_completion_event_on_impl_thread_(NULL), |
56 readback_request_on_impl_thread_(NULL), | 56 readback_request_on_impl_thread_(NULL), |
57 commit_completion_event_on_impl_thread_(NULL), | 57 commit_completion_event_on_impl_thread_(NULL), |
58 completion_event_for_commit_held_on_tree_activation_(NULL), | 58 completion_event_for_commit_held_on_tree_activation_(NULL), |
59 texture_acquisition_completion_event_on_impl_thread_(NULL), | 59 texture_acquisition_completion_event_on_impl_thread_(NULL), |
60 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 60 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
61 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), | 61 throttle_frame_production_( |
62 render_vsync_notification_enabled_( | 62 layer_tree_host->settings().throttle_frame_production), |
63 layer_tree_host->settings().render_vsync_notification_enabled), | 63 render_parent_drives_begin_impl_frame__( |
64 synchronously_disable_vsync_( | 64 layer_tree_host->settings().render_parent_drives_begin_impl_frame_), |
65 layer_tree_host->settings().synchronously_disable_vsync), | 65 using_synchronous_renderer_compositor_( |
| 66 layer_tree_host->settings().using_synchronous_renderer_compositor), |
66 vsync_client_(NULL), | 67 vsync_client_(NULL), |
67 inside_draw_(false), | 68 inside_draw_(false), |
68 defer_commits_(false), | 69 defer_commits_(false), |
69 renew_tree_priority_on_impl_thread_pending_(false) { | 70 renew_tree_priority_on_impl_thread_pending_(false) { |
70 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
71 DCHECK(IsMainThread()); | 72 DCHECK(IsMainThread()); |
72 DCHECK(layer_tree_host_); | 73 DCHECK(layer_tree_host_); |
73 } | 74 } |
74 | 75 |
75 ThreadProxy::~ThreadProxy() { | 76 ThreadProxy::~ThreadProxy() { |
76 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 77 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
77 DCHECK(IsMainThread()); | 78 DCHECK(IsMainThread()); |
78 DCHECK(!started_); | 79 DCHECK(!started_); |
79 } | 80 } |
80 | 81 |
81 bool ThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { | 82 bool ThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { |
82 TRACE_EVENT0("cc", "ThreadProxy::CompositeAndReadback"); | 83 TRACE_EVENT0("cc", "ThreadProxy::CompositeAndReadback"); |
83 DCHECK(IsMainThread()); | 84 DCHECK(IsMainThread()); |
84 DCHECK(layer_tree_host_); | 85 DCHECK(layer_tree_host_); |
85 DCHECK(!defer_commits_); | 86 DCHECK(!defer_commits_); |
86 | 87 |
87 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) { | 88 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) { |
88 TRACE_EVENT0("cc", "CompositeAndReadback_EarlyOut_LR_Uninitialized"); | 89 TRACE_EVENT0("cc", "CompositeAndReadback_EarlyOut_LR_Uninitialized"); |
89 return false; | 90 return false; |
90 } | 91 } |
91 | 92 |
92 // Perform a synchronous commit. | 93 // Perform a synchronous commit. |
93 { | 94 { |
94 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 95 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
95 CompletionEvent begin_frame_completion; | 96 CompletionEvent begin_main_frame_completion; |
96 Proxy::ImplThread()->PostTask( | 97 Proxy::ImplThread()->PostTask( |
97 base::Bind(&ThreadProxy::ForceBeginFrameOnImplThread, | 98 base::Bind(&ThreadProxy::ForceBeginMainFrameOnImplThread, |
98 impl_thread_weak_ptr_, | 99 impl_thread_weak_ptr_, |
99 &begin_frame_completion)); | 100 &begin_main_frame_completion)); |
100 begin_frame_completion.Wait(); | 101 begin_main_frame_completion.Wait(); |
101 } | 102 } |
102 in_composite_and_readback_ = true; | 103 in_composite_and_readback_ = true; |
103 BeginFrame(scoped_ptr<BeginFrameAndCommitState>()); | 104 BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState>()); |
104 in_composite_and_readback_ = false; | 105 in_composite_and_readback_ = false; |
105 | 106 |
106 // Perform a synchronous readback. | 107 // Perform a synchronous readback. |
107 ReadbackRequest request; | 108 ReadbackRequest request; |
108 request.rect = rect; | 109 request.rect = rect; |
109 request.pixels = pixels; | 110 request.pixels = pixels; |
110 { | 111 { |
111 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 112 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
112 Proxy::ImplThread()->PostTask( | 113 Proxy::ImplThread()->PostTask( |
113 base::Bind(&ThreadProxy::RequestReadbackOnImplThread, | 114 base::Bind(&ThreadProxy::RequestReadbackOnImplThread, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 DCHECK(IsImplThread()); | 320 DCHECK(IsImplThread()); |
320 TRACE_EVENT2("cc", | 321 TRACE_EVENT2("cc", |
321 "ThreadProxy::OnVSyncParametersChanged", | 322 "ThreadProxy::OnVSyncParametersChanged", |
322 "timebase", | 323 "timebase", |
323 (timebase - base::TimeTicks()).InMilliseconds(), | 324 (timebase - base::TimeTicks()).InMilliseconds(), |
324 "interval", | 325 "interval", |
325 interval.InMilliseconds()); | 326 interval.InMilliseconds()); |
326 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); | 327 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); |
327 } | 328 } |
328 | 329 |
329 void ThreadProxy::DidVSync(base::TimeTicks frame_time) { | 330 void ThreadProxy::DidBeginImplFrame(base::TimeTicks frame_time) { |
330 DCHECK(IsImplThread()); | 331 DCHECK(IsImplThread()); |
331 TRACE_EVENT0("cc", "ThreadProxy::DidVSync"); | 332 TRACE_EVENT0("cc", "ThreadProxy::DidBeginImplFrame"); |
332 if (vsync_client_) | 333 if (vsync_client_) |
333 vsync_client_->DidVSync(frame_time); | 334 vsync_client_->DidVSync(frame_time); |
334 } | 335 } |
335 | 336 |
336 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) { | 337 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) { |
337 DCHECK(IsImplThread()); | 338 DCHECK(IsImplThread()); |
338 TRACE_EVENT1( | 339 TRACE_EVENT1( |
339 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); | 340 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); |
340 vsync_client_ = client; | 341 vsync_client_ = client; |
341 layer_tree_host_impl_->EnableVSyncNotification(!!client); | 342 layer_tree_host_impl_->SetNeedsBeginImplFrame(!!client); |
342 } | 343 } |
343 | 344 |
344 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 345 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
345 DCHECK(IsImplThread()); | 346 DCHECK(IsImplThread()); |
346 TRACE_EVENT1( | 347 TRACE_EVENT1( |
347 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 348 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
348 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 349 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
349 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 350 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
350 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | 351 !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
351 } | 352 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 DCHECK_NE(defer_commits_, defer_commits); | 467 DCHECK_NE(defer_commits_, defer_commits); |
467 defer_commits_ = defer_commits; | 468 defer_commits_ = defer_commits; |
468 | 469 |
469 if (defer_commits_) | 470 if (defer_commits_) |
470 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 471 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
471 else | 472 else |
472 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 473 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
473 | 474 |
474 if (!defer_commits_ && pending_deferred_commit_) | 475 if (!defer_commits_ && pending_deferred_commit_) |
475 Proxy::MainThread()->PostTask( | 476 Proxy::MainThread()->PostTask( |
476 base::Bind(&ThreadProxy::BeginFrame, | 477 base::Bind(&ThreadProxy::BeginMainFrame, |
477 main_thread_weak_ptr_, | 478 main_thread_weak_ptr_, |
478 base::Passed(&pending_deferred_commit_))); | 479 base::Passed(&pending_deferred_commit_))); |
479 } | 480 } |
480 | 481 |
481 bool ThreadProxy::CommitRequested() const { | 482 bool ThreadProxy::CommitRequested() const { |
482 DCHECK(IsMainThread()); | 483 DCHECK(IsMainThread()); |
483 return commit_requested_; | 484 return commit_requested_; |
484 } | 485 } |
485 | 486 |
486 void ThreadProxy::SetNeedsRedrawOnImplThread() { | 487 void ThreadProxy::SetNeedsRedrawOnImplThread() { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 completion->Signal(); | 597 completion->Signal(); |
597 } | 598 } |
598 | 599 |
599 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { | 600 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { |
600 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 601 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
601 DCHECK(IsImplThread()); | 602 DCHECK(IsImplThread()); |
602 layer_tree_host_impl_->FinishAllRendering(); | 603 layer_tree_host_impl_->FinishAllRendering(); |
603 completion->Signal(); | 604 completion->Signal(); |
604 } | 605 } |
605 | 606 |
606 void ThreadProxy::ForceBeginFrameOnImplThread(CompletionEvent* completion) { | 607 void ThreadProxy::ForceBeginMainFrameOnImplThread(CompletionEvent* completion) { |
607 TRACE_EVENT0("cc", "ThreadProxy::ForceBeginFrameOnImplThread"); | 608 TRACE_EVENT0("cc", "ThreadProxy::ForceBeginMainFrameOnImplThread"); |
608 DCHECK(!begin_frame_completion_event_on_impl_thread_); | 609 DCHECK(!begin_main_frame_completion_event_on_impl_thread_); |
609 | 610 |
610 SetNeedsForcedCommitOnImplThread(); | 611 SetNeedsForcedCommitOnImplThread(); |
611 if (scheduler_on_impl_thread_->CommitPending()) { | 612 if (scheduler_on_impl_thread_->CommitPending()) { |
612 completion->Signal(); | 613 completion->Signal(); |
613 return; | 614 return; |
614 } | 615 } |
615 | 616 |
616 begin_frame_completion_event_on_impl_thread_ = completion; | 617 begin_main_frame_completion_event_on_impl_thread_ = completion; |
617 } | 618 } |
618 | 619 |
619 void ThreadProxy::ScheduledActionBeginFrame() { | 620 void ThreadProxy::ScheduledActionBeginMainFrame() { |
620 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginFrame"); | 621 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginMainFrame"); |
621 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( | 622 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
622 new BeginFrameAndCommitState); | 623 new BeginMainFrameAndCommitState); |
623 begin_frame_state->monotonic_frame_begin_time = base::TimeTicks::Now(); | 624 begin_main_frame_state->monotonic_frame_begin_time = base::TimeTicks::Now(); |
624 begin_frame_state->scroll_info = layer_tree_host_impl_->ProcessScrollDeltas(); | 625 begin_main_frame_state->scroll_info = |
| 626 layer_tree_host_impl_->ProcessScrollDeltas(); |
625 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); | 627 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); |
626 begin_frame_state->memory_allocation_limit_bytes = | 628 begin_main_frame_state->memory_allocation_limit_bytes = |
627 layer_tree_host_impl_->memory_allocation_limit_bytes(); | 629 layer_tree_host_impl_->memory_allocation_limit_bytes(); |
628 Proxy::MainThread()->PostTask(base::Bind(&ThreadProxy::BeginFrame, | 630 Proxy::MainThread()->PostTask( |
629 main_thread_weak_ptr_, | 631 base::Bind(&ThreadProxy::BeginMainFrame, |
630 base::Passed(&begin_frame_state))); | 632 main_thread_weak_ptr_, |
| 633 base::Passed(&begin_main_frame_state))); |
631 | 634 |
632 if (begin_frame_completion_event_on_impl_thread_) { | 635 if (begin_main_frame_completion_event_on_impl_thread_) { |
633 begin_frame_completion_event_on_impl_thread_->Signal(); | 636 begin_main_frame_completion_event_on_impl_thread_->Signal(); |
634 begin_frame_completion_event_on_impl_thread_ = NULL; | 637 begin_main_frame_completion_event_on_impl_thread_ = NULL; |
635 } | 638 } |
636 } | 639 } |
637 | 640 |
638 void ThreadProxy::BeginFrame( | 641 void ThreadProxy::BeginMainFrame( |
639 scoped_ptr<BeginFrameAndCommitState> begin_frame_state) { | 642 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
640 TRACE_EVENT0("cc", "ThreadProxy::BeginFrame"); | 643 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame"); |
641 DCHECK(IsMainThread()); | 644 DCHECK(IsMainThread()); |
642 if (!layer_tree_host_) | 645 if (!layer_tree_host_) |
643 return; | 646 return; |
644 | 647 |
645 if (defer_commits_) { | 648 if (defer_commits_) { |
646 pending_deferred_commit_ = begin_frame_state.Pass(); | 649 pending_deferred_commit_ = begin_main_frame_state.Pass(); |
647 layer_tree_host_->DidDeferCommit(); | 650 layer_tree_host_->DidDeferCommit(); |
648 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 651 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
649 return; | 652 return; |
650 } | 653 } |
651 | 654 |
652 // Do not notify the impl thread of commit requests that occur during | 655 // Do not notify the impl thread of commit requests that occur during |
653 // the apply/animate/layout part of the BeginFrameAndCommit process since | 656 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
654 // those commit requests will get painted immediately. Once we have done | 657 // those commit requests will get painted immediately. Once we have done |
655 // the paint, commit_requested_ will be set to false to allow new commit | 658 // the paint, commit_requested_ will be set to false to allow new commit |
656 // requests to be scheduled. | 659 // requests to be scheduled. |
657 commit_requested_ = true; | 660 commit_requested_ = true; |
658 commit_request_sent_to_impl_thread_ = true; | 661 commit_request_sent_to_impl_thread_ = true; |
659 | 662 |
660 // On the other hand, the AnimationRequested flag needs to be cleared | 663 // On the other hand, the AnimationRequested flag needs to be cleared |
661 // here so that any animation requests generated by the apply or animate | 664 // here so that any animation requests generated by the apply or animate |
662 // callbacks will trigger another frame. | 665 // callbacks will trigger another frame. |
663 animate_requested_ = false; | 666 animate_requested_ = false; |
664 | 667 |
665 if (begin_frame_state) | 668 if (begin_main_frame_state) |
666 layer_tree_host_->ApplyScrollAndScale(*begin_frame_state->scroll_info); | 669 layer_tree_host_->ApplyScrollAndScale(*begin_main_frame_state->scroll_info); |
667 | 670 |
668 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) { | 671 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) { |
669 commit_requested_ = false; | 672 commit_requested_ = false; |
670 commit_request_sent_to_impl_thread_ = false; | 673 commit_request_sent_to_impl_thread_ = false; |
671 | 674 |
672 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); | 675 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
673 Proxy::ImplThread()->PostTask(base::Bind( | 676 Proxy::ImplThread()->PostTask(base::Bind( |
674 &ThreadProxy::BeginFrameAbortedOnImplThread, impl_thread_weak_ptr_)); | 677 &ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 678 impl_thread_weak_ptr_)); |
675 return; | 679 return; |
676 } | 680 } |
677 | 681 |
678 layer_tree_host_->WillBeginFrame(); | 682 layer_tree_host_->WillBeginMainFrame(); |
679 | 683 |
680 if (begin_frame_state) { | 684 if (begin_main_frame_state) { |
681 layer_tree_host_->UpdateClientAnimations( | 685 layer_tree_host_->UpdateClientAnimations( |
682 begin_frame_state->monotonic_frame_begin_time); | 686 begin_main_frame_state->monotonic_frame_begin_time); |
683 layer_tree_host_->AnimateLayers( | 687 layer_tree_host_->AnimateLayers( |
684 begin_frame_state->monotonic_frame_begin_time); | 688 begin_main_frame_state->monotonic_frame_begin_time); |
685 } | 689 } |
686 | 690 |
687 // Unlink any backings that the impl thread has evicted, so that we know to | 691 // Unlink any backings that the impl thread has evicted, so that we know to |
688 // re-paint them in UpdateLayers. | 692 // re-paint them in UpdateLayers. |
689 if (layer_tree_host_->contents_texture_manager()) { | 693 if (layer_tree_host_->contents_texture_manager()) { |
690 layer_tree_host_->contents_texture_manager()-> | 694 layer_tree_host_->contents_texture_manager()-> |
691 UnlinkAndClearEvictedBackings(); | 695 UnlinkAndClearEvictedBackings(); |
692 } | 696 } |
693 | 697 |
694 layer_tree_host_->Layout(); | 698 layer_tree_host_->Layout(); |
695 | 699 |
696 // Clear the commit flag after updating animations and layout here --- objects | 700 // Clear the commit flag after updating animations and layout here --- objects |
697 // that only layout when painted will trigger another SetNeedsCommit inside | 701 // that only layout when painted will trigger another SetNeedsCommit inside |
698 // UpdateLayers. | 702 // UpdateLayers. |
699 commit_requested_ = false; | 703 commit_requested_ = false; |
700 commit_request_sent_to_impl_thread_ = false; | 704 commit_request_sent_to_impl_thread_ = false; |
701 | 705 |
702 scoped_ptr<ResourceUpdateQueue> queue = | 706 scoped_ptr<ResourceUpdateQueue> queue = |
703 make_scoped_ptr(new ResourceUpdateQueue); | 707 make_scoped_ptr(new ResourceUpdateQueue); |
704 layer_tree_host_->UpdateLayers( | 708 layer_tree_host_->UpdateLayers( |
705 queue.get(), | 709 queue.get(), |
706 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes | 710 begin_main_frame_state ? |
707 : 0u); | 711 begin_main_frame_state->memory_allocation_limit_bytes : 0u); |
708 | 712 |
709 // Once single buffered layers are committed, they cannot be modified until | 713 // Once single buffered layers are committed, they cannot be modified until |
710 // they are drawn by the impl thread. | 714 // they are drawn by the impl thread. |
711 textures_acquired_ = false; | 715 textures_acquired_ = false; |
712 | 716 |
713 layer_tree_host_->WillCommit(); | 717 layer_tree_host_->WillCommit(); |
714 // Before applying scrolls and calling animate, we set animate_requested_ to | 718 // Before applying scrolls and calling animate, we set animate_requested_ to |
715 // false. If it is true now, it means SetNeedAnimate was called again, but | 719 // false. If it is true now, it means SetNeedAnimate was called again, but |
716 // during a state when commit_request_sent_to_impl_thread_ = true. We need to | 720 // during a state when commit_request_sent_to_impl_thread_ = true. We need to |
717 // force that call to happen again now so that the commit request is sent to | 721 // force that call to happen again now so that the commit request is sent to |
718 // the impl thread. | 722 // the impl thread. |
719 if (animate_requested_) { | 723 if (animate_requested_) { |
720 // Forces SetNeedsAnimate to consider posting a commit task. | 724 // Forces SetNeedsAnimate to consider posting a commit task. |
721 animate_requested_ = false; | 725 animate_requested_ = false; |
722 SetNeedsAnimate(); | 726 SetNeedsAnimate(); |
723 } | 727 } |
724 | 728 |
725 scoped_refptr<cc::ContextProvider> offscreen_context_provider; | 729 scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
726 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && | 730 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && |
727 layer_tree_host_->needs_offscreen_context()) { | 731 layer_tree_host_->needs_offscreen_context()) { |
728 offscreen_context_provider = layer_tree_host_->client()-> | 732 offscreen_context_provider = layer_tree_host_->client()-> |
729 OffscreenContextProviderForCompositorThread(); | 733 OffscreenContextProviderForCompositorThread(); |
730 if (offscreen_context_provider) | 734 if (offscreen_context_provider) |
731 created_offscreen_context_provider_ = true; | 735 created_offscreen_context_provider_ = true; |
732 } | 736 } |
733 | 737 |
734 // Notify the impl thread that the BeginFrame has completed. This will | 738 // Notify the impl thread that the BeginMainFrame has completed. This will |
735 // begin the commit process, which is blocking from the main thread's | 739 // begin the commit process, which is blocking from the main thread's |
736 // point of view, but asynchronously performed on the impl thread, | 740 // point of view, but asynchronously performed on the impl thread, |
737 // coordinated by the Scheduler. | 741 // coordinated by the Scheduler. |
738 { | 742 { |
739 TRACE_EVENT0("cc", "ThreadProxy::BeginFrame::commit"); | 743 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
740 | 744 |
741 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 745 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
742 | 746 |
743 RenderingStatsInstrumentation* stats_instrumentation = | 747 RenderingStatsInstrumentation* stats_instrumentation = |
744 layer_tree_host_->rendering_stats_instrumentation(); | 748 layer_tree_host_->rendering_stats_instrumentation(); |
745 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 749 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
746 | 750 |
747 CompletionEvent completion; | 751 CompletionEvent completion; |
748 Proxy::ImplThread()->PostTask( | 752 Proxy::ImplThread()->PostTask( |
749 base::Bind(&ThreadProxy::BeginFrameCompleteOnImplThread, | 753 base::Bind(&ThreadProxy::BeginMainFrameCompleteOnImplThread, |
750 impl_thread_weak_ptr_, | 754 impl_thread_weak_ptr_, |
751 &completion, | 755 &completion, |
752 queue.release(), | 756 queue.release(), |
753 offscreen_context_provider)); | 757 offscreen_context_provider)); |
754 completion.Wait(); | 758 completion.Wait(); |
755 | 759 |
756 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); | 760 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); |
757 stats_instrumentation->AddCommit(duration); | 761 stats_instrumentation->AddCommit(duration); |
758 } | 762 } |
759 | 763 |
760 layer_tree_host_->CommitComplete(); | 764 layer_tree_host_->CommitComplete(); |
761 layer_tree_host_->DidBeginFrame(); | 765 layer_tree_host_->DidBeginMainFrame(); |
762 } | 766 } |
763 | 767 |
764 void ThreadProxy::BeginFrameCompleteOnImplThread( | 768 void ThreadProxy::BeginMainFrameCompleteOnImplThread( |
765 CompletionEvent* completion, | 769 CompletionEvent* completion, |
766 ResourceUpdateQueue* raw_queue, | 770 ResourceUpdateQueue* raw_queue, |
767 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { | 771 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { |
768 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); | 772 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); |
769 | 773 |
770 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameCompleteOnImplThread"); | 774 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameCompleteOnImplThread"); |
771 DCHECK(!commit_completion_event_on_impl_thread_); | 775 DCHECK(!commit_completion_event_on_impl_thread_); |
772 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 776 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
773 DCHECK(scheduler_on_impl_thread_); | 777 DCHECK(scheduler_on_impl_thread_); |
774 DCHECK(scheduler_on_impl_thread_->CommitPending()); | 778 DCHECK(scheduler_on_impl_thread_->CommitPending()); |
775 | 779 |
776 if (!layer_tree_host_impl_) { | 780 if (!layer_tree_host_impl_) { |
777 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 781 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
778 completion->Signal(); | 782 completion->Signal(); |
779 return; | 783 return; |
780 } | 784 } |
(...skipping 21 matching lines...) Expand all Loading... |
802 this, | 806 this, |
803 Proxy::ImplThread(), | 807 Proxy::ImplThread(), |
804 queue.Pass(), | 808 queue.Pass(), |
805 layer_tree_host_impl_->resource_provider()); | 809 layer_tree_host_impl_->resource_provider()); |
806 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates( | 810 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates( |
807 scheduler_on_impl_thread_->AnticipatedDrawTime()); | 811 scheduler_on_impl_thread_->AnticipatedDrawTime()); |
808 | 812 |
809 commit_completion_event_on_impl_thread_ = completion; | 813 commit_completion_event_on_impl_thread_ = completion; |
810 } | 814 } |
811 | 815 |
812 void ThreadProxy::BeginFrameAbortedOnImplThread() { | 816 void ThreadProxy::BeginMainFrameAbortedOnImplThread() { |
813 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameAbortedOnImplThread"); | 817 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread"); |
814 DCHECK(IsImplThread()); | 818 DCHECK(IsImplThread()); |
815 DCHECK(scheduler_on_impl_thread_); | 819 DCHECK(scheduler_on_impl_thread_); |
816 DCHECK(scheduler_on_impl_thread_->CommitPending()); | 820 DCHECK(scheduler_on_impl_thread_->CommitPending()); |
817 | 821 |
818 scheduler_on_impl_thread_->BeginFrameAborted(); | 822 scheduler_on_impl_thread_->BeginMainFrameAborted(); |
819 } | 823 } |
820 | 824 |
821 void ThreadProxy::ScheduledActionCommit() { | 825 void ThreadProxy::ScheduledActionCommit() { |
822 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 826 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
823 DCHECK(IsImplThread()); | 827 DCHECK(IsImplThread()); |
824 DCHECK(commit_completion_event_on_impl_thread_); | 828 DCHECK(commit_completion_event_on_impl_thread_); |
825 DCHECK(current_resource_update_controller_on_impl_thread_); | 829 DCHECK(current_resource_update_controller_on_impl_thread_); |
826 | 830 |
827 // Complete all remaining texture updates. | 831 // Complete all remaining texture updates. |
828 current_resource_update_controller_on_impl_thread_->Finalize(); | 832 current_resource_update_controller_on_impl_thread_->Finalize(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || | 938 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || |
935 forced_draw) | 939 forced_draw) |
936 draw_frame = true; | 940 draw_frame = true; |
937 else | 941 else |
938 start_ready_animations = false; | 942 start_ready_animations = false; |
939 } | 943 } |
940 | 944 |
941 if (draw_frame) { | 945 if (draw_frame) { |
942 layer_tree_host_impl_->DrawLayers( | 946 layer_tree_host_impl_->DrawLayers( |
943 &frame, | 947 &frame, |
944 scheduler_on_impl_thread_->LastVSyncTime()); | 948 scheduler_on_impl_thread_->LastBeginImplFrameTime()); |
945 result.did_draw = true; | 949 result.did_draw = true; |
946 } | 950 } |
947 layer_tree_host_impl_->DidDrawAllLayers(frame); | 951 layer_tree_host_impl_->DidDrawAllLayers(frame); |
948 | 952 |
949 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 953 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
950 | 954 |
951 // Check for a pending CompositeAndReadback. | 955 // Check for a pending CompositeAndReadback. |
952 if (readback_request_on_impl_thread_) { | 956 if (readback_request_on_impl_thread_) { |
953 readback_request_on_impl_thread_->success = false; | 957 readback_request_on_impl_thread_->success = false; |
954 if (draw_frame) { | 958 if (draw_frame) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1035 } |
1032 | 1036 |
1033 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { | 1037 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
1034 if (current_resource_update_controller_on_impl_thread_) | 1038 if (current_resource_update_controller_on_impl_thread_) |
1035 current_resource_update_controller_on_impl_thread_ | 1039 current_resource_update_controller_on_impl_thread_ |
1036 ->PerformMoreUpdates(time); | 1040 ->PerformMoreUpdates(time); |
1037 } | 1041 } |
1038 | 1042 |
1039 void ThreadProxy::ReadyToFinalizeTextureUpdates() { | 1043 void ThreadProxy::ReadyToFinalizeTextureUpdates() { |
1040 DCHECK(IsImplThread()); | 1044 DCHECK(IsImplThread()); |
1041 scheduler_on_impl_thread_->BeginFrameComplete(); | 1045 scheduler_on_impl_thread_->BeginMainFrameComplete(); |
1042 } | 1046 } |
1043 | 1047 |
1044 void ThreadProxy::DidCommitAndDrawFrame() { | 1048 void ThreadProxy::DidCommitAndDrawFrame() { |
1045 DCHECK(IsMainThread()); | 1049 DCHECK(IsMainThread()); |
1046 if (!layer_tree_host_) | 1050 if (!layer_tree_host_) |
1047 return; | 1051 return; |
1048 layer_tree_host_->DidCommitAndDrawFrame(); | 1052 layer_tree_host_->DidCommitAndDrawFrame(); |
1049 } | 1053 } |
1050 | 1054 |
1051 void ThreadProxy::DidCompleteSwapBuffers() { | 1055 void ThreadProxy::DidCompleteSwapBuffers() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 CompletionEvent* completion, | 1107 CompletionEvent* completion, |
1104 InputHandlerClient* input_handler_client) { | 1108 InputHandlerClient* input_handler_client) { |
1105 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1109 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
1106 DCHECK(IsImplThread()); | 1110 DCHECK(IsImplThread()); |
1107 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 1111 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
1108 const base::TimeDelta display_refresh_interval = | 1112 const base::TimeDelta display_refresh_interval = |
1109 base::TimeDelta::FromMicroseconds( | 1113 base::TimeDelta::FromMicroseconds( |
1110 base::Time::kMicrosecondsPerSecond / | 1114 base::Time::kMicrosecondsPerSecond / |
1111 layer_tree_host_->settings().refresh_rate); | 1115 layer_tree_host_->settings().refresh_rate); |
1112 scoped_ptr<FrameRateController> frame_rate_controller; | 1116 scoped_ptr<FrameRateController> frame_rate_controller; |
1113 if (render_vsync_enabled_) { | 1117 if (throttle_frame_production_) { |
1114 if (render_vsync_notification_enabled_) { | 1118 if (render_parent_drives_begin_impl_frame__) { |
1115 frame_rate_controller.reset( | 1119 frame_rate_controller.reset( |
1116 new FrameRateController(VSyncTimeSource::Create( | 1120 new FrameRateController(VSyncTimeSource::Create( |
1117 this, | 1121 this, |
1118 synchronously_disable_vsync_ ? | 1122 using_synchronous_renderer_compositor_ ? |
1119 VSyncTimeSource::DISABLE_SYNCHRONOUSLY : | 1123 VSyncTimeSource::DISABLE_SYNCHRONOUSLY : |
1120 VSyncTimeSource::DISABLE_ON_NEXT_TICK))); | 1124 VSyncTimeSource::DISABLE_ON_NEXT_TICK))); |
1121 } else { | 1125 } else { |
1122 frame_rate_controller.reset( | 1126 frame_rate_controller.reset( |
1123 new FrameRateController(DelayBasedTimeSource::Create( | 1127 new FrameRateController(DelayBasedTimeSource::Create( |
1124 display_refresh_interval, Proxy::ImplThread()))); | 1128 display_refresh_interval, Proxy::ImplThread()))); |
1125 } | 1129 } |
1126 } else { | 1130 } else { |
1127 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); | 1131 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); |
1128 } | 1132 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 if (layer_tree_host_impl_->resource_provider()) | 1203 if (layer_tree_host_impl_->resource_provider()) |
1200 layer_tree_host_impl_->resource_provider()->Finish(); | 1204 layer_tree_host_impl_->resource_provider()->Finish(); |
1201 completion->Signal(); | 1205 completion->Signal(); |
1202 } | 1206 } |
1203 | 1207 |
1204 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1208 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1205 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1209 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1206 DCHECK(IsImplThread()); | 1210 DCHECK(IsImplThread()); |
1207 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1211 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1208 layer_tree_host_impl_->resource_provider()); | 1212 layer_tree_host_impl_->resource_provider()); |
1209 layer_tree_host_impl_->EnableVSyncNotification(false); | 1213 layer_tree_host_impl_->SetNeedsBeginImplFrame(false); |
1210 input_handler_client_on_impl_thread_.reset(); | 1214 input_handler_client_on_impl_thread_.reset(); |
1211 scheduler_on_impl_thread_.reset(); | 1215 scheduler_on_impl_thread_.reset(); |
1212 layer_tree_host_impl_.reset(); | 1216 layer_tree_host_impl_.reset(); |
1213 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1217 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
1214 vsync_client_ = NULL; | 1218 vsync_client_ = NULL; |
1215 completion->Signal(); | 1219 completion->Signal(); |
1216 } | 1220 } |
1217 | 1221 |
1218 size_t ThreadProxy::MaxPartialTextureUpdates() const { | 1222 size_t ThreadProxy::MaxPartialTextureUpdates() const { |
1219 return ResourceUpdateController::MaxPartialTextureUpdates(); | 1223 return ResourceUpdateController::MaxPartialTextureUpdates(); |
1220 } | 1224 } |
1221 | 1225 |
1222 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 1226 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() |
1223 : memory_allocation_limit_bytes(0) {} | 1227 : memory_allocation_limit_bytes(0) {} |
1224 | 1228 |
1225 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {} | 1229 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} |
1226 | 1230 |
1227 scoped_ptr<base::Value> ThreadProxy::AsValue() const { | 1231 scoped_ptr<base::Value> ThreadProxy::AsValue() const { |
1228 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1232 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1229 | 1233 |
1230 CompletionEvent completion; | 1234 CompletionEvent completion; |
1231 { | 1235 { |
1232 DebugScopedSetMainThreadBlocked main_thread_blocked( | 1236 DebugScopedSetMainThreadBlocked main_thread_blocked( |
1233 const_cast<ThreadProxy*>(this)); | 1237 const_cast<ThreadProxy*>(this)); |
1234 Proxy::ImplThread()->PostTask(base::Bind(&ThreadProxy::AsValueOnImplThread, | 1238 Proxy::ImplThread()->PostTask(base::Bind(&ThreadProxy::AsValueOnImplThread, |
1235 impl_thread_weak_ptr_, | 1239 impl_thread_weak_ptr_, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1365 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1362 impl_thread_weak_ptr_), | 1366 impl_thread_weak_ptr_), |
1363 delay); | 1367 delay); |
1364 } | 1368 } |
1365 | 1369 |
1366 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1370 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1367 layer_tree_host_impl_->StartScrollbarAnimation( | 1371 layer_tree_host_impl_->StartScrollbarAnimation( |
1368 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 1372 layer_tree_host_impl_->CurrentFrameTimeTicks()); |
1369 } | 1373 } |
1370 | 1374 |
1371 void ThreadProxy::DidReceiveLastInputEventForVSync( | 1375 void ThreadProxy::DidReceiveLastInputEventForBeginImplFrame( |
1372 base::TimeTicks frame_time) { | 1376 base::TimeTicks frame_time) { |
1373 if (render_vsync_notification_enabled_) { | 1377 if (render_parent_drives_begin_impl_frame__) { |
1374 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); | 1378 TRACE_EVENT0("cc", |
1375 DidVSync(frame_time); | 1379 "ThreadProxy::DidReceiveLastInputEventForBeginImplFrame"); |
| 1380 DidBeginImplFrame(frame_time); |
1376 } | 1381 } |
1377 } | 1382 } |
1378 | 1383 |
1379 void ThreadProxy::DidActivatePendingTree() { | 1384 void ThreadProxy::DidActivatePendingTree() { |
1380 DCHECK(IsImplThread()); | 1385 DCHECK(IsImplThread()); |
1381 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); | 1386 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); |
1382 | 1387 |
1383 if (completion_event_for_commit_held_on_tree_activation_ && | 1388 if (completion_event_for_commit_held_on_tree_activation_ && |
1384 !layer_tree_host_impl_->pending_tree()) { | 1389 !layer_tree_host_impl_->pending_tree()) { |
1385 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1390 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
1386 TRACE_EVENT_SCOPE_THREAD); | 1391 TRACE_EVENT_SCOPE_THREAD); |
1387 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1392 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1388 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1393 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1389 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1394 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1390 } | 1395 } |
1391 } | 1396 } |
1392 | 1397 |
1393 } // namespace cc | 1398 } // namespace cc |
OLD | NEW |