tests: Use dmabufs in compare tests

Make the --replay mode of compare-render randomly turn textures it
finds into dmabuf textures, using /dev/udmabuf.
This commit is contained in:
Matthias Clasen 2024-08-24 12:10:24 -04:00
parent acad180cee
commit 107ef2017c
2 changed files with 41 additions and 1 deletions

View File

@ -1,5 +1,5 @@
compare_render = executable('compare-render',
['compare-render.c', '../reftests/reftest-compare.c', 'replay-node.c'],
['compare-render.c', '../reftests/reftest-compare.c', 'replay-node.c', '../gdk/udmabuf.c'],
dependencies: libgtk_static_dep,
c_args: common_cflags + ['-DGTK_COMPILATION'],
)

View File

@ -1,6 +1,7 @@
#include <gtk/gtk.h>
#include <gtk/gtksnapshotprivate.h>
#include <gsk/gskrendernodeprivate.h>
#include "../gdk/udmabuf.h"
void
replay_node (GskRenderNode *node, GtkSnapshot *snapshot);
@ -113,7 +114,23 @@ replay_texture_node (GskRenderNode *node, GtkSnapshot *snapshot)
graphene_rect_t bounds;
gsk_render_node_get_bounds (node, &bounds);
g_object_ref (texture);
if (g_test_rand_bit ())
{
GdkTexture *t;
t = udmabuf_texture_from_texture (texture, NULL);
if (t)
{
g_object_unref (texture);
texture = t;
}
}
gtk_snapshot_append_texture (snapshot, texture, &bounds);
g_object_unref (texture);
}
static void
@ -327,7 +344,30 @@ replay_texture_scale_node (GskRenderNode *node, GtkSnapshot *snapshot)
graphene_rect_t bounds;
gsk_render_node_get_bounds (node, &bounds);
g_object_ref (texture);
if (g_test_rand_bit ())
{
GdkTexture *t;
GError *error = NULL;
t = udmabuf_texture_from_texture (texture, &error);
if (t)
{
g_test_message ("Using dmabuf texture");
g_object_unref (texture);
texture = t;
}
else
{
g_test_message ("Creating dmabuf texture failed: %s", error->message);
g_error_free (error);
}
}
gtk_snapshot_append_scaled_texture (snapshot, texture, filter, &bounds);
g_object_unref (texture);
}
static void