Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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, qreal sourceTransformFactor=0)
 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 createRhi (QWindow *window, QPlatformBackingStoreRhiConfig config)
QRhirhi (QWindow *window) const
void surfaceAboutToBeDestroyed ()
void graphicsDeviceReportedLost (QWindow *window)

Friends

class QBackingStore

Detailed Description

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

Since
5.0

\preliminary

Definition at line 130 of file qplatformbackingstore.h.

Member Enumeration Documentation

◆ FlushResult

Enumerator
FlushSuccess 
FlushFailed 
FlushFailedDueToLostDevice 

Definition at line 133 of file qplatformbackingstore.h.

◆ TextureFlag

Enumerator
TextureSwizzle 
TextureFlip 
TexturePremultiplied 

Definition at line 159 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 289 of file qplatformbackingstore.cpp.

◆ ~QPlatformBackingStore()

QPlatformBackingStore::~QPlatformBackingStore ( )
virtual

Destroys this surface.

Definition at line 297 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 323 of file qplatformbackingstore.cpp.

◆ beginPaint()

void QPlatformBackingStore::beginPaint ( const QRegion & )
virtual

◆ createRhi()

void QPlatformBackingStore::createRhi ( QWindow * window,
QPlatformBackingStoreRhiConfig config )

Definition at line 372 of file qplatformbackingstore.cpp.

◆ endPaint()

void QPlatformBackingStore::endPaint ( )
virtual

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

Definition at line 190 of file qplatformbackingstore.cpp.

Referenced by testing.tools.encode_pdf_filter._SinkPdfStream::close().

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 352 of file qplatformbackingstore.cpp.

◆ graphicsDeviceReportedLost()

void QPlatformBackingStore::graphicsDeviceReportedLost ( QWindow * window)

Definition at line 399 of file qplatformbackingstore.cpp.

◆ paintDevice()

◆ resize()

◆ rhi()

QRhi * QPlatformBackingStore::rhi ( QWindow * window) const

Definition at line 393 of file qplatformbackingstore.cpp.

◆ rhiFlush()

QPlatformBackingStore::FlushResult QPlatformBackingStore::rhiFlush ( QWindow * window,
qreal sourceDevicePixelRatio,
const QRegion & region,
const QPoint & offset,
QPlatformTextureList * textures,
bool translucentBackground,
qreal sourceTransformFactor = 0 )
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 QCALayerBackingStore, QOpenGLCompositorBackingStore, and QXcbBackingStore.

Definition at line 211 of file qplatformbackingstore.cpp.

◆ 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 QCALayerBackingStore, QDirectFbBackingStore, QOffscreenBackingStore, QQnxRasterBackingStore, QRasterBackingStore, QtWaylandClient::QWaylandShmBackingStore, QWindowsBackingStore, QXcbBackingStore, and QXcbNativeBackingStore.

Definition at line 363 of file qplatformbackingstore.cpp.

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

Definition at line 239 of file qplatformbackingstore.cpp.

◆ 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 270 of file qplatformbackingstore.cpp.

◆ window()

QWindow * QPlatformBackingStore::window ( ) const

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

Definition at line 306 of file qplatformbackingstore.cpp.

◆ QBackingStore

friend class QBackingStore
friend

Definition at line 187 of file qplatformbackingstore.h.


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