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 "content/browser/gpu/gpu_util.h" | 5 #include "content/browser/gpu/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/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "base/version.h" | 13 #include "base/version.h" |
14 #include "content/browser/gpu/gpu_blacklist.h" | 14 #include "content/browser/gpu/gpu_blacklist.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 #include "ui/gl/gl_switches.h" |
16 | 17 |
17 using content::GpuFeatureType; | 18 using content::GpuFeatureType; |
18 using content::GpuSwitchingOption; | 19 using content::GpuSwitchingOption; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; | 23 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; |
23 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; | 24 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; |
24 const char kGpuFeatureNameWebgl[] = "webgl"; | 25 const char kGpuFeatureNameWebgl[] = "webgl"; |
25 const char kGpuFeatureNameMultisampling[] = "multisampling"; | 26 const char kGpuFeatureNameMultisampling[] = "multisampling"; |
26 const char kGpuFeatureNameFlash3d[] = "flash_3d"; | 27 const char kGpuFeatureNameFlash3d[] = "flash_3d"; |
27 const char kGpuFeatureNameFlashStage3d[] = "flash_stage3d"; | 28 const char kGpuFeatureNameFlashStage3d[] = "flash_stage3d"; |
28 const char kGpuFeatureNameTextureSharing[] = "texture_sharing"; | 29 const char kGpuFeatureNameTextureSharing[] = "texture_sharing"; |
29 const char kGpuFeatureNameAcceleratedVideoDecode[] = "accelerated_video_decode"; | 30 const char kGpuFeatureNameAcceleratedVideoDecode[] = "accelerated_video_decode"; |
30 const char kGpuFeatureNameAll[] = "all"; | 31 const char kGpuFeatureNameAll[] = "all"; |
31 const char kGpuFeatureNameUnknown[] = "unknown"; | 32 const char kGpuFeatureNameUnknown[] = "unknown"; |
32 | 33 |
33 const char kGpuSwitchingNameAutomatic[] = "automatic"; | |
34 const char kGpuSwitchingNameForceIntegrated[] = "force_integrated"; | |
35 const char kGpuSwitchingNameForceDiscrete[] = "force_discrete"; | |
36 const char kGpuSwitchingNameUnknown[] = "unknown"; | |
37 | |
38 enum GpuFeatureStatus { | 34 enum GpuFeatureStatus { |
39 kGpuFeatureEnabled = 0, | 35 kGpuFeatureEnabled = 0, |
40 kGpuFeatureBlacklisted = 1, | 36 kGpuFeatureBlacklisted = 1, |
41 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted | 37 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted |
42 kGpuFeatureNumStatus | 38 kGpuFeatureNumStatus |
43 }; | 39 }; |
44 | 40 |
45 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
46 | 42 |
47 enum WinSubVersion { | 43 enum WinSubVersion { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) | 130 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) |
135 matches.push_back(kGpuFeatureNameAcceleratedVideoDecode); | 131 matches.push_back(kGpuFeatureNameAcceleratedVideoDecode); |
136 if (!matches.size()) | 132 if (!matches.size()) |
137 matches.push_back(kGpuFeatureNameUnknown); | 133 matches.push_back(kGpuFeatureNameUnknown); |
138 } | 134 } |
139 return JoinString(matches, ','); | 135 return JoinString(matches, ','); |
140 } | 136 } |
141 | 137 |
142 GpuSwitchingOption StringToGpuSwitchingOption( | 138 GpuSwitchingOption StringToGpuSwitchingOption( |
143 const std::string& switching_string) { | 139 const std::string& switching_string) { |
144 if (switching_string == kGpuSwitchingNameAutomatic) | 140 if (switching_string == switches::kGpuSwitchingOptionNameAutomatic) |
145 return content::GPU_SWITCHING_AUTOMATIC; | 141 return content::GPU_SWITCHING_OPTION_AUTOMATIC; |
146 if (switching_string == kGpuSwitchingNameForceIntegrated) | 142 if (switching_string == switches::kGpuSwitchingOptionNameForceIntegrated) |
147 return content::GPU_SWITCHING_FORCE_INTEGRATED; | 143 return content::GPU_SWITCHING_OPTION_FORCE_INTEGRATED; |
148 if (switching_string == kGpuSwitchingNameForceDiscrete) | 144 if (switching_string == switches::kGpuSwitchingOptionNameForceDiscrete) |
149 return content::GPU_SWITCHING_FORCE_DISCRETE; | 145 return content::GPU_SWITCHING_OPTION_FORCE_DISCRETE; |
150 return content::GPU_SWITCHING_UNKNOWN; | 146 return content::GPU_SWITCHING_OPTION_UNKNOWN; |
| 147 } |
| 148 |
| 149 std::string GpuSwitchingOptionToString(GpuSwitchingOption option) { |
| 150 switch (option) { |
| 151 case content::GPU_SWITCHING_OPTION_AUTOMATIC: |
| 152 return switches::kGpuSwitchingOptionNameAutomatic; |
| 153 case content::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: |
| 154 return switches::kGpuSwitchingOptionNameForceIntegrated; |
| 155 case content::GPU_SWITCHING_OPTION_FORCE_DISCRETE: |
| 156 return switches::kGpuSwitchingOptionNameForceDiscrete; |
| 157 default: |
| 158 return "unknown"; |
| 159 } |
151 } | 160 } |
152 | 161 |
153 void UpdateStats(const GpuBlacklist* blacklist, | 162 void UpdateStats(const GpuBlacklist* blacklist, |
154 uint32 blacklisted_features) { | 163 uint32 blacklisted_features) { |
155 uint32 max_entry_id = blacklist->max_entry_id(); | 164 uint32 max_entry_id = blacklist->max_entry_id(); |
156 if (max_entry_id == 0) { | 165 if (max_entry_id == 0) { |
157 // GPU Blacklist was not loaded. No need to go further. | 166 // GPU Blacklist was not loaded. No need to go further. |
158 return; | 167 return; |
159 } | 168 } |
160 | 169 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 kGpuBlacklistFeatureHistogramNamesWin[i], | 238 kGpuBlacklistFeatureHistogramNamesWin[i], |
230 1, kNumWinSubVersions * kGpuFeatureNumStatus, | 239 1, kNumWinSubVersions * kGpuFeatureNumStatus, |
231 kNumWinSubVersions * kGpuFeatureNumStatus + 1, | 240 kNumWinSubVersions * kGpuFeatureNumStatus + 1, |
232 base::Histogram::kUmaTargetedHistogramFlag); | 241 base::Histogram::kUmaTargetedHistogramFlag); |
233 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); | 242 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); |
234 #endif | 243 #endif |
235 } | 244 } |
236 } | 245 } |
237 | 246 |
238 } // namespace gpu_util; | 247 } // namespace gpu_util; |
OLD | NEW |