OLD | NEW |
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/renderer_host/delegated_frame_host.h" | 5 #include "content/browser/renderer_host/delegated_frame_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/time/default_tick_clock.h" | 15 #include "base/time/default_tick_clock.h" |
| 16 #include "cc/base/switches.h" |
16 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
17 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
18 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
19 #include "cc/resources/texture_mailbox.h" | 20 #include "cc/resources/texture_mailbox.h" |
20 #include "cc/surfaces/surface.h" | 21 #include "cc/surfaces/surface.h" |
21 #include "cc/surfaces/surface_factory.h" | 22 #include "cc/surfaces/surface_factory.h" |
22 #include "cc/surfaces/surface_hittest.h" | 23 #include "cc/surfaces/surface_hittest.h" |
23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
24 #include "components/display_compositor/gl_helper.h" | 25 #include "components/display_compositor/gl_helper.h" |
25 #include "content/browser/compositor/surface_utils.h" | 26 #include "content/browser/compositor/surface_utils.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 59 } |
59 | 60 |
60 } // namespace | 61 } // namespace |
61 | 62 |
62 //////////////////////////////////////////////////////////////////////////////// | 63 //////////////////////////////////////////////////////////////////////////////// |
63 // DelegatedFrameHost | 64 // DelegatedFrameHost |
64 | 65 |
65 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 66 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
66 : client_(client), | 67 : client_(client), |
67 compositor_(nullptr), | 68 compositor_(nullptr), |
| 69 using_begin_frame_scheduling_( |
| 70 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 71 cc::switches::kDisableBeginFrameScheduling)), |
68 tick_clock_(new base::DefaultTickClock()), | 72 tick_clock_(new base::DefaultTickClock()), |
69 last_output_surface_id_(0), | 73 last_output_surface_id_(0), |
70 pending_delegated_ack_count_(0), | 74 pending_delegated_ack_count_(0), |
71 skipped_frames_(false), | 75 skipped_frames_(false), |
72 background_color_(SK_ColorRED), | 76 background_color_(SK_ColorRED), |
73 current_scale_factor_(1.f), | 77 current_scale_factor_(1.f), |
74 can_lock_compositor_(YES_CAN_LOCK), | 78 can_lock_compositor_(YES_CAN_LOCK), |
75 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 79 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
76 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 80 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
77 factory->GetContextFactory()->AddObserver(this); | 81 factory->GetContextFactory()->AddObserver(this); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 } | 794 } |
791 | 795 |
792 void DelegatedFrameHost::OnCompositingShuttingDown(ui::Compositor* compositor) { | 796 void DelegatedFrameHost::OnCompositingShuttingDown(ui::Compositor* compositor) { |
793 DCHECK_EQ(compositor, compositor_); | 797 DCHECK_EQ(compositor, compositor_); |
794 ResetCompositor(); | 798 ResetCompositor(); |
795 DCHECK(!compositor_); | 799 DCHECK(!compositor_); |
796 } | 800 } |
797 | 801 |
798 void DelegatedFrameHost::OnUpdateVSyncParameters(base::TimeTicks timebase, | 802 void DelegatedFrameHost::OnUpdateVSyncParameters(base::TimeTicks timebase, |
799 base::TimeDelta interval) { | 803 base::TimeDelta interval) { |
800 SetVSyncParameters(timebase, interval); | 804 vsync_timebase_ = timebase; |
801 if (client_->DelegatedFrameHostIsVisible()) | 805 vsync_interval_ = interval; |
| 806 if (!using_begin_frame_scheduling_ && client_->DelegatedFrameHostIsVisible()) |
802 client_->DelegatedFrameHostUpdateVSyncParameters(timebase, interval); | 807 client_->DelegatedFrameHostUpdateVSyncParameters(timebase, interval); |
803 } | 808 } |
804 | 809 |
805 //////////////////////////////////////////////////////////////////////////////// | 810 //////////////////////////////////////////////////////////////////////////////// |
806 // DelegatedFrameHost, ImageTransportFactoryObserver implementation: | 811 // DelegatedFrameHost, ImageTransportFactoryObserver implementation: |
807 | 812 |
808 void DelegatedFrameHost::OnLostResources() { | 813 void DelegatedFrameHost::OnLostResources() { |
809 if (!surface_id_.is_null()) | 814 if (!surface_id_.is_null()) |
810 EvictDelegatedFrame(); | 815 EvictDelegatedFrame(); |
811 idle_frame_subscriber_textures_.clear(); | 816 idle_frame_subscriber_textures_.clear(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 | 852 |
848 void DelegatedFrameHost::ResetCompositor() { | 853 void DelegatedFrameHost::ResetCompositor() { |
849 if (!compositor_) | 854 if (!compositor_) |
850 return; | 855 return; |
851 if (resize_lock_) { | 856 if (resize_lock_) { |
852 resize_lock_.reset(); | 857 resize_lock_.reset(); |
853 client_->DelegatedFrameHostResizeLockWasReleased(); | 858 client_->DelegatedFrameHostResizeLockWasReleased(); |
854 } | 859 } |
855 if (compositor_->HasObserver(this)) | 860 if (compositor_->HasObserver(this)) |
856 compositor_->RemoveObserver(this); | 861 compositor_->RemoveObserver(this); |
857 if (vsync_manager_.get()) { | 862 if (vsync_manager_) { |
858 vsync_manager_->RemoveObserver(this); | 863 vsync_manager_->RemoveObserver(this); |
859 vsync_manager_ = NULL; | 864 vsync_manager_ = nullptr; |
860 } | 865 } |
861 | 866 |
862 compositor_->RemoveSurfaceClient(id_allocator_->client_id()); | 867 compositor_->RemoveSurfaceClient(id_allocator_->client_id()); |
863 compositor_ = nullptr; | 868 compositor_ = nullptr; |
864 } | 869 } |
865 | 870 |
866 void DelegatedFrameHost::SetVSyncParameters(const base::TimeTicks& timebase, | |
867 const base::TimeDelta& interval) { | |
868 vsync_timebase_ = timebase; | |
869 vsync_interval_ = interval; | |
870 } | |
871 | |
872 void DelegatedFrameHost::LockResources() { | 871 void DelegatedFrameHost::LockResources() { |
873 DCHECK(!surface_id_.is_null()); | 872 DCHECK(!surface_id_.is_null()); |
874 delegated_frame_evictor_->LockFrame(); | 873 delegated_frame_evictor_->LockFrame(); |
875 } | 874 } |
876 | 875 |
877 void DelegatedFrameHost::RequestCopyOfOutput( | 876 void DelegatedFrameHost::RequestCopyOfOutput( |
878 std::unique_ptr<cc::CopyOutputRequest> request) { | 877 std::unique_ptr<cc::CopyOutputRequest> request) { |
879 if (!request_copy_of_output_callback_for_testing_.is_null()) { | 878 if (!request_copy_of_output_callback_for_testing_.is_null()) { |
880 request_copy_of_output_callback_for_testing_.Run(std::move(request)); | 879 request_copy_of_output_callback_for_testing_.Run(std::move(request)); |
881 } else { | 880 } else { |
(...skipping 20 matching lines...) Expand all Loading... |
902 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 901 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
903 new_layer->SetShowSurface( | 902 new_layer->SetShowSurface( |
904 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 903 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
905 base::Bind(&RequireCallback, base::Unretained(manager)), | 904 base::Bind(&RequireCallback, base::Unretained(manager)), |
906 current_surface_size_, current_scale_factor_, | 905 current_surface_size_, current_scale_factor_, |
907 current_frame_size_in_dip_); | 906 current_frame_size_in_dip_); |
908 } | 907 } |
909 } | 908 } |
910 | 909 |
911 } // namespace content | 910 } // namespace content |
OLD | NEW |