Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
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// Qt-Security score:significant reason:default
4
5#ifndef QOPENGLCOMPOSITOR_H
6#define QOPENGLCOMPOSITOR_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtOpenGL/qtopenglglobal.h>
20
21#include <QtCore/QTimer>
22#include <QtOpenGL/QOpenGLTextureBlitter>
23#include <QtGui/QMatrix4x4>
24#include <QtCore/private/qglobal_p.h>
25
27
28class QOpenGLContext;
29class QOpenGLFramebufferObject;
30class QWindow;
31class QPlatformTextureList;
32
33class QOpenGLCompositorBackingStore;
35{
36public:
38 virtual QWindow *sourceWindow() const = 0;
39 virtual const QPlatformTextureList *textures() const = 0;
40 virtual void beginCompositing() { }
41 virtual void endCompositing() { }
42 virtual void setBackingStore(QOpenGLCompositorBackingStore *backingStore) = 0;
43 virtual QOpenGLCompositorBackingStore *backingStore() const = 0;
44};
45
46class Q_OPENGL_EXPORT QOpenGLCompositor : public QObject
47{
48 Q_OBJECT
49
50public:
51 enum GrabOrientation {
52 Flipped,
53 NotFlipped,
54 };
55
56 static QOpenGLCompositor *instance();
57 static void destroy();
58
59 void setTargetWindow(QWindow *window, const QRect &nativeTargetGeometry);
60 void setTargetContext(QOpenGLContext *context);
61 void setRotation(int degrees);
62 QOpenGLContext *context() const { return m_context; }
63 QWindow *targetWindow() const { return m_targetWindow; }
64 QRect nativeTargetGeometry() const { return m_nativeTargetGeometry; }
65
66 void update();
67 QImage grab();
68
69 bool grabToFrameBufferObject(QOpenGLFramebufferObject *fbo, GrabOrientation orientation = Flipped);
70
71 QList<QOpenGLCompositorWindow *> windows() const { return m_windows; }
72 void addWindow(QOpenGLCompositorWindow *window);
73 void removeWindow(QOpenGLCompositorWindow *window);
74 void moveToTop(QOpenGLCompositorWindow *window);
75 void changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx);
76
77signals:
78 void topWindowChanged(QOpenGLCompositorWindow *window);
79
80private slots:
81 void handleRenderAllRequest();
82
83private:
84 QOpenGLCompositor();
85 ~QOpenGLCompositor();
86
87 void renderAll(QOpenGLFramebufferObject *fbo,
88 QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft);
89 void render(QOpenGLCompositorWindow *window,
90 QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft);
91 void ensureCorrectZOrder();
92
93 QOpenGLContext *m_context;
94 QWindow *m_targetWindow;
95 QRect m_nativeTargetGeometry;
96 int m_rotation;
97 QMatrix4x4 m_rotationMatrix;
98 QTimer m_updateTimer;
99 QOpenGLTextureBlitter m_blitter;
100 QList<QOpenGLCompositorWindow *> m_windows;
101};
102
103QT_END_NAMESPACE
104
105#endif // QOPENGLCOMPOSITOR_H
virtual QOpenGLCompositorBackingStore * backingStore() const =0
virtual const QPlatformTextureList * textures() const =0
virtual QWindow * sourceWindow() const =0
virtual void setBackingStore(QOpenGLCompositorBackingStore *backingStore)=0
A generic OpenGL-based compositor.
Combined button and popup list for selecting options.
static QOpenGLCompositor * compositor
static QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &sourceWindowRect, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter, QMatrix4x4 *rotationMatrix, QOpenGLTextureBlitter::Origin sourceOrigin)
void set(bool blend)