Chromium Code Reviews| Index: content/browser/gpu/gpu_data_manager_impl_private.cc |
| diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc |
| index 161f07b1bff27f3fb959bb7f7246051317fbc24f..74daf8e1993cba81a02d220d4df05baff31a83f0 100644 |
| --- a/content/browser/gpu/gpu_data_manager_impl_private.cc |
| +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| +#include "base/cpu.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/sparse_histogram.h" |
| @@ -247,6 +248,48 @@ void DisplayReconfigCallback(CGDirectDisplayID display, |
| } |
| #endif // OS_MACOSX |
| +#if defined(OS_LINUX) |
| +bool ShouldEnableAcceleratedVideoDecodeInLinux() { |
| +#if defined(OS_CHROMEOS) |
| + return true; |
| +#endif // defined(OS_CHROMEOS) |
| + |
| +// Allow only latest Intel architecture. +IvyBridge |
| +#if defined(ARCH_CPU_X86_FAMILY) |
| + struct CPU { |
| + int family; // family of the processor |
| + int model; // model of processor |
| + }; |
| + const CPU kIntelWhitelistTable[] = { |
| + // http://instlatx64.atw.hu/ for CPUID |
| + {0x06, 0x3A}, // IvyBridge |
| + {0x06, 0x3C}, // Haswell |
| + {0x06, 0x3D}, // Broadwell |
| + {0x06, 0x3E}, // IvyBridge |
| + {0x06, 0x3F}, // Haswell |
| + {0x06, 0x45}, // Haswell |
| + {0x06, 0x46}, // Haswell |
| + {0x06, 0x47}, // Broadwell-H |
| + {0x06, 0x4C}, // Braswell |
| + {0x06, 0x4E}, // Skylake |
| + {0x06, 0x56}, // Broadwell-DE |
| + }; |
| + |
| + base::CPU cpuid; |
| + const CPU search_elem = {cpuid.family(), cpuid.model()}; |
|
allan.jensen
2016/04/15 09:16:20
This seems completely wrong.
VAAPI is usually co
|
| + bool allowed = std::binary_search( |
| + kIntelWhitelistTable, |
| + kIntelWhitelistTable + arraysize(kIntelWhitelistTable), search_elem, |
| + [](const CPU& a, const CPU& b) { |
| + return std::tie(a.family, a.model) < std::tie(b.family, b.model); |
| + }); |
| + return allowed; |
| +#endif // defined(ARCH_CPU_X86_FAMILY) |
| + |
| + return false; |
| +} |
| +#endif |
| + |
| // Block all domains' use of 3D APIs for this many milliseconds if |
| // approaching a threshold where system stability might be compromised. |
| const int64_t kBlockAllDomainsMs = 10000; |
| @@ -954,6 +997,11 @@ bool GpuDataManagerImplPrivate::ShouldDisableAcceleratedVideoDecode( |
| if (group_name == "Disabled") |
| return true; |
| +#if defined(OS_LINUX) |
| + if (!ShouldEnableAcceleratedVideoDecodeInLinux()) |
| + return true; |
| +#endif |
| + |
| // Accelerated decode is never available with --disable-gpu. |
| return command_line->HasSwitch(switches::kDisableGpu); |
| } |