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_host_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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 403 |
403 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { | 404 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { |
404 #if defined(OS_WIN) | 405 #if defined(OS_WIN) |
405 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) | 406 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) |
406 return false; | 407 return false; |
407 #endif | 408 #endif |
408 return IsEssentialGpuInfoAvailable(); | 409 return IsEssentialGpuInfoAvailable(); |
409 } | 410 } |
410 | 411 |
411 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 412 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { |
412 GpuProcessHost::SendOnIO( | 413 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
413 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 414 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
414 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 415 new GpuMsg_GetVideoMemoryUsageStats()); |
415 new GpuMsg_GetVideoMemoryUsageStats()); | |
416 } | 416 } |
417 | 417 |
418 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 418 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
419 return use_swiftshader_; | 419 return use_swiftshader_; |
420 } | 420 } |
421 | 421 |
422 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( | 422 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( |
423 const base::FilePath& path) { | 423 const base::FilePath& path) { |
424 swiftshader_path_ = path; | 424 swiftshader_path_ = path; |
425 EnableSwiftShaderIfNecessary(); | 425 EnableSwiftShaderIfNecessary(); |
(...skipping 23 matching lines...) Expand all Loading... |
449 // | 449 // |
450 // These policies could be refined, but at a certain point the behavior | 450 // These policies could be refined, but at a certain point the behavior |
451 // will become difficult to explain. | 451 // will become difficult to explain. |
452 std::string domain = GetDomainFromURL(url); | 452 std::string domain = GetDomainFromURL(url); |
453 | 453 |
454 blocked_domains_.erase(domain); | 454 blocked_domains_.erase(domain); |
455 timestamps_of_gpu_resets_.clear(); | 455 timestamps_of_gpu_resets_.clear(); |
456 } | 456 } |
457 | 457 |
458 void GpuDataManagerImplPrivate::DisableGpuWatchdog() { | 458 void GpuDataManagerImplPrivate::DisableGpuWatchdog() { |
459 GpuProcessHost::SendOnIO( | 459 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
460 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 460 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
461 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 461 new GpuMsg_DisableWatchdog); |
462 new GpuMsg_DisableWatchdog); | |
463 } | 462 } |
464 | 463 |
465 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, | 464 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, |
466 const std::string& gl_renderer, | 465 const std::string& gl_renderer, |
467 const std::string& gl_version) { | 466 const std::string& gl_version) { |
468 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) | 467 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) |
469 return; | 468 return; |
470 | 469 |
471 if (!is_initialized_) { | 470 if (!is_initialized_) { |
472 post_init_tasks_.push_back( | 471 post_init_tasks_.push_back( |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 value->Append(dict); | 886 value->Append(dict); |
888 } | 887 } |
889 return value; | 888 return value; |
890 } | 889 } |
891 | 890 |
892 void GpuDataManagerImplPrivate::HandleGpuSwitch() { | 891 void GpuDataManagerImplPrivate::HandleGpuSwitch() { |
893 GpuDataManagerImpl::UnlockedSession session(owner_); | 892 GpuDataManagerImpl::UnlockedSession session(owner_); |
894 // Notify observers in the browser process. | 893 // Notify observers in the browser process. |
895 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 894 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
896 // Pass the notification to the GPU process to notify observers there. | 895 // Pass the notification to the GPU process to notify observers there. |
897 GpuProcessHost::SendOnIO( | 896 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
898 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 897 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
899 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 898 new GpuMsg_GpuSwitched); |
900 new GpuMsg_GpuSwitched); | |
901 } | 899 } |
902 | 900 |
903 bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id, | 901 bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id, |
904 uint32_t device_id) { | 902 uint32_t device_id) { |
905 if (gpu_info_.gpu.vendor_id == vendor_id && | 903 if (gpu_info_.gpu.vendor_id == vendor_id && |
906 gpu_info_.gpu.device_id == device_id) { | 904 gpu_info_.gpu.device_id == device_id) { |
907 // The primary GPU is active. | 905 // The primary GPU is active. |
908 if (gpu_info_.gpu.active) | 906 if (gpu_info_.gpu.active) |
909 return false; | 907 return false; |
910 gpu_info_.gpu.active = true; | 908 gpu_info_.gpu.active = true; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1238 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1241 #if defined(OS_WIN) | 1239 #if defined(OS_WIN) |
1242 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1240 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
1243 #endif | 1241 #endif |
1244 complete_gpu_info_already_requested_ = true; | 1242 complete_gpu_info_already_requested_ = true; |
1245 // Some observers might be waiting. | 1243 // Some observers might be waiting. |
1246 NotifyGpuInfoUpdate(); | 1244 NotifyGpuInfoUpdate(); |
1247 } | 1245 } |
1248 | 1246 |
1249 } // namespace content | 1247 } // namespace content |
OLD | NEW |