Commit 66a57415 authored by achaulk's avatar achaulk Committed by Commit bot

Change to using an Ozone GLImage for VAAPI DRM video

Clearing the pixmap in Destroy fixes the apparent allocation ordering issues

BUG=370522
TEST=~15 minutes of HD youtube video on link with size changes between 360p, 480p, 720p, usually this would fail immediately

Review URL: https://codereview.chromium.org/974583002

Cr-Commit-Position: refs/heads/master@{#319900}
parent d4b61b40
......@@ -102,17 +102,14 @@ bool VaapiDrmPicture::Initialize() {
if (!make_context_current_.Run())
return false;
// Create an EGLImage out of the same buffer.
gl_image_ = new gfx::GLImageLinuxDMABuffer(size(), GL_RGBA);
if (!gl_image_->Initialize(base::FileDescriptor(dmabuf_fd, false),
gfx::GpuMemoryBuffer::BGRA_8888, dmabuf_pitch)) {
LOG(ERROR) << "Failed to create a GLImageLinuxDMABuffer for a NativePixmap";
return false;
}
// Bind the EGLImage to the given GL texture.
gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES,
texture_id());
gl_image_ = ui::GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmap(
pixmap_, size(), gfx::GpuMemoryBuffer::BGRA_8888, GL_RGBA);
if (!gl_image_) {
LOG(ERROR) << "Failed to create GLImage";
return false;
}
if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) {
LOG(ERROR) << "Failed to bind texture to GLImage";
return false;
......
......@@ -15,7 +15,7 @@
#include "ui/gfx/geometry/size.h"
namespace gfx {
class GLImageLinuxDMABuffer;
class GLImage;
}
namespace ui {
......@@ -53,7 +53,7 @@ class VaapiDrmPicture : public VaapiPicture {
scoped_refptr<ui::NativePixmap> pixmap_;
// EGLImage bound to the GL textures used by the VDA client.
scoped_refptr<gfx::GLImageLinuxDMABuffer> gl_image_;
scoped_refptr<gfx::GLImage> gl_image_;
// VASurface used to transfer from the decoder's pixel format.
scoped_refptr<VASurface> va_surface_;
......
......@@ -17,6 +17,11 @@ class GLImageOzoneNativePixmap : public gfx::GLImageEGL {
public:
explicit GLImageOzoneNativePixmap(const gfx::Size& size) : GLImageEGL(size) {}
void Destroy(bool have_context) override {
gfx::GLImageEGL::Destroy(have_context);
pixmap_ = nullptr;
}
bool Initialize(NativePixmap* pixmap) {
EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
if (!Initialize(EGL_NATIVE_PIXMAP_KHR, pixmap->GetEGLClientBuffer(), attrs))
......@@ -48,6 +53,11 @@ class GLImageOzoneNativePixmapDmaBuf : public gfx::GLImageLinuxDMABuffer {
unsigned internalformat)
: GLImageLinuxDMABuffer(size, internalformat) {}
void Destroy(bool have_context) override {
gfx::GLImageLinuxDMABuffer::Destroy(have_context);
pixmap_ = nullptr;
}
bool Initialize(NativePixmap* pixmap, gfx::GpuMemoryBuffer::Format format) {
base::FileDescriptor handle(pixmap->GetDmaBufFd(), false);
if (!GLImageLinuxDMABuffer::Initialize(handle, format,
......
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