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" |
18 #include "chrome/browser/browser_trial.h" | |
17 #include "chrome/browser/gpu_blacklist.h" | 19 #include "chrome/browser/gpu_blacklist.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 |
22 using content::GpuDataManager; | 24 using content::GpuDataManager; |
23 using content::GpuFeatureType; | 25 using content::GpuFeatureType; |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 if (type & content::GPU_FEATURE_TYPE_FLASH3D) | 198 if (type & content::GPU_FEATURE_TYPE_FLASH3D) |
197 matches.push_back(kGpuFeatureNameFlash3d); | 199 matches.push_back(kGpuFeatureNameFlash3d); |
198 if (type & content::GPU_FEATURE_TYPE_FLASH_STAGE3D) | 200 if (type & content::GPU_FEATURE_TYPE_FLASH_STAGE3D) |
199 matches.push_back(kGpuFeatureNameFlashStage3d); | 201 matches.push_back(kGpuFeatureNameFlashStage3d); |
200 if (!matches.size()) | 202 if (!matches.size()) |
201 matches.push_back(kGpuFeatureNameUnknown); | 203 matches.push_back(kGpuFeatureNameUnknown); |
202 } | 204 } |
203 return JoinString(matches, ','); | 205 return JoinString(matches, ','); |
204 } | 206 } |
205 | 207 |
208 bool InForceCompositingFieldTrial() { | |
SteveT
2012/06/06 13:06:02
nit: Indent is 4 here instead of 2.
| |
209 base::FieldTrial* trial = | |
210 base::FieldTrialList::Find(BrowserTrial::kForceCompositingModeTrial); | |
211 if (!trial) | |
212 return false; | |
Ilya Sherman
2012/06/06 09:50:21
Can this be a DCHECK rather than an if-stmt? (See
| |
213 if (trial->group_name() != std::string("enable")) | |
Ilya Sherman
2012/06/06 09:50:21
nit: return trial->group_name() == "enable";
| |
214 return false; | |
215 | |
216 return true; | |
217 } | |
218 | |
206 Value* GetFeatureStatus() { | 219 Value* GetFeatureStatus() { |
207 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 220 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
208 bool gpu_access_blocked = !GpuDataManager::GetInstance()->GpuAccessAllowed(); | 221 bool gpu_access_blocked = !GpuDataManager::GetInstance()->GpuAccessAllowed(); |
209 | 222 |
210 uint32 flags = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 223 uint32 flags = GpuDataManager::GetInstance()->GetGpuFeatureType(); |
211 DictionaryValue* status = new DictionaryValue(); | 224 DictionaryValue* status = new DictionaryValue(); |
212 | 225 |
213 const GpuFeatureInfo kGpuFeatureInfo[] = { | 226 const GpuFeatureInfo kGpuFeatureInfo[] = { |
214 { | 227 { |
215 "2d_canvas", | 228 "2d_canvas", |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 status = "enabled"; | 320 status = "enabled"; |
308 if (kGpuFeatureInfo[i].name == "webgl" && | 321 if (kGpuFeatureInfo[i].name == "webgl" && |
309 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || | 322 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
310 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) | 323 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) |
311 status += "_readback"; | 324 status += "_readback"; |
312 bool has_thread = CommandLine::ForCurrentProcess()->HasSwitch( | 325 bool has_thread = CommandLine::ForCurrentProcess()->HasSwitch( |
313 switches::kEnableThreadedCompositing) && | 326 switches::kEnableThreadedCompositing) && |
314 (!CommandLine::ForCurrentProcess()->HasSwitch( | 327 (!CommandLine::ForCurrentProcess()->HasSwitch( |
315 switches::kDisableThreadedCompositing)); | 328 switches::kDisableThreadedCompositing)); |
316 if (kGpuFeatureInfo[i].name == "compositing" && | 329 if (kGpuFeatureInfo[i].name == "compositing" && |
317 CommandLine::ForCurrentProcess()->HasSwitch( | 330 (CommandLine::ForCurrentProcess()->HasSwitch( |
318 switches::kForceCompositingMode)) | 331 switches::kForceCompositingMode) || |
332 InForceCompositingFieldTrial())) | |
Ilya Sherman
2012/06/06 09:50:21
Will the field trial always be set up by the time
| |
319 status += "_force"; | 333 status += "_force"; |
320 if (kGpuFeatureInfo[i].name == "compositing" && | 334 if (kGpuFeatureInfo[i].name == "compositing" && |
321 has_thread) | 335 has_thread) |
322 status += "_threaded"; | 336 status += "_threaded"; |
323 if (kGpuFeatureInfo[i].name == "css_animation") { | 337 if (kGpuFeatureInfo[i].name == "css_animation") { |
324 if (has_thread) | 338 if (has_thread) |
325 status = "accelerated_threaded"; | 339 status = "accelerated_threaded"; |
326 else | 340 else |
327 status = "accelerated"; | 341 status = "accelerated"; |
328 } | 342 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 kGpuBlacklistFeatureHistogramNamesWin[i], | 523 kGpuBlacklistFeatureHistogramNamesWin[i], |
510 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 524 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
511 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 525 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
512 base::Histogram::kUmaTargetedHistogramFlag); | 526 base::Histogram::kUmaTargetedHistogramFlag); |
513 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 527 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
514 #endif | 528 #endif |
515 } | 529 } |
516 } | 530 } |
517 | 531 |
518 } // namespace gpu_util; | 532 } // namespace gpu_util; |
OLD | NEW |