| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gpu/gpu_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, | 257 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, |
| 258 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, | 258 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, |
| 259 BLOCK_STATUS_MAX | 259 BLOCK_STATUS_MAX |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 bool ShouldDisableHardwareAcceleration() { | 262 bool ShouldDisableHardwareAcceleration() { |
| 263 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 263 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 264 switches::kDisableGpu); | 264 switches::kDisableGpu); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void OnVideoMemoryUsageStats(const gpu::VideoMemoryUsageStats& stats) { | 267 void OnVideoMemoryUsageStats( |
| 268 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(stats); | 268 const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>& |
| 269 callback, |
| 270 const gpu::VideoMemoryUsageStats& stats) { |
| 271 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 272 base::Bind(callback, stats)); |
| 269 } | 273 } |
| 270 | 274 |
| 271 void RequestVideoMemoryUsageStats(GpuProcessHost* host) { | 275 void RequestVideoMemoryUsageStats( |
| 276 const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>& |
| 277 callback, |
| 278 GpuProcessHost* host) { |
| 272 if (!host) | 279 if (!host) |
| 273 return; | 280 return; |
| 274 host->gpu_service()->GetVideoMemoryUsageStats( | 281 host->gpu_service()->GetVideoMemoryUsageStats( |
| 275 base::Bind(&OnVideoMemoryUsageStats)); | 282 base::Bind(&OnVideoMemoryUsageStats, callback)); |
| 276 } | 283 } |
| 277 | 284 |
| 278 void UpdateGpuInfoOnIO(const gpu::GPUInfo& gpu_info) { | 285 void UpdateGpuInfoOnIO(const gpu::GPUInfo& gpu_info) { |
| 279 // This function is called on the IO thread, but GPUInfo on GpuDataManagerImpl | 286 // This function is called on the IO thread, but GPUInfo on GpuDataManagerImpl |
| 280 // should be updated on the UI thread (since it can call into functions that | 287 // should be updated on the UI thread (since it can call into functions that |
| 281 // expect to run in the UI thread, e.g. ContentClient::SetGpuInfo()). | 288 // expect to run in the UI thread, e.g. ContentClient::SetGpuInfo()). |
| 282 BrowserThread::PostTask( | 289 BrowserThread::PostTask( |
| 283 BrowserThread::UI, FROM_HERE, | 290 BrowserThread::UI, FROM_HERE, |
| 284 base::Bind( | 291 base::Bind( |
| 285 [](const gpu::GPUInfo& gpu_info) { | 292 [](const gpu::GPUInfo& gpu_info) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 450 } |
| 444 | 451 |
| 445 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { | 452 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { |
| 446 #if defined(OS_WIN) | 453 #if defined(OS_WIN) |
| 447 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) | 454 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) |
| 448 return false; | 455 return false; |
| 449 #endif | 456 #endif |
| 450 return IsEssentialGpuInfoAvailable(); | 457 return IsEssentialGpuInfoAvailable(); |
| 451 } | 458 } |
| 452 | 459 |
| 453 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 460 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate( |
| 461 const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>& |
| 462 callback) const { |
| 454 GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 463 GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 455 false /* force_create */, | 464 false /* force_create */, |
| 456 base::Bind(&RequestVideoMemoryUsageStats)); | 465 base::Bind(&RequestVideoMemoryUsageStats, callback)); |
| 457 } | 466 } |
| 458 | 467 |
| 459 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 468 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
| 460 return use_swiftshader_; | 469 return use_swiftshader_; |
| 461 } | 470 } |
| 462 | 471 |
| 463 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { | 472 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { |
| 464 GpuDataManagerImpl::UnlockedSession session(owner_); | 473 GpuDataManagerImpl::UnlockedSession session(owner_); |
| 465 observer_list_->AddObserver(observer); | 474 observer_list_->AddObserver(observer); |
| 466 } | 475 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 UpdateGpuInfoHelper(); | 715 UpdateGpuInfoHelper(); |
| 707 } | 716 } |
| 708 | 717 |
| 709 void GpuDataManagerImplPrivate::UpdateGpuFeatureInfo( | 718 void GpuDataManagerImplPrivate::UpdateGpuFeatureInfo( |
| 710 const gpu::GpuFeatureInfo& gpu_feature_info) { | 719 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 711 if (!use_swiftshader_) { | 720 if (!use_swiftshader_) { |
| 712 gpu_feature_info_ = gpu_feature_info; | 721 gpu_feature_info_ = gpu_feature_info; |
| 713 } | 722 } |
| 714 } | 723 } |
| 715 | 724 |
| 716 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( | |
| 717 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { | |
| 718 GpuDataManagerImpl::UnlockedSession session(owner_); | |
| 719 observer_list_->Notify(FROM_HERE, | |
| 720 &GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, | |
| 721 video_memory_usage_stats); | |
| 722 } | |
| 723 | |
| 724 void GpuDataManagerImplPrivate::AppendRendererCommandLine( | 725 void GpuDataManagerImplPrivate::AppendRendererCommandLine( |
| 725 base::CommandLine* command_line) const { | 726 base::CommandLine* command_line) const { |
| 726 DCHECK(command_line); | 727 DCHECK(command_line); |
| 727 | 728 |
| 728 if (ShouldDisableAcceleratedVideoDecode(command_line)) | 729 if (ShouldDisableAcceleratedVideoDecode(command_line)) |
| 729 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); | 730 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); |
| 730 #if BUILDFLAG(ENABLE_WEBRTC) | 731 #if BUILDFLAG(ENABLE_WEBRTC) |
| 731 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && | 732 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && |
| 732 !command_line->HasSwitch(switches::kDisableWebRtcHWVP8Encoding)) | 733 !command_line->HasSwitch(switches::kDisableWebRtcHWVP8Encoding)) |
| 733 command_line->AppendSwitch(switches::kDisableWebRtcHWVP8Encoding); | 734 command_line->AppendSwitch(switches::kDisableWebRtcHWVP8Encoding); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1408 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1408 #if defined(OS_WIN) | 1409 #if defined(OS_WIN) |
| 1409 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1410 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1410 #endif | 1411 #endif |
| 1411 complete_gpu_info_already_requested_ = true; | 1412 complete_gpu_info_already_requested_ = true; |
| 1412 // Some observers might be waiting. | 1413 // Some observers might be waiting. |
| 1413 NotifyGpuInfoUpdate(); | 1414 NotifyGpuInfoUpdate(); |
| 1414 } | 1415 } |
| 1415 | 1416 |
| 1416 } // namespace content | 1417 } // namespace content |
| OLD | NEW |