| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { | 66 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { |
| 67 return Singleton<GpuDataManagerImpl>::get(); | 67 return Singleton<GpuDataManagerImpl>::get(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 GpuDataManagerImpl::GpuDataManagerImpl() | 70 GpuDataManagerImpl::GpuDataManagerImpl() |
| 71 : complete_gpu_info_already_requested_(false), | 71 : complete_gpu_info_already_requested_(false), |
| 72 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), | 72 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), |
| 73 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), | 73 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), |
| 74 gpu_switching_(content::GPU_SWITCHING_OPTION_AUTOMATIC), | 74 gpu_switching_(content::GPU_SWITCHING_AUTOMATIC), |
| 75 observer_list_(new GpuDataManagerObserverList), | 75 observer_list_(new GpuDataManagerObserverList), |
| 76 software_rendering_(false), | 76 software_rendering_(false), |
| 77 card_blacklisted_(false), | 77 card_blacklisted_(false), |
| 78 update_histograms_(true) { | 78 update_histograms_(true) { |
| 79 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 79 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 80 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 80 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
| 81 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 81 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
| 82 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 82 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
| 83 } | 83 } |
| 84 if (command_line->HasSwitch(switches::kDisableGpu)) | 84 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 85 BlacklistCard(); | 85 BlacklistCard(); |
| 86 if (command_line->HasSwitch(switches::kGpuSwitching)) { | |
| 87 std::string option_string = command_line->GetSwitchValueASCII( | |
| 88 switches::kGpuSwitching); | |
| 89 GpuSwitchingOption option = gpu_util::StringToGpuSwitchingOption( | |
| 90 option_string); | |
| 91 if (option != content::GPU_SWITCHING_OPTION_UNKNOWN) | |
| 92 gpu_switching_ = option; | |
| 93 } | |
| 94 } | 86 } |
| 95 | 87 |
| 96 void GpuDataManagerImpl::Initialize() { | 88 void GpuDataManagerImpl::Initialize() { |
| 97 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 89 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 98 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) | 90 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) |
| 99 return; | 91 return; |
| 100 | 92 |
| 101 content::GPUInfo gpu_info; | 93 content::GPUInfo gpu_info; |
| 102 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 94 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
| 103 #if defined(ARCH_CPU_X86_FAMILY) | 95 #if defined(ARCH_CPU_X86_FAMILY) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 170 |
| 179 if (gpu_blacklist_.get()) { | 171 if (gpu_blacklist_.get()) { |
| 180 GpuBlacklist::Decision decision = | 172 GpuBlacklist::Decision decision = |
| 181 gpu_blacklist_->MakeBlacklistDecision( | 173 gpu_blacklist_->MakeBlacklistDecision( |
| 182 GpuBlacklist::kOsAny, NULL, gpu_info); | 174 GpuBlacklist::kOsAny, NULL, gpu_info); |
| 183 if (update_histograms_) { | 175 if (update_histograms_) { |
| 184 gpu_util::UpdateStats(gpu_blacklist_.get(), | 176 gpu_util::UpdateStats(gpu_blacklist_.get(), |
| 185 decision.blacklisted_features); | 177 decision.blacklisted_features); |
| 186 } | 178 } |
| 187 UpdateBlacklistedFeatures(decision.blacklisted_features); | 179 UpdateBlacklistedFeatures(decision.blacklisted_features); |
| 188 if (decision.gpu_switching != content::GPU_SWITCHING_OPTION_UNKNOWN) | 180 gpu_switching_ = decision.gpu_switching; |
| 189 gpu_switching_ = decision.gpu_switching; | |
| 190 } | 181 } |
| 191 | 182 |
| 192 { | 183 { |
| 193 base::AutoLock auto_lock(gpu_info_lock_); | 184 base::AutoLock auto_lock(gpu_info_lock_); |
| 194 gpu_info_ = gpu_info; | 185 gpu_info_ = gpu_info; |
| 195 complete_gpu_info_already_requested_ = | 186 complete_gpu_info_already_requested_ = |
| 196 complete_gpu_info_already_requested_ || gpu_info_.finalized; | 187 complete_gpu_info_already_requested_ || gpu_info_.finalized; |
| 197 } | 188 } |
| 198 | 189 |
| 199 // We have to update GpuFeatureType before notify all the observers. | 190 // We have to update GpuFeatureType before notify all the observers. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 swiftshader_path = swiftshader_path_; | 332 swiftshader_path = swiftshader_path_; |
| 342 } else if ((flags & (content::GPU_FEATURE_TYPE_WEBGL | | 333 } else if ((flags & (content::GPU_FEATURE_TYPE_WEBGL | |
| 343 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | | 334 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | |
| 344 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && | 335 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && |
| 345 (use_gl == "any")) { | 336 (use_gl == "any")) { |
| 346 command_line->AppendSwitchASCII( | 337 command_line->AppendSwitchASCII( |
| 347 switches::kUseGL, gfx::kGLImplementationOSMesaName); | 338 switches::kUseGL, gfx::kGLImplementationOSMesaName); |
| 348 } else if (!use_gl.empty()) { | 339 } else if (!use_gl.empty()) { |
| 349 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); | 340 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); |
| 350 } | 341 } |
| 351 switch (gpu_switching_) { | |
| 352 case content::GPU_SWITCHING_OPTION_FORCE_DISCRETE: | |
| 353 command_line->AppendSwitchASCII(switches::kGpuSwitching, | |
| 354 switches::kGpuSwitchingOptionNameForceDiscrete); | |
| 355 break; | |
| 356 case content::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: | |
| 357 command_line->AppendSwitchASCII(switches::kGpuSwitching, | |
| 358 switches::kGpuSwitchingOptionNameForceIntegrated); | |
| 359 break; | |
| 360 default: | |
| 361 break; | |
| 362 } | |
| 363 | 342 |
| 364 if (!swiftshader_path.empty()) | 343 if (!swiftshader_path.empty()) |
| 365 command_line->AppendSwitchPath(switches::kSwiftShaderPath, | 344 command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
| 366 swiftshader_path); | 345 swiftshader_path); |
| 367 | 346 |
| 368 { | 347 { |
| 369 base::AutoLock auto_lock(gpu_info_lock_); | 348 base::AutoLock auto_lock(gpu_info_lock_); |
| 370 if (gpu_info_.optimus) | 349 if (gpu_info_.optimus) |
| 371 command_line->AppendSwitch(switches::kReduceGpuSandbox); | 350 command_line->AppendSwitch(switches::kReduceGpuSandbox); |
| 372 if (gpu_info_.amd_switchable) { | 351 if (gpu_info_.amd_switchable) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 472 } |
| 494 | 473 |
| 495 void GpuDataManagerImpl::BlacklistCard() { | 474 void GpuDataManagerImpl::BlacklistCard() { |
| 496 card_blacklisted_ = true; | 475 card_blacklisted_ = true; |
| 497 | 476 |
| 498 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; | 477 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; |
| 499 | 478 |
| 500 EnableSoftwareRenderingIfNecessary(); | 479 EnableSoftwareRenderingIfNecessary(); |
| 501 NotifyGpuInfoUpdate(); | 480 NotifyGpuInfoUpdate(); |
| 502 } | 481 } |
| OLD | NEW |