KWin
Loading...
Searching...
No Matches
eglplatformcontext.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
6 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include <epoxy/egl.h>
14
15#include <qpa/qplatformopenglcontext.h>
16
17#include <unordered_map>
18
19namespace KWin
20{
21
22class GLFramebuffer;
23class GLTexture;
24class GraphicsBuffer;
25class EglDisplay;
26class EglContext;
27
28namespace QPA
29{
30
31class Window;
32
34{
35public:
36 EGLRenderTarget(GraphicsBuffer *buffer, std::unique_ptr<GLFramebuffer> fbo, std::shared_ptr<GLTexture> texture);
38
40 std::unique_ptr<GLFramebuffer> fbo;
41 std::shared_ptr<GLTexture> texture;
42};
43
44class EGLPlatformContext : public QObject, public QPlatformOpenGLContext
45{
46 Q_OBJECT
47
48public:
49 EGLPlatformContext(QOpenGLContext *context, EglDisplay *display);
50 ~EGLPlatformContext() override;
51
52 bool makeCurrent(QPlatformSurface *surface) override;
53 void doneCurrent() override;
54 QSurfaceFormat format() const override;
55 bool isValid() const override;
56 bool isSharing() const override;
57 GLuint defaultFramebufferObject(QPlatformSurface *surface) const override;
58 QFunctionPointer getProcAddress(const char *procName) override;
59 void swapBuffers(QPlatformSurface *surface) override;
60
61private:
62 void create(const QSurfaceFormat &format, ::EGLContext shareContext);
63 void updateFormatFromContext();
64
65 EglDisplay *m_eglDisplay = nullptr;
66 QSurfaceFormat m_format;
67 EGLConfig m_config = EGL_NO_CONFIG_KHR;
68 std::unique_ptr<EglContext> m_eglContext;
69 std::unordered_map<GraphicsBuffer *, std::shared_ptr<EGLRenderTarget>> m_renderTargets;
70 std::vector<std::shared_ptr<EGLRenderTarget>> m_zombieRenderTargets;
71 std::shared_ptr<EGLRenderTarget> m_current;
72};
73
74} // namespace QPA
75} // namespace KWin
GLuint defaultFramebufferObject(QPlatformSurface *surface) const override
EGLPlatformContext(QOpenGLContext *context, EglDisplay *display)
QFunctionPointer getProcAddress(const char *procName) override
void swapBuffers(QPlatformSurface *surface) override
bool makeCurrent(QPlatformSurface *surface) override
QSurfaceFormat format() const override
std::unique_ptr< GLFramebuffer > fbo
EGLRenderTarget(GraphicsBuffer *buffer, std::unique_ptr< GLFramebuffer > fbo, std::shared_ptr< GLTexture > texture)
std::shared_ptr< GLTexture > texture