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
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;
28class QOpenGLFramebufferObject;
29class QWindow;
30class QPlatformTextureList;
31
32class QOpenGLCompositorBackingStore;
34{
35public:
37 virtual QWindow *sourceWindow() const = 0;
38 virtual const QPlatformTextureList *textures() const = 0;
39 virtual void beginCompositing() { }
40 virtual void endCompositing() { }
41 virtual void setBackingStore(QOpenGLCompositorBackingStore *backingStore) = 0;
42 virtual QOpenGLCompositorBackingStore *backingStore() const = 0;
43};
44
45class Q_OPENGL_EXPORT QOpenGLCompositor : public QObject
46{
47 Q_OBJECT
48
49public:
50 enum GrabOrientation {
51 Flipped,
52 NotFlipped,
53 };
54
55 static QOpenGLCompositor *instance();
56 static void destroy();
57
58 void setTargetWindow(QWindow *window, const QRect &nativeTargetGeometry);
59 void setTargetContext(QOpenGLContext *context);
60 void setRotation(int degrees);
61 QOpenGLContext *context() const { return m_context; }
62 QWindow *targetWindow() const { return m_targetWindow; }
63 QRect nativeTargetGeometry() const { return m_nativeTargetGeometry; }
64
65 void update();
66 QImage grab();
67
68 bool grabToFrameBufferObject(QOpenGLFramebufferObject *fbo, GrabOrientation orientation = Flipped);
69
70 QList<QOpenGLCompositorWindow *> windows() const { return m_windows; }
71 void addWindow(QOpenGLCompositorWindow *window);
72 void removeWindow(QOpenGLCompositorWindow *window);
73 void moveToTop(QOpenGLCompositorWindow *window);
74 void changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx);
75
76signals:
77 void topWindowChanged(QOpenGLCompositorWindow *window);
78
79private slots:
80 void handleRenderAllRequest();
81
82private:
83 QOpenGLCompositor();
84 ~QOpenGLCompositor();
85
86 void renderAll(QOpenGLFramebufferObject *fbo,
87 QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft);
88 void render(QOpenGLCompositorWindow *window,
89 QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft);
90 void ensureCorrectZOrder();
91
92 QOpenGLContext *m_context;
93 QWindow *m_targetWindow;
94 QRect m_nativeTargetGeometry;
95 int m_rotation;
96 QMatrix4x4 m_rotationMatrix;
97 QTimer m_updateTimer;
98 QOpenGLTextureBlitter m_blitter;
99 QList<QOpenGLCompositorWindow *> m_windows;
100};
101
102QT_END_NAMESPACE
103
104#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)