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 93f1b61a95e7b1e359f914e4e6a8f4e8bf746b5a..4b5c04665fd1c9e11409a7b2ab5cd4b727dbb449 100644 |
--- a/content/common/gpu/media/vaapi_wrapper.cc |
+++ b/content/common/gpu/media/vaapi_wrapper.cc |
@@ -13,16 +13,20 @@ |
#include "base/sys_info.h" |
// Auto-generated for dlopen libva libraries |
#include "content/common/gpu/media/va_stubs.h" |
+#include "content/common/gpu/media/vaapi_picture.h" |
#include "third_party/libyuv/include/libyuv.h" |
+#include "ui/gl/gl_bindings.h" |
+#if defined(USE_X11) |
+#include "ui/gfx/x/x11_types.h" |
+#endif // USE_X11 |
using content_common_gpu_media::kModuleVa; |
+#if defined(USE_X11) |
+using content_common_gpu_media::kModuleVa_x11; |
+#endif // USE_X11 |
using content_common_gpu_media::InitializeStubs; |
using content_common_gpu_media::StubPathMap; |
-// libva-x11 depends on libva, so dlopen libva-x11 is enough |
-static const base::FilePath::CharType kVaLib[] = |
- FILE_PATH_LITERAL("libva-x11.so.1"); |
- |
#define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \ |
do { \ |
LOG(ERROR) << err_msg \ |
@@ -123,9 +127,10 @@ static VAProfile ProfileToVAProfile( |
return va_profile; |
} |
-VASurface::VASurface(VASurfaceID va_surface_id, const ReleaseCB& release_cb) |
- : va_surface_id_(va_surface_id), |
- release_cb_(release_cb) { |
+VASurface::VASurface(VASurfaceID va_surface_id, |
+ const gfx::Size& size, |
+ const ReleaseCB& release_cb) |
+ : va_surface_id_(va_surface_id), size_(size), release_cb_(release_cb) { |
DCHECK(!release_cb_.is_null()); |
} |
@@ -150,24 +155,21 @@ VaapiWrapper::~VaapiWrapper() { |
scoped_ptr<VaapiWrapper> VaapiWrapper::Create( |
CodecMode mode, |
media::VideoCodecProfile profile, |
- Display* x_display, |
const base::Closure& report_error_to_uma_cb) { |
scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
- if (!vaapi_wrapper->Initialize( |
- mode, profile, x_display, report_error_to_uma_cb)) |
+ if (!vaapi_wrapper->Initialize(mode, profile, report_error_to_uma_cb)) |
vaapi_wrapper.reset(); |
return vaapi_wrapper.Pass(); |
} |
std::vector<media::VideoCodecProfile> VaapiWrapper::GetSupportedEncodeProfiles( |
- Display* x_display, |
const base::Closure& report_error_to_uma_cb) { |
std::vector<media::VideoCodecProfile> supported_profiles; |
scoped_ptr<VaapiWrapper> wrapper(new VaapiWrapper()); |
- if (!wrapper->VaInitialize(x_display, report_error_to_uma_cb)) { |
+ if (!wrapper->VaInitialize(report_error_to_uma_cb)) { |
return supported_profiles; |
} |
@@ -202,8 +204,7 @@ void VaapiWrapper::TryToSetVADisplayAttributeToLocalGPU() { |
DVLOG(2) << "vaSetDisplayAttributes unsupported, ignoring by default."; |
} |
-bool VaapiWrapper::VaInitialize(Display* x_display, |
- const base::Closure& report_error_to_uma_cb) { |
+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; |
@@ -224,7 +225,10 @@ bool VaapiWrapper::VaInitialize(Display* x_display, |
base::AutoLock auto_lock(va_lock_); |
- va_display_ = vaGetDisplay(x_display); |
+#if defined(USE_X11) |
+ va_display_ = vaGetDisplay(gfx::GetXDisplay()); |
+#endif // USE_X11 |
+ |
if (!vaDisplayIsValid(va_display_)) { |
LOG(ERROR) << "Could not get a valid VA display"; |
return false; |
@@ -321,9 +325,8 @@ bool VaapiWrapper::AreAttribsSupported( |
bool VaapiWrapper::Initialize(CodecMode mode, |
media::VideoCodecProfile profile, |
- Display* x_display, |
const base::Closure& report_error_to_uma_cb) { |
- if (!VaInitialize(x_display, report_error_to_uma_cb)) |
+ if (!VaInitialize(report_error_to_uma_cb)) |
return false; |
std::vector<VAProfile> supported_va_profiles; |
if (!GetSupportedVaProfiles(&supported_va_profiles)) |
@@ -383,7 +386,7 @@ bool VaapiWrapper::VAAPIVersionLessThan(int major, int minor) { |
(major_version_ == major && minor_version_ < minor); |
} |
-bool VaapiWrapper::CreateSurfaces(gfx::Size size, |
+bool VaapiWrapper::CreateSurfaces(const gfx::Size& size, |
size_t num_surfaces, |
std::vector<VASurfaceID>* va_surfaces) { |
base::AutoLock auto_lock(va_lock_); |
@@ -593,6 +596,7 @@ bool VaapiWrapper::ExecuteAndDestroyPendingBuffers(VASurfaceID va_surface_id) { |
return result; |
} |
+#if defined(USE_X11) |
bool VaapiWrapper::PutSurfaceIntoPixmap(VASurfaceID va_surface_id, |
Pixmap x_pixmap, |
gfx::Size dest_size) { |
@@ -611,6 +615,7 @@ bool VaapiWrapper::PutSurfaceIntoPixmap(VASurfaceID va_surface_id, |
VA_SUCCESS_OR_RETURN(va_res, "Failed putting surface to pixmap", false); |
return true; |
} |
+#endif // USE_X11 |
bool VaapiWrapper::GetVaImageForTesting(VASurfaceID va_surface_id, |
VAImage* image, |
@@ -755,7 +760,12 @@ bool VaapiWrapper::DownloadAndDestroyCodedBuffer(VABufferID buffer_id, |
// static |
bool VaapiWrapper::PostSandboxInitialization() { |
StubPathMap paths; |
- paths[kModuleVa].push_back(kVaLib); |
+ |
+ paths[kModuleVa].push_back("libva.so.1"); |
+ |
+#if defined(USE_X11) |
+ paths[kModuleVa_x11].push_back("libva-x11.so.1"); |
+#endif |
return InitializeStubs(paths); |
} |