Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qopenglcompositor_p.h
Go to the documentation of this file.
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 QOPENGLCOMPOSITOR_H
5#define QOPENGLCOMPOSITOR_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 <QtCore/QTimer>
21#include <QtOpenGL/QOpenGLTextureBlitter>
22#include <QtGui/QMatrix4x4>
23#include <QtCore/private/qglobal_p.h>
24
26
27class QOpenGLContext;
29class QWindow;
31
33{
34public:
36 virtual QWindow *sourceWindow() const = 0;
37 virtual const QPlatformTextureList *textures() const = 0;
38 virtual void beginCompositing() { }
39 virtual void endCompositing() { }
40};
41
42class Q_OPENGL_EXPORT QOpenGLCompositor : public QObject
43{
45
46public:
47 static QOpenGLCompositor *instance();
48 static void destroy();
49
50 void setTargetWindow(QWindow *window, const QRect &nativeTargetGeometry);
51 void setTargetContext(QOpenGLContext *context);
52 void setRotation(int degrees);
53 QOpenGLContext *context() const { return m_context; }
54 QWindow *targetWindow() const { return m_targetWindow; }
55
56 void update();
57 QImage grab();
58
59 QList<QOpenGLCompositorWindow *> windows() const { return m_windows; }
60 void addWindow(QOpenGLCompositorWindow *window);
61 void removeWindow(QOpenGLCompositorWindow *window);
62 void moveToTop(QOpenGLCompositorWindow *window);
63 void changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx);
64
67
68private slots:
69 void handleRenderAllRequest();
70
71private:
74
75 void renderAll(QOpenGLFramebufferObject *fbo);
77 void ensureCorrectZOrder();
78
79 QOpenGLContext *m_context;
80 QWindow *m_targetWindow;
81 QRect m_nativeTargetGeometry;
82 int m_rotation;
83 QMatrix4x4 m_rotationMatrix;
84 QTimer m_updateTimer;
85 QOpenGLTextureBlitter m_blitter;
87};
88
90
91#endif // QOPENGLCOMPOSITOR_H
\inmodule QtGui
Definition qimage.h:37
Definition qlist.h:74
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtCore
Definition qobject.h:90
virtual const QPlatformTextureList * textures() const =0
virtual QWindow * sourceWindow() const =0
A generic OpenGL-based compositor.
QOpenGLContext * context() const
QList< QOpenGLCompositorWindow * > windows() const
QWindow * targetWindow() const
void topWindowChanged(QOpenGLCompositorWindow *window)
\inmodule QtGui
The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object.
The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qtimer.h:20
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
static void * context
#define Q_OBJECT
#define slots
#define signals
aWidget window() -> setWindowTitle("New Window Title")
[2]
myWidget render(this)