compare-render: Create repeated reference without gdk-pixbuf

We use the renderer to create the reference for the repeat test by
applying the same repeat node to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates
and the gdk-pixbuf method does not.
This commit is contained in:
Benjamin Otte 2024-08-26 19:25:43 +02:00
parent 001ca0a982
commit 8c9f16fa7a

View File

@ -450,12 +450,12 @@ run_node_test (gconstpointer data)
if (repeat)
{
GskRenderNode *node2;
GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3;
GskRenderNode *node2, *texture_nodes[16], *container_node, *reference_node;
GdkTexture *repeated_reference;
int width, height;
graphene_rect_t node_bounds;
graphene_rect_t bounds;
int i, j;
gsk_render_node_get_bounds (node, &node_bounds);
@ -473,31 +473,31 @@ run_node_test (gconstpointer data)
rendered_texture = gsk_renderer_render_texture (renderer, node2, NULL);
save_image (rendered_texture, test->node_file, "repeated", ".out.png");
pixbuf = pixbuf_new_from_texture (reference_texture);
width = gdk_texture_get_width (reference_texture);
height = gdk_texture_get_height (reference_texture);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
pixbuf2 = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf),
gdk_pixbuf_get_bits_per_sample (pixbuf),
width * 4,
height * 4);
for (int i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
for (j = 0; j < 4; j++)
{
gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, pixbuf2, i * width, j * height);
texture_nodes[4 * j + i] = gsk_texture_node_new (reference_texture,
&GRAPHENE_RECT_INIT (
i * width,
j * height,
width,
height
));
}
}
pixbuf3 = gdk_pixbuf_new_subpixbuf (pixbuf2, width / 2, height / 2, MIN (1000, 3 * width), MIN (1000, 3 * height));
repeated_reference = gdk_texture_new_for_pixbuf (pixbuf3);
g_object_unref (pixbuf3);
g_object_unref (pixbuf2);
g_object_unref (pixbuf);
container_node = gsk_container_node_new (texture_nodes, G_N_ELEMENTS (texture_nodes));
reference_node = gsk_clip_node_new (container_node,
&GRAPHENE_RECT_INIT (
width / 2,
height / 2,
MIN (1000, 3 * width),
MIN (1000, 3 * height)
));
repeated_reference = gsk_renderer_render_texture (renderer, reference_node, NULL);
save_image (repeated_reference, test->node_file, "repeated", ".ref.png");
@ -512,6 +512,10 @@ run_node_test (gconstpointer data)
g_clear_object (&diff_texture);
g_clear_object (&rendered_texture);
g_clear_object (&repeated_reference);
for (i = 0; i < G_N_ELEMENTS (texture_nodes); i++)
gsk_render_node_unref (texture_nodes[i]);
gsk_render_node_unref (container_node);
gsk_render_node_unref (reference_node);
gsk_render_node_unref (node2);
}