File indexing completed on 2025-03-16 08:15:00
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 #include "kwin_export.h" 0011 0012 #include <QHash> 0013 #include <QList> 0014 #include <QString> 0015 0016 #include <epoxy/gl.h> 0017 #include <libdrm/drm_fourcc.h> 0018 #include <optional> 0019 #include <stdint.h> 0020 0021 namespace KWin 0022 { 0023 0024 struct YuvFormat 0025 { 0026 uint32_t format = DRM_FORMAT_YUYV; 0027 uint32_t widthDivisor = 1; 0028 uint32_t heightDivisor = 1; 0029 }; 0030 struct YuvConversion 0031 { 0032 QList<struct YuvFormat> plane = {}; 0033 }; 0034 0035 static const QHash<uint32_t, YuvConversion> s_drmConversions = { 0036 {DRM_FORMAT_NV12, YuvConversion{ 0037 {YuvFormat{DRM_FORMAT_R8, 1, 1}, YuvFormat{DRM_FORMAT_GR88, 2, 2}}, 0038 }}, 0039 }; 0040 0041 struct KWIN_EXPORT FormatInfo 0042 { 0043 uint32_t drmFormat; 0044 uint32_t bitsPerColor; 0045 uint32_t alphaBits; 0046 uint32_t bitsPerPixel; 0047 GLint openglFormat; 0048 0049 std::optional<YuvConversion> yuvConversion() const 0050 { 0051 const auto it = s_drmConversions.find(drmFormat); 0052 return it != s_drmConversions.end() ? *it : std::optional<YuvConversion>{}; 0053 } 0054 0055 static std::optional<FormatInfo> get(uint32_t drmFormat); 0056 static QString drmFormatName(const QString &prefix, uint32_t format); 0057 }; 0058 }