File indexing completed on 2024-05-12 05:31:41
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 0011 #include "opengl/gltexture.h" 0012 #include "opengl/openglcontext.h" 0013 0014 #include <QByteArray> 0015 #include <QList> 0016 #include <epoxy/egl.h> 0017 0018 namespace KWin 0019 { 0020 0021 class EglDisplay; 0022 class ShaderManager; 0023 struct DmaBufAttributes; 0024 0025 class KWIN_EXPORT EglContext : public OpenGlContext 0026 { 0027 public: 0028 EglContext(EglDisplay *display, EGLConfig config, ::EGLContext context); 0029 ~EglContext() override; 0030 0031 bool makeCurrent(EGLSurface surface = EGL_NO_SURFACE) const; 0032 void doneCurrent() const; 0033 std::shared_ptr<GLTexture> importDmaBufAsTexture(const DmaBufAttributes &attributes) const; 0034 0035 EglDisplay *displayObject() const; 0036 ::EGLContext handle() const; 0037 EGLConfig config() const; 0038 bool isValid() const; 0039 ShaderManager *shaderManager() const; 0040 0041 static std::unique_ptr<EglContext> create(EglDisplay *display, EGLConfig config, ::EGLContext sharedContext); 0042 0043 private: 0044 static ::EGLContext createContext(EglDisplay *display, EGLConfig config, ::EGLContext sharedContext); 0045 0046 EglDisplay *const m_display; 0047 const ::EGLContext m_handle; 0048 const EGLConfig m_config; 0049 std::unique_ptr<ShaderManager> m_shaderManager; 0050 uint32_t m_vao = 0; 0051 }; 0052 0053 }