OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/gpu/gpu_service.h" | 5 #include "services/ui/gpu/gpu_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 GpuService::GpuService(const gpu::GPUInfo& gpu_info, | 87 GpuService::GpuService(const gpu::GPUInfo& gpu_info, |
88 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, | 88 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, |
89 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | 89 scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
90 const gpu::GpuFeatureInfo& gpu_feature_info) | 90 const gpu::GpuFeatureInfo& gpu_feature_info) |
91 : main_runner_(base::ThreadTaskRunnerHandle::Get()), | 91 : main_runner_(base::ThreadTaskRunnerHandle::Get()), |
92 io_runner_(std::move(io_runner)), | 92 io_runner_(std::move(io_runner)), |
93 watchdog_thread_(std::move(watchdog_thread)), | 93 watchdog_thread_(std::move(watchdog_thread)), |
94 gpu_memory_buffer_factory_( | 94 gpu_memory_buffer_factory_( |
95 gpu::GpuMemoryBufferFactory::CreateNativeType()), | 95 gpu::GpuMemoryBufferFactory::CreateNativeType()), |
| 96 gpu_workarounds_(base::CommandLine::ForCurrentProcess()), |
96 gpu_info_(gpu_info), | 97 gpu_info_(gpu_info), |
97 gpu_feature_info_(gpu_feature_info), | 98 gpu_feature_info_(gpu_feature_info), |
98 sync_point_manager_(nullptr), | 99 sync_point_manager_(nullptr), |
99 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()), | 100 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()), |
100 weak_ptr_factory_(this) { | 101 weak_ptr_factory_(this) { |
101 DCHECK(!io_runner_->BelongsToCurrentThread()); | 102 DCHECK(!io_runner_->BelongsToCurrentThread()); |
102 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); | 103 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); |
103 } | 104 } |
104 | 105 |
105 GpuService::~GpuService() { | 106 GpuService::~GpuService() { |
(...skipping 19 matching lines...) Expand all Loading... |
125 if (owned_shutdown_event_) | 126 if (owned_shutdown_event_) |
126 owned_shutdown_event_->Signal(); | 127 owned_shutdown_event_->Signal(); |
127 } | 128 } |
128 | 129 |
129 void GpuService::UpdateGPUInfoFromPreferences( | 130 void GpuService::UpdateGPUInfoFromPreferences( |
130 const gpu::GpuPreferences& preferences) { | 131 const gpu::GpuPreferences& preferences) { |
131 DCHECK(main_runner_->BelongsToCurrentThread()); | 132 DCHECK(main_runner_->BelongsToCurrentThread()); |
132 DCHECK(!gpu_host_); | 133 DCHECK(!gpu_host_); |
133 gpu_preferences_ = preferences; | 134 gpu_preferences_ = preferences; |
134 gpu_info_.video_decode_accelerator_capabilities = | 135 gpu_info_.video_decode_accelerator_capabilities = |
135 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); | 136 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_, |
| 137 gpu_workarounds_); |
136 gpu_info_.video_encode_accelerator_supported_profiles = | 138 gpu_info_.video_encode_accelerator_supported_profiles = |
137 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); | 139 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); |
138 gpu_info_.jpeg_decode_accelerator_supported = | 140 gpu_info_.jpeg_decode_accelerator_supported = |
139 media::GpuJpegDecodeAcceleratorFactoryProvider:: | 141 media::GpuJpegDecodeAcceleratorFactoryProvider:: |
140 IsAcceleratedJpegDecodeSupported(); | 142 IsAcceleratedJpegDecodeSupported(); |
141 // Record initialization only after collecting the GPU info because that can | 143 // Record initialization only after collecting the GPU info because that can |
142 // take a significant amount of time. | 144 // take a significant amount of time. |
143 gpu_info_.initialization_time = base::Time::Now() - start_time_; | 145 gpu_info_.initialization_time = base::Time::Now() - start_time_; |
144 } | 146 } |
145 | 147 |
(...skipping 25 matching lines...) Expand all Loading... |
171 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>( | 173 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>( |
172 base::WaitableEvent::ResetPolicy::MANUAL, | 174 base::WaitableEvent::ResetPolicy::MANUAL, |
173 base::WaitableEvent::InitialState::NOT_SIGNALED); | 175 base::WaitableEvent::InitialState::NOT_SIGNALED); |
174 shutdown_event_ = owned_shutdown_event_.get(); | 176 shutdown_event_ = owned_shutdown_event_.get(); |
175 } | 177 } |
176 | 178 |
177 // Defer creation of the render thread. This is to prevent it from handling | 179 // Defer creation of the render thread. This is to prevent it from handling |
178 // IPC messages before the sandbox has been enabled and all other necessary | 180 // IPC messages before the sandbox has been enabled and all other necessary |
179 // initialization has succeeded. | 181 // initialization has succeeded. |
180 gpu_channel_manager_.reset(new gpu::GpuChannelManager( | 182 gpu_channel_manager_.reset(new gpu::GpuChannelManager( |
181 gpu_preferences_, this, watchdog_thread_.get(), | 183 gpu_preferences_, gpu_workarounds_, this, watchdog_thread_.get(), |
182 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_, | 184 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_, |
183 gpu_memory_buffer_factory_.get(), gpu_feature_info_, | 185 gpu_memory_buffer_factory_.get(), gpu_feature_info_, |
184 std::move(activity_flags))); | 186 std::move(activity_flags))); |
185 | 187 |
186 media_gpu_channel_manager_.reset( | 188 media_gpu_channel_manager_.reset( |
187 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); | 189 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); |
188 if (watchdog_thread()) | 190 if (watchdog_thread()) |
189 watchdog_thread()->AddPowerObserver(); | 191 watchdog_thread()->AddPowerObserver(); |
190 } | 192 } |
191 | 193 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 500 |
499 void GpuService::Stop(const StopCallback& callback) { | 501 void GpuService::Stop(const StopCallback& callback) { |
500 DCHECK(io_runner_->BelongsToCurrentThread()); | 502 DCHECK(io_runner_->BelongsToCurrentThread()); |
501 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { | 503 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { |
502 base::MessageLoop::current()->QuitWhenIdle(); | 504 base::MessageLoop::current()->QuitWhenIdle(); |
503 }), | 505 }), |
504 callback); | 506 callback); |
505 } | 507 } |
506 | 508 |
507 } // namespace ui | 509 } // namespace ui |
OLD | NEW |