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/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "base/version.h" | 17 #include "base/version.h" |
18 #include "chrome/browser/gpu_blacklist.h" | 18 #include "chrome/browser/gpu_blacklist.h" |
19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
20 #include "content/public/browser/gpu_data_manager.h" | 20 #include "content/public/browser/gpu_data_manager.h" |
| 21 #include "content/public/common/compositor_util.h" |
21 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
23 #include "content/public/common/gpu_info.h" | 24 #include "content/public/common/gpu_info.h" |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
26 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
27 #elif defined(OS_MACOSX) | 28 #elif defined(OS_MACOSX) |
28 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
29 #endif | 30 #endif |
30 | 31 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 entry_index++; | 163 entry_index++; |
163 break; | 164 break; |
164 case kGpuFeatureDisabled: | 165 case kGpuFeatureDisabled: |
165 entry_index += 2; | 166 entry_index += 2; |
166 break; | 167 break; |
167 } | 168 } |
168 return entry_index; | 169 return entry_index; |
169 } | 170 } |
170 #endif // OS_WIN | 171 #endif // OS_WIN |
171 | 172 |
172 bool InForceThreadedCompositingModeTrial() { | |
173 base::FieldTrial* trial = | |
174 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
175 return trial && trial->group_name() == | |
176 content::kGpuCompositingFieldTrialThreadEnabledName; | |
177 } | |
178 | |
179 } // namespace | 173 } // namespace |
180 | 174 |
181 namespace gpu_util { | 175 namespace gpu_util { |
182 | 176 |
183 void InitializeForceCompositingModeFieldTrial() { | 177 void InitializeCompositingFieldTrial() { |
184 // Enable the field trial only on desktop OS's. | 178 // Enable the field trial only on desktop OS's. |
185 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 179 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
186 return; | 180 return; |
187 #endif | 181 #endif |
188 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
189 // Only run the trial on the Canary and Dev channels. | |
190 if (channel != chrome::VersionInfo::CHANNEL_CANARY && | |
191 channel != chrome::VersionInfo::CHANNEL_DEV) | |
192 return; | |
193 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
194 // Don't run the trial on Windows XP. | 183 // Don't run the trial on Windows XP. |
195 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 184 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
196 return; | 185 return; |
197 #elif defined(OS_MACOSX) | 186 #elif defined(OS_MACOSX) |
198 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. | 187 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. |
199 if (base::mac::IsOSLeopardOrEarlier()) | 188 if (base::mac::IsOSLeopardOrEarlier()) |
200 return; | 189 return; |
201 #endif | 190 #endif |
202 | 191 |
203 // The performance of accelerated compositing is too low with software | 192 // The performance of accelerated compositing is too low with software |
204 // rendering. | 193 // rendering. |
205 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) | 194 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) |
206 return; | 195 return; |
207 | 196 |
208 // Don't activate the field trial if force-compositing-mode has been | 197 // Don't activate the field trial if force-compositing-mode has been |
209 // explicitly disabled from the command line. | 198 // explicitly disabled from the command line. |
210 if (CommandLine::ForCurrentProcess()->HasSwitch( | 199 if (CommandLine::ForCurrentProcess()->HasSwitch( |
211 switches::kDisableForceCompositingMode) || | 200 switches::kDisableForceCompositingMode)) |
212 CommandLine::ForCurrentProcess()->HasSwitch( | |
213 switches::kDisableThreadedCompositing)) | |
214 return; | 201 return; |
215 | 202 |
216 const base::FieldTrial::Probability kDivisor = 3; | 203 const base::FieldTrial::Probability kDivisor = 3; |
217 scoped_refptr<base::FieldTrial> trial( | 204 scoped_refptr<base::FieldTrial> trial( |
218 base::FieldTrialList::FactoryGetFieldTrial( | 205 base::FieldTrialList::FactoryGetFieldTrial( |
219 content::kGpuCompositingFieldTrialName, kDivisor, | 206 content::kGpuCompositingFieldTrialName, kDivisor, |
220 "disable", 2012, 12, 31, NULL)); | 207 "disable", 2012, 12, 31, NULL)); |
221 | 208 |
222 // Produce the same result on every run of this client. | 209 // Produce the same result on every run of this client. |
223 trial->UseOneTimeRandomization(); | 210 trial->UseOneTimeRandomization(); |
224 // 1/3 probability of being in the enabled or thread group. | 211 |
225 const base::FieldTrial::Probability kEnableProbability = 1; | 212 base::FieldTrial::Probability force_compositing_mode_probability = 0; |
226 int enable_group = trial->AppendGroup( | 213 base::FieldTrial::Probability threaded_compositing_probability = 0; |
227 content::kGpuCompositingFieldTrialEnabledName, kEnableProbability); | 214 |
| 215 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 216 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 217 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 218 // Stable and Beta channels: Non-threaded force-compositing-mode on by |
| 219 // default (mac and windows only). |
| 220 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 221 force_compositing_mode_probability = 3; |
| 222 #endif |
| 223 } else if (channel == chrome::VersionInfo::CHANNEL_DEV || |
| 224 channel == chrome::VersionInfo::CHANNEL_CANARY) { |
| 225 // Dev and Canary channels: force-compositing-mode and |
| 226 // threaded-compositing on with 1/3 probability each. |
| 227 force_compositing_mode_probability = 1; |
| 228 |
| 229 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 switches::kDisableThreadedCompositing)) |
| 231 threaded_compositing_probability = 1; |
| 232 } |
| 233 |
| 234 int force_compositing_group = trial->AppendGroup( |
| 235 content::kGpuCompositingFieldTrialForceCompositingEnabledName, |
| 236 force_compositing_mode_probability); |
228 int thread_group = trial->AppendGroup( | 237 int thread_group = trial->AppendGroup( |
229 content::kGpuCompositingFieldTrialThreadEnabledName, kEnableProbability); | 238 content::kGpuCompositingFieldTrialThreadEnabledName, |
| 239 threaded_compositing_probability); |
230 | 240 |
231 bool enabled = (trial->group() == enable_group); | 241 bool force_compositing = (trial->group() == force_compositing_group); |
232 bool thread = (trial->group() == thread_group); | 242 bool thread = (trial->group() == thread_group); |
233 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled); | 243 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
| 244 force_compositing); |
234 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 245 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
235 } | 246 } |
236 | 247 |
237 bool InForceCompositingModeOrThreadTrial() { | |
238 base::FieldTrial* trial = | |
239 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
240 if (!trial) | |
241 return false; | |
242 return trial->group_name() == content::kGpuCompositingFieldTrialEnabledName || | |
243 trial->group_name() == | |
244 content::kGpuCompositingFieldTrialThreadEnabledName; | |
245 } | |
246 | |
247 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { | 248 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { |
248 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) | 249 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) |
249 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; | 250 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; |
250 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) | 251 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) |
251 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; | 252 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; |
252 else if (feature_string == kGpuFeatureNameWebgl) | 253 else if (feature_string == kGpuFeatureNameWebgl) |
253 return content::GPU_FEATURE_TYPE_WEBGL; | 254 return content::GPU_FEATURE_TYPE_WEBGL; |
254 else if (feature_string == kGpuFeatureNameMultisampling) | 255 else if (feature_string == kGpuFeatureNameMultisampling) |
255 return content::GPU_FEATURE_TYPE_MULTISAMPLING; | 256 return content::GPU_FEATURE_TYPE_MULTISAMPLING; |
256 else if (feature_string == kGpuFeatureNameFlash3d) | 257 else if (feature_string == kGpuFeatureNameFlash3d) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 if (kGpuFeatureInfo[i].fallback_to_software) | 411 if (kGpuFeatureInfo[i].fallback_to_software) |
411 status += "_software"; | 412 status += "_software"; |
412 else | 413 else |
413 status += "_off"; | 414 status += "_off"; |
414 } else { | 415 } else { |
415 status = "enabled"; | 416 status = "enabled"; |
416 if (kGpuFeatureInfo[i].name == "webgl" && | 417 if (kGpuFeatureInfo[i].name == "webgl" && |
417 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || | 418 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
418 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) | 419 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) |
419 status += "_readback"; | 420 status += "_readback"; |
420 bool has_thread = | 421 bool has_thread = content::IsThreadedCompositingEnabled(); |
421 (command_line.HasSwitch(switches::kEnableThreadedCompositing) && | |
422 !command_line.HasSwitch(switches::kDisableThreadedCompositing)) || | |
423 InForceThreadedCompositingModeTrial(); | |
424 if (kGpuFeatureInfo[i].name == "compositing") { | 422 if (kGpuFeatureInfo[i].name == "compositing") { |
425 bool force_compositing = | 423 bool force_compositing = |
426 (command_line.HasSwitch(switches::kForceCompositingMode) && | 424 content::IsForceCompositingModeEnabled(); |
427 !command_line.HasSwitch( | |
428 switches::kDisableForceCompositingMode)) || | |
429 InForceCompositingModeOrThreadTrial(); | |
430 if (force_compositing) | 425 if (force_compositing) |
431 status += "_force"; | 426 status += "_force"; |
432 if (has_thread) | 427 if (has_thread) |
433 status += "_threaded"; | 428 status += "_threaded"; |
434 } | 429 } |
435 if (kGpuFeatureInfo[i].name == "css_animation") { | 430 if (kGpuFeatureInfo[i].name == "css_animation") { |
436 if (has_thread) | 431 if (has_thread) |
437 status = "accelerated_threaded"; | 432 status = "accelerated_threaded"; |
438 else | 433 else |
439 status = "accelerated"; | 434 status = "accelerated"; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 kGpuBlacklistFeatureHistogramNamesWin[i], | 620 kGpuBlacklistFeatureHistogramNamesWin[i], |
626 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 621 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
627 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 622 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
628 base::Histogram::kUmaTargetedHistogramFlag); | 623 base::Histogram::kUmaTargetedHistogramFlag); |
629 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 624 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
630 #endif | 625 #endif |
631 } | 626 } |
632 } | 627 } |
633 | 628 |
634 } // namespace gpu_util; | 629 } // namespace gpu_util; |
OLD | NEW |