testsuite: Improve memorytexture printing code

* The variables are const. Keep them const when casting

* Print float16 values

* Print integer values as hex. This is better for detecting
  byteswapping, off by one, and such. Besides, we tend to use values
  that have the same 2 hex digits, so detecting corruption is also easy.
This commit is contained in:
Benjamin Otte 2024-07-05 13:14:02 +02:00
parent df5d233155
commit c43c0275e3

View File

@ -372,88 +372,102 @@ gdk_memory_format_pixel_print (GdkMemoryFormat format,
case GDK_MEMORY_A8R8G8B8:
case GDK_MEMORY_R8G8B8A8:
case GDK_MEMORY_A8B8G8R8:
g_string_append_printf (string, "%d %d %d %d", data[0], data[1], data[2], data[3]);
g_string_append_printf (string, "%02X %02X %02X %02X", data[0], data[1], data[2], data[3]);
break;
case GDK_MEMORY_B8G8R8X8:
case GDK_MEMORY_R8G8B8X8:
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
g_string_append_printf (string, "%d %d %d", data[0], data[1], data[2]);
g_string_append_printf (string, "%02X %02X %02X", data[0], data[1], data[2]);
break;
case GDK_MEMORY_G8A8:
case GDK_MEMORY_G8A8_PREMULTIPLIED:
g_string_append_printf (string, "%d %d", data[0], data[1]);
g_string_append_printf (string, "%02X %02X", data[0], data[1]);
break;
case GDK_MEMORY_A8:
case GDK_MEMORY_G8:
g_string_append_printf (string, "%d", data[0]);
g_string_append_printf (string, "%02X", data[0]);
break;
case GDK_MEMORY_X8R8G8B8:
case GDK_MEMORY_X8B8G8R8:
g_string_append_printf (string, "%d %d %d", data[1], data[2], data[3]);
g_string_append_printf (string, "%02X %02X %02X", data[1], data[2], data[3]);
break;
case GDK_MEMORY_R16G16B16A16:
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
{
guint16 *data16 = (guint16 *) data;
g_string_append_printf (string, "%d %d %d %d", data16[0], data16[1], data16[2], data16[3]);
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%04X %04X %04X %04X", data16[0], data16[1], data16[2], data16[3]);
}
break;
case GDK_MEMORY_R16G16B16:
{
guint16 *data16 = (guint16 *) data;
g_string_append_printf (string, "%d %d %d", data16[0], data16[1], data16[2]);
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%04X %04X %04X", data16[0], data16[1], data16[2]);
}
break;
case GDK_MEMORY_G16A16:
case GDK_MEMORY_G16A16_PREMULTIPLIED:
{
guint16 *data16 = (guint16 *) data;
g_string_append_printf (string, "%d %d", data16[0], data16[1]);
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%04X %04X", data16[0], data16[1]);
}
break;
case GDK_MEMORY_G16:
case GDK_MEMORY_A16:
{
guint16 *data16 = (guint16 *) data;
g_string_append_printf (string, "%d", data16[0]);
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%04X", data16[0]);
}
break;
case GDK_MEMORY_R16G16B16_FLOAT:
{
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%f %f %f", half_to_float (data16[0]), half_to_float (data16[1]), half_to_float (data16[2]));
}
break;
case GDK_MEMORY_R16G16B16A16_FLOAT:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
{
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%f %f %f %f", half_to_float (data16[0]), half_to_float (data16[1]), half_to_float (data16[2]), half_to_float (data16[3]));
}
break;
case GDK_MEMORY_A16_FLOAT:
g_string_append (string, "FIXME print f16\n");
{
const guint16 *data16 = (const guint16 *) data;
g_string_append_printf (string, "%f", half_to_float (data16[0]));
}
break;
case GDK_MEMORY_R32G32B32A32_FLOAT:
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
{
float *dataf = (float *)data;
const float *dataf = (const float *) data;
g_string_append_printf (string, "%f %f %f %f", dataf[0], dataf[1], dataf[2], dataf[3]);
}
break;
case GDK_MEMORY_R32G32B32_FLOAT:
{
float *dataf = (float *)data;
const float *dataf = (const float *) data;
g_string_append_printf (string, "%f %f %f", dataf[0], dataf[1], dataf[2]);
}
break;
case GDK_MEMORY_A32_FLOAT:
{
float *dataf = (float *)data;
const float *dataf = (const float *) data;
g_string_append_printf (string, "%f", dataf[0]);
}
break;