wayland-buffer: Add debug logging of pixel format in use

Enable it with environment `MUTTER_DEBUG=wayland`.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1387
This commit is contained in:
Daniel van Vugt 2020-07-29 18:01:40 +08:00 committed by Jonas Ådahl
parent e480d0c71e
commit 345976192d

View File

@ -61,6 +61,7 @@
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-drm-buffer-gbm.h" #include "backends/native/meta-drm-buffer-gbm.h"
#include "backends/native/meta-kms-utils.h"
#include "backends/native/meta-renderer-native.h" #include "backends/native/meta-renderer-native.h"
#endif #endif
@ -282,6 +283,28 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
return TRUE; return TRUE;
} }
static const char *
shm_format_to_string (MetaDrmFormatBuf *format_buf,
uint32_t shm_format)
{
const char *result;
switch (shm_format)
{
case WL_SHM_FORMAT_ARGB8888:
result = "ARGB8888";
break;
case WL_SHM_FORMAT_XRGB8888:
result = "XRGB8888";
break;
default:
result = meta_drm_format_to_string (format_buf, shm_format);
break;
}
return result;
}
static gboolean static gboolean
shm_buffer_attach (MetaWaylandBuffer *buffer, shm_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
@ -296,6 +319,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
CoglTextureComponents components; CoglTextureComponents components;
CoglBitmap *bitmap; CoglBitmap *bitmap;
CoglTexture *new_texture; CoglTexture *new_texture;
MetaDrmFormatBuf format_buf;
shm_buffer = wl_shm_buffer_get (buffer->resource); shm_buffer = wl_shm_buffer_get (buffer->resource);
stride = wl_shm_buffer_get_stride (shm_buffer); stride = wl_shm_buffer_get_stride (shm_buffer);
@ -308,6 +332,13 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
return FALSE; return FALSE;
} }
meta_topic (META_DEBUG_WAYLAND,
"[wl-shm] wl_buffer@%u wl_shm_format %s -> CoglPixelFormat %s",
wl_resource_get_id (meta_wayland_buffer_get_resource (buffer)),
shm_format_to_string (&format_buf,
wl_shm_buffer_get_format (shm_buffer)),
cogl_pixel_format_to_string (format));
if (*texture && if (*texture &&
cogl_texture_get_width (*texture) == width && cogl_texture_get_width (*texture) == width &&
cogl_texture_get_height (*texture) == height && cogl_texture_get_height (*texture) == height &&