| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QOPENGLCOMPOSITORBACKINGSTORE_H |
| 5 | #define QOPENGLCOMPOSITORBACKINGSTORE_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtOpenGL/qtopenglglobal.h> |
| 19 | |
| 20 | #include <qpa/qplatformbackingstore.h> |
| 21 | #include <QImage> |
| 22 | #include <QRegion> |
| 23 | #include <private/qglobal_p.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QOpenGLContext; |
| 28 | class QPlatformTextureList; |
| 29 | class QRhiTexture; |
| 30 | |
| 31 | class Q_OPENGL_EXPORT QOpenGLCompositorBackingStore : public QPlatformBackingStore |
| 32 | { |
| 33 | public: |
| 34 | QOpenGLCompositorBackingStore(QWindow *window); |
| 35 | ~QOpenGLCompositorBackingStore(); |
| 36 | |
| 37 | QPaintDevice *paintDevice() override; |
| 38 | |
| 39 | void beginPaint(const QRegion ®ion) override; |
| 40 | |
| 41 | void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; |
| 42 | void resize(const QSize &size, const QRegion &staticContents) override; |
| 43 | |
| 44 | QImage toImage() const override; |
| 45 | |
| 46 | FlushResult rhiFlush(QWindow *window, |
| 47 | qreal sourceDevicePixelRatio, |
| 48 | const QRegion ®ion, |
| 49 | const QPoint &offset, |
| 50 | QPlatformTextureList *textures, |
| 51 | bool translucentBackground, |
| 52 | qreal sourceTransformFactor = 0) override; |
| 53 | |
| 54 | const QPlatformTextureList *textures() const { return m_textures; } |
| 55 | |
| 56 | void notifyComposited(); |
| 57 | |
| 58 | private: |
| 59 | void updateTexture(); |
| 60 | |
| 61 | QWindow *m_window; |
| 62 | QImage m_image; |
| 63 | QRegion m_dirty; |
| 64 | uint m_bsTexture; |
| 65 | QRhiTexture *m_bsTextureWrapper; |
| 66 | QOpenGLContext *m_bsTextureContext; |
| 67 | QPlatformTextureList *m_textures; |
| 68 | QPlatformTextureList *m_lockedWidgetTextures; |
| 69 | QRhi *m_rhi; |
| 70 | }; |
| 71 | |
| 72 | QT_END_NAMESPACE |
| 73 | |
| 74 | #endif // QOPENGLCOMPOSITORBACKINGSTORE_H |
| 75 | |