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
25QT_BEGIN_NAMESPACE
26
27class QOpenGLContext;
28class QPlatformTextureList;
29class QRhiTexture;
30
31class Q_OPENGL_EXPORT QOpenGLCompositorBackingStore : public QPlatformBackingStore
32{
33public:
34 QOpenGLCompositorBackingStore(QWindow *window);
35 ~QOpenGLCompositorBackingStore();
36
37 QPaintDevice *paintDevice() override;
38
39 void beginPaint(const QRegion &region) override;
40
41 void flush(QWindow *window, const QRegion &region, 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 &region,
49 const QPoint &offset,
50 QPlatformTextureList *textures,
51 bool translucentBackground) override;
52
53 const QPlatformTextureList *textures() const { return m_textures; }
54
55 void notifyComposited();
56
57private:
58 void updateTexture();
59
60 QWindow *m_window;
61 QImage m_image;
62 QRegion m_dirty;
63 uint m_bsTexture;
64 QRhiTexture *m_bsTextureWrapper;
65 QOpenGLContext *m_bsTextureContext;
66 QPlatformTextureList *m_textures;
67 QPlatformTextureList *m_lockedWidgetTextures;
68 QRhi *m_rhi;
69};
70
71QT_END_NAMESPACE
72
73#endif // QOPENGLCOMPOSITORBACKINGSTORE_H
74

source code of qtbase/src/opengl/qopenglcompositorbackingstore_p.h