Commit 992a2071 authored by Ted Meyer's avatar Ted Meyer Committed by Commit Bot

Add VaapiPictureNativePixmapAngle for Vaapi-on-linux support

When using the flag --enable-accelerated-video-decode, use this new
angle pixmap.

Bug: 1066176
Change-Id: I9619fbda3348c163618323474dfe1372d0c198e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119669
Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797520}
parent 399e5465
......@@ -114,32 +114,36 @@ source_set("vaapi") {
]
}
if (use_x11 || use_ozone || use_egl) {
sources += [
"vaapi_picture_native_pixmap.cc",
"vaapi_picture_native_pixmap.h",
]
}
if (use_x11) {
deps += [ "//ui/gfx/x" ]
sources += [
"vaapi_picture_native_pixmap_angle.cc",
"vaapi_picture_native_pixmap_angle.h",
"vaapi_picture_tfp.cc",
"vaapi_picture_tfp.h",
]
}
if (use_ozone || use_egl) {
if (use_ozone) {
deps += [ "//ui/ozone" ]
sources += [
"vaapi_picture_native_pixmap.cc",
"vaapi_picture_native_pixmap.h",
"vaapi_picture_native_pixmap_ozone.cc",
"vaapi_picture_native_pixmap_ozone.h",
]
}
if (use_egl) {
sources += [
"vaapi_picture_native_pixmap_egl.cc",
"vaapi_picture_native_pixmap_egl.h",
]
if (use_ozone) {
sources += [
"vaapi_picture_native_pixmap_ozone.cc",
"vaapi_picture_native_pixmap_ozone.h",
]
deps += [ "//ui/ozone" ]
}
if (use_egl) {
sources += [
"vaapi_picture_native_pixmap_egl.cc",
"vaapi_picture_native_pixmap_egl.h",
]
}
}
}
......
......@@ -10,6 +10,7 @@
#include "ui/gl/gl_bindings.h"
#if defined(USE_X11)
#include "media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h"
#include "media/gpu/vaapi/vaapi_picture_tfp.h"
#endif
#if defined(USE_OZONE)
......@@ -26,6 +27,9 @@ VaapiPictureFactory::VaapiPictureFactory() {
std::make_pair(gl::kGLImplementationEGLGLES2,
VaapiPictureFactory::kVaapiImplementationDrm));
#if defined(USE_X11)
vaapi_impl_pairs_.insert(
std::make_pair(gl::kGLImplementationEGLANGLE,
VaapiPictureFactory::kVaapiImplementationAngle));
if (!features::IsUsingOzonePlatform()) {
vaapi_impl_pairs_.insert(
std::make_pair(gl::kGLImplementationDesktopGL,
......@@ -151,6 +155,13 @@ std::unique_ptr<VaapiPicture> VaapiPictureFactory::CreateVaapiPictureNative(
service_texture_id, client_texture_id,
picture_buffer.texture_target());
break;
case kVaapiImplementationAngle:
return std::make_unique<VaapiPictureNativePixmapAngle>(
std::move(vaapi_wrapper), make_context_current_cb, bind_image_cb,
picture_buffer.id(), picture_buffer.size(), visible_size,
service_texture_id, client_texture_id,
picture_buffer.texture_target());
break;
#endif // USE_X11
default:
......
......@@ -24,7 +24,8 @@ class MEDIA_GPU_EXPORT VaapiPictureFactory {
enum VaapiImplementation {
kVaapiImplementationNone = 0,
kVaapiImplementationDrm,
kVaapiImplementationX11
kVaapiImplementationX11,
kVaapiImplementationAngle,
};
VaapiPictureFactory();
......
// Copyright 2020 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.
#include "media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h"
#include "base/file_descriptor_posix.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "media/gpu/vaapi/va_surface.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "ui/gfx/linux/gbm_buffer.h"
#include "ui/gfx/linux/gpu_memory_buffer_support_x11.h"
#include "ui/gfx/linux/native_pixmap_dmabuf.h"
#include "ui/gfx/native_pixmap.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image_native_pixmap.h"
#include "ui/gl/scoped_binders.h"
namespace media {
VaapiPictureNativePixmapAngle::VaapiPictureNativePixmapAngle(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb,
int32_t picture_buffer_id,
const gfx::Size& visible_size,
const gfx::Size& size,
uint32_t service_texture_id,
uint32_t client_texture_id,
uint32_t texture_target)
: VaapiPictureNativePixmap(std::move(vaapi_wrapper),
make_context_current_cb,
bind_image_cb,
picture_buffer_id,
size,
visible_size,
service_texture_id,
client_texture_id,
texture_target) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Check that they're either both 0 or both not 0 (tests will set both to 0)
DCHECK(!!service_texture_id == !!client_texture_id);
}
VaapiPictureNativePixmapAngle::~VaapiPictureNativePixmapAngle() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (gl_image_ && make_context_current_cb_.Run()) {
gl_image_->ReleaseTexImage(texture_target_);
DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR));
}
}
bool VaapiPictureNativePixmapAngle::Allocate(gfx::BufferFormat format) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTIMPLEMENTED();
return false;
}
bool VaapiPictureNativePixmapAngle::ImportGpuMemoryBufferHandle(
gfx::BufferFormat format,
gfx::GpuMemoryBufferHandle gpu_memory_buffer_handlee) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTIMPLEMENTED();
return false;
}
} // namespace media
// Copyright 2020 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.
#ifndef MEDIA_GPU_VAAPI_VAAPI_PICTURE_NATIVE_PIXMAP_ANGLE_H_
#define MEDIA_GPU_VAAPI_VAAPI_PICTURE_NATIVE_PIXMAP_ANGLE_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "media/gpu/vaapi/vaapi_picture_native_pixmap.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/size.h"
namespace media {
class VaapiWrapper;
// Implementation of VaapiPictureNativePixmap for ANGLE backends.
class VaapiPictureNativePixmapAngle : public VaapiPictureNativePixmap {
public:
VaapiPictureNativePixmapAngle(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb_,
int32_t picture_buffer_id,
const gfx::Size& size,
const gfx::Size& visible_size,
uint32_t texture_id,
uint32_t client_texture_id,
uint32_t texture_target);
~VaapiPictureNativePixmapAngle() override;
// VaapiPicture implementation.
bool Allocate(gfx::BufferFormat format) override;
bool ImportGpuMemoryBufferHandle(
gfx::BufferFormat format,
gfx::GpuMemoryBufferHandle gpu_memory_buffer_handle) override;
private:
DISALLOW_COPY_AND_ASSIGN(VaapiPictureNativePixmapAngle);
};
} // namespace media
#endif // MEDIA_GPU_VAAPI_VAAPI_PICTURE_NATIVE_PIXMAP_ANGLE_H_
......@@ -410,11 +410,18 @@ bool VADisplayState::InitializeOnce() {
break;
case gl::kGLImplementationDesktopGL:
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
if (!features::IsUsingOzonePlatform()) {
va_display_ = vaGetDisplay(gfx::GetXDisplay());
#else
LOG(WARNING) << "VAAPI video acceleration not available without "
"DesktopGL (GLX).";
if (!vaDisplayIsValid(va_display_))
va_display_ = vaGetDisplayDRM(drm_fd_.get());
}
#endif // USE_X11
break;
case gl::kGLImplementationEGLANGLE:
#if defined(USE_X11)
va_display_ = vaGetDisplay(gfx::GetXDisplay());
if (vaDisplayIsValid(va_display_))
break;
#endif // USE_X11
break;
// Cannot infer platform from GL, try all available displays
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment