QtBase
v6.3.1
|
The QOffscreenSurface class represents an offscreen surface in the underlying platform. More...
#include <qoffscreensurface.h>
Signals | |
void | screenChanged (QScreen *screen) |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
The QOffscreenSurface class represents an offscreen surface in the underlying platform.
\inmodule QtGui
QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in an arbitrary thread without the need to create a QWindow.
Even though the surface is typically renderable, the surface's pixels are not accessible. QOffscreenSurface should only be used to create OpenGL resources such as textures or framebuffer objects.
An application will typically use QOffscreenSurface to perform some time-consuming tasks in a separate thread in order to avoid stalling the main rendering thread. Resources created in the QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.
How the offscreen surface is implemented depends on the underlying platform, but it will typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.
Definition at line 56 of file qoffscreensurface.h.
|
explicit |
Creates an offscreen surface for the targetScreen with the given parent.
The underlying platform surface is not created until create() is called.
Definition at line 104 of file qoffscreensurface.cpp.
QOffscreenSurface::~QOffscreenSurface | ( | ) |
Destroys the offscreen surface.
Definition at line 123 of file qoffscreensurface.cpp.
void QOffscreenSurface::create | ( | ) |
Allocates the platform resources associated with the offscreen surface.
It is at this point that the surface format set using setFormat() gets resolved into an actual native surface.
Call destroy() to free the platform resources if necessary.
Definition at line 151 of file qoffscreensurface.cpp.
void QOffscreenSurface::destroy | ( | ) |
Releases the native platform resources associated with this offscreen surface.
Definition at line 187 of file qoffscreensurface.cpp.
|
overridevirtual |
Returns the actual format of this offscreen surface.
After the offscreen surface has been created, this function will return the actual surface format of the surface. It might differ from the requested format if the requested format could not be fulfilled by the platform.
Implements QSurface.
Definition at line 256 of file qoffscreensurface.cpp.
QPlatformOffscreenSurface * QOffscreenSurface::handle | ( | ) | const |
Returns the platform offscreen surface corresponding to the offscreen surface.
Definition at line 339 of file qoffscreensurface.cpp.
bool QOffscreenSurface::isValid | ( | ) | const |
Returns true
if this offscreen surface is valid; otherwise returns false
.
The offscreen surface is valid if the platform resources have been successfully allocated.
Definition at line 210 of file qoffscreensurface.cpp.
QSurfaceFormat QOffscreenSurface::requestedFormat | ( | ) | const |
Returns the requested surfaceformat of this offscreen surface.
If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual offscreen surface format.
This is the value set with setFormat().
Definition at line 241 of file qoffscreensurface.cpp.
QScreen * QOffscreenSurface::screen | ( | ) | const |
Returns the screen to which the offscreen surface is connected.
Definition at line 280 of file qoffscreensurface.cpp.
|
signal |
This signal is emitted when an offscreen surface's screen changes, either by being set explicitly with setScreen(), or automatically when the window's screen is removed.
void QOffscreenSurface::setFormat | ( | const QSurfaceFormat & | format | ) |
Sets the offscreen surface format.
The surface format will be resolved in the create() function. Calling this function after create() will not re-resolve the surface format of the native surface.
Definition at line 225 of file qoffscreensurface.cpp.
Sets the screen to which the offscreen surface is connected.
If the offscreen surface has been created, it will be recreated on the newScreen.
Definition at line 293 of file qoffscreensurface.cpp.
|
overridevirtual |
Returns the size of the offscreen surface.
Implements QSurface.
Definition at line 269 of file qoffscreensurface.cpp.
|
overridevirtual |
Returns the surface type of the offscreen surface.
The surface type of an offscreen surface is always QSurface::OpenGLSurface.
Implements QSurface.
Definition at line 133 of file qoffscreensurface.cpp.