Chromium Code Reviews| Index: content/browser/gpu/gpu_data_manager_impl_private.cc |
| =================================================================== |
| --- content/browser/gpu/gpu_data_manager_impl_private.cc (revision 200330) |
| +++ content/browser/gpu/gpu_data_manager_impl_private.cc (working copy) |
| @@ -18,6 +18,10 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "base/sys_info.h" |
| #include "base/version.h" |
| +#if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
| +#endif // OS_WIN |
| +#include "cc/base/switches.h" |
| #include "content/browser/gpu/gpu_control_list_jsons.h" |
| #include "content/browser/gpu/gpu_process_host.h" |
| #include "content/browser/gpu/gpu_util.h" |
| @@ -31,16 +35,15 @@ |
| #include "content/public/common/gpu_feature_type.h" |
| #include "gpu/command_buffer/service/gpu_switches.h" |
| #include "ui/base/ui_base_switches.h" |
| +#if defined(OS_ANDROID) |
| +#include "ui/gfx/android/device_display_info.h" |
| +#endif // OS_ANDROID |
| #include "ui/gl/gl_implementation.h" |
| #include "ui/gl/gl_switches.h" |
| #include "ui/gl/gpu_switching_manager.h" |
| #include "webkit/glue/webpreferences.h" |
| #include "webkit/plugins/plugin_switches.h" |
| -#if defined(OS_WIN) |
| -#include "base/win/windows_version.h" |
| -#endif |
|
no sievers
2013/05/16 23:04:24
Shouldn't the includes be here? http://www.chromiu
Zhenyao Mo
2013/05/16 23:10:35
Done.
|
| - |
| namespace content { |
| namespace { |
| @@ -84,6 +87,78 @@ |
| } |
| #endif // OS_MACOSX |
| +#if defined(OS_ANDROID) |
| +void ApplyAndroidWorkarounds(const GPUInfo& gpu_info, |
| + CommandLine* command_line) { |
| + std::string vendor(StringToLowerASCII(gpu_info.gl_vendor)); |
| + std::string renderer(StringToLowerASCII(gpu_info.gl_renderer)); |
| + bool is_img = |
| + gpu_info.gl_vendor.find("Imagination") != std::string::npos; |
| + bool is_arm = |
| + gpu_info.gl_vendor.find("ARM") != std::string::npos; |
| + bool is_qualcomm = |
| + gpu_info.gl_vendor.find("Qualcomm") != std::string::npos; |
| + bool is_mali_t604 = is_arm && |
| + gpu_info.gl_renderer.find("Mali-T604") != std::string::npos; |
| + |
| + bool is_vivante = |
| + gpu_info.gl_extensions.find("GL_VIV_shader_binary") != |
| + std::string::npos; |
| + |
| + bool is_nexus7 = |
| + gpu_info.machine_model.find("Nexus 7") != std::string::npos; |
| + bool is_nexus10 = |
| + gpu_info.machine_model.find("Nexus 10") != std::string::npos; |
| + |
| + // IMG: avoid context switching perf problems, crashes with share groups |
| + // Mali-T604: http://crbug.com/154715 |
| + // QualComm, NVIDIA: Crashes with share groups |
| + if (is_vivante || is_img || is_mali_t604 || is_nexus7 || is_qualcomm) |
| + command_line->AppendSwitch(switches::kEnableVirtualGLContexts); |
| + |
| + gfx::DeviceDisplayInfo info; |
| + int default_tile_size = 256; |
| + |
| + // For very high resolution displays (eg. Nexus 10), set the default |
| + // tile size to be 512. This should be removed in favour of a generic |
| + // hueristic that works across all platforms and devices, once that |
| + // exists: http://crbug.com/159524. This switches to 512 for screens |
| + // containing 40 or more 256x256 tiles, such that 1080p devices do |
| + // not use 512x512 tiles (eg. 1920x1280 requires 37.5 tiles) |
| + int numTiles = (info.GetDisplayWidth() * |
| + info.GetDisplayHeight()) / (256 * 256); |
| + if (numTiles >= 40) |
| + default_tile_size = 512; |
| + |
| + // IMG: Fast async texture uploads only work with non-power-of-two, |
| + // but still multiple-of-eight sizes. |
| + // http://crbug.com/168099 |
| + if (is_img) |
| + default_tile_size -= 8; |
| + |
| + // Set the command line if it isn't already set and we changed |
| + // the default tile size. |
| + if (default_tile_size != 256 && |
| + !command_line->HasSwitch(switches::kDefaultTileWidth) && |
| + !command_line->HasSwitch(switches::kDefaultTileHeight)) { |
| + std::stringstream size; |
| + size << default_tile_size; |
| + command_line->AppendSwitchASCII( |
| + switches::kDefaultTileWidth, size.str()); |
| + command_line->AppendSwitchASCII( |
| + switches::kDefaultTileHeight, size.str()); |
| + } |
| + |
| + // Increase the resolution of low resolution tiles for Nexus tablets. |
| + if ((is_nexus7 || is_nexus10) && |
| + !command_line->HasSwitch( |
| + cc::switches::kLowResolutionContentsScaleFactor)) { |
| + command_line->AppendSwitchASCII( |
| + cc::switches::kLowResolutionContentsScaleFactor, "0.25"); |
| + } |
| +} |
| +#endif // OS_ANDROID |
| + |
| // 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; |
| @@ -328,16 +403,6 @@ |
| gpu_switching_list_string, |
| gpu_driver_bug_list_string, |
| gpu_info); |
| - // We pass down the list to GPU command buffer through commandline |
| - // switches at GPU process launch. However, in situations where we don't |
| - // have a GPU process, we append the browser process commandline. |
| - if (command_line->HasSwitch(switches::kSingleProcess) || |
| - command_line->HasSwitch(switches::kInProcessGPU)) { |
| - if (!gpu_driver_bugs_.empty()) { |
| - command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, |
| - IntSetToString(gpu_driver_bugs_)); |
| - } |
| - } |
| } |
| void GpuDataManagerImplPrivate::UpdateGpuInfo(const GPUInfo& gpu_info) { |
| @@ -747,6 +812,21 @@ |
| UpdateGpuInfo(gpu_info); |
| UpdateGpuSwitchingManager(gpu_info); |
| UpdatePreliminaryBlacklistedFeatures(); |
| + |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + // We pass down the list to GPU command buffer through commandline |
| + // switches at GPU process launch. However, in situations where we don't |
| + // have a GPU process, we append the browser process commandline. |
| + if (command_line->HasSwitch(switches::kSingleProcess) || |
| + command_line->HasSwitch(switches::kInProcessGPU)) { |
| + if (!gpu_driver_bugs_.empty()) { |
| + command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, |
| + IntSetToString(gpu_driver_bugs_)); |
| + } |
| + } |
| +#if defined(OS_ANDROID) |
| + ApplyAndroidWorkarounds(gpu_info, command_line); |
| +#endif // OS_ANDROID |
| } |
| void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( |