From 43ccc5910b1d0f23293da7de4dd67224c33b1d8f Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 23 Nov 2021 11:14:37 +0100 Subject: [PATCH] linuxdmabuf: split out declarations for private classes The cpp file is getting too long and unwieldy --- src/wayland/linuxdmabufv1clientbuffer.cpp | 70 +----------------- src/wayland/linuxdmabufv1clientbuffer_p.h | 86 +++++++++++++++++++++++ 2 files changed, 87 insertions(+), 69 deletions(-) create mode 100644 src/wayland/linuxdmabufv1clientbuffer_p.h diff --git a/src/wayland/linuxdmabufv1clientbuffer.cpp b/src/wayland/linuxdmabufv1clientbuffer.cpp index 695a16aff1..cb1457a780 100644 --- a/src/wayland/linuxdmabufv1clientbuffer.cpp +++ b/src/wayland/linuxdmabufv1clientbuffer.cpp @@ -10,80 +10,12 @@ */ #include "linuxdmabufv1clientbuffer.h" -#include "clientbuffer_p.h" -#include "display.h" -#include "display_p.h" -#include "drm_fourcc.h" - -#include "qwayland-server-linux-dmabuf-unstable-v1.h" -#include "qwayland-server-wayland.h" - -#include -#include - -#include +#include "linuxdmabufv1clientbuffer_p.h" namespace KWaylandServer { static const int s_version = 3; -class LinuxDmaBufV1ClientBufferIntegrationPrivate : public QtWaylandServer::zwp_linux_dmabuf_v1 -{ -public: - LinuxDmaBufV1ClientBufferIntegrationPrivate(LinuxDmaBufV1ClientBufferIntegration *q, Display *display); - - LinuxDmaBufV1ClientBufferIntegration *q; - LinuxDmaBufV1ClientBufferIntegration::RendererInterface *rendererInterface = nullptr; - QHash> supportedModifiers; - -protected: - void zwp_linux_dmabuf_v1_bind_resource(Resource *resource) override; - void zwp_linux_dmabuf_v1_destroy(Resource *resource) override; - void zwp_linux_dmabuf_v1_create_params(Resource *resource, uint32_t params_id) override; -}; - -class LinuxDmaBufV1ClientBufferPrivate : public ClientBufferPrivate, public QtWaylandServer::wl_buffer -{ -public: - QSize size; - quint32 format; - quint32 flags; - QVector planes; - bool hasAlphaChannel = false; - -protected: - void buffer_destroy(Resource *resource) override; -}; - -class LinuxDmaBufParamsV1 : public QtWaylandServer::zwp_linux_buffer_params_v1 -{ -public: - LinuxDmaBufParamsV1(LinuxDmaBufV1ClientBufferIntegration *integration, ::wl_resource *resource); - ~LinuxDmaBufParamsV1() override; - -protected: - void zwp_linux_buffer_params_v1_destroy_resource(Resource *resource) override; - 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(Resource *resource, int32_t width, int32_t height, uint32_t format, uint32_t flags) 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; - -private: - bool test(Resource *resource, uint32_t width, uint32_t height); - - LinuxDmaBufV1ClientBufferIntegration *m_integration; - QVector m_planes; - int m_planeCount = 0; - bool m_isUsed = false; -}; - LinuxDmaBufV1ClientBufferIntegrationPrivate::LinuxDmaBufV1ClientBufferIntegrationPrivate(LinuxDmaBufV1ClientBufferIntegration *q, Display *display) : QtWaylandServer::zwp_linux_dmabuf_v1(*display, s_version) , q(q) diff --git a/src/wayland/linuxdmabufv1clientbuffer_p.h b/src/wayland/linuxdmabufv1clientbuffer_p.h new file mode 100644 index 0000000000..f69a0c1e46 --- /dev/null +++ b/src/wayland/linuxdmabufv1clientbuffer_p.h @@ -0,0 +1,86 @@ +/* + SPDX-FileCopyrightText: 2018 Fredrik Höglund + SPDX-FileCopyrightText: 2019 Roman Gilg + SPDX-FileCopyrightText: 2021 Vlad Zahorodnii + + Based on the libweston implementation, + SPDX-FileCopyrightText: 2014, 2015 Collabora, Ltd. + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ +#pragma once +#include "clientbuffer_p.h" +#include "display.h" +#include "display_p.h" +#include "drm_fourcc.h" +#include "linuxdmabufv1clientbuffer.h" + +#include "qwayland-server-linux-dmabuf-unstable-v1.h" +#include "qwayland-server-wayland.h" + +#include +#include + +#include + +namespace KWaylandServer +{ + +class LinuxDmaBufV1ClientBufferIntegrationPrivate : public QtWaylandServer::zwp_linux_dmabuf_v1 +{ +public: + LinuxDmaBufV1ClientBufferIntegrationPrivate(LinuxDmaBufV1ClientBufferIntegration *q, Display *display); + + LinuxDmaBufV1ClientBufferIntegration *q; + LinuxDmaBufV1ClientBufferIntegration::RendererInterface *rendererInterface = nullptr; + QHash> supportedModifiers; + +protected: + void zwp_linux_dmabuf_v1_bind_resource(Resource *resource) override; + void zwp_linux_dmabuf_v1_destroy(Resource *resource) override; + void zwp_linux_dmabuf_v1_create_params(Resource *resource, uint32_t params_id) override; +}; + +class LinuxDmaBufV1ClientBufferPrivate : public ClientBufferPrivate, public QtWaylandServer::wl_buffer +{ +public: + QSize size; + quint32 format; + quint32 flags; + QVector planes; + bool hasAlphaChannel = false; + +protected: + void buffer_destroy(Resource *resource) override; +}; + +class LinuxDmaBufParamsV1 : public QtWaylandServer::zwp_linux_buffer_params_v1 +{ +public: + LinuxDmaBufParamsV1(LinuxDmaBufV1ClientBufferIntegration *integration, ::wl_resource *resource); + ~LinuxDmaBufParamsV1() override; + +protected: + void zwp_linux_buffer_params_v1_destroy_resource(Resource *resource) override; + 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(Resource *resource, int32_t width, int32_t height, uint32_t format, uint32_t flags) 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; + +private: + bool test(Resource *resource, uint32_t width, uint32_t height); + + LinuxDmaBufV1ClientBufferIntegration *m_integration; + QVector m_planes; + int m_planeCount = 0; + bool m_isUsed = false; +}; + +}