| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/gpu_util.h" | 5 #include "chrome/browser/gpu_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 14 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "base/version.h" | 17 #include "base/version.h" |
| 17 #include "chrome/browser/gpu_blacklist.h" | 18 #include "chrome/browser/gpu_blacklist.h" |
| 19 #include "chrome/common/chrome_version_info.h" |
| 18 #include "content/public/browser/gpu_data_manager.h" | 20 #include "content/public/browser/gpu_data_manager.h" |
| 19 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/gpu_info.h" | 22 #include "content/public/common/gpu_info.h" |
| 21 | 23 |
| 24 #if defined(OS_WIN) |
| 25 #include "base/win/windows_version.h" |
| 26 #elif defined(OS_MACOSX) |
| 27 #include "base/mac/mac_util.h" |
| 28 #endif |
| 29 |
| 22 using content::GpuDataManager; | 30 using content::GpuDataManager; |
| 23 using content::GpuFeatureType; | 31 using content::GpuFeatureType; |
| 24 | 32 |
| 25 namespace { | 33 namespace { |
| 26 | 34 |
| 27 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; | 35 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; |
| 28 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; | 36 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; |
| 29 const char kGpuFeatureNameWebgl[] = "webgl"; | 37 const char kGpuFeatureNameWebgl[] = "webgl"; |
| 30 const char kGpuFeatureNameMultisampling[] = "multisampling"; | 38 const char kGpuFeatureNameMultisampling[] = "multisampling"; |
| 31 const char kGpuFeatureNameFlash3d[] = "flash_3d"; | 39 const char kGpuFeatureNameFlash3d[] = "flash_3d"; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 break; | 163 break; |
| 156 } | 164 } |
| 157 return entry_index; | 165 return entry_index; |
| 158 } | 166 } |
| 159 #endif // OS_WIN | 167 #endif // OS_WIN |
| 160 | 168 |
| 161 } // namespace | 169 } // namespace |
| 162 | 170 |
| 163 namespace gpu_util { | 171 namespace gpu_util { |
| 164 | 172 |
| 173 const char kForceCompositingModeFieldTrialName[] = "ForceCompositingMode"; |
| 174 const char kFieldTrialEnabledName[] = "enabled"; |
| 175 |
| 176 void InitializeForceCompositingModeFieldTrial() { |
| 177 // Enable the field trial only on desktop OS's. |
| 178 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
| 179 return; |
| 180 #endif |
| 181 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 182 // Only run the trial on the Canary channel. |
| 183 if (channel != chrome::VersionInfo::CHANNEL_CANARY) |
| 184 return; |
| 185 #if defined(OS_WIN) |
| 186 // Don't run the trial on Windows XP. |
| 187 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 188 return; |
| 189 #elif defined(OS_MACOSX) |
| 190 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. |
| 191 if (base::mac::IsOSLeopardOrEarlier()) |
| 192 return; |
| 193 #endif |
| 194 |
| 195 const base::FieldTrial::Probability kDivisor = 100; |
| 196 scoped_refptr<base::FieldTrial> trial( |
| 197 base::FieldTrialList::FactoryGetFieldTrial( |
| 198 kForceCompositingModeFieldTrialName, kDivisor, |
| 199 "disable", 2012, 12, 31, NULL)); |
| 200 |
| 201 // Produce the same result on every run of this client. |
| 202 trial->UseOneTimeRandomization(); |
| 203 // 50% probability of being in the enabled group. |
| 204 const base::FieldTrial::Probability kEnableProbability = 50; |
| 205 int enable_group = trial->AppendGroup( |
| 206 kFieldTrialEnabledName, kEnableProbability); |
| 207 |
| 208 bool enabled = (trial->group() == enable_group); |
| 209 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled); |
| 210 } |
| 211 |
| 212 bool InForceCompositingModeTrial() { |
| 213 base::FieldTrial* trial = |
| 214 base::FieldTrialList::Find(kForceCompositingModeFieldTrialName); |
| 215 if (!trial) |
| 216 return false; |
| 217 return trial->group_name() == kFieldTrialEnabledName; |
| 218 } |
| 219 |
| 165 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { | 220 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { |
| 166 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) | 221 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) |
| 167 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; | 222 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; |
| 168 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) | 223 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) |
| 169 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; | 224 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; |
| 170 else if (feature_string == kGpuFeatureNameWebgl) | 225 else if (feature_string == kGpuFeatureNameWebgl) |
| 171 return content::GPU_FEATURE_TYPE_WEBGL; | 226 return content::GPU_FEATURE_TYPE_WEBGL; |
| 172 else if (feature_string == kGpuFeatureNameMultisampling) | 227 else if (feature_string == kGpuFeatureNameMultisampling) |
| 173 return content::GPU_FEATURE_TYPE_MULTISAMPLING; | 228 return content::GPU_FEATURE_TYPE_MULTISAMPLING; |
| 174 else if (feature_string == kGpuFeatureNameFlash3d) | 229 else if (feature_string == kGpuFeatureNameFlash3d) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (kGpuFeatureInfo[i].fallback_to_software) | 357 if (kGpuFeatureInfo[i].fallback_to_software) |
| 303 status += "_software"; | 358 status += "_software"; |
| 304 else | 359 else |
| 305 status += "_off"; | 360 status += "_off"; |
| 306 } else { | 361 } else { |
| 307 status = "enabled"; | 362 status = "enabled"; |
| 308 if (kGpuFeatureInfo[i].name == "webgl" && | 363 if (kGpuFeatureInfo[i].name == "webgl" && |
| 309 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || | 364 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
| 310 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) | 365 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) |
| 311 status += "_readback"; | 366 status += "_readback"; |
| 312 bool has_thread = CommandLine::ForCurrentProcess()->HasSwitch( | 367 bool has_thread = |
| 313 switches::kEnableThreadedCompositing) && | 368 command_line.HasSwitch(switches::kEnableThreadedCompositing) && |
| 314 (!CommandLine::ForCurrentProcess()->HasSwitch( | 369 !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| 315 switches::kDisableThreadedCompositing)); | 370 if (kGpuFeatureInfo[i].name == "compositing") { |
| 316 if (kGpuFeatureInfo[i].name == "compositing" && | 371 bool force_compositing = |
| 317 CommandLine::ForCurrentProcess()->HasSwitch( | 372 command_line.HasSwitch(switches::kForceCompositingMode) || |
| 318 switches::kForceCompositingMode)) | 373 InForceCompositingModeTrial(); |
| 319 status += "_force"; | 374 if (force_compositing) |
| 320 if (kGpuFeatureInfo[i].name == "compositing" && | 375 status += "_force"; |
| 321 has_thread) | 376 if (has_thread) |
| 322 status += "_threaded"; | 377 status += "_threaded"; |
| 378 } |
| 323 if (kGpuFeatureInfo[i].name == "css_animation") { | 379 if (kGpuFeatureInfo[i].name == "css_animation") { |
| 324 if (has_thread) | 380 if (has_thread) |
| 325 status = "accelerated_threaded"; | 381 status = "accelerated_threaded"; |
| 326 else | 382 else |
| 327 status = "accelerated"; | 383 status = "accelerated"; |
| 328 } | 384 } |
| 329 } | 385 } |
| 330 feature_status_list->Append( | 386 feature_status_list->Append( |
| 331 NewStatusValue(kGpuFeatureInfo[i].name.c_str(), status.c_str())); | 387 NewStatusValue(kGpuFeatureInfo[i].name.c_str(), status.c_str())); |
| 332 } | 388 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 kGpuBlacklistFeatureHistogramNamesWin[i], | 565 kGpuBlacklistFeatureHistogramNamesWin[i], |
| 510 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 566 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
| 511 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 567 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
| 512 base::Histogram::kUmaTargetedHistogramFlag); | 568 base::Histogram::kUmaTargetedHistogramFlag); |
| 513 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 569 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
| 514 #endif | 570 #endif |
| 515 } | 571 } |
| 516 } | 572 } |
| 517 | 573 |
| 518 } // namespace gpu_util; | 574 } // namespace gpu_util; |
| OLD | NEW |