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

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 548153004: Unified BeginFrame scheduling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/delegated_frame_host.h" 5 #include "content/browser/compositor/delegated_frame_host.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "cc/output/begin_frame_args.h"
9 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 11 #include "cc/output/compositor_frame_ack.h"
11 #include "cc/output/copy_output_request.h" 12 #include "cc/output/copy_output_request.h"
12 #include "cc/resources/single_release_callback.h" 13 #include "cc/resources/single_release_callback.h"
13 #include "cc/resources/texture_mailbox.h" 14 #include "cc/resources/texture_mailbox.h"
14 #include "cc/surfaces/surface_factory.h" 15 #include "cc/surfaces/surface_factory.h"
15 #include "content/browser/compositor/resize_lock.h" 16 #include "content/browser/compositor/resize_lock.h"
16 #include "content/common/gpu/client/gl_helper.h" 17 #include "content/common/gpu/client/gl_helper.h"
17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 18 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
18 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 dfh->AsWeakPtr(), 824 dfh->AsWeakPtr(),
824 callback, 825 callback,
825 subscriber_texture, 826 subscriber_texture,
826 base::Passed(&release_callback)); 827 base::Passed(&release_callback));
827 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), 828 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
828 texture_mailbox.sync_point(), 829 texture_mailbox.sync_point(),
829 video_frame.get(), 830 video_frame.get(),
830 finished_callback); 831 finished_callback);
831 } 832 }
832 833
834 void DelegatedFrameHost::UpdateVSyncParameters(const cc::BeginFrameArgs& args) {
835 vsync_timebase_ = args.frame_time;
836 vsync_interval_ = args.interval;
837 }
838
833 //////////////////////////////////////////////////////////////////////////////// 839 ////////////////////////////////////////////////////////////////////////////////
834 // DelegatedFrameHost, ui::CompositorObserver implementation: 840 // DelegatedFrameHost, ui::CompositorObserver implementation:
835 841
836 void DelegatedFrameHost::OnCompositingDidCommit( 842 void DelegatedFrameHost::OnCompositingDidCommit(
837 ui::Compositor* compositor) { 843 ui::Compositor* compositor) {
838 RenderWidgetHostImpl* host = client_->GetHost(); 844 RenderWidgetHostImpl* host = client_->GetHost();
839 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 845 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
840 can_lock_compositor_ = YES_CAN_LOCK; 846 can_lock_compositor_ = YES_CAN_LOCK;
841 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 847 if (resize_lock_.get() && resize_lock_->GrabDeferredLock())
842 can_lock_compositor_ = YES_DID_LOCK; 848 can_lock_compositor_ = YES_DID_LOCK;
(...skipping 24 matching lines...) Expand all
867 873
868 void DelegatedFrameHost::OnCompositingLockStateChanged( 874 void DelegatedFrameHost::OnCompositingLockStateChanged(
869 ui::Compositor* compositor) { 875 ui::Compositor* compositor) {
870 // A compositor lock that is part of a resize lock timed out. We 876 // A compositor lock that is part of a resize lock timed out. We
871 // should display a renderer frame. 877 // should display a renderer frame.
872 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { 878 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) {
873 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; 879 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME;
874 } 880 }
875 } 881 }
876 882
877 void DelegatedFrameHost::OnUpdateVSyncParameters(
878 base::TimeTicks timebase,
879 base::TimeDelta interval) {
880 vsync_timebase_ = timebase;
881 vsync_interval_ = interval;
882 RenderWidgetHostImpl* host = client_->GetHost();
883 if (client_->IsVisible())
884 host->UpdateVSyncParameters(timebase, interval);
885 }
886
887 //////////////////////////////////////////////////////////////////////////////// 883 ////////////////////////////////////////////////////////////////////////////////
888 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 884 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
889 885
890 void DelegatedFrameHost::OnLostResources() { 886 void DelegatedFrameHost::OnLostResources() {
891 RenderWidgetHostImpl* host = client_->GetHost(); 887 RenderWidgetHostImpl* host = client_->GetHost();
892 if (frame_provider_.get() || !surface_id_.is_null()) 888 if (frame_provider_.get() || !surface_id_.is_null())
893 EvictDelegatedFrame(); 889 EvictDelegatedFrame();
894 idle_frame_subscriber_textures_.clear(); 890 idle_frame_subscriber_textures_.clear();
895 yuv_readback_pipeline_.reset(); 891 yuv_readback_pipeline_.reset();
896 892
897 host->ScheduleComposite(); 893 host->ScheduleComposite();
898 } 894 }
899 895
900 //////////////////////////////////////////////////////////////////////////////// 896 ////////////////////////////////////////////////////////////////////////////////
901 // DelegatedFrameHost, private: 897 // DelegatedFrameHost, private:
902 898
903 DelegatedFrameHost::~DelegatedFrameHost() { 899 DelegatedFrameHost::~DelegatedFrameHost() {
904 ImageTransportFactory::GetInstance()->RemoveObserver(this); 900 ImageTransportFactory::GetInstance()->RemoveObserver(this);
905 901
906 if (!surface_id_.is_null()) 902 if (!surface_id_.is_null())
907 surface_factory_->Destroy(surface_id_); 903 surface_factory_->Destroy(surface_id_);
908 if (resource_collection_.get()) 904 if (resource_collection_.get())
909 resource_collection_->SetClient(NULL); 905 resource_collection_->SetClient(NULL);
910
911 DCHECK(!vsync_manager_.get());
912 } 906 }
913 907
914 void DelegatedFrameHost::RunOnCommitCallbacks() { 908 void DelegatedFrameHost::RunOnCommitCallbacks() {
915 for (std::vector<base::Closure>::const_iterator 909 for (std::vector<base::Closure>::const_iterator
916 it = on_compositing_did_commit_callbacks_.begin(); 910 it = on_compositing_did_commit_callbacks_.begin();
917 it != on_compositing_did_commit_callbacks_.end(); ++it) { 911 it != on_compositing_did_commit_callbacks_.end(); ++it) {
918 it->Run(); 912 it->Run();
919 } 913 }
920 on_compositing_did_commit_callbacks_.clear(); 914 on_compositing_did_commit_callbacks_.clear();
921 } 915 }
922 916
923 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( 917 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks(
924 const base::Closure& callback) { 918 const base::Closure& callback) {
925 ui::Compositor* compositor = client_->GetCompositor(); 919 ui::Compositor* compositor = client_->GetCompositor();
926 DCHECK(compositor); 920 DCHECK(compositor);
927 921
928 if (!compositor->HasObserver(this)) 922 if (!compositor->HasObserver(this))
929 compositor->AddObserver(this); 923 compositor->AddObserver(this);
930 924
931 can_lock_compositor_ = NO_PENDING_COMMIT; 925 can_lock_compositor_ = NO_PENDING_COMMIT;
932 on_compositing_did_commit_callbacks_.push_back(callback); 926 on_compositing_did_commit_callbacks_.push_back(callback);
933 } 927 }
934 928
935 void DelegatedFrameHost::AddedToWindow() { 929 void DelegatedFrameHost::AddedToWindow() {
936 ui::Compositor* compositor = client_->GetCompositor();
937 if (compositor) {
938 DCHECK(!vsync_manager_.get());
939 vsync_manager_ = compositor->vsync_manager();
940 vsync_manager_->AddObserver(this);
941 }
942 } 930 }
943 931
944 void DelegatedFrameHost::RemovingFromWindow() { 932 void DelegatedFrameHost::RemovingFromWindow() {
945 RunOnCommitCallbacks(); 933 RunOnCommitCallbacks();
946 resize_lock_.reset(); 934 resize_lock_.reset();
947 client_->GetHost()->WasResized(); 935 client_->GetHost()->WasResized();
948 ui::Compositor* compositor = client_->GetCompositor(); 936 ui::Compositor* compositor = client_->GetCompositor();
949 if (compositor && compositor->HasObserver(this)) 937 if (compositor && compositor->HasObserver(this))
950 compositor->RemoveObserver(this); 938 compositor->RemoveObserver(this);
951
952 if (vsync_manager_.get()) {
953 vsync_manager_->RemoveObserver(this);
954 vsync_manager_ = NULL;
955 }
956 } 939 }
957 940
958 void DelegatedFrameHost::LockResources() { 941 void DelegatedFrameHost::LockResources() {
959 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 942 DCHECK(frame_provider_.get() || !surface_id_.is_null());
960 delegated_frame_evictor_->LockFrame(); 943 delegated_frame_evictor_->LockFrame();
961 } 944 }
962 945
963 void DelegatedFrameHost::UnlockResources() { 946 void DelegatedFrameHost::UnlockResources() {
964 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 947 DCHECK(frame_provider_.get() || !surface_id_.is_null());
965 delegated_frame_evictor_->UnlockFrame(); 948 delegated_frame_evictor_->UnlockFrame();
(...skipping 10 matching lines...) Expand all
976 if (frame_provider_.get()) { 959 if (frame_provider_.get()) {
977 new_layer->SetShowDelegatedContent(frame_provider_.get(), 960 new_layer->SetShowDelegatedContent(frame_provider_.get(),
978 current_frame_size_in_dip_); 961 current_frame_size_in_dip_);
979 } 962 }
980 if (!surface_id_.is_null()) { 963 if (!surface_id_.is_null()) {
981 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); 964 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_);
982 } 965 }
983 } 966 }
984 967
985 } // namespace content 968 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/delegated_frame_host.h ('k') | content/browser/compositor/gpu_browser_compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698