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
QOpenGLCompositorBackingStore Class Reference

A backing store implementation for OpenGL. More...

#include <qopenglcompositorbackingstore_p.h>

+ Inheritance diagram for QOpenGLCompositorBackingStore:
+ Collaboration diagram for QOpenGLCompositorBackingStore:

Public Member Functions

 QOpenGLCompositorBackingStore (QWindow *window)
 
 ~QOpenGLCompositorBackingStore ()
 
QPaintDevicepaintDevice () override
 Implement this function to return the appropriate paint device.
 
void beginPaint (const QRegion &region) override
 This function is called before painting onto the surface begins, with the region in which the painting will occur.
 
void flush (QWindow *window, const QRegion &region, const QPoint &offset) override
 Flushes the given region from the specified window.
 
void resize (const QSize &size, const QRegion &staticContents) override
 
QImage toImage () const override
 Implemented in subclasses to return the content of the backingstore as a QImage.
 
FlushResult rhiFlush (QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground) override
 Flushes the given region from the specified window, and compositing it with the specified textures list.
 
const QPlatformTextureListtextures () const
 
void notifyComposited ()
 
- Public Member Functions inherited from QPlatformBackingStore
 QPlatformBackingStore (QWindow *window)
 Constructs an empty surface for the given top-level window.
 
virtual ~QPlatformBackingStore ()
 Destroys this surface.
 
QWindowwindow () const
 Returns a pointer to the top-level window associated with this surface.
 
QBackingStorebackingStore () const
 Returns a pointer to the backing store associated with this surface.
 
virtual QRhiTexturetoTexture (QRhiResourceUpdateBatch *resourceUpdates, const QRegion &dirtyRegion, TextureFlags *flags) const
 May be reimplemented in subclasses to return the content of the backingstore as an QRhiTexture.
 
virtual QPlatformGraphicsBuffergraphicsBuffer () const
 Accessor for a backingstores graphics buffer abstraction.
 
virtual bool scroll (const QRegion &area, int dx, int dy)
 Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
 
virtual void endPaint ()
 This function is called after painting onto the surface has ended.
 
void setRhiConfig (const QPlatformBackingStoreRhiConfig &config)
 
QRhirhi () const
 
void surfaceAboutToBeDestroyed ()
 
void graphicsDeviceReportedLost ()
 

Additional Inherited Members

- Public Types inherited from QPlatformBackingStore
enum  FlushResult { FlushSuccess , FlushFailed , FlushFailedDueToLostDevice }
 
enum  TextureFlag { TextureSwizzle = 0x01 , TextureFlip = 0x02 , TexturePremultiplied = 0x04 }
 

Detailed Description

A backing store implementation for OpenGL.

Since
5.4

This implementation uploads raster-rendered widget windows into textures. It is meant to be used with QOpenGLCompositor that composites the textures onto a single native window using OpenGL. This means that multiple top-level widgets are supported without creating actual native windows for each of them.

Note
It is important to call notifyComposited() from the corresponding platform window's endCompositing() callback (inherited from QOpenGLCompositorWindow).
When implementing QOpenGLCompositorWindow::textures() for windows of type RasterSurface or RasterGLSurface, simply return the list provided by this class' textures().

Definition at line 31 of file qopenglcompositorbackingstore_p.h.

Constructor & Destructor Documentation

◆ QOpenGLCompositorBackingStore()

QOpenGLCompositorBackingStore::QOpenGLCompositorBackingStore ( QWindow * window)

Definition at line 42 of file qopenglcompositorbackingstore.cpp.

◆ ~QOpenGLCompositorBackingStore()

QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore ( )

Definition at line 54 of file qopenglcompositorbackingstore.cpp.

References QRhi::makeThreadLocalNativeContextCurrent().

+ Here is the call graph for this function:

Member Function Documentation

◆ beginPaint()

void QOpenGLCompositorBackingStore::beginPaint ( const QRegion & )
overridevirtual

This function is called before painting onto the surface begins, with the region in which the painting will occur.

See also
endPaint(), paintDevice()

Reimplemented from QPlatformBackingStore.

Definition at line 234 of file qopenglcompositorbackingstore.cpp.

References QPainter::CompositionMode_Source, QImage::hasAlphaChannel(), and Qt::transparent.

+ Here is the call graph for this function:

◆ flush()

void QOpenGLCompositorBackingStore::flush ( QWindow * window,
const QRegion & region,
const QPoint & offset )
overridevirtual

Flushes the given region from the specified window.

Note
region is relative to the window which may not be top-level in case window corresponds to a native child widget. offset is the position of the native child relative to the top-level window.

Unlike rhiFlush(), this function's default implementation does nothing. It is expected that subclasses provide a platform-specific (non-QRhi-based) implementation, if applicable on the given platform.

See also
rhiFlush()

Reimplemented from QPlatformBackingStore.

Definition at line 137 of file qopenglcompositorbackingstore.cpp.

References QPlatformTextureList::appendTexture(), QPlatformTextureList::clear(), compositor, QOpenGLCompositor::instance(), QPlatformBackingStoreRhiConfig::OpenGL, Q_ASSERT, Q_UNUSED, QPlatformBackingStore::rhi(), QOpenGLCompositorWindow::setBackingStore(), QPlatformBackingStore::setRhiConfig(), and QPlatformBackingStore::window().

+ Here is the call graph for this function:

◆ notifyComposited()

void QOpenGLCompositorBackingStore::notifyComposited ( )

Definition at line 225 of file qopenglcompositorbackingstore.cpp.

References QPlatformTextureList::lock().

Referenced by QEglFSWindow::endCompositing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ paintDevice()

QPaintDevice * QOpenGLCompositorBackingStore::paintDevice ( )
overridevirtual

Implement this function to return the appropriate paint device.

Implements QPlatformBackingStore.

Definition at line 67 of file qopenglcompositorbackingstore.cpp.

◆ resize()

void QOpenGLCompositorBackingStore::resize ( const QSize & size,
const QRegion & staticContents )
overridevirtual

Implements QPlatformBackingStore.

Definition at line 246 of file qopenglcompositorbackingstore.cpp.

References compositor, QImage::Format_RGBA8888, QOpenGLCompositor::instance(), and Q_UNUSED.

+ Here is the call graph for this function:

◆ rhiFlush()

QPlatformBackingStore::FlushResult QOpenGLCompositorBackingStore::rhiFlush ( QWindow * window,
qreal sourceDevicePixelRatio,
const QRegion & region,
const QPoint & offset,
QPlatformTextureList * textures,
bool translucentBackground )
overridevirtual

Flushes the given region from the specified window, and compositing it with the specified textures list.

The default implementation retrieves the contents using toTexture() and composes using QRhi with OpenGL, Metal, Vulkan, or Direct 3D underneath. May be reimplemented in subclasses if customization is desired.

Note
region is relative to the window which may not be top-level in case window corresponds to a native child widget. offset is the position of the native child relative to the top-level window.
See also
flush()

Reimplemented from QPlatformBackingStore.

Definition at line 173 of file qopenglcompositorbackingstore.cpp.

References QPlatformTextureList::appendTexture(), QPlatformTextureList::clear(), compositor, QPlatformBackingStore::FlushFailed, QPlatformBackingStore::FlushSuccess, QWindowPrivate::get(), i, QOpenGLCompositor::instance(), QPlatformBackingStoreRhiConfig::OpenGL, Q_ASSERT, Q_UNUSED, QPlatformBackingStore::rhi(), QPlatformBackingStore::setRhiConfig(), textures(), and QPlatformBackingStore::window().

+ Here is the call graph for this function:

◆ textures()

const QPlatformTextureList * QOpenGLCompositorBackingStore::textures ( ) const
inline

Definition at line 53 of file qopenglcompositorbackingstore_p.h.

Referenced by rhiFlush(), and QEglFSWindow::textures().

+ Here is the caller graph for this function:

◆ toImage()

QImage QOpenGLCompositorBackingStore::toImage ( ) const
overridevirtual

Implemented in subclasses to return the content of the backingstore as a QImage.

If composition via a 3D graphics API is supported, either this function or toTexture() must be implemented.

The returned image is only valid until the next operation (resize, paint, scroll, or flush) on the backingstore. The caller must not store the return value between calls, but instead call this function before each use, or make an explicit copy.

See also
toTexture()

Reimplemented from QPlatformBackingStore.

Definition at line 272 of file qopenglcompositorbackingstore.cpp.


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