compare-render: Add a KEEP_BOUNDS flag

If that flag is set, we keep the bounds of the original node when
rendering the modified node.

Gets around the replay test having to draw a transparent color node to
ensure the same bounds.
This commit is contained in:
Benjamin Otte
2024-10-02 01:15:35 +02:00
parent 76980e10a0
commit 7a1e5b4418

View File

@@ -459,18 +459,6 @@ replay_create_test (GskRenderNode *node,
/* Check that the node didn't grow. */
if (!graphene_rect_contains_rect (&node_bounds, &result_bounds))
g_test_fail_printf ("Node bounds grew");
else if (!graphene_rect_equal (&node_bounds, &result_bounds))
{
GskRenderNode *nodes[2];
/* Add a transparent color node to pad the bounds */
nodes[0] = gsk_color_node_new (&(GdkRGBA) { 0,0,0,0 },
&node_bounds);
nodes[1] = result;
result = gsk_container_node_new (nodes, 2);
gsk_render_node_unref (nodes[0]);
gsk_render_node_unref (nodes[1]);
}
return result;
}
@@ -583,11 +571,17 @@ colorflip_create_reference (GskRenderer *renderer,
return result;
}
typedef enum
{
KEEP_BOUNDS = (1 << 0),
} TestFlags;
typedef struct _TestSetup TestSetup;
struct _TestSetup
{
const char *name;
const char *description;
TestFlags flags;
gpointer (* setup) (GskRenderNode *node);
void (* free) (gpointer data);
GskRenderNode * (* create_test) (GskRenderNode *node,
@@ -631,6 +625,7 @@ static const TestSetup test_setups[] = {
{
.name = "replay",
.description = "Do replay test",
.flags = KEEP_BOUNDS,
.create_test = replay_create_test,
.create_reference = NULL,
},
@@ -659,8 +654,17 @@ run_single_test (const TestSetup *setup,
{
GskRenderNode *test;
GdkTexture *reference, *rendered, *diff;
graphene_rect_t test_bounds, *render_bounds;
gpointer test_data;
if (setup->flags & KEEP_BOUNDS)
{
gsk_render_node_get_bounds (org_test, &test_bounds);
render_bounds = &test_bounds;
}
else
render_bounds = NULL;
if (setup->setup)
test_data = setup->setup (org_test);
else
@@ -674,7 +678,7 @@ run_single_test (const TestSetup *setup,
else
test = gsk_render_node_ref (org_test);
rendered = gsk_renderer_render_texture (renderer, test, NULL);
rendered = gsk_renderer_render_texture (renderer, test, render_bounds);
save_image (rendered, file_name, setup->name, ".out.png");
if (setup->create_reference)