![]() |
Qt 6.x
The Qt SDK
|
The QBackingStore class provides a drawing area for QWindow. More...
#include <qbackingstore.h>
Public Member Functions | |
QBackingStore (QWindow *window) | |
Constructs an empty surface for the given top-level window. | |
~QBackingStore () | |
Destroys this surface. | |
QWindow * | window () const |
Returns a pointer to the top-level window associated with this surface. | |
QPaintDevice * | paintDevice () |
Returns the paint device for this surface. | |
void | flush (const QRegion ®ion, QWindow *window=nullptr, const QPoint &offset=QPoint()) |
Flushes the given region from the specified window onto the screen. | |
void | resize (const QSize &size) |
Sets the size of the window surface to size. | |
QSize | size () const |
Returns the current size of the window surface. | |
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. | |
void | beginPaint (const QRegion &) |
Begins painting on the backing store surface in the given region. | |
void | endPaint () |
Ends painting. | |
void | setStaticContents (const QRegion ®ion) |
Set region as the static contents of this window. | |
QRegion | staticContents () const |
Returns a QRegion representing the area of the window that has static contents. | |
bool | hasStaticContents () const |
Returns a boolean indicating if this window has static contents or not. | |
QPlatformBackingStore * | handle () const |
Returns a pointer to the QPlatformBackingStore implementation. | |
The QBackingStore class provides a drawing area for QWindow.
QBackingStore enables the use of QPainter to paint on a QWindow with type RasterSurface. The other way of rendering to a QWindow is through the use of OpenGL with QOpenGLContext.
A QBackingStore contains a buffered representation of the window contents, and thus supports partial updates by using QPainter to only update a sub region of the window contents.
QBackingStore might be used by an application that wants to use QPainter without OpenGL acceleration and without the extra overhead of using the QWidget or QGraphicsView UI stacks. For an example of how to use QBackingStore see the \l{Raster Window Example}.
Definition at line 23 of file qbackingstore.h.
|
explicit |
Constructs an empty surface for the given top-level window.
Definition at line 80 of file qbackingstore.cpp.
References handle(), and window().
QBackingStore::~QBackingStore | ( | ) |
Destroys this surface.
Definition at line 93 of file qbackingstore.cpp.
References QBackingStorePrivate::platformBackingStore.
Begins painting on the backing store surface in the given region.
You should call this function before using the paintDevice() to paint.
Definition at line 116 of file qbackingstore.cpp.
References QBackingStorePrivate::backingStoreDevicePixelRatio(), QPlatformBackingStore::beginPaint(), QImage::data_ptr(), device, QBackingStorePrivate::deviceIndependentToNativeFactor(), QImage::devicePixelRatio(), dpr(), handle(), QBackingStorePrivate::highDpiBackingstore, QInternal::Image, QHighDpiScaling::isActive(), QScopedPointer< T, Cleanup >::isNull(), QPlatformBackingStore::paintDevice(), QScopedPointer< T, Cleanup >::reset(), resize(), QHighDpi::scale(), QImage::setDevicePixelRatio(), QImage::size(), and size().
Referenced by QRasterWindowPrivate::beginPaint(), QVideoWindowPrivate::render(), and QSGSoftwareRenderer::render().
void QBackingStore::endPaint | ( | ) |
Ends painting.
You should call this function after painting with the paintDevice() has ended.
Definition at line 173 of file qbackingstore.cpp.
References QPlatformBackingStore::endPaint(), handle(), paintDevice(), and qWarning.
Referenced by QRasterWindowPrivate::endPaint(), QVideoWindowPrivate::render(), and QSGSoftwareRenderer::render().
void QBackingStore::flush | ( | const QRegion & | region, |
QWindow * | window = nullptr , |
||
const QPoint & | offset = QPoint() |
||
) |
Flushes the given region from the specified window onto the screen.
The window must either be the top level window represented by this backingstore, or a non-transient child of that window. Passing \nullptr falls back to using the backingstore's top level window.
If the window is a child window, the region should be in child window coordinates, and the offset should be the child window's offset in relation to the backingstore's top level window.
You should call this function after ending painting with endPaint().
Definition at line 195 of file qbackingstore.cpp.
References QRegion::boundingRect(), QBackingStorePrivate::deviceIndependentToNativeFactor(), QPlatformBackingStore::flush(), handle(), Q_ASSERT, qAbs(), qMax(), qWarning, QHighDpi::scale(), QRect::topLeft(), QRegion::translate(), window(), QPoint::x(), and QPoint::y().
Referenced by QRasterWindowPrivate::flush(), QVideoWindowPrivate::render(), and QSGSoftwareRenderThread::syncAndRender().
QPlatformBackingStore * QBackingStore::handle | ( | ) | const |
Returns a pointer to the QPlatformBackingStore implementation.
Definition at line 341 of file qbackingstore.cpp.
References QPlatformIntegration::createPlatformBackingStore(), QBackingStorePrivate::platformBackingStore, QGuiApplicationPrivate::platformIntegration(), and QBackingStorePrivate::window.
Referenced by QBackingStore(), beginPaint(), QWidgetPrivate::create(), endPaint(), QSGSoftwareRenderThread::event(), flush(), QWindowsDirect2DNativeInterface::nativeResourceForBackingStore(), QWindowsGdiNativeInterface::nativeResourceForBackingStore(), paintDevice(), resize(), QWidgetRepaintManager::rhi(), and scroll().
bool QBackingStore::hasStaticContents | ( | ) | const |
Returns a boolean indicating if this window has static contents or not.
Definition at line 284 of file qbackingstore.cpp.
References QRegion::isEmpty(), and QBackingStorePrivate::staticContents.
QPaintDevice * QBackingStore::paintDevice | ( | ) |
Returns the paint device for this surface.
Definition at line 155 of file qbackingstore.cpp.
References QScopedPointer< T, Cleanup >::data(), device, handle(), QBackingStorePrivate::highDpiBackingstore, QInternal::Image, QHighDpiScaling::isActive(), and QPlatformBackingStore::paintDevice().
Referenced by endPaint(), QVideoWindowPrivate::render(), and QSGSoftwareRenderer::render().
Sets the size of the window surface to size.
Definition at line 230 of file qbackingstore.cpp.
References QBackingStorePrivate::deviceIndependentToNativeFactor(), handle(), QPlatformBackingStore::resize(), QHighDpi::scale(), QBackingStorePrivate::size, size(), and QBackingStorePrivate::staticContents.
Referenced by beginPaint(), QRasterWindowPrivate::beginPaint(), QSGSoftwareRenderThread::event(), and QVideoWindowPrivate::render().
bool QBackingStore::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.
Returns true
if the area was scrolled successfully; false otherwise.
Definition at line 250 of file qbackingstore.cpp.
References area(), QBackingStorePrivate::deviceIndependentToNativeFactor(), handle(), qFloor(), QHighDpi::scale(), and QPlatformBackingStore::scroll().
Referenced by QWidgetRepaintManager::bltRect().
Set region as the static contents of this window.
Definition at line 267 of file qbackingstore.cpp.
References QBackingStorePrivate::staticContents.
QSize QBackingStore::size | ( | ) | const |
Returns the current size of the window surface.
Definition at line 239 of file qbackingstore.cpp.
References QBackingStorePrivate::size.
Referenced by beginPaint(), QRasterWindowPrivate::beginPaint(), QSGSoftwareRenderThread::event(), QVideoWindowPrivate::render(), resize(), QWidgetRepaintManager::staticContents(), and QWidgetRepaintManager::sync().
QRegion QBackingStore::staticContents | ( | ) | const |
Returns a QRegion representing the area of the window that has static contents.
Definition at line 276 of file qbackingstore.cpp.
References QBackingStorePrivate::staticContents.
QWindow * QBackingStore::window | ( | ) | const |
Returns a pointer to the top-level window associated with this surface.
Definition at line 102 of file qbackingstore.cpp.
References QBackingStorePrivate::window.
Referenced by QBackingStore(), and flush().