diff options
author | sL1pKn07 | 2017-08-24 22:25:05 +0200 |
---|---|---|
committer | sL1pKn07 | 2017-08-24 22:37:15 +0200 |
commit | 56fc44e51abf27750d34487486d810a77d6b6206 (patch) | |
tree | 6d192031345d9dfb54848f404beb616653f351fe | |
parent | 396f0f3e113cc7287ab69927a210c861730ddad2 (diff) | |
download | aur-56fc44e51abf27750d34487486d810a77d6b6206.tar.gz |
Update to 62.0.3192.0
- Rework in how enable the vaapi patch. now apply/active automagically the vaapi patch throught what video driver is loaded. if detect nvidia or vfio-pci (kvm vga passtrougth)(Blacklisted)(i'm not sure if noveau have the same problems as nvidia), can't apply/active the patch.
with this _enable_vaapi option is not need set by hand anymore, and has been gone.
- Rework in how set the compiler.
-rw-r--r-- | .SRCINFO | 34 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | PKGBUILD | 144 | ||||
-rw-r--r-- | chromium-blink-gcc7-r1.patch | 77 | ||||
-rw-r--r-- | vaapi_patch-r3.patch | 909 | ||||
-rw-r--r-- | vaapi_patch_r2.patch | 616 |
6 files changed, 1094 insertions, 688 deletions
@@ -1,8 +1,8 @@ # Generated by mksrcinfo v8 -# Fri Aug 11 04:54:49 UTC 2017 +# Thu Aug 24 20:18:26 UTC 2017 pkgbase = chromium-dev pkgdesc = The open-source project behind Google Chrome (Dev Channel) - pkgver = 62.0.3178.0 + pkgver = 62.0.3192.0 pkgrel = 1 url = http://www.chromium.org install = chromium-dev.install @@ -39,32 +39,34 @@ pkgbase = chromium-dev optdepends = pepper-flash: PPAPI Flash Player optdepends = chromium-widevine-dev: Widevine plugin (eg: Netflix) (Dev Channel) optdepends = kdialog: Needed for file dialogs in KF5 - optdepends = kwalletmanager: Needed for storing passwords in KWallet + optdepends = kwalletmanager: Needed for storing passwords in KWallet5, needs add "--password-store=kwallet5" into $HOME/config/chromium-dev.conf optdepends = ttf-font: For some typography - optdepends = libappindicator-gtk3: Needed for show systray icon in the panel + optdepends = libappindicator-gtk3: Needed for show systray icon in the panel on GTK3 Desktop based options = !strip - source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-62.0.3178.0.tar.xz + source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-62.0.3192.0.tar.xz source = git+https://github.com/foutrelis/chromium-launcher.git source = chromium-dev.svg source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-FORTIFY_SOURCE-r2.patch - source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-zlib-r1.patch - source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gn-bootstrap-r15.patch + source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gn-bootstrap-r16.patch + source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gcc5-r2.patch + source = https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-icu-r2.patch source = minizip.patch - source = vaapi_patch_r2.patch + source = vaapi_patch-r3.patch::https://sl1pkn07.wtf/paste/view/raw/918a2c94 + source = https://raw.githubusercontent.com/OSSystems/meta-browser/master/recipes-browser/chromium/files/0002-replace-struct-ucontext-with-ucontext_t.patch source = chromium-widevine-r1.patch - source = chromium-blink-gcc7.patch::https://git.archlinux.org/svntogit/packages.git/plain/trunk/chromium-blink-gcc7.patch?h=packages/chromium - source = chromium-v8-gcc7.patch::https://git.archlinux.org/svntogit/packages.git/plain/trunk/chromium-v8-gcc7.patch?h=packages/chromium - sha256sums = 86abba3a2bf996de642b4141c69b13ffd3c92443bc271d1be07d3f9de669cf50 + source = chromium-blink-gcc7-r1.patch + sha256sums = 437cc2045ebbb755ec929d403f7f51afe58ea3916aee609937b903772a7c7919 sha256sums = SKIP sha256sums = dd2b5c4191e468972b5ea8ddb4fa2e2fa3c2c94c79fc06645d0efc0e63ce7ee1 sha256sums = fa3f703d599051135c5be24b81dfcb23190bb282db73121337ac76bc9638e8a5 - sha256sums = 5de85a0e1be742ad629443655730028ee918826ae8e0dcade927b8877c5a3ad5 - sha256sums = 8aee756a778e98b722cc55421e58466b3b35a132fc91d8f8a309a2df9ca559ac + sha256sums = 0dc153c76900a1a4ab3a33af767aad22b833c657a9acec8f8fbf0be2ed57b993 + sha256sums = d44b90fc7313afaa6d6f77cde72c0e9a5e4a1cc792216cbca2ed45c39658c472 + sha256sums = 9128edb5a29ba1a5ad21be4a7b83eb07965b172425064c12c4abcc431deea2b4 sha256sums = 95ba939b9372e533ecbcc9ca034f3e9fc6621d3bddabb57c4d092ea69fa6c840 - sha256sums = 4ec8b2df4859b9d26b8ea4afc205f563f59844c54a6659bb279776b93163a0ce + sha256sums = a67a1c086ed54047b568fda7b62070e6cfb04e087820729b7553e972fcfe9ba8 + sha256sums = 6e9a345f810d36068ee74ebba4708c70ab30421dad3571b6be5e9db635078ea8 sha256sums = 0d537830944814fe0854f834b5dc41dc5fc2428f77b2ad61d4a5e76b0fe99880 - sha256sums = f94310a7ba9b8b777adfb4442bcc0a8f0a3d549b2cf4a156066f8e2e28e2f323 - sha256sums = 46dacc4fa52652b7d99b8996d6a97e5e3bac586f879aefb9fb95020d2c4e5aec + sha256sums = fab4c65e2802e709a32d059784182be5a89bc3ca862a7e27810714ea7b86f868 pkgname = chromium-dev diff --git a/.gitignore b/.gitignore index c21acd614c6c..d04f8c970759 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ !chromium-dev.svg !chromium-widevine-r1.patch !minizip.patch -!vaapi_patch_r2.patch +!vaapi_patch-r3.patch @@ -12,13 +12,12 @@ _use_clang=1 # Use clang compiler (downloaded binaries from google). Results in faster build and smaller chromium. _use_ccache=0 # Use ccache when build. _debug_mode=0 # Build in debug mode. -_enable_vaapi=0 # Patch for VA-API HW acceleration NOTE: don't work in some graphic cards, for example, NVIDIA ############################################## ## -- Package and components information -- ## ############################################## pkgname=chromium-dev -pkgver=62.0.3178.0 +pkgver=62.0.3192.0 pkgrel=1 pkgdesc="The open-source project behind Google Chrome (Dev Channel)" arch=('i686' 'x86_64') @@ -63,11 +62,11 @@ optdepends=( 'chromium-widevine-dev: Widevine plugin (eg: Netflix) (Dev Channel)' # 'kdialog: Needed for file dialogs in KF5' - 'kwalletmanager: Needed for storing passwords in KWallet' + 'kwalletmanager: Needed for storing passwords in KWallet5, needs add "--password-store=kwallet5" into $HOME/config/chromium-dev.conf' # 'ttf-font: For some typography' # - 'libappindicator-gtk3: Needed for show systray icon in the panel' + 'libappindicator-gtk3: Needed for show systray icon in the panel on GTK3 Desktop based' ) if [ "${_enable_vaapi}" = "1" ]; then optdepends+=('libva-vdpau-driver-chromium: HW video acceleration for NVIDIA users' @@ -82,15 +81,16 @@ source=( #"https://gsdview.appspot.com/chromium-browser-official/chromium-${pkgv 'chromium-dev.svg' # Patch form Gentoo 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-FORTIFY_SOURCE-r2.patch' - 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-zlib-r1.patch' - 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gn-bootstrap-r15.patch' + 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gn-bootstrap-r16.patch' + 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-gcc5-r2.patch' + 'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-icu-r2.patch' # Misc Patches 'minizip.patch' - 'vaapi_patch_r2.patch' + 'vaapi_patch-r3.patch::https://sl1pkn07.wtf/paste/view/raw/918a2c94' #'vaapi_patch-r3.base64::https://chromium-review.googlesource.com/changes/532294/revisions/53b93dfe87fd10cced5d2a2a63072dfc7a2af6e4/patch?download' + 'https://raw.githubusercontent.com/OSSystems/meta-browser/master/recipes-browser/chromium/files/0002-replace-struct-ucontext-with-ucontext_t.patch' # from https://github.com/OSSystems/meta-browser/tree/master/recipes-browser/chromium # Patch from crbug (chromium bugtracker) or Arch chromium package 'chromium-widevine-r1.patch' - 'chromium-blink-gcc7.patch::https://git.archlinux.org/svntogit/packages.git/plain/trunk/chromium-blink-gcc7.patch?h=packages/chromium' # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853347 - 'chromium-v8-gcc7.patch::https://git.archlinux.org/svntogit/packages.git/plain/trunk/chromium-v8-gcc7.patch?h=packages/chromium' # https://bugs.chromium.org/p/chromium/issues/detail?id=614289 + 'chromium-blink-gcc7-r1.patch' #::https://git.archlinux.org/svntogit/packages.git/plain/trunk/chromium-blink-gcc7.patch?h=packages/chromium' # https://bugs.chromium.org/p/chromium/issues/detail?id=614289 ) sha256sums=( #"$(curl -sL https://gsdview.appspot.com/chromium-browser-official/chromium-55.0.2873.0.tar.xz.hashes | grep sha256 | cut -d ' ' -f3)" "$(curl -sL https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${pkgver}.tar.xz.hashes | grep sha256 | cut -d ' ' -f3)" @@ -98,15 +98,16 @@ sha256sums=( #"$(curl -sL https://gsdview.appspot.com/chromium-browser-official/ 'dd2b5c4191e468972b5ea8ddb4fa2e2fa3c2c94c79fc06645d0efc0e63ce7ee1' # Patch form Gentoo 'fa3f703d599051135c5be24b81dfcb23190bb282db73121337ac76bc9638e8a5' - '5de85a0e1be742ad629443655730028ee918826ae8e0dcade927b8877c5a3ad5' - '8aee756a778e98b722cc55421e58466b3b35a132fc91d8f8a309a2df9ca559ac' + '0dc153c76900a1a4ab3a33af767aad22b833c657a9acec8f8fbf0be2ed57b993' + 'd44b90fc7313afaa6d6f77cde72c0e9a5e4a1cc792216cbca2ed45c39658c472' + '9128edb5a29ba1a5ad21be4a7b83eb07965b172425064c12c4abcc431deea2b4' # Misc Patches '95ba939b9372e533ecbcc9ca034f3e9fc6621d3bddabb57c4d092ea69fa6c840' - '4ec8b2df4859b9d26b8ea4afc205f563f59844c54a6659bb279776b93163a0ce' + 'a67a1c086ed54047b568fda7b62070e6cfb04e087820729b7553e972fcfe9ba8' #'4696ff0eb1b33e97958f4eb677e2f5d88bf72b3d454a2c8f0dadb5abbe1ae439' + '6e9a345f810d36068ee74ebba4708c70ab30421dad3571b6be5e9db635078ea8' # Patch from crbug (chromium bugtracker) '0d537830944814fe0854f834b5dc41dc5fc2428f77b2ad61d4a5e76b0fe99880' - 'f94310a7ba9b8b777adfb4442bcc0a8f0a3d549b2cf4a156066f8e2e28e2f323' - '46dacc4fa52652b7d99b8996d6a97e5e3bac586f879aefb9fb95020d2c4e5aec' + 'fab4c65e2802e709a32d059784182be5a89bc3ca862a7e27810714ea7b86f868' ) options=('!strip') install=chromium-dev.install @@ -144,9 +145,6 @@ fi # Need you use ccache?. if [ "${_use_ccache}" = "1" ]; then makedepends+=('ccache') - export CCACHE_CPP2=yes - export CCACHE_SLOPPINESS=time_macros - _ccache='ccache' fi # Are you use gnome-keyring/gnome?. @@ -205,7 +203,6 @@ _keeplibs=( 'third_party/flatbuffers' 'third_party/flot' 'third_party/freetype' - 'third_party/glslang-angle' 'third_party/google_input_tools' 'third_party/google_input_tools/third_party/closure_library' 'third_party/google_input_tools/third_party/closure_library/third_party/closure' @@ -227,8 +224,8 @@ _keeplibs=( 'third_party/libvpx' 'third_party/libvpx/source/libvpx/third_party/x86inc' 'third_party/libwebm' - 'third_party/libyuv' 'third_party/libxml' + 'third_party/libyuv' 'third_party/lss' 'third_party/lzma_sdk' 'third_party/markupsafe' @@ -245,7 +242,7 @@ _keeplibs=( 'third_party/pdfium/third_party/build' 'third_party/pdfium/third_party/bigint' 'third_party/pdfium/third_party/freetype' - 'third_party/pdfium/third_party/lcms2-2.6' + 'third_party/pdfium/third_party/lcms' 'third_party/pdfium/third_party/libopenjpeg20' 'third_party/pdfium/third_party/libpng16' 'third_party/pdfium/third_party/libtiff' @@ -256,18 +253,17 @@ _keeplibs=( 'third_party/qcms' 'third_party/sfntly' 'third_party/skia' + 'third_party/skia/third_party/gif' 'third_party/skia/third_party/vulkan' 'third_party/smhasher' 'third_party/spirv-headers' 'third_party/spirv-tools-angle' + 'third_party/sqlite' 'third_party/swiftshader' 'third_party/swiftshader/third_party/llvm-subzero' 'third_party/swiftshader/third_party/subzero' - 'third_party/sqlite' 'third_party/tcmalloc' 'third_party/usrsctp' - 'third_party/vulkan' - 'third_party/vulkan-validation-layers' 'third_party/web-animations-js' 'third_party/webdriver' 'third_party/webrtc' @@ -285,6 +281,15 @@ _keeplibs=( 'third_party/usb_ids' 'third_party/xdg-utils' 'third_party/yasm/run_yasm.py' + + # VULKAN!! + 'third_party/SPIRV-Tools' + 'third_party/angle/src/third_party/compiler' + 'third_party/glslang-angle' + 'third_party/glslang' + 'third_party/shaderc' + 'third_party/vulkan-validation-layers' + 'third_party/vulkan' ) # Set build flags. @@ -312,12 +317,22 @@ _flags=( "enable_nacl=${_nacl}" "enable_nacl_nonsfi=${_nacl}" 'use_custom_libcxx=false' + # VULKAN!! disable at the moment (fail build) + #'enable_vulkan=true' ) -# Enable VA-API, see https://chromium-review.googlesource.com/c/569529 -if [ "${_enable_vaapi}" = 1 ]; then - _flags+=('use_vaapi=true') -fi +# Enable VAAPI, see https://chromium-review.googlesource.com/532294 +# NOTE : The detector is Experimental, Can kill you kitty/doggy/waifu/husbando +# NOTE 2: vfio-pci is for avoid systems with KVM VGA passtrought enabled +# NOTE 3: Nvidia (bloob drivers) seems have problem with this patch. disable it +_vga_drivers="$(lspci -vk | grep -A10 VGA | grep 'Kernel driver in use' | cut -d ' ' -f5)" +for _driver in ${_vga_drivers}; do + if [ "${_driver}" != "vfio-pci" ] && [ "${_driver}" != "nvidia" ]; then + _enable_vaapi=1 + _flags+=('use_vaapi=true') + break + fi +done # Set the bundled/external components. # TODO: need ported to GN as GYP doing before. see status page: https://crbug.com/551343 @@ -326,7 +341,6 @@ _use_system=( 'flac' # 'freetype' # https://bugs.chromium.org/p/pdfium/issues/detail?id=733 'harfbuzz-ng' -# 'hunspell' # Needs ustream changes # 'icu' # https://crbug.com/678661 'libdrm' # 'libevent' # Get segfaults and other problems https://bugs.gentoo.org/593458 @@ -339,11 +353,8 @@ _use_system=( 'libxslt' 'openh264' 'opus' -# 'protobuf' # https://bugs.gentoo.org/525560 're2' -# 'sqlite' # https://crbug.com/58087 'snappy' -# 'ssl' # https://crbug.com/22208 'yasm' 'zlib' ) @@ -387,12 +398,21 @@ prepare() { msg2 "Patching the sources" # Patch sources from Gentoo. patch -p1 -i "${srcdir}/chromium-FORTIFY_SOURCE-r2.patch" - patch -p1 -i "${srcdir}/chromium-gn-bootstrap-r15.patch" - patch -p1 -i "${srcdir}/chromium-system-zlib-r1.patch" + patch -p1 -i "${srcdir}/chromium-gn-bootstrap-r16.patch" + patch -p1 -i "${srcdir}/chromium-gcc5-r2.patch" + patch -p1 -i "${srcdir}/chromium-system-icu-r2.patch" # Misc Patches: + patch -p1 -i "${srcdir}/chromium-blink-gcc7-r1.patch" + patch -p1 -i "${srcdir}/0002-replace-struct-ucontext-with-ucontext_t.patch" + + # VULKAN!!! + sed 's|base/||' -i cc/output/vulkan_renderer.h + + # Apply VAAPI patch if [ "${_enable_vaapi}" = 1 ]; then - patch -p1 -i "${srcdir}/vaapi_patch_r2.patch" + msg2 "Enable VAAPI" + patch -p1 -i "${srcdir}/vaapi_patch-r3.patch" # base64 -d "${srcdir}/vaapi_patch-r3.base64" | patch -p1 -i - fi # Fix paths. @@ -453,40 +473,54 @@ prepare() { python2 tools/clang/scripts/update.py fi -_set_gcc() { - _flags+=( - 'is_clang=false' - 'clang_use_chrome_plugins=false' - ) - export CC="${_ccache} gcc -Wall" - export CXX="${_ccache} g++ -Wall" - patch -p1 "${srcdir}/chromium-v8-gcc7.patch" - patch -p1 "${srcdir}/chromium-blink-gcc7.patch" -} - # Setup compilers. - # Use system/bundled Clang? or GCC?. - export AR=ar - export NM=nm + if [ "${_use_ccache}" = "1" ]; then + export CCACHE_CPP2=yes + export CCACHE_SLOPPINESS=time_macros + _ccache='ccache' + _ccache_flags='-Qunused-arguments' + fi + + _set_gcc() { + _compiler=GCC + _flags+=( + 'is_clang=false' + 'clang_use_chrome_plugins=false' + ) + _c_compiler="gcc" + _cpp_compiler="g++" + CFLAGS+=" -fno-delete-null-pointer-checks" + CXXFLAGS+=" -fno-delete-null-pointer-checks" + } + if [ "${_use_clang}" = "0" ]; then _set_gcc elif [ "${_use_clang}" = "1" ]; then if [ "${CARCH}" = 'i686' ]; then - msg2 "Build with (bundled) clang is not possible in 32bit systems. then, Use system GCC" _set_gcc + _compiler_msg=": Build with (bundled) clang is not possible in 32bit systems." elif [ "${CARCH}" = 'x86_64' ]; then - msg2 "Setup for use clang" + _compiler=Clang _flags+=( 'is_clang=true' 'clang_use_chrome_plugins=true' ) _clang_path="${srcdir}/chromium-${pkgver}/third_party/llvm-build/Release+Asserts/bin" - export CXXFLAGS="${CXXFLAGS//-fno-plt/} -Wno-unknown-warning-option" - export CFLAGS="${CXXFLAGS//-fno-plt/}" - export CC="${_ccache} ${_clang_path}/clang -Qunused-arguments" - export CXX="${_ccache} ${_clang_path}/clang++ -Qunused-arguments" + _c_compiler="${_clang_path}/clang" + _cpp_compiler="${_clang_path}/clang++" + export CXXFLAGS="${CXXFLAGS//-fno-plt/}" + export CFLAGS="${CFLAGS//-fno-plt/}" + CFLAGS+=' -Wno-unknown-warning-option' + CXXFLAGS+=' -Wno-unknown-warning-option' fi fi + + # Export compilers + msg2 "Setup ${_compiler} compiler${_compiler_msg}" + export AR=ar + export NM=nm + export CC="${_ccache} ${_c_compiler} ${_ccache_flags}" + export CXX="${_ccache} ${_cpp_compiler} ${_ccache_flags}" } build() { @@ -579,7 +613,7 @@ package() { esac install -Dm644 "${_branding}/product_logo_${_size}.png" "${pkgdir}/usr/share/icons/hicolor/${_size}x${_size}/apps/chromium-dev.png" done - install -Dm644 "${srcdir}/chromium-dev.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/chromium-dev.svg" + install -Dm644 "${srcdir}/chromium-dev.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/chromium-dev.svg" # Install NaCL stuff if is detected. if [ "${_build_nacl}" = "1" ]; then diff --git a/chromium-blink-gcc7-r1.patch b/chromium-blink-gcc7-r1.patch new file mode 100644 index 000000000000..4791a449dd01 --- /dev/null +++ b/chromium-blink-gcc7-r1.patch @@ -0,0 +1,77 @@ +--- chromium-59.0.3071.86/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h.orig 2017-06-06 15:05:38.145247996 +0300 ++++ chromium-59.0.3071.86/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h 2017-06-06 15:06:13.866246667 +0300 +@@ -647,31 +647,6 @@ + friend class LinkedHashSet; + }; + +-inline void SwapAnchor(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { +- DCHECK(a.prev_); +- DCHECK(a.next_); +- DCHECK(b.prev_); +- DCHECK(b.next_); +- swap(a.prev_, b.prev_); +- swap(a.next_, b.next_); +- if (b.next_ == &a) { +- DCHECK_EQ(b.prev_, &a); +- b.next_ = &b; +- b.prev_ = &b; +- } else { +- b.next_->prev_ = &b; +- b.prev_->next_ = &b; +- } +- if (a.next_ == &b) { +- DCHECK_EQ(a.prev_, &b); +- a.next_ = &a; +- a.prev_ = &a; +- } else { +- a.next_->prev_ = &a; +- a.prev_->next_ = &a; +- } +-} +- + inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { + DCHECK_NE(a.next_, &a); + DCHECK_NE(b.next_, &b); +@@ -725,6 +700,31 @@ + return *this; + } + ++inline void SwapAnchor(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { ++ DCHECK(a.prev_); ++ DCHECK(a.next_); ++ DCHECK(b.prev_); ++ DCHECK(b.next_); ++ swap(a.prev_, b.prev_); ++ swap(a.next_, b.next_); ++ if (b.next_ == &a) { ++ DCHECK_EQ(b.prev_, &a); ++ b.next_ = &b; ++ b.prev_ = &b; ++ } else { ++ b.next_->prev_ = &b; ++ b.prev_->next_ = &b; ++ } ++ if (a.next_ == &b) { ++ DCHECK_EQ(a.prev_, &b); ++ a.next_ = &a; ++ a.prev_ = &a; ++ } else { ++ a.next_->prev_ = &a; ++ a.prev_->next_ = &a; ++ } ++} ++ + template <typename T, typename U, typename V, typename W> + inline void LinkedHashSet<T, U, V, W>::Swap(LinkedHashSet& other) { + impl_.swap(other.impl_); + +--- chromium-59.0.3071.86/third_party/WebKit/Source/platform/graphics/gpu/SharedGpuContext.h.orig 2017-06-06 16:16:43.657661313 +0300 ++++ chromium-59.0.3071.86/third_party/WebKit/Source/platform/graphics/gpu/SharedGpuContext.h 2017-06-06 16:16:50.911198032 +0300 +@@ -5,6 +5,7 @@ + #include "platform/PlatformExport.h" + #include "platform/wtf/ThreadSpecific.h" + ++#include <functional> + #include <memory> + + namespace gpu { diff --git a/vaapi_patch-r3.patch b/vaapi_patch-r3.patch new file mode 100644 index 000000000000..ef6d673ed51a --- /dev/null +++ b/vaapi_patch-r3.patch @@ -0,0 +1,909 @@ +From 53b93dfe87fd10cced5d2a2a63072dfc7a2af6e4 Mon Sep 17 00:00:00 2001 +From: Daniel Charles <daniel.charles@intel.com> +Date: Fri, 28 Jul 2017 16:31:47 -0700 +Subject: [PATCH] Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only + +This patch contains all the changes necessary to use VA-API along with +vaapi-driver to run all media use cases supported with hardware acceleration. + +It is intended to remain as experimental accessible from chrome://flags on linux. +It requires libva/intel-vaapi-driver to be installed on the system path where +chrome is executed. Other drivers could be tested if available. Flags are +kept independent for linux, where this feature has to be enabled before +actually using it. This should not change how other OSes use the flags +already, the new flags will show at the buttom on the section of unavailable +experiments + +The changes cover a range of compiler pre-processor flags to enable the stack. +It moves the presandbox operations to the vaapi_wrapper class as the hook function +is available there. vaInit will open driver on the correct installed folder. + +chrome flags consolidtation into only two flags for linux. Mjpeg and accelerated +video are used. The other flags are kept for ChromeOS and other OSes. + +Developer testing was made on skylake hardware, ChromeOS and Ubuntu. + +BUG=NONE +TEST="subjective testing with VAVDA,VAVEA and VAJDA, autotest for encoder" +TEST="and decoder hardware accelerated" +TEST="have libva/intel-vaapi-driver installed and not installed in the system" +TEST="repeat on different hardware families" +R=posciak@chromium.org +R=kcwu@chromium.org + +Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel +Change-Id: Ifbbf5c9e5221a8b5733fc6d4d0cf984a1f103171 +Signed-off-by: Daniel Charles <daniel.charles@intel.com> +--- + +diff --git a/AUTHORS b/AUTHORS +index 79becdb..c2905ff 100644 +--- a/AUTHORS ++++ b/AUTHORS +@@ -159,6 +159,7 @@ + Daniel Bevenius <daniel.bevenius@gmail.com> + Daniel Bomar <dbdaniel42@gmail.com> + Daniel Carvalho Liedke <dliedke@gmail.com> ++Daniel Charles <daniel.charles@intel.com> + Daniel Imms <daniimms@amazon.com> + Daniel Johnson <danielj41@gmail.com> + Daniel Lockyer <thisisdaniellockyer@gmail.com> +diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc +index 4cb4ae5..19f663c 100644 +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -1161,12 +1161,14 @@ + flag_descriptions::kUiPartialSwapDescription, kOsAll, + SINGLE_DISABLE_VALUE_TYPE(switches::kUIDisablePartialSwap)}, + #if BUILDFLAG(ENABLE_WEBRTC) ++#if !defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) + {"disable-webrtc-hw-decoding", flag_descriptions::kWebrtcHwDecodingName, + flag_descriptions::kWebrtcHwDecodingDescription, kOsAndroid | kOsCrOS, + SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWDecoding)}, + {"disable-webrtc-hw-encoding", flag_descriptions::kWebrtcHwEncodingName, + flag_descriptions::kWebrtcHwEncodingDescription, kOsAndroid | kOsCrOS, + SINGLE_DISABLE_VALUE_TYPE(switches::kDisableWebRtcHWEncoding)}, ++#endif + {"enable-webrtc-hw-h264-encoding", + flag_descriptions::kWebrtcHwH264EncodingName, + flag_descriptions::kWebrtcHwH264EncodingDescription, kOsAndroid | kOsCrOS, +@@ -1474,6 +1476,13 @@ + flag_descriptions::kMultideviceDescription, kOsCrOS, + FEATURE_VALUE_TYPE(features::kMultidevice)}, + #endif // OS_CHROMEOS ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ { ++ "enable-accelerated-video", flag_descriptions::kAcceleratedVideoName, ++ flag_descriptions::kAcceleratedVideoDescription, kOsLinux, ++ SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideo), ++ }, ++#else + { + "disable-accelerated-video-decode", + flag_descriptions::kAcceleratedVideoDecodeName, +@@ -1481,6 +1490,7 @@ + kOsMac | kOsWin | kOsCrOS | kOsAndroid, + SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode), + }, ++#endif + {"mojo-video-encode-accelerator", + flag_descriptions::kMojoVideoEncodeAcceleratorName, + flag_descriptions::kMojoVideoEncodeAcceleratorDescription, +@@ -2127,12 +2137,17 @@ + FEATURE_VALUE_TYPE(chrome::android::kWebVrAutopresent)}, + #endif // OS_ANDROID + #endif // ENABLE_VR +-#if defined(OS_CHROMEOS) ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ {"enable-accelerated-mjpeg-decode", ++ flag_descriptions::kAcceleratedMjpegDecodeName, ++ flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsLinux, ++ SINGLE_VALUE_TYPE(switches::kEnableAcceleratedMjpegDecode)}, ++#elif defined(OS_CHROMEOS) + {"disable-accelerated-mjpeg-decode", + flag_descriptions::kAcceleratedMjpegDecodeName, + flag_descriptions::kAcceleratedMjpegDecodeDescription, kOsCrOS, + SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedMjpegDecode)}, +-#endif // OS_CHROMEOS ++#endif + {"v8-cache-options", flag_descriptions::kV8CacheOptionsName, + flag_descriptions::kV8CacheOptionsDescription, kOsAll, + MULTI_VALUE_TYPE(kV8CacheOptionsChoices)}, +diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc +index 7ac532c..0afa57b 100644 +--- a/chrome/browser/chromeos/login/chrome_restart_request.cc ++++ b/chrome/browser/chromeos/login/chrome_restart_request.cc +@@ -19,6 +19,7 @@ + #include "base/sys_info.h" + #include "base/timer/timer.h" + #include "base/values.h" ++#include "build/build_config.h" + #include "cc/base/switches.h" + #include "chrome/browser/browser_process.h" + #include "chrome/browser/chromeos/boot_times_recorder.h" +@@ -79,8 +80,13 @@ + ::switches::kDisable2dCanvasImageChromium, + ::switches::kDisableAccelerated2dCanvas, + ::switches::kDisableAcceleratedJpegDecoding, ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ ::switches::kEnableAcceleratedMjpegDecode, ++ ::switches::kEnableAcceleratedVideo, ++#else + ::switches::kDisableAcceleratedMjpegDecode, + ::switches::kDisableAcceleratedVideoDecode, ++#endif + ::switches::kDisableBlinkFeatures, + ::switches::kDisableCastStreamingHWEncoding, + ::switches::kDisableDistanceFieldText, +@@ -169,7 +175,7 @@ + ::switches::kDisableWebGLImageChromium, + ::switches::kEnableWebGLImageChromium, + ::switches::kEnableWebVR, +-#if BUILDFLAG(ENABLE_WEBRTC) ++#if BUILDFLAG(ENABLE_WEBRTC) && (defined(OS_CHROMEOS) || defined(OS_ANDROID)) + ::switches::kDisableWebRtcHWDecoding, + ::switches::kDisableWebRtcHWEncoding, + #endif +diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc +index 100f689..4e7ca96 100644 +--- a/chrome/browser/flag_descriptions.cc ++++ b/chrome/browser/flag_descriptions.cc +@@ -11,6 +11,13 @@ + "Enables the use of the GPU to perform 2d canvas rendering instead of " + "using software rendering."; + ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++const char kAcceleratedVideoName[] = "Hardware-accelerated video"; ++const char kAcceleratedVideoDescription[] = ++ "Hardware-accelerated video where VA-API driver is installed on the" ++ "system."; ++#endif ++ + const char kAcceleratedVideoDecodeName[] = "Hardware-accelerated video decode"; + const char kAcceleratedVideoDecodeDescription[] = + "Hardware-accelerated video decode where available."; +@@ -1326,6 +1333,7 @@ + const char kWebrtcEchoCanceller3Description[] = + "Experimental WebRTC echo canceller (AEC3)."; + ++#if !defined(OS_LINUX) || !defined(OS_CHROMEOS) + const char kWebrtcHwDecodingName[] = "WebRTC hardware video decoding"; + const char kWebrtcHwDecodingDescription[] = + "Support in WebRTC for decoding video streams using platform hardware."; +@@ -1333,6 +1341,7 @@ + const char kWebrtcHwEncodingName[] = "WebRTC hardware video encoding"; + const char kWebrtcHwEncodingDescription[] = + "Support in WebRTC for encoding video streams using platform hardware."; ++#endif + + const char kWebrtcHwH264EncodingName[] = "WebRTC hardware h264 video encoding"; + const char kWebrtcHwH264EncodingDescription[] = +@@ -2117,7 +2126,7 @@ + + #endif // defined(OS_MACOSX) + +-#if defined(OS_CHROMEOS) ++#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID)) + + const char kAcceleratedMjpegDecodeName[] = + "Hardware-accelerated mjpeg decode for captured frame"; +@@ -2126,7 +2135,7 @@ + "Enable hardware-accelerated mjpeg decode for captured frame where " + "available."; + +-#endif // defined(OS_CHROMEOS) ++#endif // defined(OS_CHROMEOS) || BUILDFLAG(USE_VAAPI) + + #if defined(OS_WIN) + +diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h +index 3a99fb6..57e8c93 100644 +--- a/chrome/browser/flag_descriptions.h ++++ b/chrome/browser/flag_descriptions.h +@@ -34,6 +34,10 @@ + extern const char kAccelerated2dCanvasName[]; + extern const char kAccelerated2dCanvasDescription[]; + ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++extern const char kAcceleratedVideoName[]; ++extern const char kAcceleratedVideoDescription[]; ++#endif + extern const char kAcceleratedVideoDecodeName[]; + extern const char kAcceleratedVideoDecodeDescription[]; + +@@ -1251,13 +1255,17 @@ + + #endif // defined(OS_MACOSX) + +-// Chrome OS ------------------------------------------------------------------ +- +-#if defined(OS_CHROMEOS) ++#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID)) + + extern const char kAcceleratedMjpegDecodeName[]; + extern const char kAcceleratedMjpegDecodeDescription[]; + ++#endif ++ ++// Chrome OS ------------------------------------------------------------------ ++ ++#if defined(OS_CHROMEOS) ++ + extern const char kAllowTouchpadThreeFingerClickName[]; + extern const char kAllowTouchpadThreeFingerClickDescription[]; + +diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc +index 0461556..3dc14164 100644 +--- a/content/browser/gpu/compositor_util.cc ++++ b/content/browser/gpu/compositor_util.cc +@@ -104,7 +104,11 @@ + {"video_decode", + manager->IsFeatureBlacklisted( + gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE), ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ !command_line.HasSwitch(switches::kEnableAcceleratedVideo), ++#else + command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode), ++#endif + "Accelerated video decode has been disabled, either via blacklist," + " about:flags or the command line.", + true}, +@@ -112,7 +116,11 @@ + {"video_encode", + manager->IsFeatureBlacklisted( + gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE), ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ !command_line.HasSwitch(switches::kEnableAcceleratedVideo), ++#else + command_line.HasSwitch(switches::kDisableWebRtcHWEncoding), ++#endif + "Accelerated video encode has been disabled, either via blacklist," + " about:flags or the command line.", + true}, +diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc +index d1b78d7..92819ae 100644 +--- a/content/browser/gpu/gpu_data_manager_impl_private.cc ++++ b/content/browser/gpu/gpu_data_manager_impl_private.cc +@@ -760,7 +760,11 @@ + DCHECK(command_line); + + if (ShouldDisableAcceleratedVideoDecode(command_line)) ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ command_line->AppendSwitch(switches::kEnableAcceleratedVideo); ++#else + command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); ++#endif + + #if defined(USE_AURA) + if (!CanUseGpuBrowserCompositor()) +@@ -818,7 +822,11 @@ + } + + if (ShouldDisableAcceleratedVideoDecode(command_line)) { ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ command_line->AppendSwitch(switches::kEnableAcceleratedVideo); ++#else + command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); ++#endif + } + + if (gpu_driver_bugs_.find(gpu::CREATE_DEFAULT_GL_CONTEXT) != +@@ -912,7 +920,12 @@ + const base::CommandLine* command_line = + base::CommandLine::ForCurrentProcess(); + if (!ShouldDisableAcceleratedVideoDecode(command_line) && +- !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ command_line->HasSwitch(switches::kEnableAcceleratedVideo) ++#else ++ !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode) ++#endif ++ ) { + prefs->pepper_accelerated_video_decode_enabled = true; + } + prefs->disable_2d_canvas_copy_on_write = +@@ -1107,7 +1120,13 @@ + // to resolve crbug/442039 has been collected. + const std::string group_name = base::FieldTrialList::FindFullName( + "DisableAcceleratedVideoDecode"); +- if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { ++ if ( ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ !command_line->HasSwitch(switches::kEnableAcceleratedVideo) ++#else ++ command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode) ++#endif ++ ) { + // It was already disabled on the command line. + return false; + } +diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc +index 53e96f5..16379e8 100644 +--- a/content/browser/gpu/gpu_process_host.cc ++++ b/content/browser/gpu/gpu_process_host.cc +@@ -116,7 +116,11 @@ + // Command-line switches to propagate to the GPU process. + static const char* const kSwitchNames[] = { + switches::kCreateDefaultGLContext, ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ switches::kEnableAcceleratedVideo, ++#else + switches::kDisableAcceleratedVideoDecode, ++#endif + switches::kDisableBreakpad, + switches::kDisableES3GLContext, + switches::kDisableGpuRasterization, +@@ -126,7 +130,7 @@ + switches::kDisableLogging, + switches::kDisableSeccompFilterSandbox, + switches::kDisableShaderNameHashing, +-#if BUILDFLAG(ENABLE_WEBRTC) ++#if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_LINUX) + switches::kDisableWebRtcHWEncoding, + #endif + #if defined(OS_WIN) +diff --git a/content/browser/renderer_host/media/video_capture_browsertest.cc b/content/browser/renderer_host/media/video_capture_browsertest.cc +index e4c37d1..4634e92 100644 +--- a/content/browser/renderer_host/media/video_capture_browsertest.cc ++++ b/content/browser/renderer_host/media/video_capture_browsertest.cc +@@ -154,8 +154,13 @@ + base::CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kUseFakeJpegDecodeAccelerator); + } else { ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ base::CommandLine::ForCurrentProcess()->AppendSwitch( ++ switches::kEnableAcceleratedMjpegDecode); ++#else + base::CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kDisableAcceleratedMjpegDecode); ++#endif + } + if (params_.use_mojo_service) { + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( +diff --git a/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc b/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc +index 6970008..89ba93d 100644 +--- a/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc ++++ b/content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc +@@ -56,15 +56,21 @@ + bool is_platform_supported = + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseFakeJpegDecodeAccelerator); +-#if defined(OS_CHROMEOS) +- // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish +- // gpu channel to avoid introducing overhead. ++#if !defined(OS_ANDROID) && defined(OS_LINUX) ++ // Non-ChromeOS or Non-Linux platforms do not support HW JPEG decode now. Do ++ // not establish gpu channel to avoid introducing overhead. + is_platform_supported = true; + #endif + + if (!is_platform_supported || ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++ !base::CommandLine::ForCurrentProcess()->HasSwitch( ++ switches::kEnableAcceleratedMjpegDecode) ++#else + base::CommandLine::ForCurrentProcess()->HasSwitch( +- switches::kDisableAcceleratedMjpegDecode)) { ++ switches::kDisableAcceleratedMjpegDecode) ++#endif ++ ) { + decoder_status_ = FAILED; + RecordInitDecodeUMA_Locked(); + return; +diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc +index a750cdc..bd05641 100644 +--- a/content/browser/renderer_host/render_process_host_impl.cc ++++ b/content/browser/renderer_host/render_process_host_impl.cc +@@ -2450,7 +2450,11 @@ + switches::kDisable2dCanvasImageChromium, + switches::kDisable3DAPIs, + switches::kDisableAcceleratedJpegDecoding, ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ switches::kEnableAcceleratedVideo, ++#else + switches::kDisableAcceleratedVideoDecode, ++#endif + switches::kDisableBackgroundTimerThrottling, + switches::kDisableBlinkFeatures, + switches::kDisableBreakpad, +@@ -2603,8 +2607,10 @@ + switches::kEnablePepperTesting, + #endif + #if BUILDFLAG(ENABLE_WEBRTC) ++#if !defined(OS_LINUX) || defined(OS_CHROMEOS) + switches::kDisableWebRtcHWDecoding, + switches::kDisableWebRtcHWEncoding, ++#endif + switches::kEnableWebRtcSrtpAesGcm, + switches::kEnableWebRtcStunOrigin, + switches::kEnforceWebRtcIPPermissionCheck, +diff --git a/content/browser/webrtc/webrtc_media_recorder_browsertest.cc b/content/browser/webrtc/webrtc_media_recorder_browsertest.cc +index 3d815a2..2c96048 100644 +--- a/content/browser/webrtc/webrtc_media_recorder_browsertest.cc ++++ b/content/browser/webrtc/webrtc_media_recorder_browsertest.cc +@@ -58,7 +58,12 @@ + return; + // This flag is also used for encoding, https://crbug.com/616640. + base::CommandLine::ForCurrentProcess()->AppendSwitch( +- switches::kDisableAcceleratedVideoDecode); ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ switches::kEnableAcceleratedVideo ++#else ++ switches::kDisableAcceleratedVideoDecode ++#endif ++ ); + } + + private: +diff --git a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc +index fe2f298..507f481 100644 +--- a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc ++++ b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc +@@ -56,22 +56,6 @@ + #endif + } + +-inline bool IsArchitectureX86_64() { +-#if defined(__x86_64__) +- return true; +-#else +- return false; +-#endif +-} +- +-inline bool IsArchitectureI386() { +-#if defined(__i386__) +- return true; +-#else +- return false; +-#endif +-} +- + inline bool IsArchitectureArm() { + #if defined(__arm__) || defined(__aarch64__) + return true; +@@ -96,21 +80,14 @@ + #endif + } + +-bool IsAcceleratedVaapiVideoEncodeEnabled() { +- bool accelerated_encode_enabled = false; +-#if defined(OS_CHROMEOS) +- const base::CommandLine& command_line = +- *base::CommandLine::ForCurrentProcess(); +- accelerated_encode_enabled = +- !command_line.HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode); +-#endif +- return accelerated_encode_enabled; +-} +- + bool IsAcceleratedVideoDecodeEnabled() { + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ return command_line.HasSwitch(switches::kEnableAcceleratedVideo); ++#else + return !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode); ++#endif + } + + intptr_t GpuSIGSYS_Handler(const struct arch_seccomp_data& args, +@@ -296,33 +273,6 @@ + GpuBrokerProcessPolicy::Create, + std::vector<BrokerFilePermission>()); // No extra files in whitelist. + +- if (IsArchitectureX86_64() || IsArchitectureI386()) { +- // Accelerated video dlopen()'s some shared objects +- // inside the sandbox, so preload them now. +- if (IsAcceleratedVaapiVideoEncodeEnabled() || +- IsAcceleratedVideoDecodeEnabled()) { +- const char* I965DrvVideoPath = NULL; +- const char* I965HybridDrvVideoPath = NULL; +- +- if (IsArchitectureX86_64()) { +- I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; +- I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so"; +- } else if (IsArchitectureI386()) { +- I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; +- } +- +- dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); +- if (I965HybridDrvVideoPath) +- dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); +- dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); +-#if defined(USE_OZONE) +- dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); +-#elif defined(USE_X11) +- dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); +-#endif +- } +- } +- + return true; + } + +diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn +index a5424bb..b68b802 100644 +--- a/content/gpu/BUILD.gn ++++ b/content/gpu/BUILD.gn +@@ -45,7 +45,6 @@ + ] + + configs += [ "//content:content_implementation" ] +- + deps = [ + "//base", + "//base/third_party/dynamic_annotations", +@@ -114,4 +113,8 @@ + if (enable_vulkan) { + deps += [ "//gpu/vulkan" ] + } ++ ++ if (is_desktop_linux) { ++ public_configs = [ "//media/gpu:libva_config" ] ++ } + } +diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc +index 4b87a8c..1bbf7c8 100644 +--- a/content/gpu/gpu_main.cc ++++ b/content/gpu/gpu_main.cc +@@ -246,7 +246,7 @@ + // Initializes StatisticsRecorder which tracks UMA histograms. + base::StatisticsRecorder::Initialize(); + +-#if defined(OS_ANDROID) || defined(OS_CHROMEOS) ++#if defined(OS_LINUX) + // Set thread priority before sandbox initialization. + base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); + #endif +@@ -274,7 +274,7 @@ + GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); + + base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; +-#if defined(OS_ANDROID) || defined(OS_CHROMEOS) ++#if defined(OS_LINUX) + io_thread_priority = base::ThreadPriority::DISPLAY; + #endif + +diff --git a/content/public/browser/gpu_utils.cc b/content/public/browser/gpu_utils.cc +index a4145ba..e9ff010 100644 +--- a/content/public/browser/gpu_utils.cc ++++ b/content/public/browser/gpu_utils.cc +@@ -7,6 +7,7 @@ + #include "base/command_line.h" + #include "base/single_thread_task_runner.h" + #include "base/strings/string_number_conversions.h" ++#include "build/build_config.h" + #include "content/browser/gpu/gpu_process_host.h" + #include "content/public/common/content_features.h" + #include "content/public/common/content_switches.h" +@@ -56,12 +57,19 @@ + gpu_preferences.ui_prioritize_in_gpu_process = + command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess); + gpu_preferences.disable_accelerated_video_decode = ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ !command_line->HasSwitch(switches::kEnableAcceleratedVideo); ++#else + command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); +-#if defined(OS_CHROMEOS) ++#endif ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ gpu_preferences.disable_vaapi_accelerated_video_encode = ++ !command_line->HasSwitch(switches::kEnableAcceleratedVideo); ++#elif defined(OS_CHROMEOS) + gpu_preferences.disable_vaapi_accelerated_video_encode = + command_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode); + #endif +-#if BUILDFLAG(ENABLE_WEBRTC) ++#if BUILDFLAG(ENABLE_WEBRTC) && (!defined(OS_LINUX) || defined(OS_CHROMEOS)) + gpu_preferences.disable_web_rtc_hw_encoding = + command_line->HasSwitch(switches::kDisableWebRtcHWEncoding); + #endif +diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc +index d7101f4..d81b381 100644 +--- a/content/public/common/content_switches.cc ++++ b/content/public/common/content_switches.cc +@@ -85,12 +85,21 @@ + + // Disable gpu-accelerated 2d canvas. + const char kDisableAccelerated2dCanvas[] = "disable-accelerated-2d-canvas"; +- ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++// Enable hardware accelerated mjpeg decode on linux ++const char kEnableAcceleratedMjpegDecode[] = "enable-accelerated-mjpeg-decode"; ++#else + // Disable hardware acceleration of mjpeg decode for captured frame, where + // available. + const char kDisableAcceleratedMjpegDecode[] = + "disable-accelerated-mjpeg-decode"; ++#endif + ++#if defined(OS_LINUX) ++// Enables hardware acceleration of video for Linux only. VA-API driver ++// is required to be present on the system installation. ++const char kEnableAcceleratedVideo[] = "enable-accelerated-video"; ++#endif + // Disables hardware acceleration of video decode, where available. + const char kDisableAcceleratedVideoDecode[] = + "disable-accelerated-video-decode"; +@@ -915,11 +924,13 @@ + // ignores this switch on its stable and beta channels. + const char kDisableWebRtcEncryption[] = "disable-webrtc-encryption"; + ++#if defined(OS_CHROMEOS) + // Disables HW decode acceleration for WebRTC. + const char kDisableWebRtcHWDecoding[] = "disable-webrtc-hw-decoding"; + + // Disables HW encode acceleration for WebRTC. + const char kDisableWebRtcHWEncoding[] = "disable-webrtc-hw-encoding"; ++#endif + + // Enables negotiation of GCM cipher suites from RFC 7714 for SRTP in WebRTC. + // See https://tools.ietf.org/html/rfc7714 for further information. +diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h +index 0227769..6d72feb 100644 +--- a/content/public/common/content_switches.h ++++ b/content/public/common/content_switches.h +@@ -34,7 +34,11 @@ + CONTENT_EXPORT extern const char kDisable3DAPIs[]; + CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[]; + CONTENT_EXPORT extern const char kDisableAcceleratedJpegDecoding[]; ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++CONTENT_EXPORT extern const char kEnableAcceleratedMjpegDecode[]; ++#else + CONTENT_EXPORT extern const char kDisableAcceleratedMjpegDecode[]; ++#endif + CONTENT_EXPORT extern const char kDisableAcceleratedVideoDecode[]; + CONTENT_EXPORT extern const char kDisableAudioSupportForDesktopShare[]; + extern const char kDisableBackingStoreLimit[]; +@@ -107,6 +111,9 @@ + CONTENT_EXPORT extern const char kDomAutomationController[]; + extern const char kDisable2dCanvasClipAntialiasing[]; + CONTENT_EXPORT extern const char kDumpBlinkRuntimeCallStats[]; ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID) ++CONTENT_EXPORT extern const char kEnableAcceleratedVideo[]; ++#endif + CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[]; + CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[]; + CONTENT_EXPORT extern const char kEnableBlinkFeatures[]; +@@ -257,8 +264,10 @@ + + #if BUILDFLAG(ENABLE_WEBRTC) + CONTENT_EXPORT extern const char kDisableWebRtcEncryption[]; ++#if defined(OS_CHROMEOS) + CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[]; + CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[]; ++#endif + CONTENT_EXPORT extern const char kEnableWebRtcSrtpAesGcm[]; + CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[]; + CONTENT_EXPORT extern const char kEnforceWebRtcIPPermissionCheck[]; +diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc +index 38fa749..7f7bf18 100644 +--- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc ++++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc +@@ -240,10 +240,19 @@ + + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); + if (gpu_factories && gpu_factories->IsGpuVideoAcceleratorEnabled()) { ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo)) ++#else + if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding)) ++#endif + decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); + +- if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ if (cmd_line->HasSwitch(switches::kEnableAcceleratedVideo)) ++#else ++ if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) ++#endif ++ { + encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); + } + } +diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc +index 763f2fe..603660f 100644 +--- a/content/renderer/render_thread_impl.cc ++++ b/content/renderer/render_thread_impl.cc +@@ -1443,7 +1443,11 @@ + scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = + GetMediaThreadTaskRunner(); + const bool enable_video_accelerator = ++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) ++ cmd_line->HasSwitch(switches::kEnableAcceleratedVideo); ++#else + !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); ++#endif + const bool enable_gpu_memory_buffer_video_frames = + #if defined(OS_MACOSX) || defined(OS_LINUX) + !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames) && +diff --git a/gpu/command_buffer/service/gpu_preferences.h b/gpu/command_buffer/service/gpu_preferences.h +index 8dd0ff1..d6e5c59 100644 +--- a/gpu/command_buffer/service/gpu_preferences.h ++++ b/gpu/command_buffer/service/gpu_preferences.h +@@ -50,7 +50,7 @@ + // Disables hardware acceleration of video decode, where available. + bool disable_accelerated_video_decode = false; + +-#if defined(OS_CHROMEOS) ++#if defined(OS_CHROMEOS) || defined(OS_LINUX) + // Disables VA-API accelerated video encode. + bool disable_vaapi_accelerated_video_encode = false; + #endif +diff --git a/gpu/config/software_rendering_list.json b/gpu/config/software_rendering_list.json +index ed5c6d6..4c45159 100644 +--- a/gpu/config/software_rendering_list.json ++++ b/gpu/config/software_rendering_list.json +@@ -371,17 +371,6 @@ + ] + }, + { +- "id": 48, +- "description": "Accelerated video decode is unavailable on Linux", +- "cr_bugs": [137247], +- "os": { +- "type": "linux" +- }, +- "features": [ +- "accelerated_video_decode" +- ] +- }, +- { + "id": 50, + "description": "Disable VMware software renderer on older Mesa", + "cr_bugs": [145531, 332596, 571899, 629434], +diff --git a/media/filters/BUILD.gn b/media/filters/BUILD.gn +index e8ff812..18735d2 100644 +--- a/media/filters/BUILD.gn ++++ b/media/filters/BUILD.gn +@@ -195,7 +195,7 @@ + ] + } + +- if (current_cpu != "arm" && is_chromeos) { ++ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) { + sources += [ + "h264_bitstream_buffer.cc", + "h264_bitstream_buffer.h", +diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn +index 3a65c75..dd2d957 100644 +--- a/media/gpu/BUILD.gn ++++ b/media/gpu/BUILD.gn +@@ -25,6 +25,14 @@ + import("//build/config/mac/mac_sdk.gni") + } + ++if (is_desktop_linux && use_vaapi) { ++ import("//build/config/linux/pkg_config.gni") ++ ++ pkg_config("libva_config") { ++ packages = [ "libva" ] ++ } ++} ++ + if (use_vaapi) { + action("libva_generate_stubs") { + extra_header = "va_stub_header.fragment" +@@ -258,7 +266,7 @@ + } + } + +- if (is_chromeos) { ++ if (is_chromeos || is_desktop_linux) { + sources += [ + "vp8_decoder.cc", + "vp8_decoder.h", +@@ -341,6 +349,9 @@ + "vaapi_drm_picture.h", + ] + } ++ if (is_desktop_linux) { ++ public_configs = [ ":libva_config" ] ++ } + } + + if (is_win) { +@@ -387,7 +398,7 @@ + } + + # TODO(watk): Run this on bots. http://crbug.com/461437 +-if (is_win || is_android || is_chromeos) { ++if (is_win || is_android || is_chromeos || is_desktop_linux) { + test("video_decode_accelerator_unittest") { + sources = [ + "video_accelerator_unittest_helpers.h", +@@ -500,7 +511,7 @@ + } + } + +-if (is_chromeos || is_mac || is_win) { ++if (is_chromeos || is_mac || is_win || is_desktop_linux) { + test("video_encode_accelerator_unittest") { + deps = [ + "//base", +@@ -532,7 +543,7 @@ + } + } + +-if (is_chromeos) { ++if (is_chromeos || is_desktop_linux) { + test("jpeg_decode_accelerator_unittest") { + deps = [ + "//base", +diff --git a/media/gpu/gpu_video_decode_accelerator_factory.cc b/media/gpu/gpu_video_decode_accelerator_factory.cc +index b440d26..1558796 100644 +--- a/media/gpu/gpu_video_decode_accelerator_factory.cc ++++ b/media/gpu/gpu_video_decode_accelerator_factory.cc +@@ -18,7 +18,7 @@ + #include "media/gpu/dxva_video_decode_accelerator_win.h" + #elif defined(OS_MACOSX) + #include "media/gpu/vt_video_decode_accelerator_mac.h" +-#elif defined(OS_CHROMEOS) ++#elif defined(OS_CHROMEOS) || defined(OS_LINUX) + #if defined(USE_V4L2_CODEC) + #include "media/gpu/v4l2_device.h" + #include "media/gpu/v4l2_slice_video_decode_accelerator.h" +@@ -85,6 +85,7 @@ + // profile (instead of calculating a superset). + // TODO(posciak,henryhsu): improve this so that we choose a superset of + // resolutions and other supported profile parameters. ++ DVLOG(1) << "Get Supported profiles"; + #if defined(OS_WIN) + capabilities.supported_profiles = + DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences, +diff --git a/media/gpu/gpu_video_encode_accelerator_factory.cc b/media/gpu/gpu_video_encode_accelerator_factory.cc +index d1b8ff3..c3f1f03 100644 +--- a/media/gpu/gpu_video_encode_accelerator_factory.cc ++++ b/media/gpu/gpu_video_encode_accelerator_factory.cc +@@ -9,7 +9,7 @@ + #include "media/gpu/features.h" + #include "media/gpu/gpu_video_accelerator_util.h" + +-#if defined(OS_CHROMEOS) ++#if defined(OS_CHROMEOS) || defined(OS_LINUX) + #if defined(USE_V4L2_CODEC) + #include "media/gpu/v4l2_video_encode_accelerator.h" + #endif +diff --git a/media/gpu/vaapi_wrapper.cc b/media/gpu/vaapi_wrapper.cc +index 0739e56..b059fd4 100644 +--- a/media/gpu/vaapi_wrapper.cc ++++ b/media/gpu/vaapi_wrapper.cc +@@ -1110,6 +1110,7 @@ + if (drm_file.IsValid()) + GetDisplayState()->SetDrmFd(drm_file.GetPlatformFile()); + #endif ++ GetProfileInfos(); // dlopen all necessary libraries + } + + // static +diff --git a/services/ui/gpu/gpu_main.cc b/services/ui/gpu/gpu_main.cc +index f1b8567..15cf123 100644 +--- a/services/ui/gpu/gpu_main.cc ++++ b/services/ui/gpu/gpu_main.cc +@@ -10,6 +10,7 @@ + #include "base/power_monitor/power_monitor_device_source.h" + #include "base/single_thread_task_runner.h" + #include "base/threading/sequenced_task_runner_handle.h" ++#include "build/build_config.h" + #include "components/viz/service/display_embedder/gpu_display_provider.h" + #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" + #include "gpu/command_buffer/common/activity_flags.h" +@@ -79,7 +80,7 @@ + thread_options.message_loop_type = base::MessageLoop::TYPE_IO; + #endif + +-#if defined(OS_ANDROID) || defined(OS_CHROMEOS) ++#if defined(OS_LINUX) + thread_options.priority = base::ThreadPriority::DISPLAY; + #endif + CHECK(gpu_thread_.StartWithOptions(thread_options)); +@@ -89,7 +90,7 @@ + // should be possible to use |main_task_runner_| for doing IO tasks. + thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0); + thread_options.priority = base::ThreadPriority::NORMAL; +-#if defined(OS_ANDROID) || defined(OS_CHROMEOS) ++#if defined(OS_LINUX) + // TODO(reveman): Remove this in favor of setting it explicitly for each type + // of process. + thread_options.priority = base::ThreadPriority::DISPLAY; diff --git a/vaapi_patch_r2.patch b/vaapi_patch_r2.patch deleted file mode 100644 index ec4651a38818..000000000000 --- a/vaapi_patch_r2.patch +++ /dev/null @@ -1,616 +0,0 @@ ---- a/chrome/browser/about_flags.cc -+++ b/chrome/browser/about_flags.cc -@@ -1044,7 +1044,7 @@ const FeatureEntry kFeatureEntries[] = { - "disable-accelerated-video-decode", - flag_descriptions::kAcceleratedVideoDecodeName, - flag_descriptions::kAcceleratedVideoDecodeDescription, -- kOsMac | kOsWin | kOsCrOS | kOsAndroid, -+ kOsAll, - SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode), - }, - #if defined(OS_WIN) ---- a/content/common/BUILD.gn -+++ b/content/common/BUILD.gn -@@ -13,6 +13,49 @@ if (is_mac) { - import("//build/config/mac/mac_sdk.gni") - } - -+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { -+ action("libva_generate_stubs") { -+ extra_header = "../../media/gpu/va_stub_header.fragment" -+ -+ script = "../../tools/generate_stubs/generate_stubs.py" -+ sources = [ -+ "../../media/gpu/vaapi/va.sigs", -+ ] -+ inputs = [ -+ extra_header, -+ ] -+ sources += [ "../../media/gpu/vaapi/va_x11.sigs" ] -+ if (use_ozone) { -+ sources += [ -+ "../../media/gpu/vaapi/va_drm.sigs", -+ "va_wayland.sigs", -+ ] -+ } -+ stubs_filename_root = "va_stubs" -+ -+ outputs = [ -+ "$target_gen_dir/$stubs_filename_root.cc", -+ "$target_gen_dir/$stubs_filename_root.h", -+ ] -+ args = [ -+ "-i", -+ rebase_path("$target_gen_dir", root_build_dir), -+ "-o", -+ rebase_path("$target_gen_dir", root_build_dir), -+ "-t", -+ "posix_stubs", -+ "-e", -+ rebase_path(extra_header, root_build_dir), -+ "-s", -+ stubs_filename_root, -+ "-p", -+ "content/common", -+ ] -+ -+ args += rebase_path(sources, root_build_dir) -+ } -+} -+ - source_set("common") { - # Targets external to content should always link to the public API. - # In addition, targets outside of the content component (shell and tests) -@@ -525,6 +568,16 @@ source_set("common") { - "sandbox_linux/android/sandbox_bpf_base_policy_android.h", - ] - } -+ } else { -+ if (current_cpu != "arm" && is_desktop_linux) { -+ sources += get_target_outputs(":libva_generate_stubs") -+ deps += [ ":libva_generate_stubs" ] -+ configs += [ "//third_party/libva:libva_config" ] -+ if (use_ozone) { -+ configs += [ "//build/config/linux:x11" ] -+ deps += [ "//third_party/wayland:wayland_client" ] -+ } -+ } - } - - if (is_mac) { ---- a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc -+++ b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc -@@ -25,6 +25,12 @@ - #include "base/memory/ptr_util.h" - #include "base/strings/stringprintf.h" - #include "build/build_config.h" -+ -+#if !defined(__arm__) -+// Auto-generated for dlopen libva libraries -+#include "content/common/va_stubs.h" -+#endif -+ - #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" - #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" - #include "content/common/set_process_title.h" -@@ -36,6 +42,28 @@ - #include "sandbox/linux/syscall_broker/broker_process.h" - #include "sandbox/linux/system_headers/linux_syscalls.h" - -+#if !defined(__arm__) -+#include "third_party/libva/va/va.h" -+#include "third_party/libva/va/va_backend.h" -+#if defined(USE_X11) -+#include "third_party/libva/va/va_x11.h" -+#include "ui/gfx/x/x11_types.h" -+#elif defined(USE_OZONE) -+#include "base/files/file.h" -+#include "third_party/libva/va/drm/va_drm.h" -+#include "third_party/libva/va/va_drmcommon.h" -+#endif -+#endif -+ -+#define DRIVER_EXTENSION "_drv_video.so" -+#if defined(__x86_64__) -+#define VA_DRIVERS_PATH "/usr/lib/x86_64-linux-gnu/dri" -+#elif defined(__i386__) -+#define VA_DRIVERS_PATH "/usr/lib/i386-linux-gnu/dri" -+#elif defined(__aarch64__) -+#define VA_DRIVERS_PATH "/usr/lib/aarch64-linux-gnu/dri" -+#endif -+ - using sandbox::arch_seccomp_data; - using sandbox::bpf_dsl::Allow; - using sandbox::bpf_dsl::ResultExpr; -@@ -44,6 +72,17 @@ using sandbox::syscall_broker::BrokerFilePermission; - using sandbox::syscall_broker::BrokerProcess; - using sandbox::SyscallSets; - -+#if !defined(__arm__) -+using content_common::kModuleVa; -+#if defined(USE_X11) -+using content_common::kModuleVa_x11; -+#elif defined(USE_OZONE) -+using content_common::kModuleVa_drm; -+#endif -+using content_common::InitializeStubs; -+using content_common::StubPathMap; -+#endif -+ - namespace content { - - namespace { -@@ -98,7 +137,7 @@ inline bool UseLibV4L2() { - - bool IsAcceleratedVaapiVideoEncodeEnabled() { - bool accelerated_encode_enabled = false; --#if defined(OS_CHROMEOS) -+#if defined(OS_CHROMEOS) || defined(OS_LINUX) - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - accelerated_encode_enabled = -@@ -290,6 +329,36 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { - } - } - -+#if !defined(__arm__) -+static VADisplay VaapiGetVADisplay() { -+ StubPathMap paths; -+ VADisplay va_display; -+ paths[kModuleVa].push_back("libva.so.1"); -+#if defined(USE_OZONE) -+ paths[kModuleVa_drm].push_back("libva-drm.so.1"); -+#elif defined (USE_X11) -+ paths[kModuleVa_x11].push_back("libva-x11.so.1"); -+#endif -+ if (!InitializeStubs(paths)) { -+ return NULL; -+ } -+#if defined(USE_OZONE) -+ const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; -+ base::File drm_file = base::File( -+ base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), -+ base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE); -+ va_display = vaGetDisplayDRM(drm_file.GetPlatformFile()); -+#elif defined(USE_X11) -+ va_display = vaGetDisplay(gfx::GetXDisplay()); -+#endif -+ if (!vaDisplayIsValid(va_display)) { -+ LOG(WARNING) << "Unable to get display."; -+ return NULL; -+ } -+ return va_display; -+} -+#endif -+ - bool GpuProcessPolicy::PreSandboxHook() { - // Warm up resources needed by the policy we're about to enable and - // eventually start a broker process. -@@ -303,32 +372,75 @@ bool GpuProcessPolicy::PreSandboxHook() { - GpuBrokerProcessPolicy::Create, - std::vector<BrokerFilePermission>()); // No extra files in whitelist. - -+#if !defined(__arm__) - if (IsArchitectureX86_64() || IsArchitectureI386()) { - // Accelerated video dlopen()'s some shared objects - // inside the sandbox, so preload them now. - if (IsAcceleratedVaapiVideoEncodeEnabled() || - IsAcceleratedVideoDecodeEnabled()) { -- const char* I965DrvVideoPath = NULL; -- const char* I965HybridDrvVideoPath = NULL; -- -- if (IsArchitectureX86_64()) { -- I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; -- I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so"; -- } else if (IsArchitectureI386()) { -- I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; -- } -- -- dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -- if (I965HybridDrvVideoPath) -- dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -- dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -+ // Init a VA Context, get driver name (and path), close context and preload -+#if defined(USE_OZONE) || defined(USE_X11) -+ VADisplay va_display = VaapiGetVADisplay(); -+ if (va_display) { -+ char *va_search_path = getenv("LIBVA_DRIVERS_PATH"); -+ char *va_driver_name = getenv("LIBVA_DRIVER_NAME"); -+ char *saveptr, *driver_dir; -+ if (!va_driver_name) { -+ VADisplayContextP pDisplayContext = -+ static_cast<VADisplayContextP>(va_display); -+ pDisplayContext->vaGetDriverName(pDisplayContext, &va_driver_name); -+ } -+ -+ if (!va_driver_name) { -+ return true; -+ } -+ -+ if (!va_search_path) { -+ va_search_path = strdup(VA_DRIVERS_PATH); -+ } -+ -+ driver_dir = strtok_r(va_search_path, ":", &saveptr); -+ while (driver_dir) { -+ std::string driver_path = base::StringPrintf("%s/%s%s", driver_dir, -+ va_driver_name, DRIVER_EXTENSION); -+ -+ // attempt to dlopen() the va driver -+ LOG(INFO) << "Looking for " << driver_path << "..."; -+ if (access(driver_path.c_str(), R_OK) != -1) { -+ LOG(WARNING) << "Attempting to pre-load " << va_driver_name << " VA driver..."; -+ if (dlopen(driver_path.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) { -+ LOG(WARNING) << "VA driver \"" << driver_path << "\" opened!"; -+ -+ if (strcmp(va_driver_name, "nvidia") == 0) { -+ LOG(WARNING) << "Pre-loading NVIDIA VDPAU driver libraries..."; -+ if (dlopen("libvdpau_nvidia.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) { -+ LOG(WARNING) << "Loaded libvdpau_nvidia.so"; -+ } -+ -+ if (dlopen("libvdpau.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) { -+ LOG(WARNING) << "Loaded libvdpau.so"; -+ } -+ } -+ LOG(WARNING) << "Loading libva libraries..."; -+ dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); - #if defined(USE_OZONE) -- dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -+ dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); - #elif defined(USE_X11) -- dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -+ dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -+#endif -+ break; -+ } -+ LOG(ERROR) << "VA driver failed to open!"; -+ } -+ -+ driver_dir = strtok_r(NULL, ":", &saveptr); -+ } -+ free(va_search_path); -+ } - #endif - } - } -+#endif - - return true; - } ---- /dev/null -+++ b/content/common/va_wayland.sigs -@@ -0,0 +1,8 @@ -+// Copyright 2014 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+//------------------------------------------------ -+// Functions from libva-wayland used in chromium code. -+//------------------------------------------------ -+VADisplay vaGetDisplayWl(struct wl_display *display); ---- a/content/gpu/BUILD.gn -+++ b/content/gpu/BUILD.gn -@@ -92,7 +92,7 @@ target(link_target_type, "gpu_sources") { - ] - } - -- if (is_chromeos && current_cpu != "arm") { -+ if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { - configs += [ "//third_party/libva:libva_config" ] - } - ---- a/content/gpu/gpu_main.cc -+++ b/content/gpu/gpu_main.cc -@@ -85,7 +85,7 @@ - #include "ui/ozone/public/ozone_platform.h" - #endif - --#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) - #include "media/gpu/vaapi_wrapper.h" - #endif - -@@ -141,7 +141,7 @@ class ContentSandboxHelper : public gpu::GpuSandboxHelper { - (void)base::RandUint64(); - } - --#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) - media::VaapiWrapper::PreSandboxInitialization(); - #endif - #if defined(OS_WIN) ---- a/content/public/common/content_switches.cc -+++ b/content/public/common/content_switches.cc -@@ -1000,7 +1000,9 @@ const char kDisableAudioSupportForDesktopShare[] = - #if defined(OS_CHROMEOS) - // Disables panel fitting (used for mirror mode). - const char kDisablePanelFitting[] = "disable-panel-fitting"; -+#endif - -+#if defined(OS_CHROMEOS) || defined(OS_LINUX) - // Disables VA-API accelerated video encode. - const char kDisableVaapiAcceleratedVideoEncode[] = - "disable-vaapi-accelerated-video-encode"; ---- a/content/public/common/content_switches.h -+++ b/content/public/common/content_switches.h -@@ -291,6 +291,8 @@ CONTENT_EXPORT extern const char kEnableOSKOverscroll[]; - - #if defined(OS_CHROMEOS) - CONTENT_EXPORT extern const char kDisablePanelFitting[]; -+#endif -+#if defined(OS_CHROMEOS) || defined(OS_LINUX) - CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[]; - #endif - ---- a/gpu/config/software_rendering_list.json -+++ b/gpu/config/software_rendering_list.json -@@ -395,17 +395,6 @@ const char kSoftwareRenderingListJson[] = LONG_STRING_CONST( - ] - }, - { -- "id": 48, -- "description": "Accelerated video decode is unavailable on Linux", -- "cr_bugs": [137247], -- "os": { -- "type": "linux" -- }, -- "features": [ -- "accelerated_video_decode" -- ] -- }, -- { - "id": 50, - "description": "Disable VMware software renderer on older Mesa", - "cr_bugs": [145531, 332596, 571899, 629434], ---- a/media/BUILD.gn -+++ b/media/BUILD.gn -@@ -396,7 +396,7 @@ component("media") { - allow_circular_includes_from = [ "//media/base/android" ] - } - -- if (current_cpu != "arm" && is_chromeos) { -+ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) { - sources += [ - "filters/h264_bitstream_buffer.cc", - "filters/h264_bitstream_buffer.h", -@@ -667,7 +667,7 @@ source_set("unit_tests") { - } - } - -- if (current_cpu != "arm" && is_chromeos) { -+ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) { - sources += [ "filters/h264_bitstream_buffer_unittest.cc" ] - } - ---- a/media/gpu/BUILD.gn -+++ b/media/gpu/BUILD.gn -@@ -18,7 +18,7 @@ if (is_mac) { - import("//build/config/mac/mac_sdk.gni") - } - --if (is_chromeos && current_cpu != "arm") { -+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { - action("libva_generate_stubs") { - extra_header = "va_stub_header.fragment" - -@@ -212,7 +212,7 @@ component("gpu") { - } - } - -- if (is_chromeos || is_win) { -+ if (is_linux || is_win) { - sources += [ - "accelerated_video_decoder.h", - "h264_decoder.cc", -@@ -221,7 +221,7 @@ component("gpu") { - "h264_dpb.h", - ] - } -- if (is_chromeos) { -+ if (is_linux) { - sources += [ - "vp8_decoder.cc", - "vp8_decoder.h", -@@ -259,7 +259,7 @@ component("gpu") { - "EGL", - "GLESv2", - ] -- if (current_cpu == "arm") { -+ if (current_cpu == "arm" && is_chromeos) { - sources += [ - "tegra_v4l2_device.cc", - "tegra_v4l2_device.h", ---- a/media/gpu/gpu_video_decode_accelerator_factory.cc -+++ b/media/gpu/gpu_video_decode_accelerator_factory.cc -@@ -16,7 +16,7 @@ - #include "media/gpu/dxva_video_decode_accelerator_win.h" - #elif defined(OS_MACOSX) - #include "media/gpu/vt_video_decode_accelerator_mac.h" --#elif defined(OS_CHROMEOS) -+#elif defined(OS_CHROMEOS) || defined(OS_LINUX) - #if defined(USE_V4L2_CODEC) - #include "media/gpu/v4l2_device.h" - #include "media/gpu/v4l2_slice_video_decode_accelerator.h" -@@ -86,7 +86,7 @@ - capabilities.supported_profiles = - DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences, - workarounds); --#elif defined(OS_CHROMEOS) -+#elif defined(OS_CHROMEOS) || defined(OS_LINUX) - VideoDecodeAccelerator::SupportedProfiles vda_profiles; - #if defined(USE_V4L2_CODEC) - vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); -@@ -139,7 +139,7 @@ - &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, - &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA, - #endif --#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) - &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, - #endif - #if defined(OS_MACOSX) -@@ -222,11 +222,12 @@ - } - #endif - --#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) - std::unique_ptr<VideoDecodeAccelerator> - GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA( - const gpu::GpuDriverBugWorkarounds& workarounds, - const gpu::GpuPreferences& gpu_preferences) const { -+ VLOG(1) << "Creating new VAAPI video decode accelerator."; - std::unique_ptr<VideoDecodeAccelerator> decoder; - decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_, - bind_image_cb_)); ---- a/media/gpu/gpu_video_decode_accelerator_factory.h -+++ b/media/gpu/gpu_video_decode_accelerator_factory.h -@@ -101,7 +101,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcceleratorFactory { - const gpu::GpuDriverBugWorkarounds& workarounds, - const gpu::GpuPreferences& gpu_preferences) const; - #endif --#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) - std::unique_ptr<VideoDecodeAccelerator> CreateVaapiVDA( - const gpu::GpuDriverBugWorkarounds& workarounds, - const gpu::GpuPreferences& gpu_preferences) const; ---- a/media/gpu/ipc/service/BUILD.gn -+++ b/media/gpu/ipc/service/BUILD.gn -@@ -47,7 +47,7 @@ target(link_target_type, "service") { - - configs += [ "//media/gpu:gpu_config" ] - -- if (is_chromeos && current_cpu != "arm") { -+ if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { - configs += [ "//third_party/libva:libva_config" ] - } - ---- a/media/gpu/ipc/service/gpu_video_decode_accelerator.cc -+++ b/media/gpu/ipc/service/gpu_video_decode_accelerator.cc -@@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent( - return true; - } - --#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \ -+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || \ - defined(OS_MACOSX) || defined(OS_WIN) - static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub, - uint32_t client_texture_id, -@@ -172,7 +172,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( - get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); - make_context_current_cb_ = - base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); --#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \ -+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || \ - defined(OS_MACOSX) || defined(OS_WIN) - bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); - #endif ---- a/media/gpu/va_stub_header.fragment -+++ b/media/gpu/va_stub_header.fragment -@@ -5,8 +5,9 @@ extern "C" { - - #include "third_party/libva/va/drm/va_drm.h" - #include "third_party/libva/va/va.h" --#if defined(USE_X11) - #include "third_party/libva/va/va_x11.h" -+#if defined(USE_OZONE) -+#include "third_party/libva/va/wayland/va_wayland.h" - #endif - - } ---- a/media/gpu/vaapi_video_decode_accelerator.cc -+++ b/media/gpu/vaapi_video_decode_accelerator.cc -@@ -358,17 +358,17 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config, - - base::AutoLock auto_lock(lock_); - DCHECK_EQ(state_, kUninitialized); -- DVLOG(2) << "Initializing VAVDA, profile: " << GetProfileName(profile); -+ VLOG(1) << "Initializing VAVDA, profile: " << GetProfileName(profile); - - #if defined(USE_X11) - if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) { -- DVLOG(1) << "HW video decode acceleration not available without " -+ VLOG(1) << "HW video decode acceleration not available without " - "DesktopGL (GLX)."; - return false; - } - #elif defined(USE_OZONE) - if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) { -- DVLOG(1) << "HW video decode acceleration not available without " -+ VLOG(1) << "HW video decode acceleration not available without " - << "EGLGLES2."; - return false; - } -@@ -378,7 +378,7 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config, - VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR)); - - if (!vaapi_wrapper_.get()) { -- DVLOG(1) << "Failed initializing VAAPI for profile " -+ VLOG(1) << "Failed initializing VAAPI for profile " - << GetProfileName(profile); - return false; - } -@@ -394,7 +394,7 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config, - vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get())); - decoder_.reset(new VP9Decoder(vp9_accelerator_.get())); - } else { -- DLOG(ERROR) << "Unsupported profile " << GetProfileName(profile); -+ VLOG(1) << "Unsupported profile " << GetProfileName(profile); - return false; - } - ---- a/media/gpu/vaapi_wrapper.cc -+++ b/media/gpu/vaapi_wrapper.cc -@@ -188,7 +188,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper::Create( - VAProfile va_profile, - const base::Closure& report_error_to_uma_cb) { - if (!GetProfileInfos()->IsProfileSupported(mode, va_profile)) { -- DVLOG(1) << "Unsupported va_profile: " << va_profile; -+ VLOG(1) << "Unsupported va_profile: " << va_profile; - return nullptr; - } - -@@ -340,15 +340,17 @@ VaapiWrapper::GetSupportedProfileInfosForCodecModeInternal(CodecMode mode) { - bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) { - static bool vaapi_functions_initialized = PostSandboxInitialization(); - if (!vaapi_functions_initialized) { -- bool running_on_chromeos = false; --#if defined(OS_CHROMEOS) -+ bool error_level_logging = false; -+#if defined(OS_LINUX) -+ error_level_logging = true; -+#elif defined(OS_CHROMEOS) - // When chrome runs on linux with chromeos=1, do not log error message - // without VAAPI libraries. -- running_on_chromeos = base::SysInfo::IsRunningOnChromeOS(); -+ error_level_logging = base::SysInfo::IsRunningOnChromeOS(); - #endif - static const char kErrorMsg[] = "Failed to initialize VAAPI libs"; -- if (running_on_chromeos) -- LOG(ERROR) << kErrorMsg; -+ if (error_level_logging) -+ VLOG(1) << kErrorMsg; - else - DVLOG(1) << kErrorMsg; - return false; -@@ -407,7 +409,7 @@ bool VaapiWrapper::IsEntrypointSupported_Locked(VAProfile va_profile, - - if (std::find(supported_entrypoints.begin(), supported_entrypoints.end(), - entrypoint) == supported_entrypoints.end()) { -- DVLOG(1) << "Unsupported entrypoint"; -+ VLOG(1) << "Unsupported entrypoint"; - return false; - } - return true; -@@ -431,8 +433,8 @@ bool VaapiWrapper::AreAttribsSupported_Locked( - if (attribs[i].type != required_attribs[i].type || - (attribs[i].value & required_attribs[i].value) != - required_attribs[i].value) { -- DVLOG(1) << "Unsupported value " << required_attribs[i].value -- << " for attribute type " << required_attribs[i].type; -+ VLOG(1) << "Unsupported value " << required_attribs[i].value -+ << " for attribute type " << required_attribs[i].type; - return false; - } - } |