Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPlatformSharedGraphicsCache Class Referenceabstract

The QPlatformSharedGraphicsCache is an abstraction of a cross-process graphics cache. More...

#include <qplatformsharedgraphicscache.h>

+ Inheritance diagram for QPlatformSharedGraphicsCache:
+ Collaboration diagram for QPlatformSharedGraphicsCache:

Public Types

enum  PixelFormat { Alpha8 }
 Defines the pixel format of a cache. More...
 
enum  BufferType { OpenGLTexture }
 Defines how the type of buffer required to contain a cache. More...
 

Signals

void itemsMissing (const QByteArray &cacheId, const QList< quint32 > &itemIds)
 This signal is emitted when requestItems() has been called for one or more items in the cache named cacheId which are not yet available in the cache.
 
void itemsAvailable (const QByteArray &cacheId, void *bufferId, const QList< quint32 > &itemIds, const QList< QPoint > &positionsInBuffer)
 This signal can be emitted at any time when either requestItems() or insertItems() has been called by the application for one or more items in the cache named cacheId, as long as releaseItems() has not subsequently been called for the same items.
 
void itemsInvalidated (const QByteArray &cacheId, const QList< quint32 > &itemIds)
 This signal is emitted when the items given by itemIds in the cache named cacheId have been removed from the cache and the previously reported information about them is considered invalid.
 
void itemsUpdated (const QByteArray &cacheId, void *bufferId, const QList< quint32 > &itemIds, const QList< QPoint > &positionsInBuffer)
 This signal is similar in usage to the itemsAvailable() signal, but will be emitted when the location of a previously requested or inserted item has been updated.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QPlatformSharedGraphicsCache (QObject *parent=nullptr)
 
virtual void beginRequestBatch ()=0
 This is a hint to the cache that a burst of requests is pending.
 
virtual void ensureCacheInitialized (const QByteArray &cacheId, BufferType bufferType, PixelFormat pixelFormat)=0
 Initializes a cache named cacheId if it has not yet been initialized.
 
virtual void requestItems (const QByteArray &cacheId, const QList< quint32 > &itemIds)=0
 Requests all the items in itemIds from the cache with the name cacheId.
 
virtual void insertItems (const QByteArray &cacheId, const QList< quint32 > &itemIds, const QList< QImage > &items)=0
 Inserts the items in itemIds into the cache named cacheId.
 
virtual void releaseItems (const QByteArray &cacheId, const QList< quint32 > &itemIds)=0
 Releases the reference to the items in itemIds from the cache named cacheId.
 
virtual void endRequestBatch ()=0
 Signals to the cache that the request sequence which has previously been commenced using beginRequestBatch() has now finished.
 
virtual bool requestBatchStarted () const =0
 Returns true if a request batch has previously been started using beginRequestBatch() and not yet stopped using endRequestBatch().
 
virtual uint textureIdForBuffer (void *bufferId)=0
 Returns an OpenGL texture ID corresponding to the buffer bufferId, which has previously been passed through signals itemsAvailable() or itemsUpdated().
 
virtual void referenceBuffer (void *bufferId)=0
 Registers a reference to the buffer bufferId.
 
virtual bool dereferenceBuffer (void *bufferId)=0
 Removed a previously registered reference to the buffer bufferId.
 
virtual QSize sizeOfBuffer (void *bufferId)=0
 Returns the size of the buffer bufferId.
 
virtual voideglImageForBuffer (void *bufferId)=0
 Returns an EGLImageKHR image corresponding to the buffer bufferId.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

The QPlatformSharedGraphicsCache is an abstraction of a cross-process graphics cache.

Since
5.0

\preliminary

If supported, it is possible to retrieve a QPlatformSharedGraphicsCache object from the platform integration. This is typically used to store graphical items which should be shared between several processes.

Items are requested from the cache by calling requestItems(). If the cache contains the requested items in the requested cache, the itemsAvailable() signal is emitted with the ID of the graphical buffer and each item's coordinates inside the buffer. Before requesting items from a cache, the user must call ensureCacheInitialized() to set the correct parameters for the cache.

If the cache does not yet contain the requested items, it will emit a similar itemsMissing() signal. The client can then call updateItems() with rasterizations of the items and they will be entered into the shared cache. As the items are rendered into the cache, itemsAvailable() signals will be emitted for each of the items which have previously been requested and which have not yet been reported as ready.

Using beginRequestBatch() and endRequestBatch(), it's possible to batch glyph requests, which could improve performance in cases where you have a sequence of requests pending, and you do not need the results during this sequence.

Definition at line 22 of file qplatformsharedgraphicscache.h.

Member Enumeration Documentation

◆ BufferType

Defines how the type of buffer required to contain a cache.

\value OpenGLTexture The buffer will be allocated in graphics memory, and an OpenGL texture for a buffer belonging to the cache can be requested using textureIdForBuffer().

Enumerator
OpenGLTexture 

Definition at line 31 of file qplatformsharedgraphicscache.h.

◆ PixelFormat

Defines the pixel format of a cache.

\value Alpha8 The cache will use 8 bits to represent the alpha value of each pixel. If an OpenGL texture is created for a buffer belong to the cache, it will have the pixel format GL_ALPHA.

Enumerator
Alpha8 

Definition at line 26 of file qplatformsharedgraphicscache.h.

Constructor & Destructor Documentation

◆ QPlatformSharedGraphicsCache()

QPlatformSharedGraphicsCache::QPlatformSharedGraphicsCache ( QObject * parent = nullptr)
inlineexplicit

Definition at line 36 of file qplatformsharedgraphicscache.h.

Member Function Documentation

◆ beginRequestBatch()

void QPlatformSharedGraphicsCache::beginRequestBatch ( )
pure virtual

This is a hint to the cache that a burst of requests is pending.

In some implementations, this will improve performance, as the cache can focus on handling the requests and wait with the results until it is done. It should typically be called prior to a sequence of calls to requestItems() and releaseItems().

Any call to beginRequestBatch() must be followed at some point by a call to endRequestBatch(). Failing to do this may lead to the results of requests never being emitted.

Note
beginRequestBatch() and endRequestBatch() have no stacking logic. Calling beginRequestBatch() twice in a row has no effect, and the single existing batch will be ended by the earliest call to endRequestBatch().
See also
endRequestBatch(), requestBatchStarted()

◆ dereferenceBuffer()

bool QPlatformSharedGraphicsCache::dereferenceBuffer ( void * bufferId)
pure virtual

Removed a previously registered reference to the buffer bufferId.

Returns true if there are still more references to the buffer in question, or false if this was the last reference (in which case the buffer may have been deleted in the cache.)

See also
dereferenceBuffer()

◆ eglImageForBuffer()

void * QPlatformSharedGraphicsCache::eglImageForBuffer ( void * bufferId)
pure virtual

Returns an EGLImageKHR image corresponding to the buffer bufferId.

See also
textureIdForBuffer(), sizeOfBuffer()

◆ endRequestBatch()

void QPlatformSharedGraphicsCache::endRequestBatch ( )
pure virtual

Signals to the cache that the request sequence which has previously been commenced using beginRequestBatch() has now finished.

See also
beginRequestBatch(), requestBatchStarted()

◆ ensureCacheInitialized()

void QPlatformSharedGraphicsCache::ensureCacheInitialized ( const QByteArray & cacheId,
BufferType bufferType,
PixelFormat pixelFormat )
pure virtual

Initializes a cache named cacheId if it has not yet been initialized.

The bufferType and pixelFormat gives the format of the buffers that will be used to contain the items in the cache. If a cache with the same cacheId has previously been initialized, the call will be ignored. The cache will keep its previously set buffer type and pixel format.

◆ insertItems()

void QPlatformSharedGraphicsCache::insertItems ( const QByteArray & cacheId,
const QList< quint32 > & itemIds,
const QList< QImage > & items )
pure virtual

Inserts the items in itemIds into the cache named cacheId.

The appearance of each item is stored in items. The format of the QImage objects is expected to match the pixel format of the cache as it was initialized in ensureCacheInitialized().

When the items have been successfully entered into the cache, one or more itemsAvailable() signals will be emitted for the items.

If the cache already contains the items, the behavior is implementation-specific. The implementation may choose to ignore the items or it may overwrite the existing instances in the cache. Either way, itemsAvailable() signals corresponding to the inserted items will be emitted.

◆ itemsAvailable

void QPlatformSharedGraphicsCache::itemsAvailable ( const QByteArray & cacheId,
void * bufferId,
const QList< quint32 > & itemIds,
const QList< QPoint > & positionsInBuffer )
signal

This signal can be emitted at any time when either requestItems() or insertItems() has been called by the application for one or more items in the cache named cacheId, as long as releaseItems() has not subsequently been called for the same items.

It instructs the application on where to find the items that have been entered into the cache. When the application receives a buffer, it is expected to reference it using referenceBuffer() on it if it keeps a reference to the buffer.

The bufferId is an ID for the buffer that contains the items. The bufferId can be converted to a format usable by the application depending on which format it was given at initialization. If it is a OpenGLTexture, its texture ID can be requested using the textureIdForBuffer() function. The dimensions of the buffer are given by bufferSize.

The items provided by the cache are identified in the itemIds list. The positionsInBuffer list contains the locations inside the buffer of each item. Each entry in positionsInBuffer corresponds to an item in itemIds.

The buffer and the items' locations within the buffer can be considered valid until an itemsInvalidated() signal has been emitted for the items, or until releaseItems() is called for the items.

See also
itemsMissing(), requestItems(), bufferType()

◆ itemsInvalidated

void QPlatformSharedGraphicsCache::itemsInvalidated ( const QByteArray & cacheId,
const QList< quint32 > & itemIds )
signal

This signal is emitted when the items given by itemIds in the cache named cacheId have been removed from the cache and the previously reported information about them is considered invalid.

It will only be emitted for items for which a buffer has previously been identified through the itemsAvailable() signal (either as response to a requestItems() call or an insertItems() call.)

The application is expected to throw away information about the items in the itemIds array and drop any references it might have to the memory held by the buffer. If the items are still required by the application, it can re-commit them to the cache using the insertItems() function.

If the application no longer holds any references to previously referenced items in a given cache, it should call releaseItems() for these items, at which point it will no longer receive any itemsInvalidated() signal for these items.

◆ itemsMissing

void QPlatformSharedGraphicsCache::itemsMissing ( const QByteArray & cacheId,
const QList< quint32 > & itemIds )
signal

This signal is emitted when requestItems() has been called for one or more items in the cache named cacheId which are not yet available in the cache.

The user is then expected to call insertItems() to update the cache with the respective items, at which point they will become available to all clients of the shared cache.

The itemIds list contains the IDs of the items that need to be inserted into the cache.

See also
itemsAvailable(), insertItems(), requestItems()

◆ itemsUpdated

void QPlatformSharedGraphicsCache::itemsUpdated ( const QByteArray & cacheId,
void * bufferId,
const QList< quint32 > & itemIds,
const QList< QPoint > & positionsInBuffer )
signal

This signal is similar in usage to the itemsAvailable() signal, but will be emitted when the location of a previously requested or inserted item has been updated.

The application must update its data for the respective items and release any references to old buffers held by the items.

If the application no longer holds any references to previously referenced items in a given cache, it should call releaseItems() for these items, at which point it will no longer receive any itemsUpdated() signal for these items.

See also
requestItems(), insertItems(), itemsAvailable()

◆ referenceBuffer()

void QPlatformSharedGraphicsCache::referenceBuffer ( void * bufferId)
pure virtual

Registers a reference to the buffer bufferId.

See also
dereferenceBuffer()

◆ releaseItems()

void QPlatformSharedGraphicsCache::releaseItems ( const QByteArray & cacheId,
const QList< quint32 > & itemIds )
pure virtual

Releases the reference to the items in itemIds from the cache named cacheId.

This should only be called when all references to the items have been released by the user, and they are no longer needed.

◆ requestBatchStarted()

bool QPlatformSharedGraphicsCache::requestBatchStarted ( ) const
pure virtual

Returns true if a request batch has previously been started using beginRequestBatch() and not yet stopped using endRequestBatch().

See also
beginRequestBatch(), endRequestBatch()

◆ requestItems()

void QPlatformSharedGraphicsCache::requestItems ( const QByteArray & cacheId,
const QList< quint32 > & itemIds )
pure virtual

Requests all the items in itemIds from the cache with the name cacheId.

If any or all of the items are available in the cache, one or more itemsAvailable() signals will be emitted corresponding to the items. If the cache does not contain all of the items in question, then an itemsMissing() signal will be emitted corresponding to the missing items. The user is at this point expected to call insertItems() to insert the missing items into the cache. If the inserted items have previously been requested by the user, at which point an itemsAvailable() signal will be emitted corresponding to the items.

Before requesting items from a cache, the user must call ensureCacheInitialized() with the correct parameters for the cache.

◆ sizeOfBuffer()

QSize QPlatformSharedGraphicsCache::sizeOfBuffer ( void * bufferId)
pure virtual

Returns the size of the buffer bufferId.

See also
textureIdForBuffer(), eglImageForBuffer()

◆ textureIdForBuffer()

uint QPlatformSharedGraphicsCache::textureIdForBuffer ( void * bufferId)
pure virtual

Returns an OpenGL texture ID corresponding to the buffer bufferId, which has previously been passed through signals itemsAvailable() or itemsUpdated().

The relevant OpenGL context should be current when calling this function.

See also
eglImageForBuffer(), sizeOfBuffer()

The documentation for this class was generated from the following files: