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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 entry_index++; | 162 entry_index++; |
162 break; | 163 break; |
163 case kGpuFeatureDisabled: | 164 case kGpuFeatureDisabled: |
164 entry_index += 2; | 165 entry_index += 2; |
165 break; | 166 break; |
166 } | 167 } |
167 return entry_index; | 168 return entry_index; |
168 } | 169 } |
169 #endif // OS_WIN | 170 #endif // OS_WIN |
170 | 171 |
171 bool InForceThreadedCompositingModeTrial() { | |
172 base::FieldTrial* trial = | |
173 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
174 return trial && trial->group_name() == | |
175 content::kGpuCompositingFieldTrialThreadEnabledName; | |
176 } | |
177 | |
178 } // namespace | 172 } // namespace |
179 | 173 |
180 namespace gpu_util { | 174 namespace gpu_util { |
181 | 175 |
182 void InitializeForceCompositingModeFieldTrial() { | 176 void InitializeCompositingFieldTrial() { |
183 // Enable the field trial only on desktop OS's. | 177 // Enable the field trial only on desktop OS's. |
184 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 178 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
185 return; | 179 return; |
186 #endif | 180 #endif |
187 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
188 // Only run the trial on the Canary and Dev channels. | |
189 if (channel != chrome::VersionInfo::CHANNEL_CANARY && | |
190 channel != chrome::VersionInfo::CHANNEL_DEV) | |
191 return; | |
192 #if defined(OS_WIN) | 181 #if defined(OS_WIN) |
193 // Don't run the trial on Windows XP. | 182 // Don't run the trial on Windows XP. |
194 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 183 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
195 return; | 184 return; |
196 #elif defined(OS_MACOSX) | 185 #elif defined(OS_MACOSX) |
197 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. | 186 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. |
198 if (base::mac::IsOSLeopardOrEarlier()) | 187 if (base::mac::IsOSLeopardOrEarlier()) |
199 return; | 188 return; |
200 #endif | 189 #endif |
201 | 190 |
202 // The performance of accelerated compositing is too low with software | 191 // The performance of accelerated compositing is too low with software |
203 // rendering. | 192 // rendering. |
204 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) | 193 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) |
205 return; | 194 return; |
206 | 195 |
207 // Don't activate the field trial if force-compositing-mode has been | 196 // Don't activate the field trial if force-compositing-mode has been |
208 // explicitly disabled from the command line. | 197 // explicitly disabled from the command line. |
209 if (CommandLine::ForCurrentProcess()->HasSwitch( | 198 if (CommandLine::ForCurrentProcess()->HasSwitch( |
210 switches::kDisableForceCompositingMode) || | 199 switches::kDisableForceCompositingMode)) |
211 CommandLine::ForCurrentProcess()->HasSwitch( | |
212 switches::kDisableThreadedCompositing)) | |
213 return; | 200 return; |
214 | 201 |
215 const base::FieldTrial::Probability kDivisor = 3; | 202 const base::FieldTrial::Probability kDivisor = 3; |
216 scoped_refptr<base::FieldTrial> trial( | 203 scoped_refptr<base::FieldTrial> trial( |
217 base::FieldTrialList::FactoryGetFieldTrial( | 204 base::FieldTrialList::FactoryGetFieldTrial( |
218 content::kGpuCompositingFieldTrialName, kDivisor, | 205 content::kGpuCompositingFieldTrialName, kDivisor, |
219 "disable", 2012, 12, 31, NULL)); | 206 "disable", 2012, 12, 31, NULL)); |
220 | 207 |
221 // Produce the same result on every run of this client. | 208 // Produce the same result on every run of this client. |
222 trial->UseOneTimeRandomization(); | 209 trial->UseOneTimeRandomization(); |
223 // 1/3 probability of being in the enabled or thread group. | 210 |
224 const base::FieldTrial::Probability kEnableProbability = 1; | 211 base::FieldTrial::Probability forceCompositingModeProbability = 0; |
darin (slow to review)
2012/08/06 20:39:38
nit: google_style_variables
| |
225 int enable_group = trial->AppendGroup( | 212 base::FieldTrial::Probability threadedCompositingProbability = 0; |
226 content::kGpuCompositingFieldTrialEnabledName, kEnableProbability); | 213 |
214 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
215 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | |
216 channel == chrome::VersionInfo::CHANNEL_BETA) { | |
217 // Stable and Beta channels: Non-threaded force-compositing-mode on by | |
218 // default (mac and windows only). | |
219 #if defined(OS_WIN) || defined(OS_MACOSX) | |
220 forceCompositingModeProbability = 3; | |
221 #endif | |
222 } else if (channel == chrome::VersionInfo::CHANNEL_DEV || | |
223 channel == chrome::VersionInfo::CHANNEL_CANARY) { | |
224 // Dev and Canary channels: force-compositing-mode and | |
225 // threaded-compositing on with 1/3 probability each. | |
226 forceCompositingModeProbability = 1; | |
227 | |
228 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
229 switches::kDisableThreadedCompositing)) | |
230 threadedCompositingProbability = 1; | |
231 } | |
232 | |
233 int force_compositing_group = trial->AppendGroup( | |
234 content::kGpuCompositingFieldTrialForceCompositingEnabledName, | |
235 forceCompositingModeProbability); | |
227 int thread_group = trial->AppendGroup( | 236 int thread_group = trial->AppendGroup( |
228 content::kGpuCompositingFieldTrialThreadEnabledName, kEnableProbability); | 237 content::kGpuCompositingFieldTrialThreadEnabledName, |
238 threadedCompositingProbability); | |
229 | 239 |
230 bool enabled = (trial->group() == enable_group); | 240 bool force_compositing = (trial->group() == force_compositing_group); |
231 bool thread = (trial->group() == thread_group); | 241 bool thread = (trial->group() == thread_group); |
232 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled); | 242 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
243 force_compositing); | |
233 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 244 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
234 } | 245 } |
235 | 246 |
236 bool InForceCompositingModeOrThreadTrial() { | |
237 base::FieldTrial* trial = | |
238 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
239 if (!trial) | |
240 return false; | |
241 return trial->group_name() == content::kGpuCompositingFieldTrialEnabledName || | |
242 trial->group_name() == | |
243 content::kGpuCompositingFieldTrialThreadEnabledName; | |
244 } | |
245 | |
246 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { | 247 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { |
247 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) | 248 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) |
248 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; | 249 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; |
249 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) | 250 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) |
250 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; | 251 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; |
251 else if (feature_string == kGpuFeatureNameWebgl) | 252 else if (feature_string == kGpuFeatureNameWebgl) |
252 return content::GPU_FEATURE_TYPE_WEBGL; | 253 return content::GPU_FEATURE_TYPE_WEBGL; |
253 else if (feature_string == kGpuFeatureNameMultisampling) | 254 else if (feature_string == kGpuFeatureNameMultisampling) |
254 return content::GPU_FEATURE_TYPE_MULTISAMPLING; | 255 return content::GPU_FEATURE_TYPE_MULTISAMPLING; |
255 else if (feature_string == kGpuFeatureNameFlash3d) | 256 else if (feature_string == kGpuFeatureNameFlash3d) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 if (kGpuFeatureInfo[i].fallback_to_software) | 400 if (kGpuFeatureInfo[i].fallback_to_software) |
400 status += "_software"; | 401 status += "_software"; |
401 else | 402 else |
402 status += "_off"; | 403 status += "_off"; |
403 } else { | 404 } else { |
404 status = "enabled"; | 405 status = "enabled"; |
405 if (kGpuFeatureInfo[i].name == "webgl" && | 406 if (kGpuFeatureInfo[i].name == "webgl" && |
406 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || | 407 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
407 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) | 408 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) |
408 status += "_readback"; | 409 status += "_readback"; |
409 bool has_thread = | 410 bool has_thread = compositor_util::IsThreadedCompositingEnabled(); |
410 (command_line.HasSwitch(switches::kEnableThreadedCompositing) && | |
411 !command_line.HasSwitch(switches::kDisableThreadedCompositing)) || | |
412 InForceThreadedCompositingModeTrial(); | |
413 if (kGpuFeatureInfo[i].name == "compositing") { | 411 if (kGpuFeatureInfo[i].name == "compositing") { |
414 bool force_compositing = | 412 bool force_compositing = |
415 (command_line.HasSwitch(switches::kForceCompositingMode) && | 413 compositor_util::IsForceCompositingModeEnabled(); |
416 !command_line.HasSwitch( | |
417 switches::kDisableForceCompositingMode)) || | |
418 InForceCompositingModeOrThreadTrial(); | |
419 if (force_compositing) | 414 if (force_compositing) |
420 status += "_force"; | 415 status += "_force"; |
421 if (has_thread) | 416 if (has_thread) |
422 status += "_threaded"; | 417 status += "_threaded"; |
423 } | 418 } |
424 if (kGpuFeatureInfo[i].name == "css_animation") { | 419 if (kGpuFeatureInfo[i].name == "css_animation") { |
425 if (has_thread) | 420 if (has_thread) |
426 status = "accelerated_threaded"; | 421 status = "accelerated_threaded"; |
427 else | 422 else |
428 status = "accelerated"; | 423 status = "accelerated"; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 kGpuBlacklistFeatureHistogramNamesWin[i], | 609 kGpuBlacklistFeatureHistogramNamesWin[i], |
615 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 610 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
616 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 611 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
617 base::Histogram::kUmaTargetedHistogramFlag); | 612 base::Histogram::kUmaTargetedHistogramFlag); |
618 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 613 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
619 #endif | 614 #endif |
620 } | 615 } |
621 } | 616 } |
622 | 617 |
623 } // namespace gpu_util; | 618 } // namespace gpu_util; |
OLD | NEW |