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/content_constants.h" | |
21 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
22 #include "content/public/common/gpu_info.h" | 23 #include "content/public/common/gpu_info.h" |
23 | 24 |
24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
25 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
26 #elif defined(OS_MACOSX) | 27 #elif defined(OS_MACOSX) |
27 #include "base/mac/mac_util.h" | 28 #include "base/mac/mac_util.h" |
28 #endif | 29 #endif |
29 | 30 |
30 using content::GpuDataManager; | 31 using content::GpuDataManager; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 entry_index++; | 160 entry_index++; |
160 break; | 161 break; |
161 case kGpuFeatureDisabled: | 162 case kGpuFeatureDisabled: |
162 entry_index += 2; | 163 entry_index += 2; |
163 break; | 164 break; |
164 } | 165 } |
165 return entry_index; | 166 return entry_index; |
166 } | 167 } |
167 #endif // OS_WIN | 168 #endif // OS_WIN |
168 | 169 |
170 bool InForceThreadedCompositingModeTrial() { | |
171 base::FieldTrial* trial = | |
172 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
173 return trial && trial->group_name() == | |
174 content::kGpuCompositingFieldTrialThreadEnabledName; | |
175 } | |
176 | |
169 } // namespace | 177 } // namespace |
170 | 178 |
171 namespace gpu_util { | 179 namespace gpu_util { |
172 | 180 |
173 const char kForceCompositingModeFieldTrialName[] = "ForceCompositingMode"; | |
174 const char kFieldTrialEnabledName[] = "enabled"; | |
175 | |
176 void InitializeForceCompositingModeFieldTrial() { | 181 void InitializeForceCompositingModeFieldTrial() { |
177 // Enable the field trial only on desktop OS's. | 182 // Enable the field trial only on desktop OS's. |
178 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 183 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
179 return; | 184 return; |
180 #endif | 185 #endif |
181 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 186 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
182 // Only run the trial on the Canary and Dev channels. | 187 // Only run the trial on the Canary and Dev channels. |
183 if (channel != chrome::VersionInfo::CHANNEL_CANARY && | 188 if (channel != chrome::VersionInfo::CHANNEL_CANARY && |
184 channel != chrome::VersionInfo::CHANNEL_DEV) | 189 channel != chrome::VersionInfo::CHANNEL_DEV) |
185 return; | 190 return; |
186 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
187 // Don't run the trial on Windows XP. | 192 // Don't run the trial on Windows XP. |
188 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 193 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
189 return; | 194 return; |
190 #elif defined(OS_MACOSX) | 195 #elif defined(OS_MACOSX) |
191 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. | 196 // Accelerated compositing is only implemented on Mac OSX 10.6 or later. |
192 if (base::mac::IsOSLeopardOrEarlier()) | 197 if (base::mac::IsOSLeopardOrEarlier()) |
193 return; | 198 return; |
194 #endif | 199 #endif |
195 | 200 |
196 // Don't activate the field trial if force-compositing-mode has been | 201 // Don't activate the field trial if force-compositing-mode has been |
197 // explicitly disabled from the command line. | 202 // explicitly disabled from the command line. |
198 if (CommandLine::ForCurrentProcess()->HasSwitch( | 203 if (CommandLine::ForCurrentProcess()->HasSwitch( |
199 switches::kDisableForceCompositingMode)) | 204 switches::kDisableForceCompositingMode) || |
205 CommandLine::ForCurrentProcess()->HasSwitch( | |
206 switches::kDisableThreadedCompositing)) | |
200 return; | 207 return; |
201 | 208 |
202 const base::FieldTrial::Probability kDivisor = 100; | 209 const base::FieldTrial::Probability kDivisor = 99; |
Ilya Sherman
2012/07/20 05:36:05
Optional nit: Perhaps set this to 3 rather than to
jbates
2012/07/23 17:47:00
Done.
| |
203 scoped_refptr<base::FieldTrial> trial( | 210 scoped_refptr<base::FieldTrial> trial( |
204 base::FieldTrialList::FactoryGetFieldTrial( | 211 base::FieldTrialList::FactoryGetFieldTrial( |
205 kForceCompositingModeFieldTrialName, kDivisor, | 212 content::kGpuCompositingFieldTrialName, kDivisor, |
206 "disable", 2012, 12, 31, NULL)); | 213 "disable", 2012, 12, 31, NULL)); |
207 | 214 |
208 // Produce the same result on every run of this client. | 215 // Produce the same result on every run of this client. |
209 trial->UseOneTimeRandomization(); | 216 trial->UseOneTimeRandomization(); |
210 // 50% probability of being in the enabled group. | 217 // (33/99)% probability of being in the enabled or thread group. |
211 const base::FieldTrial::Probability kEnableProbability = 50; | 218 const base::FieldTrial::Probability kEnableProbability = 33; |
212 int enable_group = trial->AppendGroup( | 219 int enable_group = trial->AppendGroup( |
213 kFieldTrialEnabledName, kEnableProbability); | 220 content::kGpuCompositingFieldTrialEnabledName, kEnableProbability); |
221 int thread_group = trial->AppendGroup( | |
222 content::kGpuCompositingFieldTrialThreadEnabledName, kEnableProbability); | |
214 | 223 |
215 bool enabled = (trial->group() == enable_group); | 224 bool enabled = (trial->group() == enable_group); |
225 bool thread = (trial->group() == thread_group); | |
216 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled); | 226 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled); |
227 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | |
217 } | 228 } |
218 | 229 |
219 bool InForceCompositingModeTrial() { | 230 bool InForceCompositingModeOrThreadTrial() { |
220 base::FieldTrial* trial = | 231 base::FieldTrial* trial = |
221 base::FieldTrialList::Find(kForceCompositingModeFieldTrialName); | 232 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); |
222 if (!trial) | 233 if (!trial) |
223 return false; | 234 return false; |
224 return trial->group_name() == kFieldTrialEnabledName; | 235 return trial->group_name() == content::kGpuCompositingFieldTrialEnabledName || |
236 trial->group_name() == | |
237 content::kGpuCompositingFieldTrialThreadEnabledName; | |
225 } | 238 } |
226 | 239 |
227 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { | 240 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { |
228 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) | 241 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) |
229 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; | 242 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; |
230 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) | 243 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) |
231 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; | 244 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; |
232 else if (feature_string == kGpuFeatureNameWebgl) | 245 else if (feature_string == kGpuFeatureNameWebgl) |
233 return content::GPU_FEATURE_TYPE_WEBGL; | 246 return content::GPU_FEATURE_TYPE_WEBGL; |
234 else if (feature_string == kGpuFeatureNameMultisampling) | 247 else if (feature_string == kGpuFeatureNameMultisampling) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 status += "_software"; | 378 status += "_software"; |
366 else | 379 else |
367 status += "_off"; | 380 status += "_off"; |
368 } else { | 381 } else { |
369 status = "enabled"; | 382 status = "enabled"; |
370 if (kGpuFeatureInfo[i].name == "webgl" && | 383 if (kGpuFeatureInfo[i].name == "webgl" && |
371 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || | 384 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
372 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) | 385 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) |
373 status += "_readback"; | 386 status += "_readback"; |
374 bool has_thread = | 387 bool has_thread = |
375 command_line.HasSwitch(switches::kEnableThreadedCompositing) && | 388 (command_line.HasSwitch(switches::kEnableThreadedCompositing) && |
376 !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 389 !command_line.HasSwitch(switches::kDisableThreadedCompositing)) || |
390 InForceThreadedCompositingModeTrial(); | |
377 if (kGpuFeatureInfo[i].name == "compositing") { | 391 if (kGpuFeatureInfo[i].name == "compositing") { |
378 bool force_compositing = | 392 bool force_compositing = |
379 (command_line.HasSwitch(switches::kForceCompositingMode) && | 393 (command_line.HasSwitch(switches::kForceCompositingMode) && |
380 !command_line.HasSwitch( | 394 !command_line.HasSwitch( |
381 switches::kDisableForceCompositingMode)) || | 395 switches::kDisableForceCompositingMode)) || |
382 InForceCompositingModeTrial(); | 396 InForceCompositingModeOrThreadTrial(); |
383 if (force_compositing) | 397 if (force_compositing) |
384 status += "_force"; | 398 status += "_force"; |
385 if (has_thread) | 399 if (has_thread) |
386 status += "_threaded"; | 400 status += "_threaded"; |
387 } | 401 } |
388 if (kGpuFeatureInfo[i].name == "css_animation") { | 402 if (kGpuFeatureInfo[i].name == "css_animation") { |
389 if (has_thread) | 403 if (has_thread) |
390 status = "accelerated_threaded"; | 404 status = "accelerated_threaded"; |
391 else | 405 else |
392 status = "accelerated"; | 406 status = "accelerated"; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 kGpuBlacklistFeatureHistogramNamesWin[i], | 588 kGpuBlacklistFeatureHistogramNamesWin[i], |
575 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 589 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
576 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 590 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
577 base::Histogram::kUmaTargetedHistogramFlag); | 591 base::Histogram::kUmaTargetedHistogramFlag); |
578 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 592 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
579 #endif | 593 #endif |
580 } | 594 } |
581 } | 595 } |
582 | 596 |
583 } // namespace gpu_util; | 597 } // namespace gpu_util; |
OLD | NEW |