QWaylandBufferRef Class

The QWaylandBufferRef class holds the reference to a surface buffer. More...

Header: #include <QWaylandBufferRef>
CMake: find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor)
target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor)
qmake: QT += waylandcompositor

Public Functions

QWaylandBufferRef()
QWaylandBufferRef(const QWaylandBufferRef &ref)
~QWaylandBufferRef()
bool hasBuffer() const
bool hasContent() const
bool hasProtectedContent() const
QImage image() const
bool isDestroyed() const
bool isNull() const
bool isSharedMemory() const
quintptr lockNativeBuffer()
QWaylandSurface::Origin origin() const
QSize size() const
QOpenGLTexture *toOpenGLTexture(int plane = 0) const
void unlockNativeBuffer(quintptr handle)
struct wl_resource *wl_buffer() const
QWaylandBufferRef &operator=(const QWaylandBufferRef &ref)
bool operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)
bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)

Detailed Description

This class can be used to reference a surface buffer. As long as a reference to the buffer exists, it is owned by the compositor and the client cannot modify it.

Member Function Documentation

QWaylandBufferRef::QWaylandBufferRef()

Constructs a null buffer ref.

QWaylandBufferRef::QWaylandBufferRef(const QWaylandBufferRef &ref)

Creates a new reference to the buffer referenced by ref.

QWaylandBufferRef::~QWaylandBufferRef()

Dereferences the buffer.

bool QWaylandBufferRef::hasBuffer() const

Returns true if this QWaylandBufferRef references a buffer. Otherwise returns false.

See also isNull() and hasContent().

bool QWaylandBufferRef::hasContent() const

Returns true if this QWaylandBufferRef references a buffer that has content. Otherwise returns false.

See also isNull() and hasBuffer().

[since 6.2] bool QWaylandBufferRef::hasProtectedContent() const

Returns true if this QWaylandBufferRef references a buffer that has protected content. Otherwise returns false.

Note: This is an enabler which presumes support in the client buffer integration. None of the client buffer integrations included with Qt currently support protected content buffers.

This function was introduced in Qt 6.2.

See also hasContent().

QImage QWaylandBufferRef::image() const

Returns an image with the contents of the buffer.

bool QWaylandBufferRef::isDestroyed() const

Returns true if this QWaylandBufferRef references a buffer that has been destroyed. Otherwise returns false.

bool QWaylandBufferRef::isNull() const

Returns true if this QWaylandBufferRef does not reference a buffer. Otherwise returns false.

See also hasBuffer() and hasContent().

bool QWaylandBufferRef::isSharedMemory() const

Returns true if the buffer is a shared memory buffer. Otherwise returns false.

quintptr QWaylandBufferRef::lockNativeBuffer()

Returns the native handle for this buffer, and marks it as locked so it will not be released until unlockNativeBuffer() is called.

Returns 0 if there is no native handle for this buffer, or if the lock was unsuccessful.

QWaylandSurface::Origin QWaylandBufferRef::origin() const

Returns the origin of the buffer. If the buffer referenced is null, QWaylandSurface::OriginBottomLeft is returned.

QSize QWaylandBufferRef::size() const

Returns the size of the buffer. If the buffer referenced is null, an invalid QSize() is returned.

QOpenGLTexture *QWaylandBufferRef::toOpenGLTexture(int plane = 0) const

Returns an OpenGL texture for the buffer. plane is the index for multi-plane formats, such as YUV.

The returned texture is owned by the buffer. The texture is only valid for as long as the buffer reference exists. The caller of this function must not delete the texture, and must keep a reference to the buffer for as long as the texture is being used.

Returns nullptr if there is no valid buffer, or if no texture can be created.

void QWaylandBufferRef::unlockNativeBuffer(quintptr handle)

Marks the native buffer as no longer in use. handle must correspond to the value returned by a previous call to lockNativeBuffer().

struct wl_resource *QWaylandBufferRef::wl_buffer() const

Returns the Wayland resource for the buffer.

QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref)

Assigns ref to this buffer and adds a reference to it. The previously referenced buffer is dereferenced.

Related Non-Members

bool operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)

Returns false if lhs references the same buffer as rhs. Otherwise returns true.

bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)

Returns true if lhs references the same buffer as rhs. Otherwise returns false.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.