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 "kwin_export.h" 0012 0013 #include <QByteArray> 0014 #include <QHash> 0015 #include <QList> 0016 #include <QSize> 0017 #include <epoxy/egl.h> 0018 0019 namespace KWin 0020 { 0021 0022 struct DmaBufAttributes; 0023 class GLTexture; 0024 0025 class KWIN_EXPORT EglDisplay 0026 { 0027 public: 0028 struct DrmFormatInfo 0029 { 0030 QList<uint64_t> allModifiers; 0031 QList<uint64_t> nonExternalOnlyModifiers; 0032 QList<uint64_t> externalOnlyModifiers; 0033 }; 0034 0035 EglDisplay(::EGLDisplay display, const QList<QByteArray> &extensions, bool owning = true); 0036 ~EglDisplay(); 0037 0038 QList<QByteArray> extensions() const; 0039 ::EGLDisplay handle() const; 0040 bool hasExtension(const QByteArray &name) const; 0041 0042 QString renderNode() const; 0043 0044 bool supportsBufferAge() const; 0045 bool supportsNativeFence() const; 0046 0047 QHash<uint32_t, QList<uint64_t>> nonExternalOnlySupportedDrmFormats() const; 0048 QHash<uint32_t, DrmFormatInfo> allSupportedDrmFormats() const; 0049 bool isExternalOnly(uint32_t format, uint64_t modifier) const; 0050 0051 EGLImageKHR importDmaBufAsImage(const DmaBufAttributes &dmabuf) const; 0052 EGLImageKHR importDmaBufAsImage(const DmaBufAttributes &dmabuf, int plane, int format, const QSize &size) const; 0053 0054 static std::unique_ptr<EglDisplay> create(::EGLDisplay display, bool owning = true); 0055 0056 private: 0057 QHash<uint32_t, DrmFormatInfo> queryImportFormats() const; 0058 0059 const ::EGLDisplay m_handle; 0060 const QList<QByteArray> m_extensions; 0061 const bool m_owning; 0062 0063 const bool m_supportsBufferAge; 0064 const bool m_supportsNativeFence; 0065 const QHash<uint32_t, DrmFormatInfo> m_importFormats; 0066 }; 0067 0068 }