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

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

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 2 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
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/browser/gpu/compositor_util.h" 17 #include "content/browser/gpu/compositor_util.h"
17 #include "content/common/gpu/client/gl_helper.h" 18 #include "content/common/gpu/client/gl_helper.h"
18 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 19 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 dfh->AsWeakPtr(), 834 dfh->AsWeakPtr(),
834 callback, 835 callback,
835 subscriber_texture, 836 subscriber_texture,
836 base::Passed(&release_callback)); 837 base::Passed(&release_callback));
837 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), 838 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
838 texture_mailbox.sync_point(), 839 texture_mailbox.sync_point(),
839 video_frame.get(), 840 video_frame.get(),
840 finished_callback); 841 finished_callback);
841 } 842 }
842 843
844 void DelegatedFrameHost::UpdateVSyncParameters(const cc::BeginFrameArgs& args) {
845 vsync_timebase_ = args.frame_time;
846 vsync_interval_ = args.interval;
847 }
848
843 //////////////////////////////////////////////////////////////////////////////// 849 ////////////////////////////////////////////////////////////////////////////////
844 // DelegatedFrameHost, ui::CompositorObserver implementation: 850 // DelegatedFrameHost, ui::CompositorObserver implementation:
845 851
846 void DelegatedFrameHost::OnCompositingDidCommit( 852 void DelegatedFrameHost::OnCompositingDidCommit(
847 ui::Compositor* compositor) { 853 ui::Compositor* compositor) {
848 RenderWidgetHostImpl* host = client_->GetHost(); 854 RenderWidgetHostImpl* host = client_->GetHost();
849 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 855 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
850 can_lock_compositor_ = YES_CAN_LOCK; 856 can_lock_compositor_ = YES_CAN_LOCK;
851 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 857 if (resize_lock_.get() && resize_lock_->GrabDeferredLock())
852 can_lock_compositor_ = YES_DID_LOCK; 858 can_lock_compositor_ = YES_DID_LOCK;
(...skipping 24 matching lines...) Expand all
877 883
878 void DelegatedFrameHost::OnCompositingLockStateChanged( 884 void DelegatedFrameHost::OnCompositingLockStateChanged(
879 ui::Compositor* compositor) { 885 ui::Compositor* compositor) {
880 // A compositor lock that is part of a resize lock timed out. We 886 // A compositor lock that is part of a resize lock timed out. We
881 // should display a renderer frame. 887 // should display a renderer frame.
882 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { 888 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) {
883 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; 889 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME;
884 } 890 }
885 } 891 }
886 892
887 void DelegatedFrameHost::OnUpdateVSyncParameters(
888 base::TimeTicks timebase,
889 base::TimeDelta interval) {
890 vsync_timebase_ = timebase;
891 vsync_interval_ = interval;
892 RenderWidgetHostImpl* host = client_->GetHost();
893 if (client_->IsVisible())
894 host->UpdateVSyncParameters(timebase, interval);
895 }
896
897 //////////////////////////////////////////////////////////////////////////////// 893 ////////////////////////////////////////////////////////////////////////////////
898 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 894 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
899 895
900 void DelegatedFrameHost::OnLostResources() { 896 void DelegatedFrameHost::OnLostResources() {
901 RenderWidgetHostImpl* host = client_->GetHost(); 897 RenderWidgetHostImpl* host = client_->GetHost();
902 if (frame_provider_.get() || !surface_id_.is_null()) 898 if (frame_provider_.get() || !surface_id_.is_null())
903 EvictDelegatedFrame(); 899 EvictDelegatedFrame();
904 idle_frame_subscriber_textures_.clear(); 900 idle_frame_subscriber_textures_.clear();
905 yuv_readback_pipeline_.reset(); 901 yuv_readback_pipeline_.reset();
906 902
907 host->ScheduleComposite(); 903 host->ScheduleComposite();
908 } 904 }
909 905
910 //////////////////////////////////////////////////////////////////////////////// 906 ////////////////////////////////////////////////////////////////////////////////
911 // DelegatedFrameHost, private: 907 // DelegatedFrameHost, private:
912 908
913 DelegatedFrameHost::~DelegatedFrameHost() { 909 DelegatedFrameHost::~DelegatedFrameHost() {
914 ImageTransportFactory::GetInstance()->RemoveObserver(this); 910 ImageTransportFactory::GetInstance()->RemoveObserver(this);
915 911
916 if (!surface_id_.is_null()) 912 if (!surface_id_.is_null())
917 surface_factory_->Destroy(surface_id_); 913 surface_factory_->Destroy(surface_id_);
918 if (resource_collection_.get()) 914 if (resource_collection_.get())
919 resource_collection_->SetClient(NULL); 915 resource_collection_->SetClient(NULL);
920
921 DCHECK(!vsync_manager_.get());
922 } 916 }
923 917
924 void DelegatedFrameHost::RunOnCommitCallbacks() { 918 void DelegatedFrameHost::RunOnCommitCallbacks() {
925 for (std::vector<base::Closure>::const_iterator 919 for (std::vector<base::Closure>::const_iterator
926 it = on_compositing_did_commit_callbacks_.begin(); 920 it = on_compositing_did_commit_callbacks_.begin();
927 it != on_compositing_did_commit_callbacks_.end(); ++it) { 921 it != on_compositing_did_commit_callbacks_.end(); ++it) {
928 it->Run(); 922 it->Run();
929 } 923 }
930 on_compositing_did_commit_callbacks_.clear(); 924 on_compositing_did_commit_callbacks_.clear();
931 } 925 }
932 926
933 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( 927 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks(
934 const base::Closure& callback) { 928 const base::Closure& callback) {
935 ui::Compositor* compositor = client_->GetCompositor(); 929 ui::Compositor* compositor = client_->GetCompositor();
936 DCHECK(compositor); 930 DCHECK(compositor);
937 931
938 if (!compositor->HasObserver(this)) 932 if (!compositor->HasObserver(this))
939 compositor->AddObserver(this); 933 compositor->AddObserver(this);
940 934
941 can_lock_compositor_ = NO_PENDING_COMMIT; 935 can_lock_compositor_ = NO_PENDING_COMMIT;
942 on_compositing_did_commit_callbacks_.push_back(callback); 936 on_compositing_did_commit_callbacks_.push_back(callback);
943 } 937 }
944 938
945 void DelegatedFrameHost::AddedToWindow() { 939 void DelegatedFrameHost::AddedToWindow() {
946 ui::Compositor* compositor = client_->GetCompositor();
947 if (compositor) {
948 DCHECK(!vsync_manager_.get());
949 vsync_manager_ = compositor->vsync_manager();
950 vsync_manager_->AddObserver(this);
951 }
952 } 940 }
953 941
954 void DelegatedFrameHost::RemovingFromWindow() { 942 void DelegatedFrameHost::RemovingFromWindow() {
955 RunOnCommitCallbacks(); 943 RunOnCommitCallbacks();
956 resize_lock_.reset(); 944 resize_lock_.reset();
957 client_->GetHost()->WasResized(); 945 client_->GetHost()->WasResized();
958 ui::Compositor* compositor = client_->GetCompositor(); 946 ui::Compositor* compositor = client_->GetCompositor();
959 if (compositor && compositor->HasObserver(this)) 947 if (compositor && compositor->HasObserver(this))
960 compositor->RemoveObserver(this); 948 compositor->RemoveObserver(this);
961
962 if (vsync_manager_.get()) {
963 vsync_manager_->RemoveObserver(this);
964 vsync_manager_ = NULL;
965 }
966 } 949 }
967 950
968 void DelegatedFrameHost::LockResources() { 951 void DelegatedFrameHost::LockResources() {
969 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 952 DCHECK(frame_provider_.get() || !surface_id_.is_null());
970 delegated_frame_evictor_->LockFrame(); 953 delegated_frame_evictor_->LockFrame();
971 } 954 }
972 955
973 void DelegatedFrameHost::UnlockResources() { 956 void DelegatedFrameHost::UnlockResources() {
974 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 957 DCHECK(frame_provider_.get() || !surface_id_.is_null());
975 delegated_frame_evictor_->UnlockFrame(); 958 delegated_frame_evictor_->UnlockFrame();
(...skipping 10 matching lines...) Expand all
986 if (frame_provider_.get()) { 969 if (frame_provider_.get()) {
987 new_layer->SetShowDelegatedContent(frame_provider_.get(), 970 new_layer->SetShowDelegatedContent(frame_provider_.get(),
988 current_frame_size_in_dip_); 971 current_frame_size_in_dip_);
989 } 972 }
990 if (!surface_id_.is_null()) { 973 if (!surface_id_.is_null()) {
991 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); 974 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_);
992 } 975 }
993 } 976 }
994 977
995 } // namespace content 978 } // 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