diff options
6 files changed, 37 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index d7f6c43bb..39fb8f1fc 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -160,6 +160,16 @@ bool QWaylandBufferRef::hasContent() const { return QtWayland::ClientBuffer::hasContent(d->buffer); } +/*! + * Returns true if this QWaylandBufferRef references a buffer that has protected content. Otherwise returns false. + * + * \since 6.2 + * \sa hasContent() + */ +bool QWaylandBufferRef::hasProtectedContent() const +{ + return QtWayland::ClientBuffer::hasProtectedContent(d->buffer); +} /*! * Returns true if this QWaylandBufferRef references a buffer that diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h index b1aaf5f19..3549fb17a 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.h +++ b/src/compositor/compositor_api/qwaylandbufferref.h @@ -62,6 +62,7 @@ public: bool isNull() const; bool hasBuffer() const; bool hasContent() const; + bool hasProtectedContent() const; bool isDestroyed() const; bool operator==(const QWaylandBufferRef &ref); bool operator!=(const QWaylandBufferRef &ref); diff --git a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h index 0195f3d4b..29bf7d081 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h @@ -67,6 +67,7 @@ public: virtual void initializeHardware(struct ::wl_display *display) = 0; virtual ClientBuffer *createBufferFor(struct ::wl_resource *buffer) = 0; + virtual bool isProtected(struct ::wl_resource *buffer) { Q_UNUSED(buffer); return false; } protected: QWaylandCompositor *m_compositor = nullptr; diff --git a/src/compositor/wayland_wrapper/qwlclientbuffer_p.h b/src/compositor/wayland_wrapper/qwlclientbuffer_p.h index a6503e86e..f58d87294 100644 --- a/src/compositor/wayland_wrapper/qwlclientbuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlclientbuffer_p.h @@ -86,6 +86,8 @@ public: virtual void setCommitted(QRegion &damage); bool isDestroyed() { return m_destroyed; } + virtual bool isProtected() { return false; } + inline struct ::wl_resource *waylandBufferHandle() const { return m_buffer; } bool isSharedMemory() const { return wl_shm_buffer_get(m_buffer); } @@ -95,6 +97,7 @@ public: #endif static bool hasContent(ClientBuffer *buffer) { return buffer && buffer->waylandBufferHandle(); } + static bool hasProtectedContent(ClientBuffer *buffer) { return buffer && buffer->isProtected(); } protected: void ref(); diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 7f8cced33..8649e70be 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -259,7 +259,14 @@ void WaylandEglClientBufferIntegrationPrivate::initEglTexture(WaylandEglClientBu } for (int i = 0; i < planes; i++) { - const EGLint attribs[] = { EGL_WAYLAND_PLANE_WL, i, EGL_NONE }; + EGLint attribs[5] = { EGL_WAYLAND_PLANE_WL, i, EGL_NONE }; +#ifdef EGL_EXT_protected_content + if (buffer->isProtected()) { + attribs[2] = EGL_PROTECTED_CONTENT_EXT; + attribs[3] = EGL_TRUE; + attribs[4] = EGL_NONE; + } +#endif EGLImageKHR image = egl_create_image(egl_display, EGL_NO_CONTEXT, EGL_WAYLAND_BUFFER_WL, @@ -573,6 +580,10 @@ QOpenGLTexture *WaylandEglClientBuffer::toOpenGlTexture(int plane) texture->bind(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); p->gl_egl_image_target_texture_2d(target, d->egl_images[plane]); +#ifdef GL_EXT_protected_textures + if (isProtected()) + glTexParameteri(target, GL_TEXTURE_PROTECTED_EXT, GL_TRUE); +#endif } return texture; } @@ -586,6 +597,15 @@ void WaylandEglClientBuffer::setCommitted(QRegion &damage) } } +bool WaylandEglClientBuffer::isProtected() +{ + if (m_integration && m_buffer) + return m_integration->isProtected(m_buffer); + + return false; +} + + QWaylandSurface::Origin WaylandEglClientBuffer::origin() const { return d->isYInverted ? QWaylandSurface::OriginTopLeft : QWaylandSurface::OriginBottomLeft; diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h index bbc0eafef..7bd13466e 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h @@ -68,6 +68,7 @@ public: void unlockNativeBuffer(quintptr native_buffer) const override; QOpenGLTexture *toOpenGlTexture(int plane) override; void setCommitted(QRegion &damage) override; + bool isProtected() override; private: friend class WaylandEglClientBufferIntegration; |