QWaylandBufferRef Class

QWaylandBufferRef 类保存对表面缓冲区的引用。更多

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

公共函数

QWaylandBufferRef()
QWaylandBufferRef(const QWaylandBufferRef &ref)
~QWaylandBufferRef()
bool hasBuffer() const
bool hasContent() const
(since 6.2) 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)

详细说明

该类可用于引用曲面缓冲区。只要存在对缓冲区的引用,该缓冲区就归合成器所有,客户端就不能修改它。

成员函数文档

QWaylandBufferRef::QWaylandBufferRef()

构造一个空缓冲区 ref。

QWaylandBufferRef::QWaylandBufferRef(const QWaylandBufferRef &ref)

ref 引用的缓冲区创建新引用。

[noexcept] QWaylandBufferRef::~QWaylandBufferRef()

取消引用缓冲区。

bool QWaylandBufferRef::hasBuffer() const

如果QWaylandBufferRef 引用了缓冲区,则返回 true。否则返回 false。

另请参阅 isNull() 和hasContent()。

bool QWaylandBufferRef::hasContent() const

如果QWaylandBufferRef 引用了有内容的缓冲区,则返回 true。否则返回 false。

另请参阅 isNull() 和hasBuffer()。

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

如果QWaylandBufferRef 引用了具有受保护内容的缓冲区,则返回 true。否则返回 false。

注意: 这是一个假定客户端缓冲区集成支持的启用程序。Qt 中包含的客户端缓冲区集成目前都不支持受保护内容缓冲区。

此函数在 Qt 6.2 中引入。

另请参阅 hasContent()。

QImage QWaylandBufferRef::image() const

返回包含缓冲区内容的图像。

bool QWaylandBufferRef::isDestroyed() const

如果QWaylandBufferRef 引用的缓冲区已被销毁,则返回 true。否则返回 false。

bool QWaylandBufferRef::isNull() const

如果QWaylandBufferRef 未引用缓冲区,则返回 true。否则返回 false。

另请参阅 hasBuffer() 和hasContent()。

bool QWaylandBufferRef::isSharedMemory() const

如果缓冲区是共享内存缓冲区,则返回 true。否则返回 false。

quintptr QWaylandBufferRef::lockNativeBuffer()

返回此缓冲区的本地句柄,并将其标记为锁定状态,直到调用unlockNativeBuffer() 时才会释放。

如果缓冲区没有本地句柄,或锁定不成功,则返回 0。

QWaylandSurface::Origin QWaylandBufferRef::origin() const

返回缓冲区的原点。如果引用的缓冲区为空,则返回QWaylandSurface::OriginBottomLeft

QSize QWaylandBufferRef::size() const

返回缓冲区的大小。如果引用的缓冲区为空,则返回无效的 QSize()。

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

plane 是多平面格式(如 YUV)的索引。

返回的纹理归缓冲区所有。只要缓冲区引用存在,纹理就一直有效。此函数的调用者不得删除纹理,只要纹理还在使用,就必须保留对缓冲区的引用。

如果没有有效的缓冲区,或无法创建纹理,则返回nullptr

void QWaylandBufferRef::unlockNativeBuffer(quintptr handle)

将本地缓冲区标记为不再使用。handle 必须与之前调用lockNativeBuffer() 返回的值一致。

struct wl_resource *QWaylandBufferRef::wl_buffer() const

返回缓冲区的 Wayland 资源。

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

ref 赋值给该缓冲区,并为其添加一个引用。之前引用的缓冲区将被取消引用。

相关非成员

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

如果lhs 引用了与rhs 相同的缓冲区,则返回false 。否则返回true

[noexcept] bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)

如果lhs 引用了与rhs 相同的缓冲区,则返回true 。否则返回false

© 2025 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.