From cebde5c2d180724d92b3ce9a91bc076c10fa1e39 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 3 Jan 2024 13:36:42 +0100 Subject: [PATCH] backend/native: Move DrmFormatBuf to cogl-drm-formats Part-of: --- src/backends/native/meta-drm-buffer.c | 1 + src/backends/native/meta-kms-utils.c | 33 -------------------------- src/backends/native/meta-kms-utils.h | 8 ------- src/common/meta-cogl-drm-formats.c | 34 +++++++++++++++++++++++++++ src/common/meta-cogl-drm-formats.h | 8 +++++++ src/wayland/meta-wayland-dma-buf.c | 4 ---- 6 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/backends/native/meta-drm-buffer.c b/src/backends/native/meta-drm-buffer.c index cb06e6f3d..eba3161a2 100644 --- a/src/backends/native/meta-drm-buffer.c +++ b/src/backends/native/meta-drm-buffer.c @@ -28,6 +28,7 @@ #include "backends/native/meta-device-pool.h" #include "backends/native/meta-kms-utils.h" +#include "common/meta-cogl-drm-formats.h" #include "meta-private-enum-types.h" diff --git a/src/backends/native/meta-kms-utils.c b/src/backends/native/meta-kms-utils.c index 8f7d92a5f..aa8e359ea 100644 --- a/src/backends/native/meta-kms-utils.c +++ b/src/backends/native/meta-kms-utils.c @@ -20,7 +20,6 @@ #include "backends/native/meta-kms-utils.h" -#include #include float @@ -61,36 +60,4 @@ meta_calculate_drm_mode_vblank_duration_us (const drmModeModeInfo *drm_mode) return value; } -/** - * meta_drm_format_to_string: - * @tmp: temporary buffer - * @drm_format: DRM fourcc pixel format - * - * Returns a pointer to a string naming the given pixel format, - * usually a pointer to the temporary buffer but not always. - * Invalid formats may return nonsense names. - * - * When calling this, allocate one MetaDrmFormatBuf on the stack to - * be used as the temporary buffer. - */ -const char * -meta_drm_format_to_string (MetaDrmFormatBuf *tmp, - uint32_t drm_format) -{ - int i; - - if (drm_format == DRM_FORMAT_INVALID) - return "INVALID"; - - G_STATIC_ASSERT (sizeof (tmp->s) == 5); - for (i = 0; i < 4; i++) - { - char c = (drm_format >> (i * 8)) & 0xff; - tmp->s[i] = g_ascii_isgraph (c) ? c : '.'; - } - - tmp->s[i] = 0; - - return tmp->s; -} diff --git a/src/backends/native/meta-kms-utils.h b/src/backends/native/meta-kms-utils.h index a693d05af..1a4cdb84a 100644 --- a/src/backends/native/meta-kms-utils.h +++ b/src/backends/native/meta-kms-utils.h @@ -23,16 +23,8 @@ #include "core/util-private.h" -typedef struct _MetaDrmFormatBuf -{ - char s[5]; -} MetaDrmFormatBuf; - META_EXPORT_TEST float meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *drm_mode); META_EXPORT_TEST int64_t meta_calculate_drm_mode_vblank_duration_us (const drmModeModeInfo *drm_mode); - -const char * meta_drm_format_to_string (MetaDrmFormatBuf *tmp, - uint32_t drm_format); diff --git a/src/common/meta-cogl-drm-formats.c b/src/common/meta-cogl-drm-formats.c index dee5c5134..225d6b537 100644 --- a/src/common/meta-cogl-drm-formats.c +++ b/src/common/meta-cogl-drm-formats.c @@ -24,6 +24,40 @@ #include "common/meta-cogl-drm-formats.h" + +/** + * meta_drm_format_to_string: + * @tmp: temporary buffer + * @drm_format: DRM fourcc pixel format + * + * Returns a pointer to a string naming the given pixel format, + * usually a pointer to the temporary buffer but not always. + * Invalid formats may return nonsense names. + * + * When calling this, allocate one MetaDrmFormatBuf on the stack to + * be used as the temporary buffer. + */ +const char * +meta_drm_format_to_string (MetaDrmFormatBuf *tmp, + uint32_t drm_format) +{ + int i; + + if (drm_format == DRM_FORMAT_INVALID) + return "INVALID"; + + G_STATIC_ASSERT (sizeof (tmp->s) == 5); + for (i = 0; i < 4; i++) + { + char c = (drm_format >> (i * 8)) & 0xff; + tmp->s[i] = g_ascii_isgraph (c) ? c : '.'; + } + + tmp->s[i] = 0; + + return tmp->s; +} + const MetaFormatInfo * meta_format_info_from_drm_format (uint32_t drm_format) { diff --git a/src/common/meta-cogl-drm-formats.h b/src/common/meta-cogl-drm-formats.h index d64bbc241..dbbc88294 100644 --- a/src/common/meta-cogl-drm-formats.h +++ b/src/common/meta-cogl-drm-formats.h @@ -29,6 +29,14 @@ G_BEGIN_DECLS +typedef struct _MetaDrmFormatBuf +{ + char s[5]; +} MetaDrmFormatBuf; + +const char * meta_drm_format_to_string (MetaDrmFormatBuf *tmp, + uint32_t drm_format); + typedef struct _MetaFormatInfo { uint32_t drm_format; diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index 52ece21bd..233bae61e 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -359,9 +359,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, MetaMultiTextureFormat multi_format; CoglPixelFormat cogl_format; const MetaFormatInfo *format_info; -#ifdef HAVE_NATIVE_BACKEND MetaDrmFormatBuf format_buf; -#endif if (buffer->dma_buf.texture) return TRUE; @@ -378,7 +376,6 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, cogl_format = format_info->cogl_format; multi_format = format_info->multi_texture_format; -#ifdef HAVE_NATIVE_BACKEND meta_topic (META_DEBUG_WAYLAND, "[dma-buf] wl_buffer@%u DRM format %s " "-> MetaMultiTextureFormat %s / CoglPixelFormat %s", @@ -386,7 +383,6 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, meta_drm_format_to_string (&format_buf, dma_buf->drm_format), meta_multi_texture_format_to_string (multi_format), cogl_pixel_format_to_string (cogl_format)); -#endif if (multi_format == META_MULTI_TEXTURE_FORMAT_SIMPLE) {