KWin
Loading...
Searching...
No Matches
drm_format_helper.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: 2023 Xaver Hugl <xaver.hugl@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10#include "kwin_export.h"
11
12#include <QHash>
13#include <QList>
14#include <QString>
15
16#include <epoxy/gl.h>
17#include <libdrm/drm_fourcc.h>
18#include <optional>
19#include <stdint.h>
20
21namespace KWin
22{
23
25{
26 uint32_t format = DRM_FORMAT_YUYV;
27 uint32_t widthDivisor = 1;
28 uint32_t heightDivisor = 1;
29};
31{
32 QList<struct YuvFormat> plane = {};
33};
34
35static const QHash<uint32_t, YuvConversion> s_drmConversions = {
36 {DRM_FORMAT_NV12, YuvConversion{
37 {YuvFormat{DRM_FORMAT_R8, 1, 1}, YuvFormat{DRM_FORMAT_GR88, 2, 2}},
38 }},
39};
40
41struct KWIN_EXPORT FormatInfo
42{
43 uint32_t drmFormat;
44 uint32_t bitsPerColor;
45 uint32_t alphaBits;
46 uint32_t bitsPerPixel;
48
49 std::optional<YuvConversion> yuvConversion() const
50 {
51 const auto it = s_drmConversions.find(drmFormat);
52 return it != s_drmConversions.end() ? *it : std::optional<YuvConversion>{};
53 }
54
55 static std::optional<FormatInfo> get(uint32_t drmFormat);
56 static QString drmFormatName(const QString &prefix, uint32_t format);
57};
58}
std::optional< YuvConversion > yuvConversion() const
QList< struct YuvFormat > plane