Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / gpu / gpu_data_manager_impl_private.cc
index 2c5b91e..bbf7231 100644 (file)
@@ -23,6 +23,7 @@
 #include "content/public/common/content_client.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/content_switches.h"
+#include "content/public/common/web_preferences.h"
 #include "gpu/command_buffer/service/gpu_switches.h"
 #include "gpu/config/gpu_control_list_jsons.h"
 #include "gpu/config/gpu_driver_bug_workaround_type.h"
@@ -33,7 +34,6 @@
 #include "ui/gl/gl_implementation.h"
 #include "ui/gl/gl_switches.h"
 #include "ui/gl/gpu_switching_manager.h"
-#include "webkit/common/webpreferences.h"
 
 #if defined(OS_MACOSX)
 #include <ApplicationServices/ApplicationServices.h>
@@ -113,7 +113,8 @@ void UpdateStats(const gpu::GPUInfo& gpu_info,
     return;
   }
 
-  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+  const base::CommandLine& command_line =
+      *base::CommandLine::ForCurrentProcess();
   bool disabled = false;
 
   // Use entry 0 to capture the total number of times that data
@@ -138,9 +139,9 @@ void UpdateStats(const gpu::GPUInfo& gpu_info,
   std::vector<uint32> flag_disabled_entries;
   disabled = true;
   blacklist->GetDecisionEntries(&flag_disabled_entries, disabled);
-  for (size_t i = 0; i < flag_disabled_entries.size(); ++i) {
+  for (uint32 disabled_entry : flag_disabled_entries) {
     UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry",
-        flag_disabled_entries[i], max_entry_id + 1);
+        disabled_entry, max_entry_id + 1);
   }
 
   const gpu::GpuFeatureType kGpuFeatures[] = {
@@ -235,81 +236,6 @@ void DisplayReconfigCallback(CGDirectDisplayID display,
 }
 #endif  // OS_MACOSX
 
-#if defined(OS_ANDROID)
-void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info,
-                             CommandLine* command_line,
-                             std::set<int>* workarounds) {
-  std::string vendor(StringToLowerASCII(gpu_info.gl_vendor));
-  std::string renderer(StringToLowerASCII(gpu_info.gl_renderer));
-  std::string version(StringToLowerASCII(gpu_info.gl_version));
-
-  bool is_img =
-      gpu_info.gl_vendor.find("Imagination") != std::string::npos;
-
-  gfx::DeviceDisplayInfo info;
-  int default_tile_size = 256;
-
-  // TODO(epenner): Now that this is somewhat generic, maybe we can
-  // unify this for all platforms (http://crbug.com/159524)
-
-  bool real_size_supported = true;
-  int display_width = info.GetPhysicalDisplayWidth();
-  int display_height = info.GetPhysicalDisplayHeight();
-  if (display_width == 0 || display_height == 0) {
-    real_size_supported = false;
-    display_width = info.GetDisplayWidth();
-    display_height = info.GetDisplayHeight();
-  }
-
-  int portrait_width = std::min(display_width, display_height);
-  int landscape_width = std::max(display_width, display_height);
-
-  if (real_size_supported) {
-    // Maximum HD dimensions should be 768x1280
-    // Maximum FHD dimensions should be 1200x1920
-    if (portrait_width > 768 || landscape_width > 1280)
-       default_tile_size = 384;
-    if (portrait_width > 1200 || landscape_width > 1920)
-       default_tile_size = 512;
-
-    // Adjust for some resolutions that barely straddle an extra
-    // tile when in portrait mode. This helps worst case scroll/raster
-    // by not needing a full extra tile for each row.
-    if (default_tile_size == 256 && portrait_width == 768)
-      default_tile_size += 32;
-    if (default_tile_size == 384 && portrait_width == 1200)
-      default_tile_size += 32;
-  } else {
-    // We don't know the exact resolution due to screen controls etc.
-    // So this just estimates the values above using tile counts.
-    int numTiles = (display_width * display_height) / (256 * 256);
-    if (numTiles > 16)
-      default_tile_size = 384;
-    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());
-  }
-}
-#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;
@@ -340,7 +266,7 @@ void GpuDataManagerImplPrivate::InitializeForTesting(
 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const {
 #if defined(OS_CHROMEOS)
   if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING &&
-      CommandLine::ForCurrentProcess()->HasSwitch(
+      base::CommandLine::ForCurrentProcess()->HasSwitch(
           switches::kDisablePanelFitting)) {
     return true;
   }
@@ -398,7 +324,7 @@ bool GpuDataManagerImplPrivate::GpuAccessAllowed(
   if (card_blacklisted_) {
     if (reason) {
       *reason = "GPU access is disabled ";
-      CommandLine* command_line = CommandLine::ForCurrentProcess();
+      base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
       if (command_line->HasSwitch(switches::kDisableGpu))
         *reason += "through commandline switch --disable-gpu.";
       else
@@ -552,7 +478,8 @@ void GpuDataManagerImplPrivate::Initialize() {
     return;
   }
 
-  const CommandLine* command_line = CommandLine::ForCurrentProcess();
+  const base::CommandLine* command_line =
+      base::CommandLine::ForCurrentProcess();
   if (command_line->HasSwitch(switches::kSkipGpuDataLoading))
     return;
 
@@ -610,7 +537,7 @@ void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() {
         gpu::GpuControlList::kOsAny, std::string(), gpu_info_);
   }
   gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine(
-      &gpu_driver_bugs_, *CommandLine::ForCurrentProcess());
+      &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess());
 
   // We have to update GpuFeatureType before notify all the observers.
   NotifyGpuInfoUpdate();
@@ -636,7 +563,7 @@ void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats(
 }
 
 void GpuDataManagerImplPrivate::AppendRendererCommandLine(
-    CommandLine* command_line) const {
+    base::CommandLine* command_line) const {
   DCHECK(command_line);
 
   if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) &&
@@ -655,13 +582,14 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
 }
 
 void GpuDataManagerImplPrivate::AppendGpuCommandLine(
-    CommandLine* command_line) const {
+    base::CommandLine* command_line) const {
   DCHECK(command_line);
 
   std::string use_gl =
-      CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
+      base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+          switches::kUseGL);
   base::FilePath swiftshader_path =
-      CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+      base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
           switches::kSwiftShaderPath);
   if (gpu_driver_bugs_.find(gpu::DISABLE_D3D11) != gpu_driver_bugs_.end())
     command_line->AppendSwitch(switches::kDisableD3D11);
@@ -720,7 +648,7 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
 }
 
 void GpuDataManagerImplPrivate::AppendPluginCommandLine(
-    CommandLine* command_line) const {
+    base::CommandLine* command_line) const {
   DCHECK(command_line);
 
 #if defined(OS_MACOSX)
@@ -767,10 +695,16 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
 #endif
 
   if (!IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) &&
-      !CommandLine::ForCurrentProcess()->HasSwitch(
+      !base::CommandLine::ForCurrentProcess()->HasSwitch(
           switches::kDisableAcceleratedVideoDecode)) {
     prefs->pepper_accelerated_video_decode_enabled = true;
   }
+
+  if (!IsFeatureBlacklisted(
+          gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION_EXPANDED_HEURISTICS) ||
+      base::FieldTrialList::FindFullName(
+          "GpuRasterizationExpandedContentWhitelist") == "Enabled")
+    prefs->use_expanded_heuristics_for_gpu_rasterization = true;
 }
 
 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
@@ -832,6 +766,7 @@ void GpuDataManagerImplPrivate::ProcessCrashed(
     return;
   }
   {
+    gpu_info_.process_crash_count = GpuProcessHost::gpu_crash_count();
     GpuDataManagerImpl::UnlockedSession session(owner_);
     observer_list_->Notify(
         &GpuDataManagerObserver::OnGpuProcessCrashed, exit_code);
@@ -939,7 +874,8 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(
       gpu_process_accessible_(true),
       finalized_(false) {
   DCHECK(owner_);
-  CommandLine* command_line = CommandLine::ForCurrentProcess();
+  const base::CommandLine* command_line =
+      base::CommandLine::ForCurrentProcess();
   if (command_line->HasSwitch(switches::kDisableGpu))
     DisableHardwareAcceleration();
 
@@ -965,7 +901,7 @@ void GpuDataManagerImplPrivate::InitializeImpl(
     const std::string& gpu_driver_bug_list_json,
     const gpu::GPUInfo& gpu_info) {
   const bool log_gpu_control_list_decisions =
-      CommandLine::ForCurrentProcess()->HasSwitch(
+      base::CommandLine::ForCurrentProcess()->HasSwitch(
           switches::kLogGpuControlListDecisions);
 
   if (!gpu_blacklist_json.empty()) {
@@ -989,11 +925,6 @@ void GpuDataManagerImplPrivate::InitializeImpl(
   UpdateGpuInfo(gpu_info);
   UpdateGpuSwitchingManager(gpu_info);
   UpdatePreliminaryBlacklistedFeatures();
-
-#if defined(OS_ANDROID)
-  ApplyAndroidWorkarounds(
-      gpu_info, CommandLine::ForCurrentProcess(), &gpu_driver_bugs_);
-#endif  // OS_ANDROID
 }
 
 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures(
@@ -1035,7 +966,7 @@ void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
   if (!GpuAccessAllowed(NULL) ||
       blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) {
     if (!swiftshader_path_.empty() &&
-        !CommandLine::ForCurrentProcess()->HasSwitch(
+        !base::CommandLine::ForCurrentProcess()->HasSwitch(
              switches::kDisableSoftwareRasterizer))
       use_swiftshader_ = true;
   }