4#include <QtGui/QOpenGLContext>
5#include <QtGui/QWindow>
6#include <QtGui/QPainter>
7#include <qpa/qplatformbackingstore.h>
8#include <private/qwindow_p.h>
14#ifndef GL_UNPACK_ROW_LENGTH
15#define GL_UNPACK_ROW_LENGTH 0x0CF2
47 m_bsTextureContext(0),
49 m_lockedWidgetTextures(0),
56 if (m_bsTexture && m_rhi) {
57 delete m_bsTextureWrapper;
61 glDeleteTextures(1, &m_bsTexture);
72void QOpenGLCompositorBackingStore::updateTexture()
77 glGenTextures(1, &m_bsTexture);
78 glBindTexture(GL_TEXTURE_2D, m_bsTexture);
79 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
80 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
85 glBindTexture(GL_TEXTURE_2D, m_bsTexture);
93 if (!
ctx->isOpenGLES() ||
ctx->format().majorVersion() >= 3) {
108 if (
r.width() >= imageRect.
width() / 2) {
110 r.setWidth(imageRect.
width());
131 if (!m_bsTextureWrapper) {
133 m_bsTextureWrapper->
createFrom({m_bsTexture, 0});
171 qreal sourceDevicePixelRatio,
175 bool translucentBackground)
224 if (m_lockedWidgetTextures) {
226 m_lockedWidgetTextures = 0;
227 textureList->
lock(
false);
238 for (
const QRect &
r : region)
259 delete m_bsTextureWrapper;
260 m_bsTextureWrapper =
nullptr;
261 glDeleteTextures(1, &m_bsTexture);
263 m_bsTextureContext =
nullptr;
void start() noexcept
Starts this timer.
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
const uchar * constScanLine(int) const
Returns a pointer to the pixel data at the scanline with index i.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
const uchar * constBits() const
Returns a pointer to the first pixel data.
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override
Flushes the given region from the specified window.
FlushResult rhiFlush(QWindow *window, qreal sourceDevicePixelRatio, const QRegion ®ion, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground) override
Flushes the given region from the specified window, and compositing it with the specified textures li...
~QOpenGLCompositorBackingStore()
QOpenGLCompositorBackingStore(QWindow *window)
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
void resize(const QSize &size, const QRegion &staticContents) override
void beginPaint(const QRegion ®ion) override
This function is called before painting onto the surface begins, with the region in which the paintin...
const QPlatformTextureList * textures() const
A generic OpenGL-based compositor.
static QOpenGLCompositor * instance()
QOpenGLContext * context() const
QWindow * targetWindow() const
bool makeCurrent(QSurface *surface)
Makes the context current in the current thread, against the given surface.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
The QPainter class performs low-level painting on widgets and other paint devices.
void appendTexture(void *source, QRhiTexture *texture, const QRect &geometry, const QRect &clipRect=QRect(), Flags flags={ })
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
virtual bool createFrom(NativeTexture src)
Similar to create(), except that no new native textures are created.
bool makeThreadLocalNativeContextCurrent()
With OpenGL this makes the OpenGL context current on the current thread.
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
static QWindowPrivate * get(QWindow *window)
QElapsedTimer lastComposeTime
Combined button and popup list for selecting options.
QTextStream & fixed(QTextStream &stream)
Calls QTextStream::setRealNumberNotation(QTextStream::FixedNotation) on stream and returns stream.
static QOpenGLCompositor * compositor
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint const GLuint GLuint const GLuint * textures
GLenum GLuint GLintptr offset