diff options
Diffstat (limited to 'src/compositor/compositor_api/qwaylandbufferref.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandbufferref.cpp | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index 7cc17fcbe..8f7c63f40 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -38,14 +38,14 @@ #include <QAtomicInt> #include "qwaylandbufferref.h" -#include "wayland_wrapper/qwlsurfacebuffer_p.h" +#include "wayland_wrapper/qwlclientbuffer_p.h" QT_BEGIN_NAMESPACE class QWaylandBufferRefPrivate { public: - QtWayland::SurfaceBuffer *buffer; + QtWayland::ClientBuffer *buffer; bool nullOrDestroyed() { return !buffer || buffer->isDestroyed(); @@ -74,7 +74,7 @@ QWaylandBufferRef::QWaylandBufferRef() /*! * Constructs a reference to \a buffer. */ -QWaylandBufferRef::QWaylandBufferRef(QtWayland::SurfaceBuffer *buffer) +QWaylandBufferRef::QWaylandBufferRef(QtWayland::ClientBuffer *buffer) : d(new QWaylandBufferRefPrivate) { d->buffer = buffer; @@ -104,17 +104,18 @@ QWaylandBufferRef::~QWaylandBufferRef() } /*! - * Assigns \a ref to this buffer. The previously referenced buffer is - * dereferenced and the new one gets a new reference. + * Assigns \a ref to this buffer and adds a reference to it. The previously referenced buffer is + * dereferenced. */ QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref) { + if (ref.d->buffer) + ref.d->buffer->ref(); + if (d->buffer) d->buffer->deref(); d->buffer = ref.d->buffer; - if (d->buffer) - d->buffer->ref(); return *this; } @@ -141,7 +142,7 @@ bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &ref) * Returns true if this QWaylandBufferRef does not reference a buffer. * Otherwise returns false. * - * \sa hasBuffer() + * \sa hasBuffer(), hasContent() */ bool QWaylandBufferRef::isNull() const { @@ -151,12 +152,21 @@ bool QWaylandBufferRef::isNull() const /*! * Returns true if this QWaylandBufferRef references a buffer. Otherwise returns false. * - * \sa isNull() + * \sa isNull(), hasContent() */ bool QWaylandBufferRef::hasBuffer() const { return d->buffer; } +/*! + * Returns true if this QWaylandBufferRef references a buffer that has content. Otherwise returns false. + * + * \sa isNull(), hasBuffer() + */ +bool QWaylandBufferRef::hasContent() const +{ + return QtWayland::ClientBuffer::hasContent(d->buffer); +} /*! * Returns true if this QWaylandBufferRef references a buffer that @@ -176,6 +186,14 @@ struct ::wl_resource *QWaylandBufferRef::wl_buffer() const } /*! + * \internal + */ +QtWayland::ClientBuffer *QWaylandBufferRef::buffer() const +{ + return d->buffer; +} + +/*! * Returns the size of the buffer. * If the buffer referenced is null, an invalid QSize() is returned. */ @@ -242,35 +260,23 @@ QImage QWaylandBufferRef::image() const } #ifdef QT_WAYLAND_COMPOSITOR_GL -GLuint QWaylandBufferRef::textureForPlane(int plane) const -{ - if (d->nullOrDestroyed()) - return 0; - - return d->buffer->textureForPlane(plane); -} - /*! - * Binds the buffer to the current OpenGL texture. This may - * perform a copy of the buffer data, depending on the platform - * and the type of the buffer. + * Returns an OpenGL texture for the buffer. \a 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 \c nullptr if there is no valid buffer, or if no texture can be created. */ -void QWaylandBufferRef::bindToTexture() const +QOpenGLTexture *QWaylandBufferRef::toOpenGLTexture(int plane) const { if (d->nullOrDestroyed()) - return; - - return d->buffer->bindToTexture(); + return nullptr; + return d->buffer->toOpenGlTexture(plane); } -void QWaylandBufferRef::updateTexture() const -{ - if (d->nullOrDestroyed() || d->buffer->isSharedMemory()) - return; - - d->buffer->updateTexture(); -} #endif QT_END_NAMESPACE |