summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/platformcompositor
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/platformcompositor')
-rw-r--r--src/platformsupport/platformcompositor/platformcompositor.pro17
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp308
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor_p.h122
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp292
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h99
5 files changed, 0 insertions, 838 deletions
diff --git a/src/platformsupport/platformcompositor/platformcompositor.pro b/src/platformsupport/platformcompositor/platformcompositor.pro
deleted file mode 100644
index 81c31571d0..0000000000
--- a/src/platformsupport/platformcompositor/platformcompositor.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TARGET = QtPlatformCompositorSupport
-MODULE = platformcompositor_support
-
-QT = core-private gui-private
-CONFIG += static internal_module
-
-DEFINES += QT_NO_CAST_FROM_ASCII
-
-SOURCES += \
- qopenglcompositor.cpp \
- qopenglcompositorbackingstore.cpp
-
-HEADERS += \
- qopenglcompositor_p.h \
- qopenglcompositorbackingstore_p.h
-
-load(qt_module)
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
deleted file mode 100644
index 635bf0107f..0000000000
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLFramebufferObject>
-#include <QtGui/QWindow>
-#include <qpa/qplatformbackingstore.h>
-
-#include "qopenglcompositor_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QOpenGLCompositor
- \brief A generic OpenGL-based compositor
- \since 5.4
- \internal
- \ingroup qpa
-
- This class provides a lightweight compositor that maintains the
- basic stacking order of windows and composites them by drawing
- textured quads via OpenGL.
-
- It it meant to be used by platform plugins that run without a
- windowing system.
-
- It is up to the platform plugin to manage the lifetime of the
- compositor (instance(), destroy()), set the correct destination
- context and window as early as possible (setTarget()),
- register the composited windows as they are shown, activated,
- raised and lowered (addWindow(), moveToTop(), etc.), and to
- schedule repaints (update()).
-
- \note To get support for QWidget-based windows, just use
- QOpenGLCompositorBackingStore. It will automatically create
- textures from the raster-rendered content and trigger the
- necessary repaints.
- */
-
-static QOpenGLCompositor *compositor = 0;
-
-QOpenGLCompositor::QOpenGLCompositor()
- : m_context(0),
- m_targetWindow(0),
- m_rotation(0)
-{
- Q_ASSERT(!compositor);
- m_updateTimer.setSingleShot(true);
- m_updateTimer.setInterval(0);
- connect(&m_updateTimer, SIGNAL(timeout()), SLOT(handleRenderAllRequest()));
-}
-
-QOpenGLCompositor::~QOpenGLCompositor()
-{
- Q_ASSERT(compositor == this);
- m_blitter.destroy();
- compositor = 0;
-}
-
-void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow,
- const QRect &nativeTargetGeometry)
-{
- m_context = context;
- m_targetWindow = targetWindow;
- m_nativeTargetGeometry = nativeTargetGeometry;
-}
-
-void QOpenGLCompositor::setRotation(int degrees)
-{
- m_rotation = degrees;
- m_rotationMatrix.setToIdentity();
- m_rotationMatrix.rotate(degrees, 0, 0, 1);
-}
-
-void QOpenGLCompositor::update()
-{
- if (!m_updateTimer.isActive())
- m_updateTimer.start();
-}
-
-QImage QOpenGLCompositor::grab()
-{
- Q_ASSERT(m_context && m_targetWindow);
- m_context->makeCurrent(m_targetWindow);
- QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_nativeTargetGeometry.size()));
- renderAll(fbo.data());
- return fbo->toImage();
-}
-
-void QOpenGLCompositor::handleRenderAllRequest()
-{
- Q_ASSERT(m_context && m_targetWindow);
- m_context->makeCurrent(m_targetWindow);
- renderAll(0);
-}
-
-void QOpenGLCompositor::renderAll(QOpenGLFramebufferObject *fbo)
-{
- if (fbo)
- fbo->bind();
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glViewport(0, 0, m_nativeTargetGeometry.width(), m_nativeTargetGeometry.height());
-
- if (!m_blitter.isCreated())
- m_blitter.create();
-
- m_blitter.bind();
-
- for (int i = 0; i < m_windows.size(); ++i)
- m_windows.at(i)->beginCompositing();
-
- for (int i = 0; i < m_windows.size(); ++i)
- render(m_windows.at(i));
-
- m_blitter.release();
- if (!fbo)
- m_context->swapBuffers(m_targetWindow);
- else
- fbo->release();
-
- for (int i = 0; i < m_windows.size(); ++i)
- m_windows.at(i)->endCompositing();
-}
-
-struct BlendStateBinder
-{
- BlendStateBinder() : m_blend(false) {
- glDisable(GL_BLEND);
- }
- void set(bool blend) {
- if (blend != m_blend) {
- if (blend) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- } else {
- glDisable(GL_BLEND);
- }
- m_blend = blend;
- }
- }
- ~BlendStateBinder() {
- if (m_blend)
- glDisable(GL_BLEND);
- }
- bool m_blend;
-};
-
-static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
-{
- return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1,
- topLeftRect.width(), topLeftRect.height());
-}
-
-static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &sourceWindowRect,
- const QRect &targetWindowRect,
- QOpenGLTextureBlitter *blitter, QMatrix4x4 *rotationMatrix)
-{
- const QRect clipRect = textures->clipRect(idx);
- if (clipRect.isEmpty())
- return;
-
- const QRect rectInWindow = textures->geometry(idx).translated(sourceWindowRect.topLeft());
- const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
- const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
-
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
- if (rotationMatrix)
- target = *rotationMatrix * target;
-
- const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, rectInWindow.size(),
- QOpenGLTextureBlitter::OriginBottomLeft);
-
- blitter->blit(textures->textureId(idx), target, source);
-}
-
-void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
-{
- const QPlatformTextureList *textures = window->textures();
- if (!textures)
- return;
-
- const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
- float currentOpacity = 1.0f;
- BlendStateBinder blend;
- const QRect sourceWindowRect = window->sourceWindow()->geometry();
- for (int i = 0; i < textures->count(); ++i) {
- uint textureId = textures->textureId(i);
- const float opacity = window->sourceWindow()->opacity();
- if (opacity != currentOpacity) {
- currentOpacity = opacity;
- m_blitter.setOpacity(currentOpacity);
- }
-
- if (textures->count() > 1 && i == textures->count() - 1) {
- // Backingstore for a widget with QOpenGLWidget subwidgets
- blend.set(true);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
- if (m_rotation)
- target = m_rotationMatrix * target;
- m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
- } else if (textures->count() == 1) {
- // A regular QWidget window
- const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
- blend.set(translucent);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
- if (m_rotation)
- target = m_rotationMatrix * target;
- m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
- } else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- // Texture from an FBO belonging to a QOpenGLWidget or QQuickWidget
- blend.set(false);
- clippedBlit(textures, i, sourceWindowRect, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
- }
- }
-
- for (int i = 0; i < textures->count(); ++i) {
- if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- blend.set(true);
- clippedBlit(textures, i, sourceWindowRect, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
- }
- }
-
- m_blitter.setOpacity(1.0f);
-}
-
-QOpenGLCompositor *QOpenGLCompositor::instance()
-{
- if (!compositor)
- compositor = new QOpenGLCompositor;
- return compositor;
-}
-
-void QOpenGLCompositor::destroy()
-{
- delete compositor;
- compositor = 0;
-}
-
-void QOpenGLCompositor::addWindow(QOpenGLCompositorWindow *window)
-{
- if (!m_windows.contains(window)) {
- m_windows.append(window);
- emit topWindowChanged(window);
- }
-}
-
-void QOpenGLCompositor::removeWindow(QOpenGLCompositorWindow *window)
-{
- m_windows.removeOne(window);
- if (!m_windows.isEmpty())
- emit topWindowChanged(m_windows.last());
-}
-
-void QOpenGLCompositor::moveToTop(QOpenGLCompositorWindow *window)
-{
- m_windows.removeOne(window);
- m_windows.append(window);
- emit topWindowChanged(window);
-}
-
-void QOpenGLCompositor::changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx)
-{
- int idx = m_windows.indexOf(window);
- if (idx != -1 && idx != newIdx) {
- m_windows.move(idx, newIdx);
- if (newIdx == m_windows.size() - 1)
- emit topWindowChanged(m_windows.last());
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor_p.h b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
deleted file mode 100644
index 41a3288240..0000000000
--- a/src/platformsupport/platformcompositor/qopenglcompositor_p.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QOPENGLCOMPOSITOR_H
-#define QOPENGLCOMPOSITOR_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QTimer>
-#include <QtGui/QOpenGLTextureBlitter>
-#include <QtGui/QMatrix4x4>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLContext;
-class QOpenGLFramebufferObject;
-class QWindow;
-class QPlatformTextureList;
-
-class QOpenGLCompositorWindow
-{
-public:
- virtual ~QOpenGLCompositorWindow() { }
- virtual QWindow *sourceWindow() const = 0;
- virtual const QPlatformTextureList *textures() const = 0;
- virtual void beginCompositing() { }
- virtual void endCompositing() { }
-};
-
-class QOpenGLCompositor : public QObject
-{
- Q_OBJECT
-
-public:
- static QOpenGLCompositor *instance();
- static void destroy();
-
- void setTarget(QOpenGLContext *context, QWindow *window, const QRect &nativeTargetGeometry);
- void setRotation(int degrees);
- QOpenGLContext *context() const { return m_context; }
- QWindow *targetWindow() const { return m_targetWindow; }
-
- void update();
- QImage grab();
-
- QList<QOpenGLCompositorWindow *> windows() const { return m_windows; }
- void addWindow(QOpenGLCompositorWindow *window);
- void removeWindow(QOpenGLCompositorWindow *window);
- void moveToTop(QOpenGLCompositorWindow *window);
- void changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx);
-
-signals:
- void topWindowChanged(QOpenGLCompositorWindow *window);
-
-private slots:
- void handleRenderAllRequest();
-
-private:
- QOpenGLCompositor();
- ~QOpenGLCompositor();
-
- void renderAll(QOpenGLFramebufferObject *fbo);
- void render(QOpenGLCompositorWindow *window);
-
- QOpenGLContext *m_context;
- QWindow *m_targetWindow;
- QRect m_nativeTargetGeometry;
- int m_rotation;
- QMatrix4x4 m_rotationMatrix;
- QTimer m_updateTimer;
- QOpenGLTextureBlitter m_blitter;
- QList<QOpenGLCompositorWindow *> m_windows;
-};
-
-QT_END_NAMESPACE
-
-#endif // QOPENGLCOMPOSITOR_H
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
deleted file mode 100644
index 40400e2a19..0000000000
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QWindow>
-#include <QtGui/QPainter>
-#include <QtGui/QOffscreenSurface>
-#include <qpa/qplatformbackingstore.h>
-#include <private/qwindow_p.h>
-
-#include "qopenglcompositorbackingstore_p.h"
-#include "qopenglcompositor_p.h"
-
-#ifndef GL_UNPACK_ROW_LENGTH
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QOpenGLCompositorBackingStore
- \brief A backing store implementation for OpenGL
- \since 5.4
- \internal
- \ingroup qpa
-
- This implementation uploads raster-rendered widget windows into
- textures. It is meant to be used with QOpenGLCompositor that
- composites the textures onto a single native window using OpenGL.
- This means that multiple top-level widgets are supported without
- creating actual native windows for each of them.
-
- \note It is important to call notifyComposited() from the
- corresponding platform window's endCompositing() callback
- (inherited from QOpenGLCompositorWindow).
-
- \note When implementing QOpenGLCompositorWindow::textures() for
- windows of type RasterSurface or RasterGLSurface, simply return
- the list provided by this class' textures().
-*/
-
-QOpenGLCompositorBackingStore::QOpenGLCompositorBackingStore(QWindow *window)
- : QPlatformBackingStore(window),
- m_window(window),
- m_bsTexture(0),
- m_bsTextureContext(0),
- m_textures(new QPlatformTextureList),
- m_lockedWidgetTextures(0)
-{
-}
-
-QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore()
-{
- if (m_bsTexture) {
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- // With render-to-texture-widgets QWidget makes sure the TLW's shareContext() is
- // made current before destroying backingstores. That is however not the case for
- // windows with regular widgets only.
- QScopedPointer<QOffscreenSurface> tempSurface;
- if (!ctx) {
- ctx = QOpenGLCompositor::instance()->context();
- tempSurface.reset(new QOffscreenSurface);
- tempSurface->setFormat(ctx->format());
- tempSurface->create();
- ctx->makeCurrent(tempSurface.data());
- }
-
- if (m_bsTextureContext && ctx->shareGroup() == m_bsTextureContext->shareGroup())
- glDeleteTextures(1, &m_bsTexture);
- else
- qWarning("QOpenGLCompositorBackingStore: Texture is not valid in the current context");
-
- if (tempSurface)
- ctx->doneCurrent();
- }
-
- delete m_textures; // this does not actually own any GL resources
-}
-
-QPaintDevice *QOpenGLCompositorBackingStore::paintDevice()
-{
- return &m_image;
-}
-
-void QOpenGLCompositorBackingStore::updateTexture()
-{
- if (!m_bsTexture) {
- m_bsTextureContext = QOpenGLContext::currentContext();
- Q_ASSERT(m_bsTextureContext);
- glGenTextures(1, &m_bsTexture);
- glBindTexture(GL_TEXTURE_2D, m_bsTexture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_image.width(), m_image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- } else {
- glBindTexture(GL_TEXTURE_2D, m_bsTexture);
- }
-
- if (!m_dirty.isNull()) {
- QRegion fixed;
- QRect imageRect = m_image.rect();
-
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
- for (const QRect &rect : m_dirty) {
- QRect r = imageRect & rect;
- glPixelStorei(GL_UNPACK_ROW_LENGTH, m_image.width());
- glTexSubImage2D(GL_TEXTURE_2D, 0, r.x(), r.y(), r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.constScanLine(r.y()) + r.x() * 4);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- }
- } else {
- for (const QRect &rect : m_dirty) {
- // intersect with image rect to be sure
- QRect r = imageRect & rect;
-
- // if the rect is wide enough it's cheaper to just
- // extend it instead of doing an image copy
- if (r.width() >= imageRect.width() / 2) {
- r.setX(0);
- r.setWidth(imageRect.width());
- }
-
- fixed |= r;
- }
- for (const QRect &rect : fixed) {
- // if the sub-rect is full-width we can pass the image data directly to
- // OpenGL instead of copying, since there's no gap between scanlines
- if (rect.width() == imageRect.width()) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.constScanLine(rect.y()));
- } else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.copy(rect).constBits());
- }
- }
- }
-
- m_dirty = QRegion();
- }
-}
-
-void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
-{
- // Called for ordinary raster windows.
-
- Q_UNUSED(region);
- Q_UNUSED(offset);
-
- QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
- QOpenGLContext *dstCtx = compositor->context();
- Q_ASSERT(dstCtx);
-
- QWindow *dstWin = compositor->targetWindow();
- if (!dstWin)
- return;
-
- dstCtx->makeCurrent(dstWin);
- updateTexture();
- m_textures->clear();
- m_textures->appendTexture(nullptr, m_bsTexture, window->geometry());
-
- compositor->update();
-}
-
-void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
- QPlatformTextureList *textures,
- bool translucentBackground)
-{
- // QOpenGLWidget/QQuickWidget content provided as textures. The raster content goes on top.
-
- Q_UNUSED(region);
- Q_UNUSED(offset);
- Q_UNUSED(translucentBackground);
-
- QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
- QOpenGLContext *dstCtx = compositor->context();
- Q_ASSERT(dstCtx); // setTarget() must have been called before, e.g. from QEGLFSWindow
-
- // The compositor's context and the context to which QOpenGLWidget/QQuickWidget
- // textures belong are not the same. They share resources, though.
- Q_ASSERT(qt_window_private(window)->shareContext()->shareGroup() == dstCtx->shareGroup());
-
- QWindow *dstWin = compositor->targetWindow();
- if (!dstWin)
- return;
-
- dstCtx->makeCurrent(dstWin);
-
- QWindowPrivate::get(window)->lastComposeTime.start();
-
- m_textures->clear();
- for (int i = 0; i < textures->count(); ++i)
- m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i),
- textures->clipRect(i), textures->flags(i));
-
- updateTexture();
- m_textures->appendTexture(nullptr, m_bsTexture, window->geometry());
-
- textures->lock(true);
- m_lockedWidgetTextures = textures;
-
- compositor->update();
-}
-
-void QOpenGLCompositorBackingStore::notifyComposited()
-{
- if (m_lockedWidgetTextures) {
- QPlatformTextureList *textureList = m_lockedWidgetTextures;
- m_lockedWidgetTextures = 0; // may reenter so null before unlocking
- textureList->lock(false);
- }
-}
-
-void QOpenGLCompositorBackingStore::beginPaint(const QRegion &region)
-{
- m_dirty |= region;
-
- if (m_image.hasAlphaChannel()) {
- QPainter p(&m_image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- for (const QRect &r : region)
- p.fillRect(r, Qt::transparent);
- }
-}
-
-void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &staticContents)
-{
- Q_UNUSED(staticContents);
-
- QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
- QOpenGLContext *dstCtx = compositor->context();
- QWindow *dstWin = compositor->targetWindow();
- if (!dstWin)
- return;
-
- m_image = QImage(size, QImage::Format_RGBA8888);
-
- m_window->create();
-
- dstCtx->makeCurrent(dstWin);
- if (m_bsTexture) {
- glDeleteTextures(1, &m_bsTexture);
- m_bsTexture = 0;
- m_bsTextureContext = nullptr;
- }
-}
-
-QImage QOpenGLCompositorBackingStore::toImage() const
-{
- return m_image;
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h
deleted file mode 100644
index d88738ea8f..0000000000
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QOPENGLCOMPOSITORBACKINGSTORE_H
-#define QOPENGLCOMPOSITORBACKINGSTORE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qpa/qplatformbackingstore.h>
-#include <QImage>
-#include <QRegion>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLContext;
-class QPlatformTextureList;
-
-class QOpenGLCompositorBackingStore : public QPlatformBackingStore
-{
-public:
- QOpenGLCompositorBackingStore(QWindow *window);
- ~QOpenGLCompositorBackingStore();
-
- QPaintDevice *paintDevice() override;
-
- void beginPaint(const QRegion &region) override;
-
- void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
- void resize(const QSize &size, const QRegion &staticContents) override;
-
- QImage toImage() const override;
- void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
- QPlatformTextureList *textures,
- bool translucentBackground) override;
-
- const QPlatformTextureList *textures() const { return m_textures; }
-
- void notifyComposited();
-
-private:
- void updateTexture();
-
- QWindow *m_window;
- QImage m_image;
- QRegion m_dirty;
- uint m_bsTexture;
- QOpenGLContext *m_bsTextureContext;
- QPlatformTextureList *m_textures;
- QPlatformTextureList *m_lockedWidgetTextures;
-};
-
-QT_END_NAMESPACE
-
-#endif // QOPENGLCOMPOSITORBACKINGSTORE_H