Chromium Code Reviews| Index: content/browser/gpu_blacklist.cc |
| diff --git a/content/browser/gpu_blacklist.cc b/content/browser/gpu_blacklist.cc |
| index 50486c9e43927b26dcfb40a736108ec580a6185e..3d9b5d6f88819bb7d3ff161157e4e9c6b0299c41 100644 |
| --- a/content/browser/gpu_blacklist.cc |
| +++ b/content/browser/gpu_blacklist.cc |
| @@ -693,27 +693,172 @@ void GpuBlacklist::GetGpuFeatureFlagEntries( |
| } |
| } |
| -Value* GpuBlacklist::GetBlacklistingReasons() const { |
| - ListValue* reasons = new ListValue(); |
| - for (size_t i = 0; i < active_entries_.size(); ++i) { |
| - DictionaryValue* reason = new DictionaryValue(); |
| - reason->SetString("description", active_entries_[i]->description()); |
| +Value* GpuBlacklist::GetFeatureStatus(bool gpuAccessAllowed) const { |
| + DictionaryValue* status = new DictionaryValue(); |
| + |
| + const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| + bool disableAcceleratedCompositing = |
|
zmo
2011/04/11 23:10:25
disable_accelerated_compositing
same for the othe
|
| + browser_command_line.HasSwitch(switches::kDisableAcceleratedCompositing); |
| + bool enableAccelerated2DCanvas = |
| + browser_command_line.HasSwitch(switches::kEnableAccelerated2dCanvas); |
| + bool disableExperimentalWebGL = |
| + browser_command_line.HasSwitch(switches::kDisableExperimentalWebGL); |
| + bool disableMultisampling = |
| + browser_command_line.HasSwitch(switches::kDisableGLMultisampling)); |
| + |
| + // build the feature_status field |
| + { |
| + ListValue* feature_status_list = new ListValue(); |
| + // Iterate over all feature bits in kGpuFeatureAll and set feature status |
| + // for each one. |
| + for (size_t i = 0; i < sizeof(GpuFeatureFlags::GpuFeatureType) * 8; ++i) { |
| + GpuFeatureFlags::GpuFeatureType feature = |
| + static_cast<GpuFeatureFlags::GpuFeatureType>(1 << i); |
| + if (!(feature & GpuFeatureFlags::kGpuFeatureAll)) |
| + continue; |
| + |
| + DictionaryValue* feature_status = new DictionaryValue(); |
| + |
| + std::string feature_name( |
| + GpuFeatureFlags::GpuFeatureTypeToString(feature)); |
| + feature_status->SetString("name", feature_name); |
| + |
| + // figure out if the feature is on or off |
| + bool blacklisted = false; |
| + for (size_t i = 0; i < active_entries_.size(); ++i) { |
| + if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) |
| + blacklisted = true; |
| + } |
| + |
| + // status is actually a function of blacklisting + enable/disable flags + global GPU state |
|
zmo
2011/04/11 23:10:25
80 per line
|
| + const char* status; |
| + if (!gpuAccessAllowed) { |
| + status = "unavailable"; |
| + } else { |
| + switch(feature) { |
| + case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: |
|
zmo
2011/04/11 23:10:25
switch style is incorrect. two whitespaces before
|
| + if (enableAccelerated2DCanvas) { |
| + if (blacklisted) |
| + status = "unavailable"; |
| + else |
| + status = "enabled"; |
| + } else { |
| + status = "software"; |
| + } |
| + break; |
| + case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: |
| + if (disableAcceleratedCompositing) { |
| + status = "software"; |
| + } else { |
| + if (blacklisted) |
| + status = "unavailable"; |
| + else |
| + status = "enabled"; |
| + } |
| + break; |
| + |
| + case GpuFeatureFlags::kGpuFeatureWebgl: |
| + if (disableExperimentalWebGL) { |
| + status = "software"; |
|
zmo
2011/04/11 23:10:25
Since we don't have a software renderer for WebGL
|
| + } else { |
| + if (blacklisted) |
| + status = "unavailable"; |
| + else |
| + status = "enabled"; |
| + } |
| + break; |
| + |
| + case GpuFeatureFlags::kGpuFeatureMultisampling: |
| + if(disableMultisampling) { |
| + status = "unavailable"; |
| + } else { |
| + if(blacklisted) |
| + status = "unavailable"; |
| + else |
| + status = "enabled"; |
| + } |
| + break; |
| + default: |
| + status = blacklisted ? "unavailable" : "enabled"; |
|
zmo
2011/04/11 23:10:25
shouldn't here be UNREACHABLE() or something like
|
| + break; |
| + } |
| + } |
| + feature_status->SetString("status", status); |
| + |
| + feature_status_list->Append(feature_status); |
| + } |
| + status->Set("featureStatus", feature_status_list); |
| + } |
| + |
| + // build the problems list |
| + { |
| + ListValue* problem_list = new ListValue(); |
| + if(!gpuAccessAllowed) { |
| + DictionaryValue* problem = new DictionaryValue(); |
| + problem->SetString("description", "GPU process was unable to boot. Access to GPU disallowed."); |
|
zmo
2011/04/11 23:10:25
80 per line
|
| + problem->Set("crBugs", new ListValue()); |
| + problem->Set("webkitBugs", new ListValue()); |
| + problem_list->Append(problem); |
| + } |
| + if(!enableAccelerated2DCanvas) { |
| + DictionaryValue* problem = new DictionaryValue(); |
| + problem->SetString("description", |
| + "Accelerated 2D canvas has not been enabled " |
| + "(in about:flags or command line)"); |
| + problem->Set("crBugs", new ListValue()); |
| + problem->Set("webkitBugs", new ListValue()); |
| + problem_list->Append(problem); |
| + } |
| + if(disableAcceleratedCompositing) { |
| + DictionaryValue* problem = new DictionaryValue(); |
| + problem->SetString("description", |
| + "Accelerated compositing has been disabled, either via about:flags " |
| + "or command line"); |
| + problem->Set("crBugs", new ListValue()); |
| + problem->Set("webkitBugs", new ListValue()); |
| + problem_list->Append(problem); |
| + } |
| + if(disableExperimentalWebGL) { |
| + DictionaryValue* problem = new DictionaryValue(); |
| + problem->SetString("description", |
| + "WebGL has been disabled, either via about:flags " |
| + "or command line"); |
| + problem->Set("crBugs", new ListValue()); |
| + problem->Set("webkitBugs", new ListValue()); |
| + problem_list->Append(problem); |
| + } |
| + if(disableMultisampling) { |
| + DictionaryValue* problem = new DictionaryValue(); |
| + problem->SetString("description", |
| + "Multisampling has been disabled, either via about:flags " |
| + "or command line"); |
| + problem->Set("crBugs", new ListValue()); |
| + problem->Set("webkitBugs", new ListValue()); |
| + problem_list->Append(problem); |
| + } |
| + for (size_t i = 0; i < active_entries_.size(); ++i) { |
| + GpuBlacklistEntry* entry = active_entries_[i]; |
| + DictionaryValue* problem = new DictionaryValue(); |
| + |
| + problem->SetString("description", entry->description()); |
| - ListValue* cr_bugs = new ListValue(); |
| - for (size_t j = 0; j < active_entries_[i]->cr_bugs().size(); ++j) |
| - cr_bugs->Append(Value::CreateIntegerValue( |
| - active_entries_[i]->cr_bugs()[j])); |
| - reason->Set("cr_bugs", cr_bugs); |
| + ListValue* cr_bugs = new ListValue(); |
| + for (size_t j = 0; j < entry->cr_bugs().size(); ++j) |
| + cr_bugs->Append(Value::CreateIntegerValue( |
| + entry->cr_bugs()[j])); |
| + problem->Set("crBugs", cr_bugs); |
| - ListValue* webkit_bugs = new ListValue(); |
| - for (size_t j = 0; j < active_entries_[i]->webkit_bugs().size(); ++j) |
| - webkit_bugs->Append(Value::CreateIntegerValue( |
| - active_entries_[i]->webkit_bugs()[j])); |
| - reason->Set("webkit_bugs", webkit_bugs); |
| + ListValue* webkit_bugs = new ListValue(); |
| + for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) |
| + webkit_bugs->Append(Value::CreateIntegerValue( |
| + entry->webkit_bugs()[j])); |
| + problem->Set("webkitBugs", webkit_bugs); |
| - reasons->Append(reason); |
| + problem_list->Append(problem); |
| + } |
| + status->Set("problems", problem_list); |
| } |
| - return reasons; |
| + return status; |
| } |
| uint32 GpuBlacklist::max_entry_id() const { |
| @@ -797,4 +942,3 @@ GpuBlacklist::IsEntrySupportedByCurrentBrowserVersion( |
| } |
| return kSupported; |
| } |
| - |