KWayland::Server::BufferInterface

KWayland::Server::BufferInterface Class Reference

#include <buffer_interface.h>

Inheritance diagram for KWayland::Server::BufferInterface:

Signals

void aboutToBeDestroyed (KWayland::Server::BufferInterface *)
 
void sizeChanged ()
 

Public Member Functions

QImage data ()
 
bool hasAlphaChannel () const
 
bool isReferenced () const
 
LinuxDmabufBufferlinuxDmabufBuffer ()
 
void ref ()
 
wl_resource * resource () const
 
void setSize (const QSize &size)
 
wl_shm_buffer * shmBuffer ()
 
QSize size () const
 
SurfaceInterfacesurface () const
 
void unref ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static BufferInterfaceget (wl_resource *r)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Reference counted representation of a Wayland buffer on Server side.

This class encapsulates a rendering buffer which is normally attached to a SurfaceInterface. A client should not render to a Wayland buffer as long as the buffer gets used by the server. The server signals whether it's still used. This class provides a convenience access for this functionality by performing reference counting and deleting the BufferInterface instance automatically once it is no longer accessed.

The BufferInterface is referenced as long as it is attached to a SurfaceInterface. If one wants to keep access to the BufferInterface for a longer time ensure to call ref on first usage and unref again once access to it is no longer needed.

In Wayland the buffer is an abstract concept and a buffer might represent multiple different concrete buffer techniques. This class has direct support for shared memory buffers built and provides access to the native buffer for different (e.g. EGL/drm) buffers.

If the EGL display has been registered in the Display the BufferInterface can also provide some information about an EGL/drm buffer.

For shared memory buffers a direct conversion to a memory-mapped QImage possible using the data method. Please refer to the documentation for notes on the restrictions when using the shared memory-mapped QImages.

See also
Display
SurfaceInterace

Definition at line 51 of file buffer_interface.h.

Member Function Documentation

QImage KWayland::Server::BufferInterface::data ( )

Creates a QImage for the shared memory buffer.

If the BufferInterface does not reference a shared memory buffer a null QImage is returned.

The QImage shares the memory with the buffer and this constraints how the returned QImage can be used and when this method can be invoked.

It is not safe to have two shared memory QImages for different BufferInterfaces at the same time. This method ensures that this does not happen and returns a null QImage if a different BufferInterface's data is still mapped to a QImage. Please note that this also applies to all implicitly data shared copies.

In case it is needed to keep a copy, a deep copy has to be performed by using QImage::copy.

As the underlying shared memory buffer is owned by a different client it is not safe to write to the returned QImage. The image is a read-only buffer. If there is need to modify the image, perform a deep copy.

Definition at line 266 of file buffer_interface.cpp.

bool KWayland::Server::BufferInterface::hasAlphaChannel ( ) const

Returns whether the format of the BufferInterface has an alpha channel.

For shared memory buffers returns true for format WL_SHM_FORMAT_ARGB8888, for all other formats returns false.

For EGL buffers returns true for format EGL_TEXTURE_RGBA, for all other formats returns false.

If the format cannot be queried the default value (false) is returned.

Since
5.4

Definition at line 333 of file buffer_interface.cpp.

bool KWayland::Server::BufferInterface::isReferenced ( ) const
Returns
whether the BufferInterface is currently referenced
See also
ref
unref

Definition at line 294 of file buffer_interface.cpp.

LinuxDmabufBuffer * KWayland::Server::BufferInterface::linuxDmabufBuffer ( )

Returns a pointer to the LinuxDmabufBuffer when the buffer is a dmabuf buffer, and nullptr otherwise.

Definition at line 309 of file buffer_interface.cpp.

void KWayland::Server::BufferInterface::ref ( )

Reference the BufferInterface.

As long as the reference counting has not reached 0 the BufferInterface is valid and blocked for usage by the client.

See also
unref
isReferenced

Definition at line 233 of file buffer_interface.cpp.

wl_resource * KWayland::Server::BufferInterface::resource ( ) const
Returns
the native wl_resource wrapped by this BufferInterface.

Definition at line 314 of file buffer_interface.cpp.

void KWayland::Server::BufferInterface::setSize ( const QSize size)

Sets the size for non shared memory buffers.

See also
size
sizeChanged
Since
5.3

Definition at line 324 of file buffer_interface.cpp.

wl_shm_buffer * KWayland::Server::BufferInterface::shmBuffer ( )
Returns
The native wl_shm_buffer if the BufferInterface represents a shared memory buffer, otherwise nullptr.

Definition at line 304 of file buffer_interface.cpp.

QSize KWayland::Server::BufferInterface::size ( ) const

Returns the size of this BufferInterface.

Note: only for shared memory buffers (shmBuffer) the size can be derived, for other buffers it might be possible to derive the size if an EGL display is set on Display otherwise the user of the BufferInterface has to use setSize to provide the proper size.

See also
setSize
Display::setEglDisplay
Since
5.3

Definition at line 319 of file buffer_interface.cpp.

void KWayland::Server::BufferInterface::sizeChanged ( )
signal

Emitted when the size of the Buffer changes.

Since
5.3
SurfaceInterface * KWayland::Server::BufferInterface::surface ( ) const
Returns
The SurfaceInterface this BufferInterface is attached to.

Definition at line 299 of file buffer_interface.cpp.

void KWayland::Server::BufferInterface::unref ( )

Unreference the BufferInterface.

If the reference counting reached 0 the BufferInterface is released, so that the client can use it again. The instance of this BufferInterface will be automatically deleted.

See also
ref
isReferenced

Definition at line 238 of file buffer_interface.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 22:51:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.