Index: content/browser/gpu/gpu_data_manager_impl_private.cc |
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc |
index f59dae16f2c6e869dd4dd8237037c918323ac9d1..0383499193129c961688e7ad6cf989d57ee7da74 100644 |
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc |
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc |
@@ -299,6 +299,22 @@ void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info, |
} |
#endif // OS_ANDROID |
+// Overwrite force gpu workaround if a commandline switch exists. |
+void AdjustGpuSwitchingOption(std::set<int>* workarounds) { |
+ DCHECK(workarounds); |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ std::string option = command_line.GetSwitchValueASCII( |
+ switches::kGpuSwitching); |
+ if (option == switches::kGpuSwitchingOptionNameForceDiscrete) { |
+ workarounds->erase(gpu::FORCE_INTEGRATED_GPU); |
+ workarounds->insert(gpu::FORCE_DISCRETE_GPU); |
+ } |
+ if (option == switches::kGpuSwitchingOptionNameForceIntegrated) { |
no sievers
2013/11/05 19:41:23
nit: else if
Zhenyao Mo
2013/11/05 19:45:02
Done.
|
+ workarounds->erase(gpu::FORCE_DISCRETE_GPU); |
+ workarounds->insert(gpu::FORCE_INTEGRATED_GPU); |
+ } |
+} |
+ |
// Block all domains' use of 3D APIs for this many milliseconds if |
// approaching a threshold where system stability might be compromised. |
const int64 kBlockAllDomainsMs = 10000; |
@@ -323,7 +339,7 @@ void GpuDataManagerImplPrivate::InitializeForTesting( |
// Prevent all further initialization. |
finalized_ = true; |
- InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); |
+ InitializeImpl(gpu_blacklist_json, std::string(), gpu_info); |
} |
bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
@@ -570,18 +586,15 @@ void GpuDataManagerImplPrivate::Initialize() { |
#endif |
std::string gpu_blacklist_string; |
- std::string gpu_switching_list_string; |
std::string gpu_driver_bug_list_string; |
if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && |
!command_line->HasSwitch(switches::kUseGpuInTests)) { |
gpu_blacklist_string = gpu::kSoftwareRenderingListJson; |
- gpu_switching_list_string = gpu::kGpuSwitchingListJson; |
} |
if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; |
} |
InitializeImpl(gpu_blacklist_string, |
- gpu_switching_list_string, |
gpu_driver_bug_list_string, |
gpu_info); |
} |
@@ -605,22 +618,11 @@ void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
UpdateBlacklistedFeatures(features); |
} |
- if (gpu_switching_list_) { |
- std::set<int> option = gpu_switching_list_->MakeDecision( |
- gpu::GpuControlList::kOsAny, std::string(), gpu_info_); |
- if (option.size() == 1) { |
- // Blacklist decision should not overwrite commandline switch from users. |
- CommandLine* command_line = CommandLine::ForCurrentProcess(); |
- if (!command_line->HasSwitch(switches::kGpuSwitching)) { |
- gpu_switching_ = static_cast<gpu::GpuSwitchingOption>( |
- *(option.begin())); |
- } |
- } |
- } |
if (gpu_driver_bug_list_) { |
gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( |
gpu::GpuControlList::kOsAny, std::string(), gpu_info_); |
} |
+ AdjustGpuSwitchingOption(&gpu_driver_bugs_); |
// We have to update GpuFeatureType before notify all the observers. |
NotifyGpuInfoUpdate(); |
@@ -703,24 +705,10 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine( |
} else if (!use_gl.empty()) { |
command_line->AppendSwitchASCII(switches::kUseGL, use_gl); |
} |
- if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { |
+ if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) |
command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); |
- switch (gpu_switching_) { |
- case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE: |
- command_line->AppendSwitchASCII(switches::kGpuSwitching, |
- switches::kGpuSwitchingOptionNameForceDiscrete); |
- break; |
- case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: |
- command_line->AppendSwitchASCII(switches::kGpuSwitching, |
- switches::kGpuSwitchingOptionNameForceIntegrated); |
- break; |
- case gpu::GPU_SWITCHING_OPTION_AUTOMATIC: |
- case gpu::GPU_SWITCHING_OPTION_UNKNOWN: |
- break; |
- } |
- } else { |
+ else |
command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); |
- } |
if (!swiftshader_path.empty()) { |
command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
@@ -840,13 +828,6 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( |
#endif |
} |
-gpu::GpuSwitchingOption |
-GpuDataManagerImplPrivate::GetGpuSwitchingOption() const { |
- if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) |
- return gpu::GPU_SWITCHING_OPTION_UNKNOWN; |
- return gpu_switching_; |
-} |
- |
void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { |
card_blacklisted_ = true; |
@@ -982,7 +963,6 @@ GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( |
GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( |
GpuDataManagerImpl* owner) |
: complete_gpu_info_already_requested_(false), |
- gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), |
observer_list_(new GpuDataManagerObserverList), |
use_swiftshader_(false), |
card_blacklisted_(false), |
@@ -1008,14 +988,6 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( |
#if defined(USE_AURA) && !defined(OS_CHROMEOS) |
use_software_compositor_ = true; |
#endif |
- if (command_line->HasSwitch(switches::kGpuSwitching)) { |
- std::string option_string = command_line->GetSwitchValueASCII( |
- switches::kGpuSwitching); |
- gpu::GpuSwitchingOption option = |
- gpu::StringToGpuSwitchingOption(option_string); |
- if (option != gpu::GPU_SWITCHING_OPTION_UNKNOWN) |
- gpu_switching_ = option; |
- } |
#if defined(OS_MACOSX) |
CGGetActiveDisplayList (0, NULL, &display_count_); |
@@ -1036,7 +1008,6 @@ GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { |
void GpuDataManagerImplPrivate::InitializeImpl( |
const std::string& gpu_blacklist_json, |
- const std::string& gpu_switching_list_json, |
const std::string& gpu_driver_bug_list_json, |
const gpu::GPUInfo& gpu_info) { |
std::string browser_version_string = ProcessVersionString( |
@@ -1056,15 +1027,6 @@ void GpuDataManagerImplPrivate::InitializeImpl( |
gpu::GpuControlList::kCurrentOsOnly); |
DCHECK(success); |
} |
- if (!gpu_switching_list_json.empty()) { |
- gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); |
- if (log_gpu_control_list_decisions) |
- gpu_switching_list_->enable_control_list_logging("gpu_switching_list"); |
- bool success = gpu_switching_list_->LoadList( |
- browser_version_string, gpu_switching_list_json, |
- gpu::GpuControlList::kCurrentOsOnly); |
- DCHECK(success); |
- } |
if (!gpu_driver_bug_list_json.empty()) { |
gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create()); |
if (log_gpu_control_list_decisions) |
@@ -1126,17 +1088,10 @@ void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( |
gpu_info.secondary_gpus.size() + 1); |
if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { |
- switch (gpu_switching_) { |
- case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE: |
- ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
- break; |
- case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: |
- ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
- break; |
- case gpu::GPU_SWITCHING_OPTION_AUTOMATIC: |
- case gpu::GPU_SWITCHING_OPTION_UNKNOWN: |
- break; |
- } |
+ if (gpu_driver_bugs_.count(gpu::FORCE_DISCRETE_GPU) == 1) |
+ ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
+ else if (gpu_driver_bugs_.count(gpu::FORCE_INTEGRATED_GPU) == 1) |
+ ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
} |
} |