Enable libva

This commit is contained in:
Алзим 2018-01-23 08:13:40 +03:00
parent 5ea0b36ba8
commit e433dd4303
5 changed files with 733 additions and 543 deletions

View file

@ -11,7 +11,7 @@
%define chromium_system_libs 1
%define ffmpeg 1
%define icu 0
%define libva 0
%define libva 1
# Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys
# Note: these are for Mageia use ONLY.
@ -23,7 +23,7 @@
Summary: A fast web browser based on the Blink engine
Name: chromium-browser-stable
Version: 63.0.3239.132
Release: 1
Release: 2
License: BSD, LGPL
Group: Networking/WWW
Url: https://www.chromium.org/Home
@ -71,15 +71,13 @@ Patch501: chromium-ps-print.patch
# Google patched their bundled copy of icu 54 to include API functionality that wasn't added until 55.
# :P
Patch502: chromium-45.0.2454.101-system-icu-54-does-not-have-detectHostTimeZone.patch
# http://bazaar.launchpad.net/~saiarcot895/chromium-browser/chromium-browser.trusty.beta/revision/230#debian/patches/enable_vaapi_on_linux.diff
Patch503: enable_vaapi_on_linux.diff
# Patch to fix build with use_system_libvpx
# Chromium bug #541273
# fix build with icu other than 54
Patch504: chromium-system-icu-r0.patch
# fix https://bugs.chromium.org/p/chromium/issues/detail?id=585513
# vaInitialize failed VA error: unknown libva error
Patch507: issue1688073002_40001.diff
# https://aur.archlinux.org/packages/chromium-vaapi/
Patch508: chromium-vaapi-r15.patch
# ROSA Build
Patch600: chromium-buildname-60.0.3112.90.patch
# Patch to fix build
@ -202,6 +200,7 @@ your profile before changing channels.
%{_crdir}/*_blob.bin
%{_crdir}/themes
%{_crdir}/default_apps
%{_crdir}/swiftshader
%dir %{_crdir}/pepper
%{_datadir}/applications/*.desktop
%{_iconsdir}/hicolor/*/apps/chromium*
@ -282,8 +281,7 @@ members of the Chromium and WebDriver teams.
%endif
%if 0%{?libva}
%patch503 -p1 -b .vaapi
%patch507 -p1
%patch508 -p1 -b .vaapi2
%endif
%patch600 -p1
@ -376,7 +374,7 @@ mkdir -p third_party/node/linux/node-linux-x64/bin
ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/node
%build
%define system_gn_list ffmpeg flac libxslt snappy yasm libpng zlib jsoncpp freetype
%define system_gn_list ffmpeg flac libxslt snappy yasm libpng zlib jsoncpp
# opus
# icu
# libevent
@ -422,6 +420,7 @@ ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/node
use_libpci = true \
is_debug=false \
is_clang=false \
use_vaapi=true \
use_system_freetype=true \
use_system_harfbuzz=true \
google_api_key="%{google_api_key}" \
@ -473,6 +472,8 @@ ln -s %{_crdir}/chromium-wrapper %{buildroot}%{_bindir}/%{crname}
sed -i "s!@LIBDIR@!%{_libdir}!g" %{buildroot}%{_crdir}/chromium-wrapper
ln -s %{_crdir}/chromedriver %{buildroot}%{_bindir}/chromedriver
cp -r out/Release/swiftshader %{buildroot}%{_crdir}
# create global config file
mkdir -p %{buildroot}%{_sysconfdir}/default
install -m644 %{SOURCE32} %{buildroot}%{_sysconfdir}/default/%{crname}

View file

@ -1,62 +0,0 @@
--- a/gpu/ipc/common/mailbox_struct_traits.h
+++ b/gpu/ipc/common/mailbox_struct_traits.h
@@ -15,7 +15,7 @@ namespace mojo {
template <>
struct StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox> {
static base::span<const int8_t> name(const gpu::Mailbox& mailbox) {
- return mailbox.name;
+ return base::make_span(mailbox.name);
}
static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out);
};
--- a/services/viz/public/cpp/compositing/filter_operation_struct_traits.h
+++ b/services/viz/public/cpp/compositing/filter_operation_struct_traits.h
@@ -134,7 +134,7 @@ struct StructTraits<viz::mojom::FilterOperationDataView, cc::FilterOperation> {
static base::span<const float> matrix(const cc::FilterOperation& operation) {
if (operation.type() != cc::FilterOperation::COLOR_MATRIX)
return base::span<const float>();
- return operation.matrix();
+ return base::make_span(operation.matrix());
}
static base::span<const gfx::Rect> shape(
--- a/services/viz/public/cpp/compositing/quads_struct_traits.h
+++ b/services/viz/public/cpp/compositing/quads_struct_traits.h
@@ -284,7 +284,7 @@
static base::span<const float> vertex_opacity(const cc::DrawQuad& input) {
const cc::TextureDrawQuad* quad = cc::TextureDrawQuad::MaterialCast(&input);
- return quad->vertex_opacity;
+ return base::make_span(quad->vertex_opacity);
}
static bool y_flipped(const cc::DrawQuad& input) {
--- a/third_party/WebKit/Source/platform/exported/WebCORS.cpp
+++ b/third_party/WebKit/Source/platform/exported/WebCORS.cpp
@@ -480,7 +480,7 @@ WebString AccessControlErrorString(
}
default:
NOTREACHED();
- return "";
+ return WebString();
}
}
@@ -512,7 +512,7 @@ WebString PreflightErrorString(const PreflightStatus status,
}
default:
NOTREACHED();
- return "";
+ return WebString();
}
}
@@ -533,7 +533,7 @@ WebString RedirectErrorString(const RedirectStatus status,
}
default:
NOTREACHED();
- return "";
+ return WebString();
}
}

722
chromium-vaapi-r15.patch Normal file
View file

@ -0,0 +1,722 @@
From 7f29b44224439377592be2b75da0b86d82d8ad6d Mon Sep 17 00:00:00 2001
From: Daniel Charles <daniel.charles@intel.com>
Date: Wed, 18 Oct 2017 17:27:42 -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/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",
flag_descriptions::kAcceleratedVideoDecodeName,
@@ -1564,6 +1573,7 @@
kOsMac | kOsWin | kOsCrOS | kOsAndroid,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
+#endif
{"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_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 (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_OZONE)
@@ -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
+ ) {
prefs->pepper_accelerated_video_decode_enabled = true;
}
}
@@ -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 @@
// 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)
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 (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
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<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 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 @@
]
},
{
- "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 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 += [
"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_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"
@@ -334,6 +342,9 @@
"vaapi_drm_picture.h",
]
}
+ 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,
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
+ GetProfileInfos(); // dlopen all necessary libraries
}
// static

View file

@ -1,415 +0,0 @@
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.
Index: beta.wily/content/common/gpu/media/gpu_video_decode_accelerator.cc
===================================================================
--- beta.wily.orig/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ beta.wily/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -34,7 +34,7 @@
#include "content/common/gpu/media/dxva_video_decode_accelerator_win.h"
#elif defined(OS_MACOSX)
#include "content/common/gpu/media/vt_video_decode_accelerator_mac.h"
-#elif defined(OS_CHROMEOS)
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
#if defined(USE_V4L2_CODEC)
#include "content/common/gpu/media/v4l2_device.h"
#include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h"
@@ -164,7 +164,7 @@ GpuVideoDecodeAccelerator::GetCapabiliti
#if defined(OS_WIN)
capabilities.supported_profiles =
DXVAVideoDecodeAccelerator::GetSupportedProfiles();
-#elif defined(OS_CHROMEOS)
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
media::VideoDecodeAccelerator::SupportedProfiles vda_profiles;
#if defined(USE_V4L2_CODEC)
vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
@@ -346,6 +346,8 @@ void GpuVideoDecodeAccelerator::Initiali
}
#endif
+ VLOG(1) << "Initializing GPU video decode accelerator.";
+
// Array of Create..VDA() function pointers, maybe applicable to the current
// platform. This list is ordered by priority of use and it should be the
// same as the order of querying supported profiles of VDAs.
@@ -444,7 +446,9 @@ void GpuVideoDecodeAccelerator::BindImag
scoped_ptr<media::VideoDecodeAccelerator>
GpuVideoDecodeAccelerator::CreateVaapiVDA() {
scoped_ptr<media::VideoDecodeAccelerator> decoder;
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+ VLOG(1) << "About to create new VAAPI video decode accelerator.";
+#if (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY)
+ VLOG(1) << "Creating new VAAPI video decode accelerator.";
decoder.reset(new VaapiVideoDecodeAccelerator(
make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage,
base::Unretained(this))));
Index: beta.wily/content/content_common.gypi
===================================================================
--- beta.wily.orig/content/content_common.gypi
+++ beta.wily/content/content_common.gypi
@@ -878,7 +878,7 @@
},
],
}],
- ['chromeos==1', {
+ ['chromeos==1 or desktop_linux==1', {
'sources': [
'common/gpu/media/accelerated_video_decoder.h',
'common/gpu/media/gpu_arc_video_service.cc',
@@ -936,7 +936,7 @@
'common/gpu/media/tegra_v4l2_device.h',
],
}],
- ['target_arch != "arm" and chromeos == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
'dependencies': [
'../media/media.gyp:media',
'../third_party/libyuv/libyuv.gyp:libyuv',
Index: beta.wily/content/content_gpu.gypi
===================================================================
--- beta.wily.orig/content/content_gpu.gypi
+++ beta.wily/content/content_gpu.gypi
@@ -38,7 +38,7 @@
],
},
}],
- ['target_arch!="arm" and chromeos == 1', {
+ ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', {
'include_dirs': [
'<(DEPTH)/third_party/libva',
],
Index: beta.wily/content/content_tests.gypi
===================================================================
--- beta.wily.orig/content/content_tests.gypi
+++ beta.wily/content/content_tests.gypi
@@ -1757,7 +1757,7 @@
},
]
}],
- ['chromeos==1 and target_arch != "arm"', {
+ ['(chromeos==1 or desktop_linux==1) and target_arch != "arm"', {
'targets': [
{
'target_name': 'vaapi_jpeg_decoder_unittest',
Index: beta.wily/content/public/common/content_switches.cc
===================================================================
--- beta.wily.orig/content/public/common/content_switches.cc
+++ beta.wily/content/public/common/content_switches.cc
@@ -944,7 +944,9 @@ const char kDisableWebAudio[]
#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";
Index: beta.wily/content/public/common/content_switches.h
===================================================================
--- beta.wily.orig/content/public/common/content_switches.h
+++ beta.wily/content/public/common/content_switches.h
@@ -277,6 +277,8 @@ CONTENT_EXPORT extern const char kDisabl
#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
Index: beta.wily/media/media.gyp
===================================================================
--- beta.wily.orig/media/media.gyp
+++ beta.wily/media/media.gyp
@@ -783,7 +783,7 @@
],
}],
# For VaapiVideoEncodeAccelerator.
- ['target_arch != "arm" and chromeos == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
'sources': [
'filters/h264_bitstream_buffer.cc',
'filters/h264_bitstream_buffer.h',
@@ -1417,7 +1417,7 @@
'cdm/cdm_adapter_unittest.cc',
],
}],
- ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
'sources': [
'filters/h264_bitstream_buffer_unittest.cc',
],
Index: beta.wily/gpu/config/software_rendering_list_json.cc
===================================================================
--- beta.wily.orig/gpu/config/software_rendering_list_json.cc
+++ beta.wily/gpu/config/software_rendering_list_json.cc
@@ -481,17 +481,6 @@ const char kSoftwareRenderingListJson[]
]
},
{
- "id": 48,
- "description": "Accelerated video decode is unavailable on Linux",
- "cr_bugs": [137247],
- "os": {
- "type": "linux"
- },
- "features": [
- "accelerated_video_decode"
- ]
- },
- {
"id": 49,
"description": "NVidia GeForce GT 650M can cause the system to hang with flash 3D",
"cr_bugs": [140175],
Index: beta.wily/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- beta.wily.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
+++ beta.wily/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -22,6 +22,8 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
+// Auto-generated for dlopen libva libraries
+#include "content/common/gpu/media/va_stubs.h"
#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"
@@ -32,6 +34,8 @@
#include "sandbox/linux/syscall_broker/broker_file_permission.h"
#include "sandbox/linux/syscall_broker/broker_process.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
+#include "third_party/libva/va/va.h"
+#include "third_party/libva/va/va_x11.h"
using sandbox::arch_seccomp_data;
using sandbox::bpf_dsl::Allow;
@@ -41,6 +45,11 @@ using sandbox::syscall_broker::BrokerFil
using sandbox::syscall_broker::BrokerProcess;
using sandbox::SyscallSets;
+using content_common_gpu_media::kModuleVa;
+using content_common_gpu_media::kModuleVa_x11;
+using content_common_gpu_media::InitializeStubs;
+using content_common_gpu_media::StubPathMap;
+
namespace content {
namespace {
@@ -95,7 +104,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 =
@@ -300,27 +309,41 @@ bool GpuProcessPolicy::PreSandboxHook()
// inside the sandbox, so preload them now.
if (IsAcceleratedVaapiVideoEncodeEnabled() ||
IsAcceleratedVideoDecodeEnabled()) {
- const char* I965DrvVideoPath = NULL;
- const char* I965HybridDrvVideoPath = NULL;
+ VLOG(1) << "Attempting to enable hardware video acceleration.";
+ StubPathMap paths;
+ paths[kModuleVa].push_back("libva.so.1");
+ paths[kModuleVa_x11].push_back("libva-x11.so.1");
+ if (!InitializeStubs(paths)) {
+ VLOG(1) << "Failed to initialize stubs";
+ return false;
+ }
- 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";
+ // libva drivers won't get loaded even above two libraries get dlopened.
+ // Thus, libva calls will fail after post sandbox stage.
+ //
+ // To get the va driver loaded before sandboxing, upstream simply dlopen
+ // the hard-coded va driver path because ChromeOS is the only platform
+ // that Google want to support libva.
+ //
+ // While generic linux distros ship va driver as anywhere they want.
+ // Fortunately, the va driver will be loadded when vaInitialize() get
+ // called.
+ // So the following code is to call vaInitialize() before sandboxing.
+ Display* x_display = XOpenDisplay(NULL);
+ VADisplay va_display = vaGetDisplay(x_display);
+ if (!vaDisplayIsValid(va_display)) {
+ VLOG(1) << "Failed to call vaGetDisplay()";
+ return false;
}
- 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
- }
- }
+ int major_version, minor_version;
+ if (vaInitialize(va_display, &major_version, &minor_version)
+ != VA_STATUS_SUCCESS) {
+ VLOG(1) << "Failed to call vaInitialize()";
+ return false;
+ }
+ } // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled()
+ } // end of IsArchitectureX86_64() || IsArchitectureI386()
return true;
}
Index: beta.wily/chrome/browser/about_flags.cc
===================================================================
--- beta.wily.orig/chrome/browser/about_flags.cc
+++ beta.wily/chrome/browser/about_flags.cc
@@ -936,7 +936,7 @@ const FeatureEntry kFeatureEntries[] = {
"disable-accelerated-video-decode",
IDS_FLAGS_ACCELERATED_VIDEO_DECODE_NAME,
IDS_FLAGS_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
- kOsMac | kOsWin | kOsCrOS,
+ kOsAll,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
#if defined(USE_ASH)
Index: beta.wily/content/common/gpu/media/vaapi_wrapper.cc
===================================================================
--- beta.wily.orig/content/common/gpu/media/vaapi_wrapper.cc
+++ beta.wily/content/common/gpu/media/vaapi_wrapper.cc
@@ -186,7 +186,7 @@ scoped_refptr<VaapiWrapper> 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;
}
@@ -345,15 +345,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;
@@ -424,7 +426,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;
@@ -448,8 +450,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;
}
}
Index: beta.wily/content/common/gpu/media/vaapi_video_decode_accelerator.cc
===================================================================
--- beta.wily.orig/content/common/gpu/media/vaapi_video_decode_accelerator.cc
+++ beta.wily/content/common/gpu/media/vaapi_video_decode_accelerator.cc
@@ -334,17 +334,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 (gfx::GetGLImplementation() != gfx::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 (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
- DVLOG(1) << "HW video decode acceleration not available without "
+ VLOG(1) << "HW video decode acceleration not available without "
<< "EGLGLES2.";
return false;
}
@@ -354,7 +354,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;
}
@@ -371,7 +371,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: beta.wily/content/gpu/gpu_main.cc
===================================================================
--- beta.wily.orig/content/gpu/gpu_main.cc
+++ beta.wily/content/gpu/gpu_main.cc
@@ -76,7 +76,7 @@
#include "content/common/sandbox_mac.h"
#endif
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY)
#include "content/common/gpu/media/vaapi_wrapper.h"
#endif
@@ -247,7 +247,7 @@ int GpuMain(const MainFunctionParams& pa
GetGpuInfoFromCommandLine(gpu_info, command_line);
gpu_info.in_process_gpu = false;
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY)
VaapiWrapper::PreSandboxInitialization();
#endif
Index: beta.wily/content/common/gpu/client/command_buffer_proxy_impl.cc
===================================================================
--- beta.wily.orig/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ beta.wily/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -698,8 +698,10 @@ bool CommandBufferProxyImpl::ProduceFron
scoped_ptr<media::VideoDecodeAccelerator>
CommandBufferProxyImpl::CreateVideoDecoder() {
+ TRACE_EVENT0("gpu", "CommandBufferProxyImpl::CreateVideoDecoder");
if (!channel_)
return scoped_ptr<media::VideoDecodeAccelerator>();
+ VLOG(1) << "About to create GpuVideoDecodeAcceleratorHost.";
return scoped_ptr<media::VideoDecodeAccelerator>(
new GpuVideoDecodeAcceleratorHost(channel_, this));
}

View file

@ -1,56 +0,0 @@
Index: content/common/gpu/media/vaapi_wrapper.cc
diff --git a/content/common/gpu/media/vaapi_wrapper.cc b/content/common/gpu/media/vaapi_wrapper.cc
index db38f32f7f8ee6fca9a08cb3560f644f76cde222..2a18b3ff0ff67ba50f28e9acd2eb79771e584cd1 100644
--- a/content/common/gpu/media/vaapi_wrapper.cc
+++ b/content/common/gpu/media/vaapi_wrapper.cc
@@ -369,11 +369,8 @@ bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) {
return false;
}
- VAStatus va_res = VA_STATUS_SUCCESS;
- if (!va_display_state->Initialize(&va_res)) {
- VA_LOG_ON_ERROR(va_res, "vaInitialize failed");
+ if (!va_display_state->Initialize())
return false;
- }
va_display_ = va_display_state->va_display();
return true;
@@ -1218,7 +1215,7 @@ VaapiWrapper::VADisplayState::VADisplayState()
VaapiWrapper::VADisplayState::~VADisplayState() {}
-bool VaapiWrapper::VADisplayState::Initialize(VAStatus* status) {
+bool VaapiWrapper::VADisplayState::Initialize() {
va_lock_.AssertAcquired();
if (refcount_++ == 0) {
#if defined(USE_X11)
@@ -1232,9 +1229,12 @@ bool VaapiWrapper::VADisplayState::Initialize(VAStatus* status) {
return false;
}
- *status = vaInitialize(va_display_, &major_version_, &minor_version_);
- if (*status != VA_STATUS_SUCCESS)
+ VAStatus va_res =
+ vaInitialize(va_display_, &major_version_, &minor_version_);
+ if (va_res != VA_STATUS_SUCCESS) {
+ LOG(WARNING) << "vaInitialize failed: " << vaErrorStr(va_res);
return false;
+ }
va_initialized_ = true;
DVLOG(1) << "VAAPI version: " << major_version_ << "." << minor_version_;
Index: content/common/gpu/media/vaapi_wrapper.h
diff --git a/content/common/gpu/media/vaapi_wrapper.h b/content/common/gpu/media/vaapi_wrapper.h
index 7f14b49be11647d2ba7d4b5f7e1f089238627007..4394bc36b928ebf12d39b8bbb4a22af738bf8537 100644
--- a/content/common/gpu/media/vaapi_wrapper.h
+++ b/content/common/gpu/media/vaapi_wrapper.h
@@ -247,7 +247,7 @@ class CONTENT_EXPORT VaapiWrapper
~VADisplayState();
// |va_lock_| must be held on entry.
- bool Initialize(VAStatus* status);
+ bool Initialize();
void Deinitialize(VAStatus* status);
base::Lock* va_lock() { return &va_lock_; }