From 047b7865a69e26c9091b22dceceae1b609a3efbc Mon Sep 17 00:00:00 2001 From: "Ung, Teng En" Date: Fri, 8 Oct 2021 14:19:40 +0000 Subject: [PATCH 2/3] sample_misc: Addin basic wayland dmabuf support. Upstream-Status: Submitted innersource PR #269 --- tools/legacy/sample_misc/wayland/include/class_wayland.h | 16 ++++++++++++++++ tools/legacy/sample_misc/wayland/src/class_wayland.cpp | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/tools/legacy/sample_misc/wayland/include/class_wayland.h b/tools/legacy/sample_misc/wayland/include/class_wayland.h index 29f724f..753b8b1 100644 --- a/tools/legacy/sample_misc/wayland/include/class_wayland.h +++ b/tools/legacy/sample_misc/wayland/include/class_wayland.h @@ -19,6 +19,9 @@ extern "C" { #include "sample_defs.h" #include "vpl/mfxstructures.h" #include "wayland-drm-client-protocol.h" +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + #include "linux-dmabuf-unstable-v1.h" +#endif typedef struct buffer wld_buffer; @@ -80,6 +83,11 @@ public: struct wl_drm* GetDrm() { return m_drm; } +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + struct zwp_linux_dmabuf_v1* GetDMABuf() { + return m_dmabuf; + } +#endif struct wl_shm* GetShm() { return m_shm; }; @@ -107,6 +115,11 @@ public: void SetDrm(struct wl_drm* drm) { m_drm = drm; } +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + void SetDMABuf(struct zwp_linux_dmabuf_v1* dmabuf) { + m_dmabuf = dmabuf; + } +#endif void DrmHandleDevice(const char* device); void DrmHandleAuthenticated(); void RegistryGlobal(struct wl_registry* registry, @@ -134,6 +147,9 @@ private: struct wl_compositor* m_compositor; struct wl_shell* m_shell; struct wl_drm* m_drm; +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + struct zwp_linux_dmabuf_v1* m_dmabuf; +#endif struct wl_shm* m_shm; struct wl_shm_pool* m_pool; struct wl_surface* m_surface; diff --git a/tools/legacy/sample_misc/wayland/src/class_wayland.cpp b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp index c5e3359..7eac204 100644 --- a/tools/legacy/sample_misc/wayland/src/class_wayland.cpp +++ b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp @@ -37,6 +37,9 @@ Wayland::Wayland() m_compositor(NULL), m_shell(NULL), m_drm(NULL), +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + m_dmabuf(NULL), +#endif m_shm(NULL), m_pool(NULL), m_surface(NULL), @@ -347,6 +350,11 @@ void Wayland::RegistryGlobal(struct wl_registry* registry, m_drm = static_cast(wl_registry_bind(registry, name, &wl_drm_interface, 2)); wl_drm_add_listener(m_drm, &drm_listener, this); } +#if defined(WAYLAND_LINUX_DMABUF_SUPPORT) + else if(0 == strcmp(interface, "zwp_linux_dmabuf_v1")) + m_dmabuf = static_cast( + wl_registry_bind(registry, name, &zwp_linux_dmabuf_v1_interface, version)); +#endif } void Wayland::DrmHandleDevice(const char* name) { -- 2.7.4