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
QPlatformBackingStore Class Referenceabstract

The QPlatformBackingStore class provides the drawing area for top-level windows. More...

#include <qplatformbackingstore.h>

+ Inheritance diagram for QPlatformBackingStore:
+ Collaboration diagram for QPlatformBackingStore:

Public Types

enum  FlushResult { FlushSuccess , FlushFailed , FlushFailedDueToLostDevice }
 
enum  TextureFlag { TextureSwizzle = 0x01 , TextureFlip = 0x02 , TexturePremultiplied = 0x04 }
 

Public Member Functions

 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 QPaintDevicepaintDevice ()=0
 Implement this function to return the appropriate paint device.
 
virtual void flush (QWindow *window, const QRegion &region, const QPoint &offset)
 Flushes the given region from the specified window.
 
virtual FlushResult rhiFlush (QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground)
 Flushes the given region from the specified window, and compositing it with the specified textures list.
 
virtual QImage toImage () const
 Implemented in subclasses to return the content of the backingstore as a QImage.
 
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 void resize (const QSize &size, const QRegion &staticContents)=0
 
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 beginPaint (const QRegion &)
 This function is called before painting onto the surface begins, with the region in which the painting will occur.
 
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 ()
 

Friends

class QBackingStore
 

Detailed Description

The QPlatformBackingStore class provides the drawing area for top-level windows.

Since
5.0

\preliminary

Definition at line 127 of file qplatformbackingstore.h.

Member Enumeration Documentation

◆ FlushResult

Enumerator
FlushSuccess 
FlushFailed 
FlushFailedDueToLostDevice 

Definition at line 130 of file qplatformbackingstore.h.

◆ TextureFlag

Enumerator
TextureSwizzle 
TextureFlip 
TexturePremultiplied 

Definition at line 155 of file qplatformbackingstore.h.

Constructor & Destructor Documentation

◆ QPlatformBackingStore()

QPlatformBackingStore::QPlatformBackingStore ( QWindow * window)
explicit

Constructs an empty surface for the given top-level window.

Definition at line 276 of file qplatformbackingstore.cpp.

◆ ~QPlatformBackingStore()

QPlatformBackingStore::~QPlatformBackingStore ( )
virtual

Destroys this surface.

Definition at line 284 of file qplatformbackingstore.cpp.

Member Function Documentation

◆ backingStore()

QBackingStore * QPlatformBackingStore::backingStore ( ) const

Returns a pointer to the backing store associated with this surface.

Definition at line 310 of file qplatformbackingstore.cpp.

References QPlatformBackingStorePrivate::backingStore.

Referenced by QWasmBackingStore::beginPaint().

+ Here is the caller graph for this function:

◆ beginPaint()

void QPlatformBackingStore::beginPaint ( const QRegion & )
virtual

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

See also
endPaint(), paintDevice()

Reimplemented in QFbBackingStore, QWindowsDirect2DBackingStore, QMinimalEglBackingStore, QWasmBackingStore, QWindowsBackingStore, QXcbBackingStore, QXcbSystemTrayBackingStore, QRasterBackingStore, QOpenGLCompositorBackingStore, QCALayerBackingStore, QQnxRasterBackingStore, QXcbNativeBackingStore, and QtWaylandClient::QWaylandShmBackingStore.

Definition at line 322 of file qplatformbackingstore.cpp.

Referenced by QBackingStore::beginPaint().

+ Here is the caller graph for this function:

◆ endPaint()

void QPlatformBackingStore::endPaint ( )
virtual

This function is called after painting onto the surface has ended.

See also
beginPaint(), paintDevice()

Reimplemented in QFbBackingStore, QCALayerBackingStore, QWindowsDirect2DBackingStore, QMinimalEglBackingStore, QQnxRasterBackingStore, QXcbBackingStore, and QtWaylandClient::QWaylandShmBackingStore.

Definition at line 332 of file qplatformbackingstore.cpp.

Referenced by QBackingStore::endPaint().

+ Here is the caller graph for this function:

◆ flush()

void QPlatformBackingStore::flush ( QWindow * window,
const QRegion & region,
const QPoint & offset )
virtual

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 in QCALayerBackingStore, QWindowsDirect2DBackingStore, QRhiBackingStore, QOpenGLCompositorBackingStore, QFbBackingStore, QDirectFbBackingStore, QHaikuRasterBackingStore, QMinimalBackingStore, QMinimalEglBackingStore, QOffscreenBackingStore, QQnxRasterBackingStore, QVkKhrDisplayBackingStore, QWasmBackingStore, QWindowsBackingStore, QXcbNativeBackingStore, QXcbBackingStore, and QtWaylandClient::QWaylandShmBackingStore.

Definition at line 185 of file qplatformbackingstore.cpp.

References Q_UNUSED, and window().

Referenced by QBackingStore::flush().

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

◆ graphicsBuffer()

QPlatformGraphicsBuffer * QPlatformBackingStore::graphicsBuffer ( ) const
virtual

Accessor for a backingstores graphics buffer abstraction.

Reimplemented in QCALayerBackingStore, and QXcbBackingStore.

Definition at line 339 of file qplatformbackingstore.cpp.

Referenced by QBackingStoreDefaultCompositor::flush().

+ Here is the caller graph for this function:

◆ graphicsDeviceReportedLost()

void QPlatformBackingStore::graphicsDeviceReportedLost ( )

Definition at line 376 of file qplatformbackingstore.cpp.

References QPlatformBackingStorePrivate::compositor, QBackingStoreRhiSupport::create(), qWarning, QBackingStoreDefaultCompositor::reset(), QBackingStoreRhiSupport::reset(), QBackingStoreRhiSupport::rhi(), and QPlatformBackingStorePrivate::rhiSupport.

+ Here is the call graph for this function:

◆ paintDevice()

QPaintDevice * QPlatformBackingStore::paintDevice ( )
pure virtual

◆ resize()

virtual void QPlatformBackingStore::resize ( const QSize & size,
const QRegion & staticContents )
pure virtual

◆ rhi()

QRhi * QPlatformBackingStore::rhi ( ) const

Definition at line 370 of file qplatformbackingstore.cpp.

References QBackingStoreRhiSupport::rhi(), and QPlatformBackingStorePrivate::rhiSupport.

Referenced by QRhiBackingStore::flush(), QOpenGLCompositorBackingStore::flush(), QWidgetRepaintManager::rhi(), and QOpenGLCompositorBackingStore::rhiFlush().

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

◆ rhiFlush()

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

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 in QOpenGLCompositorBackingStore, QCALayerBackingStore, and QXcbBackingStore.

Definition at line 206 of file qplatformbackingstore.cpp.

References QPlatformBackingStorePrivate::compositor, QBackingStoreDefaultCompositor::flush(), QBackingStoreRhiSupport::rhi(), QPlatformBackingStorePrivate::rhiSupport, QBackingStoreRhiSupport::swapChainForWindow(), and window().

Referenced by QRhiBackingStore::flush(), QCALayerBackingStore::rhiFlush(), and QXcbBackingStore::rhiFlush().

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

◆ scroll()

bool QPlatformBackingStore::scroll ( const QRegion & area,
int dx,
int dy )
virtual

Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.

Returns true if the area was scrolled successfully; false otherwise.

Reimplemented in QRasterBackingStore, QDirectFbBackingStore, QOffscreenBackingStore, QQnxRasterBackingStore, QWindowsBackingStore, QXcbNativeBackingStore, QXcbBackingStore, and QCALayerBackingStore.

Definition at line 350 of file qplatformbackingstore.cpp.

References area(), and Q_UNUSED.

Referenced by QBackingStore::scroll().

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

◆ setRhiConfig()

void QPlatformBackingStore::setRhiConfig ( const QPlatformBackingStoreRhiConfig & config)

Definition at line 359 of file qplatformbackingstore.cpp.

References QBackingStoreRhiSupport::create(), QWindow::format(), QPlatformBackingStorePrivate::rhiSupport, QBackingStoreRhiSupport::setConfig(), QBackingStoreRhiSupport::setFormat(), QBackingStoreRhiSupport::setWindow(), and QPlatformBackingStorePrivate::window.

Referenced by QWidgetPrivate::create(), QRhiBackingStore::flush(), QOpenGLCompositorBackingStore::flush(), and QOpenGLCompositorBackingStore::rhiFlush().

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

◆ surfaceAboutToBeDestroyed()

void QPlatformBackingStore::surfaceAboutToBeDestroyed ( )

◆ toImage()

QImage QPlatformBackingStore::toImage ( ) const
virtual

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 in QRasterBackingStore, QOpenGLCompositorBackingStore, QFbBackingStore, QCALayerBackingStore, QWindowsDirect2DBackingStore, QDirectFbBackingStore, QOffscreenBackingStore, QWasmBackingStore, QWindowsBackingStore, QXcbNativeBackingStore, and QXcbBackingStore.

Definition at line 229 of file qplatformbackingstore.cpp.

Referenced by QSGSoftwareRenderThread::event(), and QBackingStoreDefaultCompositor::toTexture().

+ Here is the caller graph for this function:

◆ toTexture()

QRhiTexture * QPlatformBackingStore::toTexture ( QRhiResourceUpdateBatch * resourceUpdates,
const QRegion & dirtyRegion,
TextureFlags * flags ) const
virtual

May be reimplemented in subclasses to return the content of the backingstore as an QRhiTexture.

dirtyRegion is the part of the backingstore which may have changed since the last call to this function. The caller of this function must ensure that there is a current context.

The ownership of the texture is not transferred. The caller must not store the return value between calls, but instead call this function before each use.

The default implementation returns a cached texture if dirtyRegion is empty and the existing texture's size matches the backingstore size, otherwise it retrieves the content using toImage() and performs a texture upload.

If the red and blue components have to swapped, flags will be set to include TextureSwizzle. This allows creating textures from images in formats like QImage::Format_RGB32 without any further image conversion. Instead, the swizzling will be done in the shaders when performing composition. Other formats, that do not need such swizzling due to being already byte ordered RGBA, for example QImage::Format_RGBA8888, must result in having needsSwizzle set to false.

If the image has to be flipped (e.g. because the texture is attached to an FBO), flags will be set to include TextureFlip.

Note
dirtyRegion is relative to the backingstore so no adjustment is needed.

Definition at line 260 of file qplatformbackingstore.cpp.

References QPlatformBackingStorePrivate::compositor, QBackingStoreRhiSupport::rhi(), QPlatformBackingStorePrivate::rhiSupport, and QBackingStoreDefaultCompositor::toTexture().

+ Here is the call graph for this function:

◆ window()

QWindow * QPlatformBackingStore::window ( ) const

Returns a pointer to the top-level window associated with this surface.

Definition at line 293 of file qplatformbackingstore.cpp.

References QPlatformBackingStorePrivate::window.

Referenced by QCALayerBackingStore::QCALayerBackingStore(), QDirectFbBackingStore::QDirectFbBackingStore(), QFbBackingStore::QFbBackingStore(), QMinimalEglBackingStore::QMinimalEglBackingStore(), QQnxRasterBackingStore::QQnxRasterBackingStore(), QWasmBackingStore::QWasmBackingStore(), QtWaylandClient::QWaylandShmBackingStore::QWaylandShmBackingStore(), QWindowsBackingStore::QWindowsBackingStore(), QXcbBackingStore::QXcbBackingStore(), QXcbBackingStoreImage::QXcbBackingStoreImage(), QXcbNativeBackingStore::QXcbNativeBackingStore(), QXcbSystemTrayBackingStore::QXcbSystemTrayBackingStore(), QQnxRasterBackingStore::~QQnxRasterBackingStore(), QWasmBackingStore::~QWasmBackingStore(), QWindowsDirect2DBackingStore::beginPaint(), QMinimalEglBackingStore::beginPaint(), QWasmBackingStore::beginPaint(), QRasterBackingStore::beginPaint(), QCALayerBackingStore::beginPaint(), QQnxRasterBackingStore::beginPaint(), QCocoaBackingStore::colorSpace(), QWindowsDirect2DBackingStore::endPaint(), QQnxRasterBackingStore::endPaint(), QXcbBackingStore::endPaint(), QtWaylandClient::QWaylandShmBackingStore::endPaint(), QCALayerBackingStore::eventFilter(), QCALayerBackingStore::flush(), QWindowsDirect2DBackingStore::flush(), flush(), QRhiBackingStore::flush(), QOpenGLCompositorBackingStore::flush(), QFbBackingStore::flush(), QHaikuRasterBackingStore::flush(), QMinimalBackingStore::flush(), QMinimalEglBackingStore::flush(), QOffscreenBackingStore::flush(), QQnxRasterBackingStore::flush(), QVkKhrDisplayBackingStore::flush(), QWasmBackingStore::flush(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QXcbBackingStore::flush(), QtWaylandClient::QWaylandShmBackingStore::flush(), QRasterBackingStore::format(), QWasmBackingStore::getUpdatedWebImage(), QOffscreenBackingStore::grabWindow(), QWindowsDirect2DBackingStore::paintDevice(), QtWaylandClient::QWaylandShmBackingStore::recreateBackBufferIfNeeded(), QXcbBackingStore::render(), QXcbSystemTrayBackingStore::render(), QXcbBackingStoreImage::resize(), QWindowsBackingStore::resize(), QFbBackingStore::resize(), QWindowsDirect2DBackingStore::resize(), QQnxRasterBackingStore::resize(), QWasmBackingStore::resize(), QXcbBackingStore::resize(), rhiFlush(), QOpenGLCompositorBackingStore::rhiFlush(), QCALayerBackingStore::rhiFlush(), QXcbBackingStore::rhiFlush(), QRasterBackingStore::scroll(), QQnxRasterBackingStore::scroll(), QWindowsDirect2DBackingStore::toImage(), QWasmBackingStore::updateTexture(), and QtWaylandClient::QWaylandShmBackingStore::waylandWindow().

Friends And Related Symbol Documentation

◆ QBackingStore

friend class QBackingStore
friend

Definition at line 183 of file qplatformbackingstore.h.


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