Chromium Code Reviews| 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 fd705c8967ac20837a5d2c6b45f039d7c71b3fa2..c4fc062e42959557b5b30e4930bc2df7247bd9f9 100644 |
| --- a/content/browser/gpu/gpu_data_manager_impl_private.cc |
| +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc |
| @@ -271,7 +271,7 @@ bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
| return true; |
| } |
| #endif // OS_CHROMEOS |
| - if (use_swiftshader_) { |
| + if (use_swiftshader_ || ShouldUseWarp()) { |
| // Skia's software rendering is probably more efficient than going through |
| // software emulation of the GPU, so use that. |
| if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
| @@ -287,7 +287,7 @@ bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { |
| } |
| size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
| - if (use_swiftshader_) |
| + if (use_swiftshader_ || ShouldUseWarp()) |
| return 1; |
| return blacklisted_features_.size(); |
| } |
| @@ -311,7 +311,7 @@ void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
| bool GpuDataManagerImplPrivate::GpuAccessAllowed( |
| std::string* reason) const { |
| - if (use_swiftshader_) |
| + if (use_swiftshader_ || ShouldUseWarp()) |
| return true; |
| if (!gpu_process_accessible_) { |
| @@ -398,6 +398,11 @@ void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( |
| EnableSwiftShaderIfNecessary(); |
| } |
| +bool GpuDataManagerImplPrivate::ShouldUseWarp() const { |
| + return use_warp_ || |
| + CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseWarp); |
| +} |
| + |
| void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { |
| GpuDataManagerImpl::UnlockedSession session(owner_); |
| observer_list_->AddObserver(observer); |
| @@ -545,7 +550,7 @@ void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { |
| void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
| // No further update of gpu_info if falling back to SwiftShader. |
| - if (use_swiftshader_) |
| + if (use_swiftshader_ || ShouldUseWarp()) |
| return; |
| gpu::MergeGPUInfo(&gpu_info_, gpu_info); |
| @@ -645,6 +650,9 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine( |
| gpu_info_.driver_vendor); |
| command_line->AppendSwitchASCII(switches::kGpuDriverVersion, |
| gpu_info_.driver_version); |
| + |
| + if (ShouldUseWarp()) |
| + command_line->AppendSwitch(switches::kUseWarp); |
| } |
| void GpuDataManagerImplPrivate::AppendPluginCommandLine( |
| @@ -707,6 +715,7 @@ void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { |
| for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) |
| blacklisted_features_.insert(i); |
| + EnableWarpIfNecessary(); |
| EnableSwiftShaderIfNecessary(); |
| NotifyGpuInfoUpdate(); |
| } |
| @@ -813,6 +822,8 @@ bool GpuDataManagerImplPrivate::UpdateActiveGpu( |
| } |
| bool GpuDataManagerImplPrivate::CanUseGpuBrowserCompositor() const { |
| + if (ShouldUseWarp()) |
| + return true; |
| if (ShouldUseSwiftShader()) |
| return false; |
| if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
| @@ -859,6 +870,7 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( |
| : complete_gpu_info_already_requested_(false), |
| observer_list_(new GpuDataManagerObserverList), |
| use_swiftshader_(false), |
| + use_warp_(false), |
| card_blacklisted_(false), |
| update_histograms_(true), |
| window_count_(0), |
| @@ -932,6 +944,7 @@ void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( |
| blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); |
| } |
| + EnableWarpIfNecessary(); |
| EnableSwiftShaderIfNecessary(); |
| } |
| @@ -957,6 +970,9 @@ void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { |
| } |
| void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { |
| + if (ShouldUseWarp()) |
| + return; |
|
Zhenyao Mo
2014/08/29 18:28:50
Please add an unit test to make sure if Warp is us
luken
2014/08/29 23:34:03
Done.
|
| + |
| if (!GpuAccessAllowed(NULL) || |
| blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { |
| if (!swiftshader_path_.empty() && |
| @@ -966,6 +982,15 @@ void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { |
| } |
| } |
| +void GpuDataManagerImplPrivate::EnableWarpIfNecessary() { |
| +#if defined(OS_WIN) |
| + // We should only use WARP if we are unable to use the regular GPU for |
| + // compositing, and if we should fall back. |
| + use_warp_ = !CanUseGpuBrowserCompositor() && |
| + gpu::ShouldFallbackToWarp(); |
| +#endif |
| +} |
| + |
| std::string GpuDataManagerImplPrivate::GetDomainFromURL( |
| const GURL& url) const { |
| // For the moment, we just use the host, or its IP address, as the |