From 67b898b803ae164a09490fff1a4a15ed6bafc026 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 20 Apr 2023 15:46:51 +0300 Subject: [PATCH] Move DmaBufAttributes struct to GraphicsBuffer header The main motivation is to avoid scattering graphics buffer things around kwin. DmaBufParams struct has been moved to the OutputBackend, but with the introduction of buffer allocators, we need to port screencasting code to the new abstractions some time in the future. --- src/backends/drm/drm_backend.cpp | 1 + src/backends/drm/gbm_dmabuf.h | 6 ++- src/backends/wayland/wayland_backend.cpp | 7 ++-- src/core/dmabufattributes.h | 37 ------------------- src/core/gbmgraphicsbufferallocator.h | 1 - src/core/graphicsbuffer.h | 14 ++++++- src/core/outputbackend.h | 10 ++++- src/dmabuftexture.h | 2 +- .../scenes/opengl/eglcontext.cpp | 1 + .../scenes/opengl/eglcontext.h | 2 +- .../scenes/opengl/egldisplay.cpp | 2 +- src/plugins/screencast/screencaststream.cpp | 1 - src/plugins/screencast/screencaststream.h | 1 + src/wayland/linuxdmabufv1clientbuffer.h | 2 - 14 files changed, 35 insertions(+), 52 deletions(-) delete mode 100644 src/core/dmabufattributes.h diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index b45ee9b3ee..b91bf6897e 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -14,6 +14,7 @@ #include "core/outputconfiguration.h" #include "core/renderloop.h" #include "core/session.h" +#include "dmabuftexture.h" #include "drm_connector.h" #include "drm_crtc.h" #include "drm_egl_backend.h" diff --git a/src/backends/drm/gbm_dmabuf.h b/src/backends/drm/gbm_dmabuf.h index d8c778d97e..c9a767acea 100644 --- a/src/backends/drm/gbm_dmabuf.h +++ b/src/backends/drm/gbm_dmabuf.h @@ -7,9 +7,11 @@ #pragma once #include "config-kwin.h" -#include "dmabuftexture.h" -#include +#include "core/graphicsbuffer.h" +#include "core/outputbackend.h" + +#include #include namespace KWin diff --git a/src/backends/wayland/wayland_backend.cpp b/src/backends/wayland/wayland_backend.cpp index 4d824b8822..72490474c2 100644 --- a/src/backends/wayland/wayland_backend.cpp +++ b/src/backends/wayland/wayland_backend.cpp @@ -8,16 +8,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "wayland_backend.h" - +#include "dmabuftexture.h" +#include "dpmsinputeventfilter.h" +#include "input.h" #include "wayland_display.h" #include "wayland_egl_backend.h" #include "wayland_logging.h" #include "wayland_output.h" #include "wayland_qpainter_backend.h" -#include "dpmsinputeventfilter.h" -#include "input.h" - #include #include #include diff --git a/src/core/dmabufattributes.h b/src/core/dmabufattributes.h deleted file mode 100644 index ea2a85b93b..0000000000 --- a/src/core/dmabufattributes.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - SPDX-FileCopyrightText: 2022 Vlad Zahorodnii - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#pragma once - -#include "utils/filedescriptor.h" -#include - -namespace KWin -{ - -struct DmaBufParams -{ - int planeCount = 0; - int width = 0; - int height = 0; - uint32_t format = 0; - uint64_t modifier = 0; -}; - -struct DmaBufAttributes -{ - int planeCount = 0; - int width = 0; - int height = 0; - uint32_t format = 0; - uint64_t modifier = 0; - - FileDescriptor fd[4]; - int offset[4] = {0, 0, 0, 0}; - int pitch[4] = {0, 0, 0, 0}; -}; - -} // namespace KWin diff --git a/src/core/gbmgraphicsbufferallocator.h b/src/core/gbmgraphicsbufferallocator.h index 8c8e3d06e4..0f67cad190 100644 --- a/src/core/gbmgraphicsbufferallocator.h +++ b/src/core/gbmgraphicsbufferallocator.h @@ -6,7 +6,6 @@ #pragma once -#include "core/dmabufattributes.h" #include "core/graphicsbuffer.h" #include "core/graphicsbufferallocator.h" diff --git a/src/core/graphicsbuffer.h b/src/core/graphicsbuffer.h index 173465a7ae..e9af382de2 100644 --- a/src/core/graphicsbuffer.h +++ b/src/core/graphicsbuffer.h @@ -7,13 +7,25 @@ #pragma once #include "kwin_export.h" +#include "utils/filedescriptor.h" #include namespace KWin { -struct DmaBufAttributes; +struct DmaBufAttributes +{ + int planeCount = 0; + int width = 0; + int height = 0; + uint32_t format = 0; + uint64_t modifier = 0; + + FileDescriptor fd[4]; + int offset[4] = {0, 0, 0, 0}; + int pitch[4] = {0, 0, 0, 0}; +}; /** * The GraphicsBuffer class represents a chunk of memory containing graphics data. diff --git a/src/core/outputbackend.h b/src/core/outputbackend.h index 382136674c..5058b5fa74 100644 --- a/src/core/outputbackend.h +++ b/src/core/outputbackend.h @@ -27,9 +27,17 @@ class InputBackend; class OpenGLBackend; class QPainterBackend; class OutputConfiguration; -struct DmaBufParams; class EglDisplay; +struct DmaBufParams +{ + int planeCount = 0; + int width = 0; + int height = 0; + uint32_t format = 0; + uint64_t modifier = 0; +}; + class KWIN_EXPORT Outputs : public QVector { public: diff --git a/src/dmabuftexture.h b/src/dmabuftexture.h index d9c2d463fc..0457b2b65c 100644 --- a/src/dmabuftexture.h +++ b/src/dmabuftexture.h @@ -8,7 +8,7 @@ #include "kwin_export.h" -#include "core/dmabufattributes.h" +#include "core/graphicsbuffer.h" #include diff --git a/src/platformsupport/scenes/opengl/eglcontext.cpp b/src/platformsupport/scenes/opengl/eglcontext.cpp index 5b0df8ba1f..29764c6656 100644 --- a/src/platformsupport/scenes/opengl/eglcontext.cpp +++ b/src/platformsupport/scenes/opengl/eglcontext.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "eglcontext.h" +#include "core/graphicsbuffer.h" #include "egldisplay.h" #include "kwineglimagetexture.h" #include "kwineglutils_p.h" diff --git a/src/platformsupport/scenes/opengl/eglcontext.h b/src/platformsupport/scenes/opengl/eglcontext.h index 88eafa7f8f..d547ba7266 100644 --- a/src/platformsupport/scenes/opengl/eglcontext.h +++ b/src/platformsupport/scenes/opengl/eglcontext.h @@ -8,7 +8,6 @@ */ #pragma once -#include "core/dmabufattributes.h" #include "kwin_export.h" #include "kwingltexture.h" #include "openglcontext.h" @@ -22,6 +21,7 @@ namespace KWin class EglDisplay; class ShaderManager; +struct DmaBufAttributes; class KWIN_EXPORT EglContext : public OpenGlContext { diff --git a/src/platformsupport/scenes/opengl/egldisplay.cpp b/src/platformsupport/scenes/opengl/egldisplay.cpp index b6c19ea9c0..8aa1097af3 100644 --- a/src/platformsupport/scenes/opengl/egldisplay.cpp +++ b/src/platformsupport/scenes/opengl/egldisplay.cpp @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "egldisplay.h" -#include "core/dmabufattributes.h" +#include "core/graphicsbuffer.h" #include "kwineglimagetexture.h" #include "kwineglutils_p.h" #include "libkwineffects/kwinglutils.h" diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index 6a5e0e1e89..30c65afd9d 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -8,7 +8,6 @@ #include "screencaststream.h" #include "composite.h" -#include "core/outputbackend.h" #include "core/renderbackend.h" #include "cursor.h" #include "dmabuftexture.h" diff --git a/src/plugins/screencast/screencaststream.h b/src/plugins/screencast/screencaststream.h index 9dac7e5102..4e892cc8cb 100644 --- a/src/plugins/screencast/screencaststream.h +++ b/src/plugins/screencast/screencaststream.h @@ -10,6 +10,7 @@ #include "config-kwin.h" +#include "core/outputbackend.h" #include "dmabuftexture.h" #include "libkwineffects/kwinglobals.h" #include "wayland/screencast_v1_interface.h" diff --git a/src/wayland/linuxdmabufv1clientbuffer.h b/src/wayland/linuxdmabufv1clientbuffer.h index 942990563d..0d72e8df11 100644 --- a/src/wayland/linuxdmabufv1clientbuffer.h +++ b/src/wayland/linuxdmabufv1clientbuffer.h @@ -11,8 +11,6 @@ #include "clientbuffer.h" #include "clientbufferintegration.h" -#include "core/dmabufattributes.h" - #include #include #include