| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 17 #include "base/version.h" | 18 #include "base/version.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "cc/base/switches.h" | 20 #include "cc/base/switches.h" |
| 20 #include "content/browser/gpu/gpu_process_host.h" | 21 #include "content/browser/gpu/gpu_process_host.h" |
| 21 #include "content/common/gpu/gpu_messages.h" | 22 #include "content/common/gpu/gpu_browser_messages.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/gpu_data_manager_observer.h" | 24 #include "content/public/browser/gpu_data_manager_observer.h" |
| 24 #include "content/public/common/content_client.h" | 25 #include "content/public/common/content_client.h" |
| 25 #include "content/public/common/content_constants.h" | 26 #include "content/public/common/content_constants.h" |
| 26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 27 #include "content/public/common/web_preferences.h" | 28 #include "content/public/common/web_preferences.h" |
| 28 #include "gpu/command_buffer/service/gpu_switches.h" | 29 #include "gpu/command_buffer/service/gpu_switches.h" |
| 29 #include "gpu/config/gpu_control_list_jsons.h" | 30 #include "gpu/config/gpu_control_list_jsons.h" |
| 30 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 31 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 31 #include "gpu/config/gpu_feature_type.h" | 32 #include "gpu/config/gpu_feature_type.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 382 |
| 382 complete_gpu_info_already_requested_ = true; | 383 complete_gpu_info_already_requested_ = true; |
| 383 | 384 |
| 384 GpuProcessHost::SendOnIO( | 385 GpuProcessHost::SendOnIO( |
| 385 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
| 386 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 387 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
| 387 #else | 388 #else |
| 388 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 389 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 389 #endif | 390 #endif |
| 390 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, | 391 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, |
| 391 new GpuMsg_CollectGraphicsInfo()); | 392 new GpuBrowserMsg_CollectGraphicsInfo()); |
| 392 } | 393 } |
| 393 | 394 |
| 394 bool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { | 395 bool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { |
| 395 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || | 396 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || |
| 396 gpu_info_.context_info_state == gpu::kCollectInfoNone) { | 397 gpu_info_.context_info_state == gpu::kCollectInfoNone) { |
| 397 return false; | 398 return false; |
| 398 } | 399 } |
| 399 return true; | 400 return true; |
| 400 } | 401 } |
| 401 | 402 |
| 402 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { | 403 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { |
| 403 #if defined(OS_WIN) | 404 #if defined(OS_WIN) |
| 404 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) | 405 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) |
| 405 return false; | 406 return false; |
| 406 #endif | 407 #endif |
| 407 return IsEssentialGpuInfoAvailable(); | 408 return IsEssentialGpuInfoAvailable(); |
| 408 } | 409 } |
| 409 | 410 |
| 410 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 411 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { |
| 411 GpuProcessHost::SendOnIO( | 412 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 412 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 413 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 413 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 414 new GpuBrowserMsg_GetVideoMemoryUsageStats()); |
| 414 new GpuMsg_GetVideoMemoryUsageStats()); | |
| 415 } | 415 } |
| 416 | 416 |
| 417 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 417 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
| 418 return use_swiftshader_; | 418 return use_swiftshader_; |
| 419 } | 419 } |
| 420 | 420 |
| 421 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( | 421 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( |
| 422 const base::FilePath& path) { | 422 const base::FilePath& path) { |
| 423 swiftshader_path_ = path; | 423 swiftshader_path_ = path; |
| 424 EnableSwiftShaderIfNecessary(); | 424 EnableSwiftShaderIfNecessary(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 448 // | 448 // |
| 449 // These policies could be refined, but at a certain point the behavior | 449 // These policies could be refined, but at a certain point the behavior |
| 450 // will become difficult to explain. | 450 // will become difficult to explain. |
| 451 std::string domain = GetDomainFromURL(url); | 451 std::string domain = GetDomainFromURL(url); |
| 452 | 452 |
| 453 blocked_domains_.erase(domain); | 453 blocked_domains_.erase(domain); |
| 454 timestamps_of_gpu_resets_.clear(); | 454 timestamps_of_gpu_resets_.clear(); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void GpuDataManagerImplPrivate::DisableGpuWatchdog() { | 457 void GpuDataManagerImplPrivate::DisableGpuWatchdog() { |
| 458 GpuProcessHost::SendOnIO( | 458 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 459 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 459 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 460 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 460 new GpuBrowserMsg_DisableWatchdog); |
| 461 new GpuMsg_DisableWatchdog); | |
| 462 } | 461 } |
| 463 | 462 |
| 464 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, | 463 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, |
| 465 const std::string& gl_renderer, | 464 const std::string& gl_renderer, |
| 466 const std::string& gl_version) { | 465 const std::string& gl_version) { |
| 467 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) | 466 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) |
| 468 return; | 467 return; |
| 469 | 468 |
| 470 if (!is_initialized_) { | 469 if (!is_initialized_) { |
| 471 post_init_tasks_.push_back( | 470 post_init_tasks_.push_back( |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 value->Append(dict); | 885 value->Append(dict); |
| 887 } | 886 } |
| 888 return value; | 887 return value; |
| 889 } | 888 } |
| 890 | 889 |
| 891 void GpuDataManagerImplPrivate::HandleGpuSwitch() { | 890 void GpuDataManagerImplPrivate::HandleGpuSwitch() { |
| 892 GpuDataManagerImpl::UnlockedSession session(owner_); | 891 GpuDataManagerImpl::UnlockedSession session(owner_); |
| 893 // Notify observers in the browser process. | 892 // Notify observers in the browser process. |
| 894 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 893 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| 895 // Pass the notification to the GPU process to notify observers there. | 894 // Pass the notification to the GPU process to notify observers there. |
| 896 GpuProcessHost::SendOnIO( | 895 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 897 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 896 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 898 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 897 new GpuBrowserMsg_GpuSwitched); |
| 899 new GpuMsg_GpuSwitched); | |
| 900 } | 898 } |
| 901 | 899 |
| 902 bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id, | 900 bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id, |
| 903 uint32_t device_id) { | 901 uint32_t device_id) { |
| 904 if (gpu_info_.gpu.vendor_id == vendor_id && | 902 if (gpu_info_.gpu.vendor_id == vendor_id && |
| 905 gpu_info_.gpu.device_id == device_id) { | 903 gpu_info_.gpu.device_id == device_id) { |
| 906 // The primary GPU is active. | 904 // The primary GPU is active. |
| 907 if (gpu_info_.gpu.active) | 905 if (gpu_info_.gpu.active) |
| 908 return false; | 906 return false; |
| 909 gpu_info_.gpu.active = true; | 907 gpu_info_.gpu.active = true; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1237 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1240 #if defined(OS_WIN) | 1238 #if defined(OS_WIN) |
| 1241 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1239 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1242 #endif | 1240 #endif |
| 1243 complete_gpu_info_already_requested_ = true; | 1241 complete_gpu_info_already_requested_ = true; |
| 1244 // Some observers might be waiting. | 1242 // Some observers might be waiting. |
| 1245 NotifyGpuInfoUpdate(); | 1243 NotifyGpuInfoUpdate(); |
| 1246 } | 1244 } |
| 1247 | 1245 |
| 1248 } // namespace content | 1246 } // namespace content |
| OLD | NEW |