From 0410125f203491693ea45b78cbbd3940703904a2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 18 May 2022 21:16:33 +0200 Subject: [PATCH] nodeparser: Fix parsing of color-matrix node Negative offsets in the color matrix were inverted because it used the rect parser. --- gsk/gskrendernodeparser.c | 26 ++++++++++++++---- .../gsk/compare/color-matrix-parsing.node | 10 +++++++ .../gsk/compare/color-matrix-parsing.png | Bin 0 -> 144 bytes testsuite/gsk/meson.build | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 testsuite/gsk/compare/color-matrix-parsing.node create mode 100644 testsuite/gsk/compare/color-matrix-parsing.png diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index b5f703bd79..7e5a74db0c 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -68,6 +68,23 @@ parse_rect (GtkCssParser *parser, return TRUE; } +static gboolean +parse_vec4 (GtkCssParser *parser, + gpointer out_vec4) +{ + double numbers[4]; + + if (!gtk_css_parser_consume_number (parser, &numbers[0]) || + !gtk_css_parser_consume_number (parser, &numbers[1]) || + !gtk_css_parser_consume_number (parser, &numbers[2]) || + !gtk_css_parser_consume_number (parser, &numbers[3])) + return FALSE; + + graphene_vec4_init (out_vec4, numbers[0], numbers[1], numbers[2], numbers[3]); + + return TRUE; +} + static gboolean parse_texture (GtkCssParser *parser, gpointer out_data) @@ -1490,23 +1507,20 @@ parse_color_matrix_node (GtkCssParser *parser) GskRenderNode *child = NULL; graphene_matrix_t matrix; GskTransform *transform = NULL; - graphene_rect_t offset_rect = GRAPHENE_RECT_INIT (0, 0, 0, 0); graphene_vec4_t offset; const Declaration declarations[] = { { "matrix", parse_transform, clear_transform, &transform }, - { "offset", parse_rect, NULL, &offset_rect }, + { "offset", parse_vec4, NULL, &offset }, { "child", parse_node, clear_node, &child } }; GskRenderNode *result; + graphene_vec4_init (&offset, 0, 0, 0, 0); + parse_declarations (parser, declarations, G_N_ELEMENTS(declarations)); if (child == NULL) child = create_default_render_node (); - graphene_vec4_init (&offset, - offset_rect.origin.x, offset_rect.origin.y, - offset_rect.size.width, offset_rect.size.height); - gsk_transform_to_matrix (transform, &matrix); result = gsk_color_matrix_node_new (child, &matrix, &offset); diff --git a/testsuite/gsk/compare/color-matrix-parsing.node b/testsuite/gsk/compare/color-matrix-parsing.node new file mode 100644 index 0000000000..57cdc774c9 --- /dev/null +++ b/testsuite/gsk/compare/color-matrix-parsing.node @@ -0,0 +1,10 @@ +color-matrix { + matrix: matrix3d(255, 0, 0, 0, + 0, 255, 0, 0, + 0, 0, 255, 0, + 0, 0, 0, 1); + offset: -127 -127 -127 0; + child: color { + color: #80007f; + } +} \ No newline at end of file diff --git a/testsuite/gsk/compare/color-matrix-parsing.png b/testsuite/gsk/compare/color-matrix-parsing.png new file mode 100644 index 0000000000000000000000000000000000000000..9a5764a9b2e6bb2f1829015252759d489970f477 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETa8DPxi4@=GhTEXDy L>gTe~DWM4f*sU)x literal 0 HcmV?d00001 diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 2fb02087d3..317f6a6670 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -36,6 +36,7 @@ compare_render_tests = [ 'clip-nested1', 'color-blur0', 'color-matrix-identity', + 'color-matrix-parsing', 'cross-fade-in-opacity', 'css-background', 'empty-blend',