From 846cdbdbf965fc50478bcc4c6436e3dc6a489f3f Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Thu, 14 Oct 2021 19:01:18 -0400 Subject: Initial commit. --- .../chromium/files/chromium-vaapi-fix-87.patch | 200 +++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 www-client/chromium/files/chromium-vaapi-fix-87.patch (limited to 'www-client/chromium/files/chromium-vaapi-fix-87.patch') diff --git a/www-client/chromium/files/chromium-vaapi-fix-87.patch b/www-client/chromium/files/chromium-vaapi-fix-87.patch new file mode 100644 index 0000000..231434b --- /dev/null +++ b/www-client/chromium/files/chromium-vaapi-fix-87.patch @@ -0,0 +1,200 @@ +diff --git a/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.cc b/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.cc +index 843cf226e..af0389503 100644 +--- a/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.cc ++++ b/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.cc +@@ -7,6 +7,8 @@ + #include "media/gpu/vaapi/va_surface.h" + #include "media/gpu/vaapi/vaapi_wrapper.h" + #include "ui/base/ui_base_features.h" ++#include "ui/gfx/x/connection.h" ++#include "ui/gfx/x/xproto.h" + #include "ui/gl/gl_bindings.h" + #include "ui/gl/gl_image_egl_pixmap.h" + #include "ui/gl/scoped_binders.h" +@@ -15,25 +17,31 @@ namespace media { + + namespace { + +-inline Pixmap CreatePixmap(const gfx::Size& size) { +- auto* display = gfx::GetXDisplay(); +- if (!display) +- return 0; ++inline ::Pixmap CreatePixmap(const gfx::Size& size) { ++ auto* connection = x11::Connection::Get(); ++ if (!connection->Ready()) ++ return base::strict_cast<::Pixmap>(x11::Pixmap::None); + +- int screen = DefaultScreen(display); +- auto root = XRootWindow(display, screen); +- if (root == BadValue) +- return 0; ++ auto root = connection->default_root(); + +- XWindowAttributes win_attr = {}; +- // returns 0 on failure, see: +- // https://tronche.com/gui/x/xlib/introduction/errors.html#Status +- if (!XGetWindowAttributes(display, root, &win_attr)) +- return 0; ++ uint8_t depth = 0; ++ if (auto reply = connection->GetGeometry({root}).Sync()) ++ depth = reply->depth; ++ else ++ return base::strict_cast<::Pixmap>(x11::Pixmap::None); + + // TODO(tmathmeyer) should we use the depth from libva instead of root window? +- return XCreatePixmap(display, root, size.width(), size.height(), +- win_attr.depth); ++ auto pixmap = connection->GenerateId(); ++ uint16_t pixmap_width, pixmap_height; ++ if (!base::CheckedNumeric(size.width()).AssignIfValid(&pixmap_width) || ++ !base::CheckedNumeric(size.height()).AssignIfValid(&pixmap_height)) { ++ return base::strict_cast<::Pixmap>(x11::Pixmap::None); ++ } ++ auto req = connection->CreatePixmap( ++ {depth, pixmap, root, pixmap_width, pixmap_height}); ++ if (req.Sync().error) ++ pixmap = x11::Pixmap::None; ++ return base::strict_cast<::Pixmap>(pixmap); + } + + } // namespace +@@ -71,11 +79,8 @@ VaapiPictureNativePixmapAngle::~VaapiPictureNativePixmapAngle() { + DCHECK_EQ(glGetError(), static_cast(GL_NO_ERROR)); + } + +- if (x_pixmap_) { +- if (auto* display = gfx::GetXDisplay()) { +- XFreePixmap(display, x_pixmap_); +- } +- } ++ if (x_pixmap_) ++ x11::Connection::Get()->FreePixmap({static_cast(x_pixmap_)}); + } + + Status VaapiPictureNativePixmapAngle::Allocate(gfx::BufferFormat format) { +diff --git a/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h b/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h +index de4698abe..41f52376d 100644 +--- a/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h ++++ b/media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h +@@ -46,7 +46,7 @@ class VaapiPictureNativePixmapAngle : public VaapiPictureNativePixmap { + VASurfaceID va_surface_id() const override; + + private: +- Pixmap x_pixmap_ = 0; ++ ::Pixmap x_pixmap_ = 0; + + DISALLOW_COPY_AND_ASSIGN(VaapiPictureNativePixmapAngle); + }; +diff --git a/media/gpu/vaapi/vaapi_picture_tfp.cc b/media/gpu/vaapi/vaapi_picture_tfp.cc +index 9ff0372fa..a571b4b2b 100644 +--- a/media/gpu/vaapi/vaapi_picture_tfp.cc ++++ b/media/gpu/vaapi/vaapi_picture_tfp.cc +@@ -7,6 +7,7 @@ + #include "media/gpu/vaapi/va_surface.h" + #include "media/gpu/vaapi/vaapi_wrapper.h" + #include "ui/base/ui_base_features.h" ++#include "ui/gfx/x/connection.h" + #include "ui/gfx/x/x11_types.h" + #include "ui/gl/gl_bindings.h" + #include "ui/gl/gl_image_glx.h" +@@ -33,7 +34,7 @@ VaapiTFPPicture::VaapiTFPPicture( + texture_id, + client_texture_id, + texture_target), +- x_display_(gfx::GetXDisplay()), ++ connection_(x11::Connection::Get()), + x_pixmap_(0) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(!features::IsUsingOzonePlatform()); +@@ -49,7 +50,7 @@ VaapiTFPPicture::~VaapiTFPPicture() { + } + + if (x_pixmap_) +- XFreePixmap(x_display_, x_pixmap_); ++ connection_->FreePixmap({static_cast(x_pixmap_)}); + } + + Status VaapiTFPPicture::Initialize() { +@@ -84,16 +85,33 @@ Status VaapiTFPPicture::Allocate(gfx::BufferFormat format) { + return StatusCode::kVaapiUnsupportedFormat; + } + +- XWindowAttributes win_attr; +- int screen = DefaultScreen(x_display_); +- XGetWindowAttributes(x_display_, XRootWindow(x_display_, screen), &win_attr); ++ if (!connection_->Ready()) ++ return StatusCode::kVaapiNoPixmap; ++ ++ auto root = connection_->default_root(); ++ ++ uint8_t depth = 0; ++ if (auto reply = connection_->GetGeometry({root}).Sync()) ++ depth = reply->depth; ++ else ++ return StatusCode::kVaapiNoPixmap; ++ + // TODO(posciak): pass the depth required by libva, not the RootWindow's + // depth +- x_pixmap_ = XCreatePixmap(x_display_, XRootWindow(x_display_, screen), +- size_.width(), size_.height(), win_attr.depth); +- if (!x_pixmap_) { ++ auto pixmap = connection_->GenerateId(); ++ uint16_t pixmap_width, pixmap_height; ++ if (!base::CheckedNumeric(size_.width()).AssignIfValid(&pixmap_width) || ++ !base::CheckedNumeric(size_.height()) ++ .AssignIfValid(&pixmap_height)) { ++ return StatusCode::kVaapiNoPixmap; ++ } ++ auto req = connection_->CreatePixmap( ++ {depth, pixmap, root, pixmap_width, pixmap_height}); ++ if (req.Sync().error) { + DLOG(ERROR) << "Failed creating an X Pixmap for TFP"; + return StatusCode::kVaapiNoPixmap; ++ } else { ++ x_pixmap_ = base::strict_cast<::Pixmap>(pixmap); + } + + return Initialize(); +diff --git a/media/gpu/vaapi/vaapi_picture_tfp.h b/media/gpu/vaapi/vaapi_picture_tfp.h +index c4eb2c1b5..8da323717 100644 +--- a/media/gpu/vaapi/vaapi_picture_tfp.h ++++ b/media/gpu/vaapi/vaapi_picture_tfp.h +@@ -11,6 +11,7 @@ + #include "base/memory/ref_counted.h" + #include "media/gpu/vaapi/vaapi_picture.h" + #include "ui/gfx/geometry/size.h" ++#include "ui/gfx/x/connection.h" + #include "ui/gl/gl_bindings.h" + + namespace gl { +@@ -47,9 +48,9 @@ class VaapiTFPPicture : public VaapiPicture { + private: + Status Initialize(); + +- Display* x_display_; ++ x11::Connection* const connection_; + +- Pixmap x_pixmap_; ++ ::Pixmap x_pixmap_; + scoped_refptr glx_image_; + + DISALLOW_COPY_AND_ASSIGN(VaapiTFPPicture); +diff --git a/media/gpu/vaapi/vaapi_wrapper.cc b/media/gpu/vaapi/vaapi_wrapper.cc +index 2ad0b997e..a98823343 100644 +--- a/media/gpu/vaapi/vaapi_wrapper.cc ++++ b/media/gpu/vaapi/vaapi_wrapper.cc +@@ -57,8 +57,13 @@ + #include "ui/gl/gl_implementation.h" + + #if defined(USE_X11) +-#include + #include "ui/gfx/x/x11_types.h" // nogncheck ++ ++typedef XID Drawable; ++ ++extern "C" { ++#include "media/gpu/vaapi/va_x11.sigs" ++} + #endif + + #if defined(USE_OZONE) -- cgit v1.2.3