diff --git a/packages/addons/addon-depends/node/package.mk b/packages/addons/addon-depends/node/package.mk
new file mode 100644
index 0000000000..4e61840ff1
--- /dev/null
+++ b/packages/addons/addon-depends/node/package.mk
@@ -0,0 +1,38 @@
+################################################################################
+# This file is part of OpenELEC - http://www.openelec.tv
+# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
+#
+# OpenELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# OpenELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenELEC. If not, see .
+################################################################################
+
+PKG_NAME="node"
+PKG_VERSION="8.9.3"
+PKG_SHA256="a5042d983f9815ee18a5c6fd75f8b3b2022ed96a2aaa8834300cd1ee81e8870c"
+PKG_ARCH="any"
+PKG_LICENSE="GPL"
+PKG_SITE="https://nodejs.org"
+PKG_URL="https://github.com/nodejs/node/archive/v$PKG_VERSION.tar.gz"
+PKG_DEPENDS_HOST="toolchain"
+PKG_SHORTDESC="Node.js JavaScript runtime"
+PKG_LONGDESC="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. The Node.js package ecosystem, npm, is the largest ecosystem of open source libraries in the world."
+
+HOST_CONFIGURE_OPTS="--prefix=$TOOLCHAIN \
+ --fully-static \
+ --with-intl=none \
+ --without-npm \
+ --without-ssl"
+
+pre_configure_host() {
+ cd ..
+}
diff --git a/packages/addons/addon-depends/nss/package.mk b/packages/addons/addon-depends/nss/package.mk
index ec1d06f722..a1d8f82e42 100644
--- a/packages/addons/addon-depends/nss/package.mk
+++ b/packages/addons/addon-depends/nss/package.mk
@@ -25,7 +25,7 @@ PKG_ARCH="any"
PKG_LICENSE="Mozilla Public License"
PKG_SITE="http://ftp.mozilla.org/"
PKG_URL="http://ftp.mozilla.org/pub/security/nss/releases/NSS_3_29_5_RTM/src/nss-3.29.5-with-nspr-4.13.1.tar.gz"
-PKG_DEPENDS_TARGET="toolchain nss:host nspr zlib"
+PKG_DEPENDS_TARGET="toolchain nss:host nspr zlib sqlite"
PKG_SECTION="security"
PKG_SHORTDESC="The Network Security Services (NSS) package is a set of libraries designed to support cross-platform development of security-enabled client and server applications"
PKG_LONGDESC="The Network Security Services (NSS) package is a set of libraries designed to support cross-platform development of security-enabled client and server applications"
@@ -55,6 +55,7 @@ make_target() {
make BUILD_OPT=1 $TARGET_USE_64 \
NSS_USE_SYSTEM_SQLITE=1 \
NSPR_INCLUDE_DIR=$SYSROOT_PREFIX/usr/include/nspr \
+ NSS_USE_SYSTEM_SQLITE=1 \
USE_SYSTEM_ZLIB=1 ZLIB_LIBS=-lz \
SKIP_SHLIBSIGN=1 \
OS_TEST=$TARGET_ARCH \
diff --git a/packages/addons/browser/chromium/package.mk b/packages/addons/browser/chromium/package.mk
index 7c447eac20..9afccc7a4f 100644
--- a/packages/addons/browser/chromium/package.mk
+++ b/packages/addons/browser/chromium/package.mk
@@ -19,14 +19,15 @@
################################################################################
PKG_NAME="chromium"
-PKG_VERSION="55.0.2883.75"
-PKG_SHA256="5bcf7180935bebc7648f7e2577f612da681f7846127f79dac22630ded9984e55"
-PKG_REV="107"
+PKG_VERSION="63.0.3239.84"
+PKG_SHA256="6de2754dfc333675ae6a67ae13c95666009b35c84f847b058edbf312e42fa3af"
+PKG_REV="107.009"
PKG_ARCH="x86_64"
PKG_LICENSE="Mixed"
PKG_SITE="http://www.chromium.org/Home"
PKG_URL="https://commondatastorage.googleapis.com/chromium-browser-official/$PKG_NAME-$PKG_VERSION.tar.xz"
-PKG_DEPENDS_TARGET="toolchain pciutils dbus libXcomposite libXcursor libXtst alsa-lib bzip2 yasm nss libXScrnSaver libexif ninja:host libpng harfbuzz atk gtk+ libva-vdpau-driver unclutter xdotool"
+PKG_DEPENDS_HOST="toolchain ninja:host Python2:host"
+PKG_DEPENDS_TARGET="chromium:host node:host pciutils dbus libXcomposite libXcursor libXtst alsa-lib bzip2 yasm nss libXScrnSaver libexif libpng atk gtk+ libva-vdpau-driver unclutter xdotool"
PKG_SECTION="browser"
PKG_SHORTDESC="Chromium Browser: the open-source web browser from Google"
PKG_LONGDESC="Chromium Browser ($PKG_VERSION): the open-source web browser from Google"
@@ -37,28 +38,35 @@ PKG_ADDON_NAME="Chromium"
PKG_ADDON_TYPE="xbmc.python.script"
PKG_ADDON_PROVIDES="executable"
-pre_make_target() {
- strip_lto
-
- sed -i -e 's/@WIDEVINE_VERSION@/Pinkie Pie/' third_party/widevine/cdm/stub/widevine_cdm_version.h
-}
-
-make_target() {
- export LDFLAGS="$LDFLAGS -ludev"
- export LD=$CXX
+post_patch() {
+ cd $(get_build_dir chromium)
# Use Python 2
find . -name '*.py' -exec sed -i -r "s|/usr/bin/python$|$TOOLCHAIN/bin/python|g" {} +
+ # set correct widevine
+ sed -i -e 's/@WIDEVINE_VERSION@/Pinkie Pie/' ./third_party/widevine/cdm/stub/widevine_cdm_version.h
+}
+
+make_host() {
+ ./tools/gn/bootstrap/bootstrap.py --no-rebuild --no-clean --verbose
+}
+
+make_target() {
+ strip_lto
+ export LDFLAGS="$LDFLAGS -ludev"
+ export LD=$CXX
+
# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for OpenELEC use ONLY. For your own distribution, please
# get your own set of keys.
- _google_api_key=AIzaSyAQ6L9vt9cnN4nM0weaa6Y38K4eyPvtKgI
- _google_default_client_id=740889307901-4bkm4e0udppnp1lradko85qsbnmkfq3b.apps.googleusercontent.com
- _google_default_client_secret=9TJlhL661hvShQub4cWhANXa
+ local _google_api_key=AIzaSyAQ6L9vt9cnN4nM0weaa6Y38K4eyPvtKgI
+ local _google_default_client_id=740889307901-4bkm4e0udppnp1lradko85qsbnmkfq3b.apps.googleusercontent.com
+ local _google_default_client_secret=9TJlhL661hvShQub4cWhANXa
local _flags=(
+ "host_toolchain=\"//build/toolchain/linux:x64_host\""
'is_clang=false'
'clang_use_chrome_plugins=false'
'symbol_level=0'
@@ -73,6 +81,7 @@ make_target() {
'linux_use_bundled_binutils=false'
'use_allocator="none"'
'use_cups=false'
+ 'use_custom_libcxx=false'
'use_gconf=false'
'use_gnome_keyring=false'
'use_gold=false'
@@ -80,44 +89,29 @@ make_target() {
'use_kerberos=false'
'use_pulseaudio=false'
'use_sysroot=true'
+ 'use_vaapi=true'
+ 'use_v8_context_snapshot=false'
+ 'enable_vulkan=false'
"target_sysroot=\"${SYSROOT_PREFIX}\""
+ 'exclude_unwind_tables=true'
'enable_hangout_services_extension=true'
'enable_widevine=true'
'enable_nacl=false'
'enable_nacl_nonsfi=false'
+ 'enable_swiftshader=false'
+ 'enable_vulkan=false'
"google_api_key=\"${_google_api_key}\""
"google_default_client_id=\"${_google_default_client_id}\""
"google_default_client_secret=\"${_google_default_client_secret}\""
)
- # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
- local _system_libs=(
- harfbuzz-ng
- libjpeg
- libpng
- libxslt
- yasm
- )
-
- # Remove bundled libraries for which we will use the system copies; this
- # *should* do what the remove_bundled_libraries.py script does, with the
- # added benefit of not having to list all the remaining libraries
- local _lib
- for _lib in ${_system_libs}; do
- find -type f -path "*third_party/$_lib/*" \
- \! -path "*third_party/$_lib/chromium/*" \
- \! -path "*third_party/$_lib/google/*" \
- \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
- -delete
- done
-
- ./build/linux/unbundle/replace_gn_files.py --system-libraries "${_system_libs}"
./third_party/libaddressinput/chromium/tools/update-strings.py
- ./tools/gn/bootstrap/bootstrap.py --gn-gen-args "${_flags[*]}"
./out/Release/gn gen out/Release --args="${_flags[*]}" --script-executable=$TOOLCHAIN/bin/python
+ mkdir -p $PKG_BUILD/third_party/node/linux/node-linux-x64/bin
+ ln -fs $TOOLCHAIN/bin/node $PKG_BUILD/third_party/node/linux/node-linux-x64/bin/node
- ninja -C out/Release chrome chrome_sandbox widevinecdmadapter
+ ninja -j${CONCURRENCY_MAKE_LEVEL} -C out/Release chrome chrome_sandbox widevinecdmadapter
}
addon() {
diff --git a/packages/addons/browser/chromium/patches/chromium-0002-allow-root.patch b/packages/addons/browser/chromium/patches/chromium-0002-allow-root.patch
new file mode 100644
index 0000000000..eccfbbf87c
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0002-allow-root.patch
@@ -0,0 +1,11 @@
+--- chromium-59.0.3071.109/./chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc.org 2017-06-26 20:32:34.907628561 +0200
++++ chromium-59.0.3071.109/./chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc 2017-06-26 20:31:05.855206203 +0200
+@@ -99,7 +99,7 @@
+ IMEDriver::Register();
+ #endif
+
+-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
++#if 0
+ // On the Linux desktop, we want to prevent the user from logging in as root,
+ // so that we don't destroy the profile. Now that we have some minimal ui
+ // initialized, check to see if we're running as root and bail if we are.
diff --git a/packages/addons/browser/chromium/patches/chromium-0002-unset-madv_free.patch b/packages/addons/browser/chromium/patches/chromium-0002-unset-madv_free.patch
deleted file mode 100644
index 2867c79677..0000000000
--- a/packages/addons/browser/chromium/patches/chromium-0002-unset-madv_free.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -up chromium-52.0.2743.116/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp.madv_free chromium-52.0.2743.116/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp
---- chromium-52.0.2743.116/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp.madv_free 2016-08-15 13:07:29.279655676 -0400
-+++ chromium-52.0.2743.116/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp 2016-08-15 13:08:38.447317416 -0400
-@@ -41,6 +41,11 @@
- #include
- #include
-
-+#if OS(LINUX) && defined(MADV_FREE)
-+// Added in Linux 4.5, but it breaks the sandbox.
-+#undef MADV_FREE
-+#endif
-+
- #ifndef MADV_FREE
- #define MADV_FREE MADV_DONTNEED
- #endif
diff --git a/packages/addons/browser/chromium/patches/chromium-0004-vaapi-on-linux.patch b/packages/addons/browser/chromium/patches/chromium-0004-vaapi-on-linux.patch
index 9fdb718bd2..b8dff361a7 100644
--- a/packages/addons/browser/chromium/patches/chromium-0004-vaapi-on-linux.patch
+++ b/packages/addons/browser/chromium/patches/chromium-0004-vaapi-on-linux.patch
@@ -1,365 +1,642 @@
-Description: Enables using VA-API hardware acceleration in Linux. The patch for bpf_gpu_policy_linux.cc initially came from https://codereview.chromium.org/15955009/diff/92001/content/common/sandbox_linux/bpf_gpu_policy_linux.cc. The code in bpf_gpu_policy_linux.cc was then updated by Steven Newbury to support Nvidia drivers.
+From 7f29b44224439377592be2b75da0b86d82d8ad6d Mon Sep 17 00:00:00 2001
+From: Daniel Charles
+Date: Wed, 18 Oct 2017 17:27:42 -0700
+Subject: [PATCH] Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only
-Index: dev/chrome/browser/about_flags.cc
-===================================================================
---- dev.orig/chrome/browser/about_flags.cc
-+++ dev/chrome/browser/about_flags.cc
-@@ -947,7 +947,7 @@ const FeatureEntry kFeatureEntries[] = {
+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
+---
+
+diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
+index 3555293..4c3115f 100644
+--- a/chrome/browser/about_flags.cc
++++ b/chrome/browser/about_flags.cc
+@@ -1246,12 +1246,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,
+@@ -1557,6 +1559,13 @@
+ flag_descriptions::kSpuriousPowerButtonLidAngleChangeDescription, kOsCrOS,
+ MULTI_VALUE_TYPE(kSpuriousPowerButtonLidAngleChangeChoices)},
+ #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",
- IDS_FLAGS_ACCELERATED_VIDEO_DECODE_NAME,
- IDS_FLAGS_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
-- kOsMac | kOsWin | kOsCrOS,
-+ kOsAll,
+ flag_descriptions::kAcceleratedVideoDecodeName,
+@@ -1564,6 +1573,7 @@
+ kOsMac | kOsWin | kOsCrOS | kOsAndroid,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
- #if defined(USE_ASH)
-Index: dev/content/common/BUILD.gn
-===================================================================
---- dev.orig/content/common/BUILD.gn
-+++ dev/content/common/BUILD.gn
-@@ -11,6 +11,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/va.sigs",
-+ ]
-+ inputs = [
-+ extra_header,
-+ ]
-+ sources += [ "../../media/gpu/va_x11.sigs" ]
-+ if (use_ozone) {
-+ sources += [
-+ "../../media/gpu/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)
-@@ -502,6 +545,15 @@ source_set("common") {
-
- if (use_seccomp_bpf) {
- defines += [ "USE_SECCOMP_BPF" ]
-+ 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" ]
-+ }
-+ }
- } else {
- if (is_linux) {
- sources -= [
-Index: dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
-===================================================================
---- dev.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
-+++ dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
-@@ -24,6 +24,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"
-@@ -35,6 +41,27 @@
- #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 "third_party/libva/va/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;
-@@ -43,6 +70,17 @@ using sandbox::syscall_broker::BrokerFil
- 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 {
-@@ -97,7 +135,7 @@ inline bool UseLibV4L2() {
-
- bool IsAcceleratedVaapiVideoEncodeEnabled() {
- bool accelerated_encode_enabled = false;
+ {"mojo-video-encode-accelerator",
+ flag_descriptions::kMojoVideoEncodeAcceleratorName,
+ flag_descriptions::kMojoVideoEncodeAcceleratorDescription,
+@@ -2229,12 +2239,17 @@
+ FEATURE_VALUE_TYPE(features::kWebVrVsyncAlign)},
+ #endif // OS_ANDROID
+ #endif // ENABLE_VR
-#if defined(OS_CHROMEOS)
-+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- accelerated_encode_enabled =
-@@ -282,6 +320,32 @@ ResultExpr GpuProcessPolicy::EvaluateSys
++#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 3815e79..d5d3712 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,
+@@ -166,7 +172,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 74e6bc7..ab184a5 100644
+--- a/chrome/browser/flag_descriptions.cc
++++ b/chrome/browser/flag_descriptions.cc
+@@ -14,6 +14,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.";
+@@ -1478,6 +1485,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.";
+@@ -1485,6 +1493,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[] =
+@@ -2283,14 +2292,16 @@
+
+ // Chrome OS -------------------------------------------------------------------
+
+-#if defined(OS_CHROMEOS)
++#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && !defined(OS_ANDROID))
+
+ const char kAcceleratedMjpegDecodeName[] =
+ "Hardware-accelerated mjpeg decode for captured frame";
+ const char kAcceleratedMjpegDecodeDescription[] =
+ "Enable hardware-accelerated mjpeg decode for captured frame where "
+ "available.";
++#endif
+
++#if defined(OS_CHROMEOS)
+ const char kAllowTouchpadThreeFingerClickName[] = "Touchpad three-finger-click";
+ const char kAllowTouchpadThreeFingerClickDescription[] =
+ "Enables touchpad three-finger-click as middle button.";
+diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
+index 54a4950..5ace5e0 100644
+--- a/chrome/browser/flag_descriptions.h
++++ b/chrome/browser/flag_descriptions.h
+@@ -37,6 +37,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[];
+
+@@ -1401,13 +1405,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 122282d..bc102a3 100644
+--- a/content/browser/gpu/compositor_util.cc
++++ b/content/browser/gpu/compositor_util.cc
+@@ -105,7 +105,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},
+@@ -113,7 +117,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 51aa672..963da85 100644
+--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
++++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
+@@ -717,7 +717,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())
+@@ -748,7 +752,11 @@
}
- }
-+#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");
+ 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 (!InitializeStubs(paths)) {
-+ return NULL;
-+ }
-+#if defined(USE_OZONE)
-+ va_display = vaGetDisplayDRM(drm_fd_.get());
-+#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.
-@@ -295,32 +359,75 @@ bool GpuProcessPolicy::PreSandboxHook()
- GpuBrokerProcessPolicy::Create,
- std::vector()); // 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(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);
+@@ -826,7 +834,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
-+ break;
-+ }
-+ LOG(ERROR) << "VA driver failed to open!";
-+ }
-+
-+ driver_dir = strtok_r(NULL, ":", &saveptr);
-+ }
-+ free(va_search_path);
-+ }
- #endif
- }
++ ) {
+ prefs->pepper_accelerated_video_decode_enabled = true;
}
-+#endif
-
- return true;
}
-Index: dev/content/common/va_wayland.sigs
-===================================================================
---- /dev/null
-+++ dev/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);
-Index: dev/content/gpu/BUILD.gn
-===================================================================
---- dev.orig/content/gpu/BUILD.gn
-+++ dev/content/gpu/BUILD.gn
-@@ -91,7 +91,7 @@ target(link_target_type, "gpu_sources")
- ]
+@@ -1016,7 +1029,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 95d4dff..9b26d3f 100644
+--- a/content/browser/gpu/gpu_process_host.cc
++++ b/content/browser/gpu/gpu_process_host.cc
+@@ -111,7 +111,11 @@
-- if (is_chromeos && current_cpu != "arm") {
-+ if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
- configs += [ "//third_party/libva:libva_config" ]
- }
-
-Index: dev/content/gpu/gpu_main.cc
-===================================================================
---- dev.orig/content/gpu/gpu_main.cc
-+++ dev/content/gpu/gpu_main.cc
-@@ -79,7 +79,7 @@
- #include "content/common/sandbox_mac.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
-
-@@ -138,7 +138,7 @@ class ContentSandboxHelper : public gpu:
- (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();
+ // Command-line switches to propagate to the GPU process.
+ static const char* const kSwitchNames[] = {
++#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
++ switches::kEnableAcceleratedVideo,
++#else
+ switches::kDisableAcceleratedVideoDecode,
++#endif
+ switches::kDisableBreakpad,
+ switches::kDisableGpuRasterization,
+ switches::kDisableGpuSandbox,
+@@ -120,7 +124,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)
-Index: dev/content/public/common/content_switches.cc
-===================================================================
---- dev.orig/content/public/common/content_switches.cc
-+++ dev/content/public/common/content_switches.cc
-@@ -985,7 +985,9 @@ const char kDisableAudioSupportForDeskto
- #if defined(OS_CHROMEOS)
- // Disables panel fitting (used for mirror mode).
- const char kDisablePanelFitting[] = "disable-panel-fitting";
+diff --git a/content/browser/renderer_host/media/video_capture_browsertest.cc b/content/browser/renderer_host/media/video_capture_browsertest.cc
+index 8ca0ad0..8c489d0 100644
+--- a/content/browser/renderer_host/media/video_capture_browsertest.cc
++++ b/content/browser/renderer_host/media/video_capture_browsertest.cc
+@@ -155,8 +155,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 defined(OS_CHROMEOS) || defined(OS_LINUX)
- // Disables VA-API accelerated video encode.
- const char kDisableVaapiAcceleratedVideoEncode[] =
- "disable-vaapi-accelerated-video-encode";
-Index: dev/content/public/common/content_switches.h
-===================================================================
---- dev.orig/content/public/common/content_switches.h
-+++ dev/content/public/common/content_switches.h
-@@ -288,6 +288,8 @@ CONTENT_EXPORT extern const char kEnable
-
- #if defined(OS_CHROMEOS)
- CONTENT_EXPORT extern const char kDisablePanelFitting[];
-+#endif
-+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
- CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
+ }
+ 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 34afec23..ad77490 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
-Index: dev/gpu/config/software_rendering_list_json.cc
-===================================================================
---- dev.orig/gpu/config/software_rendering_list_json.cc
-+++ dev/gpu/config/software_rendering_list_json.cc
-@@ -415,17 +415,6 @@ const char kSoftwareRenderingListJson[]
+ 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 fbe4d21..1be295e 100644
+--- a/content/browser/renderer_host/render_process_host_impl.cc
++++ b/content/browser/renderer_host/render_process_host_impl.cc
+@@ -2506,7 +2506,11 @@
+ switches::kDefaultTileHeight,
+ switches::kDisable2dCanvasImageChromium,
+ switches::kDisableAcceleratedJpegDecoding,
++#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
++ switches::kEnableAcceleratedVideo,
++#else
+ switches::kDisableAcceleratedVideoDecode,
++#endif
+ switches::kDisableBackgroundTimerThrottling,
+ switches::kDisableBreakpad,
+ switches::kDisableBrowserSideNavigation,
+@@ -2660,8 +2664,10 @@
+ switches::kDisableMojoRenderer,
+ #endif
+ #if BUILDFLAG(ENABLE_WEBRTC)
++#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
+ switches::kDisableWebRtcHWDecoding,
+ switches::kDisableWebRtcHWEncoding,
++#endif
+ switches::kEnableWebRtcSrtpAesGcm,
+ switches::kEnableWebRtcSrtpEncryptedHeaders,
+ switches::kEnableWebRtcStunOrigin,
+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/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 556cf00..730f4ae 100644
+--- a/content/gpu/gpu_main.cc
++++ b/content/gpu/gpu_main.cc
+@@ -254,7 +254,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
+@@ -283,7 +283,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 6aafb06..d4ddd8d 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"
+@@ -57,12 +58,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 4e699d1..3a7a2b7 100644
+--- a/content/public/common/content_switches.cc
++++ b/content/public/common/content_switches.cc
+@@ -89,12 +89,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";
+@@ -932,11 +941,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 2704924..67d00bb 100644
+--- a/content/public/common/content_switches.h
++++ b/content/public/common/content_switches.h
+@@ -35,7 +35,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[];
+@@ -109,6 +113,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 kEnableAutomation[];
+ CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
+@@ -256,8 +263,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 kEnableWebRtcSrtpEncryptedHeaders[];
+ CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[];
+diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
+index 017056c..825bdce 100644
+--- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
++++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
+@@ -239,10 +239,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 dc01117..2f9ee03 100644
+--- a/content/renderer/render_thread_impl.cc
++++ b/content/renderer/render_thread_impl.cc
+@@ -1456,7 +1456,11 @@
+ scoped_refptr 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 b37c2cc..a721eb7 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 1289a55..22e11e5 100644
+--- a/gpu/config/software_rendering_list.json
++++ b/gpu/config/software_rendering_list.json
+@@ -374,17 +374,6 @@
]
},
{
@@ -376,264 +653,70 @@ Index: dev/gpu/config/software_rendering_list_json.cc
- {
"id": 50,
"description": "Disable VMware software renderer on older Mesa",
- "cr_bugs": [145531, 332596, 571899],
-Index: dev/media/BUILD.gn
-===================================================================
---- dev.orig/media/BUILD.gn
-+++ dev/media/BUILD.gn
-@@ -370,7 +370,7 @@ component("media") {
- allow_circular_includes_from = [ "//media/base/android" ]
+ "cr_bugs": [145531, 332596, 571899, 629434],
+diff --git a/media/filters/BUILD.gn b/media/filters/BUILD.gn
+index 490722c..1cda2fb 100644
+--- a/media/filters/BUILD.gn
++++ b/media/filters/BUILD.gn
+@@ -189,7 +189,7 @@
+ deps += [ "//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",
-@@ -653,7 +653,7 @@ test("media_unittests") {
- }
- }
-
-- if (current_cpu != "arm" && is_chromeos) {
-+ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
- sources += [ "filters/h264_bitstream_buffer_unittest.cc" ]
- }
-
-Index: dev/media/gpu/BUILD.gn
-===================================================================
---- dev.orig/media/gpu/BUILD.gn
-+++ dev/media/gpu/BUILD.gn
-@@ -12,7 +12,7 @@ if (is_mac) {
+ "h264_bitstream_buffer.cc",
+ "h264_bitstream_buffer.h",
+diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn
+index 729c6fa..4878251 100644
+--- a/media/gpu/BUILD.gn
++++ b/media/gpu/BUILD.gn
+@@ -24,6 +24,14 @@
import("//build/config/mac/mac_sdk.gni")
}
--if (is_chromeos && current_cpu != "arm") {
-+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
++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"
-
-@@ -238,7 +238,7 @@ component("gpu") {
- }
- }
-
-- if (is_chromeos) {
-+ if (is_linux) {
- sources += [
- "accelerated_video_decoder.h",
- "h264_decoder.cc",
-@@ -281,7 +281,7 @@ component("gpu") {
- "GLESv2",
+@@ -334,6 +342,9 @@
+ "vaapi_drm_picture.h",
]
}
-- if (current_cpu == "arm") {
-+ if (current_cpu == "arm" && is_chromeos) {
- sources += [
- "tegra_v4l2_device.cc",
- "tegra_v4l2_device.h",
-Index: dev/media/gpu/gpu_video_decode_accelerator_factory.cc
-===================================================================
---- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.cc
-+++ dev/media/gpu/gpu_video_decode_accelerator_factory.cc
-@@ -14,7 +14,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"
-@@ -79,7 +79,7 @@ GpuVideoDecodeAcceleratorFactory::GetDec
++ if (is_desktop_linux) {
++ public_configs = [ ":libva_config" ]
++ }
+ }
+
+ if (is_win) {
+diff --git a/media/gpu/gpu_video_decode_accelerator_factory.cc b/media/gpu/gpu_video_decode_accelerator_factory.cc
+index 2cee490..de02414 100644
+--- a/media/gpu/gpu_video_decode_accelerator_factory.cc
++++ b/media/gpu/gpu_video_decode_accelerator_factory.cc
+@@ -87,6 +87,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);
--#elif defined(OS_CHROMEOS)
-+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
- VideoDecodeAccelerator::SupportedProfiles vda_profiles;
- #if defined(USE_V4L2_CODEC)
- vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
-@@ -131,7 +131,7 @@ GpuVideoDecodeAcceleratorFactory::Create
- &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA,
- &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA,
+ DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences,
+diff --git a/media/gpu/vaapi_wrapper.cc b/media/gpu/vaapi_wrapper.cc
+index 1e72893..6495642 100644
+--- a/media/gpu/vaapi_wrapper.cc
++++ b/media/gpu/vaapi_wrapper.cc
+@@ -1117,6 +1117,7 @@
+ if (drm_file.IsValid())
+ GetDisplayState()->SetDrmFd(drm_file.GetPlatformFile());
#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)
-@@ -199,11 +199,12 @@ GpuVideoDecodeAcceleratorFactory::Create
- }
- #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
- GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA(
- const gpu::GpuDriverBugWorkarounds& workarounds,
- const gpu::GpuPreferences& gpu_preferences) const {
-+ VLOG(1) << "Creating new VAAPI video decode accelerator.";
- std::unique_ptr decoder;
- decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
- bind_image_cb_));
-Index: dev/media/gpu/gpu_video_decode_accelerator_factory.h
-===================================================================
---- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.h
-+++ dev/media/gpu/gpu_video_decode_accelerator_factory.h
-@@ -98,7 +98,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcc
- 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 CreateVaapiVDA(
- const gpu::GpuDriverBugWorkarounds& workarounds,
- const gpu::GpuPreferences& gpu_preferences) const;
-Index: dev/media/gpu/ipc/service/BUILD.gn
-===================================================================
---- dev.orig/media/gpu/ipc/service/BUILD.gn
-+++ dev/media/gpu/ipc/service/BUILD.gn
-@@ -45,7 +45,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" ]
- }
-
-Index: dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
-===================================================================
---- dev.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
-+++ dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
-@@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent(
- return true;
++ GetProfileInfos(); // dlopen all necessary libraries
}
--#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
-+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
- static bool BindImage(const base::WeakPtr& stub,
- uint32_t client_texture_id,
- uint32_t texture_target,
-@@ -171,7 +171,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecod
- 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)) || defined(OS_MACOSX)
-+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
- bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr());
- #endif
- get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr());
-Index: dev/media/gpu/va_stub_header.fragment
-===================================================================
---- dev.orig/media/gpu/va_stub_header.fragment
-+++ dev/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
-
- }
-Index: dev/media/gpu/vaapi_video_decode_accelerator.cc
-===================================================================
---- dev.orig/media/gpu/vaapi_video_decode_accelerator.cc
-+++ dev/media/gpu/vaapi_video_decode_accelerator.cc
-@@ -359,17 +359,17 @@ bool VaapiVideoDecodeAccelerator::Initia
-
- base::AutoLock auto_lock(lock_);
- DCHECK_EQ(state_, kUninitialized);
-- DVLOG(2) << "Initializing VAVDA, profile: " << profile;
-+ VLOG(1) << "Initializing VAVDA, profile: " << 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;
- }
-@@ -379,7 +379,7 @@ bool VaapiVideoDecodeAccelerator::Initia
- VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR));
-
- if (!vaapi_wrapper_.get()) {
-- DVLOG(1) << "Failed initializing VAAPI for profile " << profile;
-+ VLOG(1) << "Failed initializing VAAPI for profile " << profile;
- return false;
- }
-
-@@ -394,7 +394,7 @@ bool VaapiVideoDecodeAccelerator::Initia
- vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get()));
- decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
- } else {
-- DLOG(ERROR) << "Unsupported profile " << profile;
-+ VLOG(1) << "Unsupported profile " << profile;
- return false;
- }
-
-Index: dev/media/gpu/vaapi_wrapper.cc
-===================================================================
---- dev.orig/media/gpu/vaapi_wrapper.cc
-+++ dev/media/gpu/vaapi_wrapper.cc
-@@ -194,7 +194,7 @@ scoped_refptr VaapiWrapper
- VAProfile va_profile,
- const base::Closure& report_error_to_uma_cb) {
- if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) {
-- DVLOG(1) << "Unsupported va_profile: " << va_profile;
-+ VLOG(1) << "Unsupported va_profile: " << va_profile;
- return nullptr;
- }
-
-@@ -347,15 +347,17 @@ VaapiWrapper::GetSupportedProfileInfosFo
- 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;
-@@ -421,7 +423,7 @@ bool VaapiWrapper::IsEntrypointSupported
-
- 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;
-@@ -445,8 +447,8 @@ bool VaapiWrapper::AreAttribsSupported_L
- 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;
- }
- }
+ // static
diff --git a/packages/addons/browser/chromium/patches/chromium-0005-define-toolchains.patch b/packages/addons/browser/chromium/patches/chromium-0005-define-toolchains.patch
new file mode 100644
index 0000000000..b512277a4f
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0005-define-toolchains.patch
@@ -0,0 +1,48 @@
+--- a/build/toolchain/linux/BUILD.gn 2017-08-30 14:08:06.342205027 +0200
++++ b/build/toolchain/linux/BUILD.gn 2017-08-30 14:15:18.648503216 +0200
+@@ -129,12 +129,13 @@
+ }
+
+ gcc_toolchain("x64") {
+- cc = "gcc"
+- cxx = "g++"
++ toolchainprefix = "x86_64-libreelec-linux-gnu-"
++ cc = "${toolchainprefix}gcc"
++ cxx = "${toolchainprefix}g++"
+
+- readelf = "readelf"
+- nm = "nm"
+- ar = "ar"
++ readelf = "${toolchainprefix}readelf"
++ nm = "${toolchainprefix}nm"
++ ar = "${toolchainprefix}ar"
+ ld = cxx
+
+ # Output linker map files for binary size analysis.
+@@ -147,6 +148,26 @@
+ }
+ }
+
++gcc_toolchain("x64_host") {
++ toolchainprefix = "host-"
++ cc = "${toolchainprefix}gcc"
++ cxx = "${toolchainprefix}g++"
++
++ readelf = "readelf"
++ nm = "nm"
++ ar = "ar"
++ ld = cxx
++
++ # Output linker map files for binary size analysis.
++ enable_linker_map = true
++
++ toolchain_args = {
++ current_cpu = "x64"
++ current_os = "linux"
++ is_clang = false
++ }
++}
++
+ clang_toolchain("clang_mipsel") {
+ toolchain_args = {
+ current_cpu = "mipsel"
diff --git a/packages/addons/browser/chromium/patches/chromium-0005-use-toolchain-prefix.patch b/packages/addons/browser/chromium/patches/chromium-0005-use-toolchain-prefix.patch
deleted file mode 100644
index 3eada8d438..0000000000
--- a/packages/addons/browser/chromium/patches/chromium-0005-use-toolchain-prefix.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/build/toolchain/linux/BUILD.gn 2016-11-09 19:49:39.000000000 -0800
-+++ b/build/toolchain/linux/BUILD.gn 2016-11-10 20:33:18.200587987 -0800
-@@ -102,13 +102,14 @@
- }
-
- gcc_toolchain("x64") {
-- cc = "gcc"
-- cxx = "g++"
-+ toolprefix = "x86_64-libreelec-linux-gnu-"
-+ cc = "${toolprefix}gcc"
-+ cxx = "${toolprefix}g++"
-
-- readelf = "readelf"
-- nm = "nm"
-- ar = "ar"
-+ ar = "${toolprefix}ar"
- ld = cxx
-+ readelf = "${toolprefix}readelf"
-+ nm = "${toolprefix}nm"
-
- toolchain_args = {
- current_cpu = "x64"
diff --git a/packages/addons/browser/chromium/patches/chromium-0006-exclude_unwind_tables.patch b/packages/addons/browser/chromium/patches/chromium-0006-exclude_unwind_tables.patch
new file mode 100644
index 0000000000..67232595dd
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0006-exclude_unwind_tables.patch
@@ -0,0 +1,44 @@
+From 1fc37227522ccd314f82ec893ed15c6129296604 Mon Sep 17 00:00:00 2001
+From: Paul Jensen
+Date: Wed, 11 Oct 2017 08:37:34 -0400
+Subject: [PATCH] Move exclude_unwind_tables back into declare_args
+
+There is desire to adjust this flag manually.
+
+BUG=762629
+R=thakis@chromium.org
+
+Change-Id: I3bd134c19270cd1f729b3ea078674e734493d4ab
+---
+
+diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
+index ad40fd9..50e19a4 100644
+--- a/build/config/compiler/compiler.gni
++++ b/build/config/compiler/compiler.gni
+@@ -68,18 +68,18 @@
+
+ # Whether or not we should use position independent code.
+ use_pic = true
++
++ # Exclude unwind tables for official builds as unwinding can be done from
++ # stack dumps produced by Crashpad at a later time "offline" in the crash
++ # server. For unofficial (e.g. development) builds and non-Chrome branded
++ # (e.g. Cronet which doesn't use Crashpad, crbug.com/479283) builds it's
++ # useful to be able to unwind at runtime.
++ exclude_unwind_tables = (is_chrome_branded && is_official_build) ||
++ (is_chromecast && !is_cast_desktop_build && !is_debug)
+ }
+
+ assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO")
+
+-# Exclude unwind tables for official builds as unwinding can be done from stack
+-# dumps produced by Crashpad at a later time "offline" in the crash server.
+-# For unofficial (e.g. development) builds and non-Chrome branded (e.g. Cronet
+-# which doesn't use Crashpad, crbug.com/479283) builds it's useful to be able
+-# to unwind at runtime.
+-exclude_unwind_tables = (is_chrome_branded && is_official_build) ||
+- (is_chromecast && !is_cast_desktop_build && !is_debug)
+-
+ # If true, optimize for size. Does not affect windows builds.
+ # Linux & Mac favor speed over size.
+ # TODO(brettw) it's weird that Mac and desktop Linux are different. We should
diff --git a/packages/addons/browser/chromium/patches/chromium-0007-dont-link-atomic-in-gn.patch b/packages/addons/browser/chromium/patches/chromium-0007-dont-link-atomic-in-gn.patch
index f547fac5bb..b271dc7379 100644
--- a/packages/addons/browser/chromium/patches/chromium-0007-dont-link-atomic-in-gn.patch
+++ b/packages/addons/browser/chromium/patches/chromium-0007-dont-link-atomic-in-gn.patch
@@ -1,12 +1,12 @@
diff -Naur a/tools/gn/bootstrap/bootstrap.py b/tools/gn/bootstrap/bootstrap.py
---- a/tools/gn/bootstrap/bootstrap.py 2016-10-20 15:02:19.000000000 -0700
-+++ b/tools/gn/bootstrap/bootstrap.py 2016-11-10 09:26:36.026611661 -0800
-@@ -563,7 +563,7 @@
- }
-
- if is_linux:
-- libs.extend(['-lrt', '-latomic'])
-+ libs.extend(['-lrt'])
- ldflags.extend(['-pthread'])
-
- static_libraries['xdg_user_dirs'] = {
+--- a/tools/gn/bootstrap/bootstrap.py 2017-08-10 17:18:53.767165155 +0200
++++ b/tools/gn/bootstrap/bootstrap.py 2017-08-10 17:23:28.668750638 +0200
+@@ -657,7 +657,7 @@
+ 'base/allocator/allocator_shim.cc',
+ 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc',
+ ])
+- libs.extend(['-lrt', '-latomic'])
++ libs.extend(['-lrt'])
+ static_libraries['libevent']['include_dirs'].extend([
+ os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux')
+ ])
diff --git a/packages/addons/browser/chromium/patches/chromium-0008-fix-webrtc.patch b/packages/addons/browser/chromium/patches/chromium-0008-fix-webrtc.patch
new file mode 100644
index 0000000000..7b70999719
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0008-fix-webrtc.patch
@@ -0,0 +1,10 @@
+--- chromium-63.0.3239.84//third_party/webrtc/p2p/base/port.cc.org 2017-12-09 01:53:55.490672425 +0100
++++ chromium-63.0.3239.84//third_party/webrtc/p2p/base/port.cc 2017-12-09 01:54:10.826751406 +0100
+@@ -12,6 +12,7 @@
+
+ #include
+ #include
++#include
+
+ #include "p2p/base/common.h"
+ #include "p2p/base/portallocator.h"
diff --git a/packages/addons/browser/chromium/patches/chromium-0009-fix-gtk_ui.patch b/packages/addons/browser/chromium/patches/chromium-0009-fix-gtk_ui.patch
new file mode 100644
index 0000000000..edd53b2b02
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0009-fix-gtk_ui.patch
@@ -0,0 +1,10 @@
+--- a/chrome/browser/ui/libgtkui/gtk_ui.h 2017-10-19 00:15:47.451704332 +0200
++++ b/chrome/browser/ui/libgtkui/gtk_ui.h 2017-10-18 23:53:19.328373980 +0200
+@@ -14,6 +14,7 @@
+ #include "base/observer_list.h"
+ #include "chrome/browser/ui/libgtkui/gtk_signal.h"
+ #include "chrome/browser/ui/libgtkui/libgtkui_export.h"
++#include "chrome/browser/ui/libgtkui/nav_button_layout_manager.h"
+ #include "ui/gfx/color_utils.h"
+ #include "ui/views/linux_ui/linux_ui.h"
+ #include "ui/views/window/frame_buttons.h"
diff --git a/packages/addons/browser/chromium/patches/chromium-0010-fix-gcc.patch b/packages/addons/browser/chromium/patches/chromium-0010-fix-gcc.patch
new file mode 100644
index 0000000000..0101dfa03a
--- /dev/null
+++ b/packages/addons/browser/chromium/patches/chromium-0010-fix-gcc.patch
@@ -0,0 +1,16 @@
+Source: https://aur.archlinux.org/packages/chromium-vaapi/ chromium-gcc-r1.patch
+
+diff --git a/base/numerics/safe_math_shared_impl.h b/base/numerics/safe_math_shared_impl.h
+index 99f230ce7e9a..de2415d402f5 100644
+--- a/base/numerics/safe_math_shared_impl.h
++++ b/base/numerics/safe_math_shared_impl.h
+@@ -21,8 +21,7 @@
+ #if !defined(__native_client__) && \
+ ((defined(__clang__) && \
+ ((__clang_major__ > 3) || \
+- (__clang_major__ == 3 && __clang_minor__ >= 4))) || \
+- (defined(__GNUC__) && __GNUC__ >= 5))
++ (__clang_major__ == 3 && __clang_minor__ >= 4))))
+ #include "base/numerics/safe_math_clang_gcc_impl.h"
+ #define BASE_HAS_OPTIMIZED_SAFE_MATH (1)
+ #else
diff --git a/packages/addons/browser/chromium/source/bin/chromium b/packages/addons/browser/chromium/source/bin/chromium
index e0c7549cd1..74f59d8f38 100644
--- a/packages/addons/browser/chromium/source/bin/chromium
+++ b/packages/addons/browser/chromium/source/bin/chromium
@@ -16,19 +16,29 @@
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see .
################################################################################
-
. /etc/profile
oe_setup_addon browser.chromium
+if [ -e $ADDON_HOME/env ]
+then
+ . $ADDON_HOME/env
+fi
+
+# drop profile for testing only
+#rm -rf /storage/.kodi/userdata/addon_data/browser.chromium/profile
+
+# fix file permissons (zip packaging)
+chmod +x $ADDON_DIR/bin/chromium $ADDON_DIR/bin/chromium.bin
+chmod 4755 $ADDON_DIR/bin/chrome-sandbox
# make sure we use "own" gtk/pango/nss/etc
-export LD_LIBRARY_PATH=/storage/.kodi/addons/browser.chromium/lib
+export LD_LIBRARY_PATH=$ADDON_DIR/lib
# configure pango/pixbuf
-export PANGO_RC_FILE=/storage/.kodi/addons/browser.chromium/config/pangorc
-export GDK_PIXBUF_MODULE_FILE=/storage/.kodi/addons/browser.chromium/config/pixbuf.loaders.cache
+export PANGO_RC_FILE=$ADDON_DIR/config/pangorc
+export GDK_PIXBUF_MODULE_FILE=$ADDON_DIR/config/pixbuf.loaders.cache
# font rendering in gtk widgets is brokeen with nvidia blob. use our Xdefaults
-export XENVIRONMENT=/storage/.kodi/addons/browser.chromium/config/Xdefaults
+export XENVIRONMENT=$ADDON_DIR/config/Xdefaults
# start unclutter
if [ "$HIDE_CURSOR" == "true" ]
@@ -37,10 +47,57 @@ then
UNCLUTTER_PID=$!
fi
+# vaapi
+LIBVA_DRIVERS_PATH="/usr/lib/dri:$ADDON_DIR/lib"
+LIBVA_DRIVER_NAME=''
+case $VAAPI_MODE in
+ 'intel')
+ LIBVA_DRIVER_NAME='i965'
+ CHROMIUM_OPTS="$CHROMIUM_OPTS --enable-accelerated-video"
+ ;;
+ 'amd')
+ LIBVA_DRIVER_NAME='vdpau'
+ CHROMIUM_OPTS="$CHROMIUM_OPTS --enable-accelerated-video"
+ ;;
+ 'nvidia')
+ LIBVA_DRIVER_NAME='vdpau'
+ CHROMIUM_OPTS="$CHROMIUM_OPTS --enable-accelerated-video --allow-no-sandbox-job --disable-gpu-sandbox"
+ ;;
+ *)
+ LIBGL_ALWAYS_SOFTWARE='1'
+ export LIBGL_ALWAYS_SOFTWARE
+esac
+export LIBVA_DRIVER_NAME LIBVA_DRIVERS_PATH
+
+# windowed
+case $WINDOW_MODE in
+ 'maximized') CHROMIUM_OPTS="$CHROMIUM_OPTS --start-maximized";;
+ 'kiosk') CHROMIUM_OPTS="$CHROMIUM_OPTS --kiosk";;
+esac
+
+# rasterization
+case $RASTER_MODE in
+ 'off') CHROMIUM_OPTS="$CHROMIUM_OPTS --disable-accelerated-2d-canvas --disable-gpu-compositing";;
+ 'force') CHROMIUM_OPTS="$CHROMIUM_OPTS --enable-gpu-rasterization --enable-accelerated-2d-canvas --ignore-gpu-blacklist";;
+esac
+
+# flash
+if [ -e $ADDON_DIR/PepperFlash/libpepflashplayer.so ]; then
+ CHROMIUM_OPTS="$CHROMIUM_OPTS --ppapi-flash-path=$ADDON_DIR/PepperFlash/libpepflashplayer.so"
+fi
+
+# alsa
+if [ ! -z $ALSA_DEVICE ]; then
+ CHROMIUM_OPTS="$CHROMIUM_OPTS --alsa-output-device=$ALSA_DEVICE"
+fi
+
# start chromium
-LD_PRELOAD=/usr/lib/libGL.so /storage/.kodi/addons/browser.chromium/bin/chromium.bin \
- --user-data-dir=/storage/.kodi/userdata/addon_data/browser.chromium/profile \
- --test-type $@
+LD_PRELOAD=/usr/lib/libGL.so $ADDON_DIR/bin/chromium.bin \
+ $CHROMIUM_OPTS \
+ --no-sandbox \
+ --user-data-dir=$ADDON_HOME/profile \
+ --test-type $@ \
+ 2>&1 | tee $ADDON_LOG_FILE
# kill unclutter
if [ "$HIDE_CURSOR" == "true" ]
diff --git a/packages/addons/browser/chromium/source/default.py b/packages/addons/browser/chromium/source/default.py
index 973acfcc13..02bb7f9bc8 100644
--- a/packages/addons/browser/chromium/source/default.py
+++ b/packages/addons/browser/chromium/source/default.py
@@ -93,57 +93,21 @@ def resumeXbmc():
xbmc.enableNavSounds(True)
def startChromium(args):
- oe.execute('chmod +x ' + __path__ + 'chromium')
- oe.execute('chmod +x ' + __path__ + 'chromium.bin')
- oe.execute('chmod 4755 ' + __path__ + 'chrome-sandbox')
-
try:
- window_mode = {
- 'maximized': '--start-maximized',
- 'kiosk': '--kiosk',
- 'none': '',
- }
-
- raster_mode = {
- 'default': '',
- 'off': '--disable-accelerated-2d-canvas --disable-gpu-compositing',
- 'force': '--enable-gpu-rasterization --enable-accelerated-2d-canvas --ignore-gpu-blacklist',
- }
-
new_env = os.environ.copy()
- vaapi_mode = __addon__.getSetting('VAAPI_MODE')
- gpu_accel_mode = ''
- if vaapi_mode == 'intel':
- new_env['LIBVA_DRIVERS_PATH'] = '/usr/lib/va'
- new_env['LIBVA_DRIVER_NAME'] = 'i965'
- elif vaapi_mode == 'amd':
- new_env['LIBVA_DRIVERS_PATH'] = os.path.join(__addon__.getAddonInfo('path'), 'lib')
- new_env['LIBVA_DRIVER_NAME'] = 'vdpau'
- elif vaapi_mode == 'nvidia':
- new_env['LIBVA_DRIVERS_PATH'] = os.path.join(__addon__.getAddonInfo('path'), 'lib')
- new_env['LIBVA_DRIVER_NAME'] = 'vdpau'
- gpu_accel_mode = '--allow-no-sandbox-job --disable-gpu-sandbox'
- else:
- new_env['LIBGL_ALWAYS_SOFTWARE'] = '1'
-
- flash_plugin = ''
- if os.path.exists(__path__ + 'PepperFlash/libpepflashplayer.so'):
- flash_plugin = '--ppapi-flash-path=' + __path__ + 'PepperFlash/libpepflashplayer.so'
+ new_env['VAAPI_MODE'] = __addon__.getSetting('VAAPI_MODE')
+ new_env['WINDOW_MODE'] = __addon__.getSetting('WINDOW_MODE')
+ new_env['RASTER_MODE'] = __addon__.getSetting('RASTER_MODE')
+ new_env['ALSA_DEVICE'] = ''
if __addon__.getSetting('USE_CUST_AUDIODEVICE') == 'true':
alsa_device = __addon__.getSetting('CUST_AUDIODEVICE_STR')
else:
alsa_device = getAudioDevice()
- alsa_param = ''
if not alsa_device == None and not alsa_device == '':
- alsa_param = '--alsa-output-device=' + alsa_device
+ new_env['ALSA_DEVICE'] = alsa_device
- chrome_params = window_mode.get(__addon__.getSetting('WINDOW_MODE')) + ' ' + \
- raster_mode.get(__addon__.getSetting('RASTER_MODE')) + ' ' + \
- flash_plugin + ' ' + \
- gpu_accel_mode + ' ' + \
- alsa_param + ' ' + \
- args + ' ' + \
+ chrome_params = args + ' ' + \
__addon__.getSetting('HOMEPAGE')
subprocess.call(__path__ + 'chromium ' + chrome_params, shell=True, env=new_env)
except Exception, e:
diff --git a/packages/addons/browser/chromium/source/resources/settings.xml b/packages/addons/browser/chromium/source/resources/settings.xml
index 670c222fca..75c56dbba7 100644
--- a/packages/addons/browser/chromium/source/resources/settings.xml
+++ b/packages/addons/browser/chromium/source/resources/settings.xml
@@ -5,7 +5,7 @@
-
+