KWin
Loading...
Searching...
No Matches
linuxdmabufv1clientbuffer_p.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2018 Fredrik Höglund <fredrik@kde.org>
3 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
4 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
5 SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com>
6
7 Based on the libweston implementation,
8 SPDX-FileCopyrightText: 2014, 2015 Collabora, Ltd.
9
10 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
11*/
12#pragma once
13
14#include "display.h"
16#include "utils/ramfile.h"
17
18#include "qwayland-server-linux-dmabuf-unstable-v1.h"
19
20#include <QDebug>
21#include <QList>
22#include <QPointer>
23
24#include <drm_fourcc.h>
25
26namespace KWin
27{
28
29class LinuxDmaBufV1FormatTable;
30
31class LinuxDmaBufV1ClientBufferIntegrationPrivate : public QtWaylandServer::zwp_linux_dmabuf_v1
32{
33public:
35
37 std::unique_ptr<LinuxDmaBufV1Feedback> defaultFeedback;
38 std::unique_ptr<LinuxDmaBufV1FormatTable> table;
40 QPointer<RenderBackend> renderBackend;
41 QHash<uint32_t, QList<uint64_t>> supportedModifiers;
42
43protected:
44 void zwp_linux_dmabuf_v1_bind_resource(Resource *resource) override;
45 void zwp_linux_dmabuf_v1_destroy(Resource *resource) override;
46 void zwp_linux_dmabuf_v1_create_params(Resource *resource, uint32_t params_id) override;
47 void zwp_linux_dmabuf_v1_get_default_feedback(Resource *resource, uint32_t id) override;
48 void zwp_linux_dmabuf_v1_get_surface_feedback(Resource *resource, uint32_t id, wl_resource *surface) override;
49};
50
51class LinuxDmaBufParamsV1 : public QtWaylandServer::zwp_linux_buffer_params_v1
52{
53public:
54 LinuxDmaBufParamsV1(LinuxDmaBufV1ClientBufferIntegration *integration, ::wl_resource *resource);
55
56protected:
57 void zwp_linux_buffer_params_v1_destroy_resource(Resource *resource) override;
58 void zwp_linux_buffer_params_v1_destroy(Resource *resource) override;
59 void zwp_linux_buffer_params_v1_add(Resource *resource,
60 int32_t fd,
61 uint32_t plane_idx,
62 uint32_t offset,
63 uint32_t stride,
64 uint32_t modifier_hi,
65 uint32_t modifier_lo) override;
66 void zwp_linux_buffer_params_v1_create(Resource *resource, int32_t width, int32_t height, uint32_t format, uint32_t flags) override;
67 void
68 zwp_linux_buffer_params_v1_create_immed(Resource *resource, uint32_t buffer_id, int32_t width, int32_t height, uint32_t format, uint32_t flags) override;
69
70private:
71 bool test(Resource *resource, uint32_t width, uint32_t height);
72
74 DmaBufAttributes m_attrs;
75 bool m_isUsed = false;
76};
77
79{
80 Q_OBJECT
81
82public:
84
85 QSize size() const override;
86 bool hasAlphaChannel() const override;
87 const DmaBufAttributes *dmabufAttributes() const override;
88
89 static LinuxDmaBufV1ClientBuffer *get(wl_resource *resource);
90
91private:
92 void initialize(wl_resource *resource);
93
94 static void buffer_destroy_resource(wl_resource *resource);
95 static void buffer_destroy(wl_client *client, wl_resource *resource);
96 static const struct wl_buffer_interface implementation;
97
98 wl_resource *m_resource = nullptr;
99 DmaBufAttributes m_attrs;
100 bool m_hasAlphaChannel = false;
101
103};
104
106{
107public:
108 LinuxDmaBufV1FormatTable(const QHash<uint32_t, QList<uint64_t>> &supportedModifiers);
109
111 QMap<std::pair<uint32_t, uint64_t>, uint16_t> indices;
112};
113
114class LinuxDmaBufV1FeedbackPrivate : public QtWaylandServer::zwp_linux_dmabuf_feedback_v1
115{
116public:
118
120 void send(Resource *resource);
121
122 QList<LinuxDmaBufV1Feedback::Tranche> m_tranches;
124
125protected:
126 void zwp_linux_dmabuf_feedback_v1_bind_resource(Resource *resource) override;
127 void zwp_linux_dmabuf_feedback_v1_destroy(Resource *resource) override;
128};
129}
Class holding the Wayland server display loop.
Definition display.h:34
LinuxDmaBufParamsV1(LinuxDmaBufV1ClientBufferIntegration *integration, ::wl_resource *resource)
void zwp_linux_buffer_params_v1_destroy(Resource *resource) override
void zwp_linux_buffer_params_v1_add(Resource *resource, int32_t fd, uint32_t plane_idx, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo) override
void zwp_linux_buffer_params_v1_create_immed(Resource *resource, uint32_t buffer_id, int32_t width, int32_t height, uint32_t format, uint32_t flags) override
void zwp_linux_buffer_params_v1_destroy_resource(Resource *resource) override
void zwp_linux_buffer_params_v1_create(Resource *resource, int32_t width, int32_t height, uint32_t format, uint32_t flags) override
std::unique_ptr< LinuxDmaBufV1FormatTable > table
void zwp_linux_dmabuf_v1_bind_resource(Resource *resource) override
void zwp_linux_dmabuf_v1_get_default_feedback(Resource *resource, uint32_t id) override
std::unique_ptr< LinuxDmaBufV1Feedback > defaultFeedback
void zwp_linux_dmabuf_v1_get_surface_feedback(Resource *resource, uint32_t id, wl_resource *surface) override
LinuxDmaBufV1ClientBufferIntegrationPrivate(LinuxDmaBufV1ClientBufferIntegration *q, Display *display)
void zwp_linux_dmabuf_v1_create_params(Resource *resource, uint32_t params_id) override
LinuxDmaBufV1FeedbackPrivate(LinuxDmaBufV1ClientBufferIntegrationPrivate *bufferintegration)
static LinuxDmaBufV1FeedbackPrivate * get(LinuxDmaBufV1Feedback *q)
QList< LinuxDmaBufV1Feedback::Tranche > m_tranches
void zwp_linux_dmabuf_feedback_v1_bind_resource(Resource *resource) override
LinuxDmaBufV1ClientBufferIntegrationPrivate * m_bufferintegration
void zwp_linux_dmabuf_feedback_v1_destroy(Resource *resource) override
QMap< std::pair< uint32_t, uint64_t >, uint16_t > indices
LinuxDmaBufV1FormatTable(const QHash< uint32_t, QList< uint64_t > > &supportedModifiers)
Creates a file in memory.
Definition ramfile.h:47
GLenum format
Definition gltexture.cpp:49
static LinuxDmaBufV1ClientBuffer * get(wl_resource *resource)
const DmaBufAttributes * dmabufAttributes() const override
LinuxDmaBufV1ClientBuffer(DmaBufAttributes &&attrs)