Chromium Code Reviews| Index: content/browser/gpu/gpu_data_manager.cc |
| diff --git a/content/browser/gpu/gpu_data_manager.cc b/content/browser/gpu/gpu_data_manager.cc |
| index c37865ee4f05e8f832fe268ef1ae06602ade7b77..c6b9a666a4b5d31f9b96d5f8f96f300004142a78 100644 |
| --- a/content/browser/gpu/gpu_data_manager.cc |
| +++ b/content/browser/gpu/gpu_data_manager.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| +#include "base/file_util.h" |
| #include "base/metrics/histogram.h" |
| #include "base/string_number_conversions.h" |
| #include "base/stringprintf.h" |
| @@ -195,7 +196,8 @@ void GpuDataManager::UserFlags::ApplyPolicies() { |
| GpuDataManager::GpuDataManager() |
| : complete_gpu_info_already_requested_(false), |
| - observer_list_(new GpuDataManagerObserverList) { |
| + observer_list_(new GpuDataManagerObserverList), |
| + software_rendering_(false) { |
| Initialize(); |
| } |
| @@ -326,7 +328,10 @@ Value* GpuDataManager::GetFeatureStatus() { |
| status += "_software"; |
| else |
| status += "_off"; |
| - } else if (kGpuFeatureInfo[i].blocked || gpu_access_blocked) { |
| + } else if (IsSoftwareRendering()) { |
| + status = "unavailable_software"; |
| + } else if (kGpuFeatureInfo[i].blocked || |
| + gpu_access_blocked) { |
| status = "unavailable"; |
| if (kGpuFeatureInfo[i].fallback_to_software) |
| status += "_software"; |
| @@ -406,10 +411,22 @@ const ListValue& GpuDataManager::log_messages() const { |
| } |
| GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { |
| + if (software_rendering_) { |
| + GpuFeatureFlags flags; |
| + |
| + // Skia's software rendering is probably more efficient than going through |
| + // software emulation of the GPU, so use that. |
| + flags.set_flags(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas); |
|
Zhenyao Mo
2011/11/05 00:39:19
What about accelerated_compositing? what about mu
jbauman
2011/11/05 00:49:34
We need accelerated compositing, or webgl will be
Zhenyao Mo
2011/11/05 01:03:58
OK. Multisampling on/off depends on performance.
|
| + return flags; |
| + } |
| + |
| return gpu_feature_flags_; |
| } |
| bool GpuDataManager::GpuAccessAllowed() { |
| + if (IsSoftwareRendering()) |
| + return true; |
| + |
| // We only need to block GPU process if more features are disallowed other |
| // than those in the preliminary gpu feature flags because the latter work |
| // through renderer commandline switches. |
| @@ -458,7 +475,11 @@ void GpuDataManager::AppendGpuCommandLine( |
| !command_line->HasSwitch(switches::kDisableGLMultisampling)) |
| command_line->AppendSwitch(switches::kDisableGLMultisampling); |
| - if ((flags & (GpuFeatureFlags::kGpuFeatureWebgl | |
| + if (software_rendering_) { |
| + command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); |
| + command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
| + swiftshader_path_); |
| + } else if ((flags & (GpuFeatureFlags::kGpuFeatureWebgl | |
| GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | |
| GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)) && |
| (user_flags_.use_gl() == "any")) { |
| @@ -501,8 +522,9 @@ void GpuDataManager::UpdateGpuBlacklist( |
| DCHECK(succeed); |
| if (updated_version_major < current_version_major || |
| (updated_version_major == current_version_major && |
| - updated_version_minor <= current_version_minor)) |
| + updated_version_minor <= current_version_minor)) { |
| return; |
| + } |
| gpu_blacklist_.reset(updated_list.release()); |
| UpdateGpuFeatureFlags(); |
| @@ -673,6 +695,27 @@ void GpuDataManager::UpdateGpuFeatureFlags() { |
| histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
| #endif |
| } |
| + |
| + EnableSoftwareRenderingIfNecessary(); |
| +} |
| + |
| +void GpuDataManager::RegisterSwiftShaderPath(FilePath path) { |
| + swiftshader_path_ = path; |
| + EnableSoftwareRenderingIfNecessary(); |
| +} |
| + |
| +void GpuDataManager::EnableSoftwareRenderingIfNecessary() { |
| + if (!GpuAccessAllowed()) { |
|
Zhenyao Mo
2011/11/05 00:39:19
Even if GpuAccessAllowed() returns true, but if we
jbauman
2011/11/05 00:49:34
It's kind of annoying that this would slow down ac
|
| +#if defined(ENABLE_SWIFTSHADER) |
| + FilePath eglpath = swiftshader_path_.AppendASCII("libegl.dll"); |
| + if (!swiftshader_path_.empty() && file_util::PathExists(eglpath)) |
|
Zhenyao Mo
2011/11/05 00:39:19
PathExists should only be called on a thread that
jbauman
2011/11/05 00:49:34
Good point, I can remove this check.
|
| + software_rendering_ = true; |
| +#endif |
| + } |
| +} |
| + |
| +bool GpuDataManager::IsSoftwareRendering() { |
| + return software_rendering_; |
|
Zhenyao Mo
2011/11/05 00:39:19
Accessor functions should match the variable name.
jbauman
2011/11/05 00:49:34
Ok.
|
| } |
| GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { |