OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/cpu.h" | |
10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
17 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
18 #include "base/version.h" | 19 #include "base/version.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { | 241 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { |
241 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); | 242 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); |
242 } | 243 } |
243 } | 244 } |
244 | 245 |
245 if (display_changed || gpu_changed) | 246 if (display_changed || gpu_changed) |
246 manager->HandleGpuSwitch(); | 247 manager->HandleGpuSwitch(); |
247 } | 248 } |
248 #endif // OS_MACOSX | 249 #endif // OS_MACOSX |
249 | 250 |
251 #if defined(OS_LINUX) | |
252 bool ShouldEnableAcceleratedVideoDecodeInLinux() { | |
253 #if defined(OS_CHROMEOS) | |
254 return true; | |
255 #endif // defined(OS_CHROMEOS) | |
256 | |
257 // Allow only latest Intel architecture. +IvyBridge | |
258 #if defined(ARCH_CPU_X86_FAMILY) | |
259 struct CPU { | |
260 int family; // family of the processor | |
261 int model; // model of processor | |
262 }; | |
Avi (use Gerrit)
2016/02/26 17:57:40
put operator< here and use std::tie...
struct CPU
dshwang
2016/02/26 18:11:35
chromium code style prohibits from adding any meth
Avi (use Gerrit)
2016/02/26 18:33:28
Hm.
OK, leave it in the binary_search, but use st
| |
263 const CPU kIntelWhitelistTable[] = { | |
264 // http://instlatx64.atw.hu/ for CPUID | |
265 {0x06, 0x3A}, // IvyBridge | |
266 {0x06, 0x3C}, // Haswell | |
267 {0x06, 0x3D}, // Broadwell | |
268 {0x06, 0x3E}, // IvyBridge | |
269 {0x06, 0x3F}, // Haswell | |
270 {0x06, 0x45}, // Haswell | |
271 {0x06, 0x46}, // Haswell | |
272 {0x06, 0x47}, // Broadwell-H | |
273 {0x06, 0x4C}, // Braswell | |
274 {0x06, 0x4E}, // Skylake | |
275 {0x06, 0x56}, // Broadwell-DE | |
276 }; | |
277 | |
278 base::CPU cpuid; | |
279 const CPU search_elem = {cpuid.family(), cpuid.model()}; | |
280 bool allowed = | |
281 std::binary_search(kIntelWhitelistTable, | |
282 kIntelWhitelistTable + arraysize(kIntelWhitelistTable), | |
283 search_elem, [](const CPU& a, const CPU& b) { | |
284 return a.family < b.family || | |
285 (a.family == b.family && a.model < b.model); | |
Avi (use Gerrit)
2016/02/26 17:57:40
... and not in here.
| |
286 }); | |
287 return allowed; | |
288 #endif // defined(ARCH_CPU_X86_FAMILY) | |
289 | |
290 return false; | |
291 } | |
292 #endif | |
293 | |
250 // Block all domains' use of 3D APIs for this many milliseconds if | 294 // Block all domains' use of 3D APIs for this many milliseconds if |
251 // approaching a threshold where system stability might be compromised. | 295 // approaching a threshold where system stability might be compromised. |
252 const int64_t kBlockAllDomainsMs = 10000; | 296 const int64_t kBlockAllDomainsMs = 10000; |
253 const int kNumResetsWithinDuration = 1; | 297 const int kNumResetsWithinDuration = 1; |
254 | 298 |
255 // Enums for UMA histograms. | 299 // Enums for UMA histograms. |
256 enum BlockStatusHistogram { | 300 enum BlockStatusHistogram { |
257 BLOCK_STATUS_NOT_BLOCKED, | 301 BLOCK_STATUS_NOT_BLOCKED, |
258 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, | 302 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, |
259 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, | 303 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 "DisableAcceleratedVideoDecode"); | 991 "DisableAcceleratedVideoDecode"); |
948 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 992 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
949 // It was already disabled on the command line. | 993 // It was already disabled on the command line. |
950 return false; | 994 return false; |
951 } | 995 } |
952 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)) | 996 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)) |
953 return true; | 997 return true; |
954 if (group_name == "Disabled") | 998 if (group_name == "Disabled") |
955 return true; | 999 return true; |
956 | 1000 |
1001 #if defined(OS_LINUX) | |
1002 if (!ShouldEnableAcceleratedVideoDecodeInLinux()) | |
1003 return true; | |
1004 #endif | |
1005 | |
957 // Accelerated decode is never available with --disable-gpu. | 1006 // Accelerated decode is never available with --disable-gpu. |
958 return command_line->HasSwitch(switches::kDisableGpu); | 1007 return command_line->HasSwitch(switches::kDisableGpu); |
959 } | 1008 } |
960 | 1009 |
961 void GpuDataManagerImplPrivate::GetDisabledExtensions( | 1010 void GpuDataManagerImplPrivate::GetDisabledExtensions( |
962 std::string* disabled_extensions) const { | 1011 std::string* disabled_extensions) const { |
963 DCHECK(disabled_extensions); | 1012 DCHECK(disabled_extensions); |
964 *disabled_extensions = disabled_extensions_; | 1013 *disabled_extensions = disabled_extensions_; |
965 } | 1014 } |
966 | 1015 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1286 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1238 #if defined(OS_WIN) | 1287 #if defined(OS_WIN) |
1239 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1288 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
1240 #endif | 1289 #endif |
1241 complete_gpu_info_already_requested_ = true; | 1290 complete_gpu_info_already_requested_ = true; |
1242 // Some observers might be waiting. | 1291 // Some observers might be waiting. |
1243 NotifyGpuInfoUpdate(); | 1292 NotifyGpuInfoUpdate(); |
1244 } | 1293 } |
1245 | 1294 |
1246 } // namespace content | 1295 } // namespace content |
OLD | NEW |