| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 #include <ApplicationServices/ApplicationServices.h> | 43 #include <ApplicationServices/ApplicationServices.h> |
| 44 #endif // OS_MACOSX | 44 #endif // OS_MACOSX |
| 45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 46 #include "base/win/windows_version.h" | 46 #include "base/win/windows_version.h" |
| 47 #endif // OS_WIN | 47 #endif // OS_WIN |
| 48 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
| 49 #include "ui/gfx/android/device_display_info.h" | 49 #include "ui/gfx/android/device_display_info.h" |
| 50 #endif // OS_ANDROID | 50 #endif // OS_ANDROID |
| 51 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
| 52 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 53 #endif |
| 51 | 54 |
| 52 namespace content { | 55 namespace content { |
| 53 | 56 |
| 54 namespace { | 57 namespace { |
| 55 | 58 |
| 56 enum GpuFeatureStatus { | 59 enum GpuFeatureStatus { |
| 57 kGpuFeatureEnabled = 0, | 60 kGpuFeatureEnabled = 0, |
| 58 kGpuFeatureBlacklisted = 1, | 61 kGpuFeatureBlacklisted = 1, |
| 59 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted | 62 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted |
| 60 kGpuFeatureNumStatus | 63 kGpuFeatureNumStatus |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 const int kNumResetsWithinDuration = 1; | 247 const int kNumResetsWithinDuration = 1; |
| 245 | 248 |
| 246 // Enums for UMA histograms. | 249 // Enums for UMA histograms. |
| 247 enum BlockStatusHistogram { | 250 enum BlockStatusHistogram { |
| 248 BLOCK_STATUS_NOT_BLOCKED, | 251 BLOCK_STATUS_NOT_BLOCKED, |
| 249 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, | 252 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, |
| 250 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, | 253 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, |
| 251 BLOCK_STATUS_MAX | 254 BLOCK_STATUS_MAX |
| 252 }; | 255 }; |
| 253 | 256 |
| 257 bool ShouldDisableHardwareAcceleration() { |
| 258 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
| 259 if (IsRunningInMojoShell()) |
| 260 return true; |
| 261 #endif |
| 262 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 263 switches::kDisableGpu); |
| 264 } |
| 265 |
| 254 } // namespace anonymous | 266 } // namespace anonymous |
| 255 | 267 |
| 256 void GpuDataManagerImplPrivate::InitializeForTesting( | 268 void GpuDataManagerImplPrivate::InitializeForTesting( |
| 257 const std::string& gpu_blacklist_json, | 269 const std::string& gpu_blacklist_json, |
| 258 const gpu::GPUInfo& gpu_info) { | 270 const gpu::GPUInfo& gpu_info) { |
| 259 // This function is for testing only, so disable histograms. | 271 // This function is for testing only, so disable histograms. |
| 260 update_histograms_ = false; | 272 update_histograms_ = false; |
| 261 | 273 |
| 262 // Prevent all further initialization. | 274 // Prevent all further initialization. |
| 263 finalized_ = true; | 275 finalized_ = true; |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 918 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
| 907 // It was already disabled on the command line. | 919 // It was already disabled on the command line. |
| 908 return false; | 920 return false; |
| 909 } | 921 } |
| 910 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)) | 922 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)) |
| 911 return true; | 923 return true; |
| 912 if (group_name == "Disabled") | 924 if (group_name == "Disabled") |
| 913 return true; | 925 return true; |
| 914 | 926 |
| 915 // Accelerated decode is never available with --disable-gpu. | 927 // Accelerated decode is never available with --disable-gpu. |
| 916 return command_line->HasSwitch(switches::kDisableGpu); | 928 return ShouldDisableHardwareAcceleration(); |
| 917 } | 929 } |
| 918 | 930 |
| 919 void GpuDataManagerImplPrivate::GetDisabledExtensions( | 931 void GpuDataManagerImplPrivate::GetDisabledExtensions( |
| 920 std::string* disabled_extensions) const { | 932 std::string* disabled_extensions) const { |
| 921 DCHECK(disabled_extensions); | 933 DCHECK(disabled_extensions); |
| 922 *disabled_extensions = disabled_extensions_; | 934 *disabled_extensions = disabled_extensions_; |
| 923 } | 935 } |
| 924 | 936 |
| 925 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( | 937 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( |
| 926 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { | 938 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 owner_(owner), | 979 owner_(owner), |
| 968 gpu_process_accessible_(true), | 980 gpu_process_accessible_(true), |
| 969 is_initialized_(false), | 981 is_initialized_(false), |
| 970 finalized_(false) { | 982 finalized_(false) { |
| 971 DCHECK(owner_); | 983 DCHECK(owner_); |
| 972 const base::CommandLine* command_line = | 984 const base::CommandLine* command_line = |
| 973 base::CommandLine::ForCurrentProcess(); | 985 base::CommandLine::ForCurrentProcess(); |
| 974 swiftshader_path_ = | 986 swiftshader_path_ = |
| 975 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 987 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 976 switches::kSwiftShaderPath); | 988 switches::kSwiftShaderPath); |
| 977 if (command_line->HasSwitch(switches::kDisableGpu)) | 989 if (ShouldDisableHardwareAcceleration()) |
| 978 DisableHardwareAcceleration(); | 990 DisableHardwareAcceleration(); |
| 979 | 991 |
| 980 #if defined(OS_MACOSX) | 992 #if defined(OS_MACOSX) |
| 981 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); | 993 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); |
| 982 #endif // OS_MACOSX | 994 #endif // OS_MACOSX |
| 983 | 995 |
| 984 // For testing only. | 996 // For testing only. |
| 985 if (command_line->HasSwitch(switches::kDisableDomainBlockingFor3DAPIs)) { | 997 if (command_line->HasSwitch(switches::kDisableDomainBlockingFor3DAPIs)) { |
| 986 domain_blocking_enabled_ = false; | 998 domain_blocking_enabled_ = false; |
| 987 } | 999 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1209 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1198 #if defined(OS_WIN) | 1210 #if defined(OS_WIN) |
| 1199 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1211 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1200 #endif | 1212 #endif |
| 1201 complete_gpu_info_already_requested_ = true; | 1213 complete_gpu_info_already_requested_ = true; |
| 1202 // Some observers might be waiting. | 1214 // Some observers might be waiting. |
| 1203 NotifyGpuInfoUpdate(); | 1215 NotifyGpuInfoUpdate(); |
| 1204 } | 1216 } |
| 1205 | 1217 |
| 1206 } // namespace content | 1218 } // namespace content |
| OLD | NEW |