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());
118 if (
rect.width() == imageRect.width()) {
131 if (!m_bsTextureWrapper) {
133 m_bsTextureWrapper->
createFrom({m_bsTexture, 0});
163 if (!dstCtx->makeCurrent(dstWin))
174 qreal sourceDevicePixelRatio,
178 bool translucentBackground)
203 if (!dstCtx->makeCurrent(dstWin))
227 if (m_lockedWidgetTextures) {
229 m_lockedWidgetTextures = 0;
230 textureList->
lock(
false);
241 for (
const QRect &
r : region)
262 dstCtx->makeCurrent(dstWin);
264 delete m_bsTextureWrapper;
265 m_bsTextureWrapper =
nullptr;
266 glDeleteTextures(1, &m_bsTexture);
268 m_bsTextureContext =
nullptr;
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
virtual void setBackingStore(QOpenGLCompositorBackingStore *backingStore)=0
A generic OpenGL-based compositor.
static QOpenGLCompositor * instance()
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 void setX(int x) noexcept
Sets the left edge of the rectangle to the given x coordinate.
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)
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
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint const GLuint GLuint const GLuint * textures
GLenum GLuint GLintptr offset