rendernodeparser: Update to new rules

Update to the docs outlined in #1887.

In particular, the changes do:

1. Require no property, have a working default for everything
2. Be clear about what gets printed and how.

Tests ahve been adapted to still pass.
This commit is contained in:
Benjamin Otte 2019-05-18 23:06:34 +02:00
parent 678aa8088f
commit 1a65a6ce76
8 changed files with 348 additions and 435 deletions

View File

@ -404,9 +404,9 @@ parse_shadows (GtkCssParser *parser,
{
GArray *shadows = out_shadows;
for (;;)
do
{
GskShadow shadow = { {0, 0, 0, 1}, 0, 0, 0 };
GskShadow shadow = { GDK_RGBA("000000"), 0, 0, 0 };
double dx = 0, dy = 0, radius = 0;
if (!gdk_rgba_parser_parse (parser, &shadow.color))
@ -416,22 +416,21 @@ parse_shadows (GtkCssParser *parser,
gtk_css_parser_error_value (parser, "Expected shadow x offset");
if (!gtk_css_parser_consume_number (parser, &dy))
gtk_css_parser_error_value (parser, "Expected shadow x offset");
gtk_css_parser_error_value (parser, "Expected shadow y offset");
if (!gtk_css_parser_consume_number (parser, &radius))
gtk_css_parser_error_value (parser, "Expected shadow blur radius");
if (gtk_css_parser_has_number (parser))
{
if (!gtk_css_parser_consume_number (parser, &radius))
gtk_css_parser_error_value (parser, "Expected shadow blur radius");
}
shadow.dx = dx;
shadow.dy = dy;
shadow.radius = radius;
g_array_append_val (shadows, shadow);
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA))
gtk_css_parser_skip (parser);
else
break;
}
while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
return TRUE;
}
@ -483,21 +482,15 @@ parse_blend_mode (GtkCssParser *parser,
return FALSE;
}
static gboolean
parse_font (GtkCssParser *parser,
gpointer out_font)
static PangoFont *
font_from_string (const char *string)
{
const GtkCssToken *token;
PangoFontDescription *desc;
PangoFontMap *font_map;
PangoContext *context;
PangoFont *font;
token = gtk_css_parser_get_token (parser);
if (!gtk_css_token_is (token, GTK_CSS_TOKEN_STRING))
return FALSE;
desc = pango_font_description_from_string (token->string.string);
desc = pango_font_description_from_string (string);
font_map = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (font_map);
font = pango_font_map_load_font (font_map, context, desc);
@ -505,10 +498,30 @@ parse_font (GtkCssParser *parser,
pango_font_description_free (desc);
g_object_unref (context);
return font;
}
static gboolean
parse_font (GtkCssParser *parser,
gpointer out_font)
{
PangoFont *font;
char *s;
s = gtk_css_parser_consume_string (parser);
if (s == NULL)
return FALSE;
font = font_from_string (s);
if (font == NULL)
{
gtk_css_parser_error_syntax (parser, "This font does not exist.");
return FALSE;
}
*((PangoFont**)out_font) = font;
/* Skip font name token */
gtk_css_parser_consume_token (parser);
g_free (s);
return TRUE;
}
@ -523,49 +536,46 @@ static gboolean
parse_glyphs (GtkCssParser *parser,
gpointer out_glyphs)
{
GArray *glyphs;
PangoGlyphString *glyph_string;
int i;
glyphs = g_array_new (FALSE, TRUE, sizeof (double[5]));
for (;;)
{
double values[5];
/* We have 5 numbers per glyph */
for (i = 0; i < 5; i ++)
{
if (!gtk_css_parser_consume_number (parser, &values[i]))
return FALSE;
}
g_array_append_val (glyphs, values);
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA))
gtk_css_parser_skip (parser);
else
break;
}
glyph_string = pango_glyph_string_new ();
pango_glyph_string_set_size (glyph_string, glyphs->len);
for (i = 0; i < glyphs->len; i ++)
do
{
PangoGlyphInfo g;
double *v = (double *)(glyphs->data + (i * sizeof (double) * 5));
PangoGlyphInfo gi = { 0, { 0, 0, 0}, { 1 } };
double d, d2;
int i;
g.glyph = (guint)v[0];
g.geometry.width = (int)v[1];
g.geometry.x_offset = (int)v[2];
g.geometry.y_offset = (int)v[3];
g.attr.is_cluster_start = (int)v[4];
if (!gtk_css_parser_consume_integer (parser, &i) ||
!gtk_css_parser_consume_number (parser, &d))
{
pango_glyph_string_free (glyph_string);
return FALSE;
}
gi.glyph = i;
gi.geometry.width = (int) (d * PANGO_SCALE);
glyph_string->glyphs[i] = g;
if (gtk_css_parser_has_number (parser))
{
if (!gtk_css_parser_consume_number (parser, &d) ||
!gtk_css_parser_consume_number (parser, &d2))
{
pango_glyph_string_free (glyph_string);
return FALSE;
}
gi.geometry.x_offset = (int) (d * PANGO_SCALE);
gi.geometry.y_offset = (int) (d2 * PANGO_SCALE);
if (gtk_css_parser_try_ident (parser, "same-cluster"))
gi.attr.is_cluster_start = 0;
else
gi.attr.is_cluster_start = 1;
}
pango_glyph_string_set_size (glyph_string, glyph_string->num_glyphs + 1);
glyph_string->glyphs[glyph_string->num_glyphs - 1] = gi;
}
g_array_free (glyphs, TRUE);
while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
*((PangoGlyphString **)out_glyphs) = glyph_string;
@ -684,11 +694,17 @@ parse_declarations (GtkCssParser *parser,
return parsed;
}
static GskRenderNode *
create_default_render_node (void)
{
return gsk_color_node_new (&GDK_RGBA("FF00CC"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
}
static GskRenderNode *
parse_color_node (GtkCssParser *parser)
{
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0);
GdkRGBA color = GDK_RGBA("FF0000");
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 50, 50);
GdkRGBA color = GDK_RGBA("FF00CC");
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
{ "color", parse_color, NULL, &color },
@ -702,9 +718,9 @@ parse_color_node (GtkCssParser *parser)
static GskRenderNode *
parse_linear_gradient_node (GtkCssParser *parser)
{
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0);
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 50, 50);
graphene_point_t start = GRAPHENE_POINT_INIT (0, 0);
graphene_point_t end = GRAPHENE_POINT_INIT (0, 0);
graphene_point_t end = GRAPHENE_POINT_INIT (0, 50);
GArray *stops = NULL;
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
@ -717,8 +733,12 @@ parse_linear_gradient_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (stops == NULL)
{
gtk_css_parser_error_syntax (parser, "No color stops given");
return NULL;
GskColorStop from = { 0.0, GDK_RGBA("AAFF00") };
GskColorStop to = { 1.0, GDK_RGBA("FF00CC") };
stops = g_array_new (FALSE, FALSE, sizeof (GskColorStop));
g_array_append_val (stops, from);
g_array_append_val (stops, to);
}
result = gsk_linear_gradient_node_new (&bounds, &start, &end, (GskColorStop *) stops->data, stops->len);
@ -731,7 +751,7 @@ parse_linear_gradient_node (GtkCssParser *parser)
static GskRenderNode *
parse_inset_shadow_node (GtkCssParser *parser)
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GdkRGBA color = GDK_RGBA("000000");
double dx = 1, dy = 1, blur = 0, spread = 0;
const Declaration declarations[] = {
@ -751,7 +771,7 @@ parse_inset_shadow_node (GtkCssParser *parser)
static GskRenderNode *
parse_border_node (GtkCssParser *parser)
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
float widths[4] = { 1, 1, 1, 1 };
GdkRGBA colors[4] = { GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000") };
const Declaration declarations[] = {
@ -768,7 +788,7 @@ parse_border_node (GtkCssParser *parser)
static GskRenderNode *
parse_texture_node (GtkCssParser *parser)
{
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0);
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 50, 50);
GdkTexture *texture = NULL;
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
@ -780,8 +800,21 @@ parse_texture_node (GtkCssParser *parser)
if (texture == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"texture\" property definition");
return NULL;
static const guint32 pixels[100] = {
0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0, 0, 0, 0, 0,
0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0, 0, 0, 0, 0,
0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0, 0, 0, 0, 0,
0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0, 0, 0, 0, 0,
0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC,
0, 0, 0, 0, 0, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC,
0, 0, 0, 0, 0, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC,
0, 0, 0, 0, 0, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC,
0, 0, 0, 0, 0, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC, 0xFFFF00CC };
GBytes *bytes = g_bytes_new_static ((guchar *) pixels, 400);
texture = gdk_memory_texture_new (10, 10, GDK_MEMORY_DEFAULT, bytes, 40);
g_bytes_unref (bytes);
}
node = gsk_texture_node_new (texture, &bounds);
@ -793,7 +826,7 @@ parse_texture_node (GtkCssParser *parser)
static GskRenderNode *
parse_outset_shadow_node (GtkCssParser *parser)
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GdkRGBA color = GDK_RGBA("000000");
double dx = 1, dy = 1, blur = 0, spread = 0;
const Declaration declarations[] = {
@ -823,11 +856,8 @@ parse_transform_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
gsk_transform_unref (transform);
return NULL;
}
child = create_default_render_node ();
/* This is very much cheating, isn't it? */
if (transform == NULL)
transform = gsk_transform_new ();
@ -844,7 +874,7 @@ static GskRenderNode *
parse_opacity_node (GtkCssParser *parser)
{
GskRenderNode *child = NULL;
double opacity = 1.0;
double opacity = 0.5;
const Declaration declarations[] = {
{ "opacity", parse_double, NULL, &opacity },
{ "child", parse_node, clear_node, &child },
@ -853,10 +883,7 @@ parse_opacity_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
result = gsk_opacity_node_new (child, opacity);
@ -882,10 +909,7 @@ parse_color_matrix_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
graphene_vec4_init (&offset,
offset_rect.origin.x, offset_rect.origin.y,
@ -915,16 +939,10 @@ parse_cross_fade_node (GtkCssParser *parser)
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (start == NULL || end == NULL)
{
if (start == NULL)
gtk_css_parser_error_syntax (parser, "Missing \"start\" property definition");
if (end == NULL)
gtk_css_parser_error_syntax (parser, "Missing \"end\" property definition");
g_clear_pointer (&start, gsk_render_node_unref);
g_clear_pointer (&end, gsk_render_node_unref);
return NULL;
}
if (start == NULL)
start = gsk_color_node_new (&GDK_RGBA("AAFF00"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
if (end == NULL)
end = create_default_render_node ();
result = gsk_cross_fade_node_new (start, end, progress);
@ -948,16 +966,10 @@ parse_blend_node (GtkCssParser *parser)
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (bottom == NULL || top == NULL)
{
if (bottom == NULL)
gtk_css_parser_error_syntax (parser, "Missing \"bottom\" property definition");
if (top == NULL)
gtk_css_parser_error_syntax (parser, "Missing \"top\" property definition");
g_clear_pointer (&bottom, gsk_render_node_unref);
g_clear_pointer (&top, gsk_render_node_unref);
return NULL;
}
if (bottom == NULL)
bottom = gsk_color_node_new (&GDK_RGBA("AAFF00"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
if (top == NULL)
top = create_default_render_node ();
result = gsk_blend_node_new (bottom, top, mode);
@ -983,10 +995,7 @@ parse_repeat_node (GtkCssParser *parser)
parse_result = parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
if (!(parse_result & (1 << 1)))
gsk_render_node_get_bounds (child, &bounds);
@ -1017,7 +1026,13 @@ parse_text_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (!font || !glyphs)
if (font == NULL)
{
font = font_from_string ("Cantarell 11");
g_assert (font);
}
if (!glyphs)
return NULL;
result = gsk_text_node_new (font, glyphs, &color, &offset);
@ -1041,10 +1056,7 @@ parse_blur_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
result = gsk_blur_node_new (child, blur_radius);
@ -1056,32 +1068,7 @@ parse_blur_node (GtkCssParser *parser)
static GskRenderNode *
parse_clip_node (GtkCssParser *parser)
{
graphene_rect_t clip = GRAPHENE_RECT_INIT (0, 0, 0, 0);
GskRenderNode *child = NULL;
const Declaration declarations[] = {
{ "clip", parse_rect, NULL, &clip },
{ "child", parse_node, clear_node, &child },
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
result = gsk_clip_node_new (child, &clip);
gsk_render_node_unref (child);
return result;
}
static GskRenderNode *
parse_rounded_clip_node (GtkCssParser *parser)
{
GskRoundedRect clip = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
GskRoundedRect clip = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GskRenderNode *child = NULL;
const Declaration declarations[] = {
{ "clip", parse_rounded_rect, NULL, &clip },
@ -1091,10 +1078,32 @@ parse_rounded_clip_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
if (gsk_rounded_rect_is_rectilinear (&clip))
result = gsk_clip_node_new (child, &clip.bounds);
else
result = gsk_rounded_clip_node_new (child, &clip);
gsk_render_node_unref (child);
return result;
}
static GskRenderNode *
parse_rounded_clip_node (GtkCssParser *parser)
{
GskRoundedRect clip = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GskRenderNode *child = NULL;
const Declaration declarations[] = {
{ "clip", parse_rounded_rect, NULL, &clip },
{ "child", parse_node, clear_node, &child },
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
result = gsk_rounded_clip_node_new (child, &clip);
@ -1116,15 +1125,12 @@ parse_shadow_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
if (shadows->len == 0)
{
gtk_css_parser_error_syntax (parser, "Need at least one shadow");
return child;
GskShadow default_shadow = { GDK_RGBA("000000"), 1, 1, 0 };
g_array_append_val (shadows, default_shadow);
}
result = gsk_shadow_node_new (child, (GskShadow *)shadows->data, shadows->len);
@ -1148,10 +1154,7 @@ parse_debug_node (GtkCssParser *parser)
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
{
gtk_css_parser_error_syntax (parser, "Missing \"child\" property definition");
return NULL;
}
child = create_default_render_node ();
result = gsk_debug_node_new (child, message);
@ -1441,8 +1444,13 @@ append_vec4 (GString *str,
static void
append_float_param (Printer *p,
const char *param_name,
float value)
float value,
float default_value)
{
/* Don't approximate-compare here, better be topo verbose */
if (value == default_value)
return;
_indent (p);
g_string_append_printf (p->str, "%s: ", param_name);
string_append_double (p->str, value);
@ -1599,7 +1607,7 @@ render_node_print (Printer *p,
start_node (p, "cross-fade");
append_node_param (p, "end", gsk_cross_fade_node_get_end_child (node));
append_float_param (p, "progress", gsk_cross_fade_node_get_progress (node));
append_float_param (p, "progress", gsk_cross_fade_node_get_progress (node), 0.5f);
append_node_param (p, "start", gsk_cross_fade_node_get_start_child (node));
end_node (p);
@ -1609,7 +1617,7 @@ render_node_print (Printer *p,
case GSK_LINEAR_GRADIENT_NODE:
{
const guint n_stops = gsk_linear_gradient_node_get_n_color_stops (node);
const GskColorStop *stop;
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node);
int i;
start_node (p, "linear-gradient");
@ -1619,23 +1627,16 @@ render_node_print (Printer *p,
append_point_param (p, "start", gsk_linear_gradient_node_peek_start (node));
_indent (p);
g_string_append (p->str, "stops:");
for (i = 0; i < n_stops - 1; i ++)
g_string_append (p->str, "stops: ");
for (i = 0; i < n_stops; i ++)
{
stop = gsk_linear_gradient_node_peek_color_stops (node) + i;
if (i > 0)
g_string_append (p->str, ", ");
string_append_double (p->str, stops[i].offset);
g_string_append_c (p->str, ' ');
string_append_double (p->str, stop->offset);
g_string_append_c (p->str, ' ');
append_rgba (p->str, &stop->color);
g_string_append_c (p->str, ',');
append_rgba (p->str, &stops[i].color);
}
/* Last one, no comma */
stop = gsk_linear_gradient_node_peek_color_stops (node) + n_stops - 1;
string_append_double (p->str, stop->offset);
g_string_append_c (p->str, ' ');
append_rgba (p->str, &stop->color);
g_string_append (p->str, ";\n");
end_node (p);
@ -1647,7 +1648,7 @@ render_node_print (Printer *p,
start_node (p, "opacity");
append_node_param (p, "child", gsk_opacity_node_get_child (node));
append_float_param (p, "opacity", gsk_opacity_node_get_opacity (node));
append_float_param (p, "opacity", gsk_opacity_node_get_opacity (node), 0.5f);
end_node (p);
}
@ -1655,14 +1656,17 @@ render_node_print (Printer *p,
case GSK_OUTSET_SHADOW_NODE:
{
const GdkRGBA *color = gsk_outset_shadow_node_peek_color (node);
start_node (p, "outset-shadow");
append_float_param (p, "blur", gsk_outset_shadow_node_get_blur_radius (node));
append_rgba_param (p, "color", gsk_outset_shadow_node_peek_color (node));
append_float_param (p, "dx", gsk_outset_shadow_node_get_dx (node));
append_float_param (p, "dy", gsk_outset_shadow_node_get_dy (node));
append_float_param (p, "blur", gsk_outset_shadow_node_get_blur_radius (node), 0.0f);
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
append_rgba_param (p, "color", color);
append_float_param (p, "dx", gsk_outset_shadow_node_get_dx (node), 1.0f);
append_float_param (p, "dy", gsk_outset_shadow_node_get_dy (node), 1.0f);
append_rounded_rect_param (p, "outline", gsk_outset_shadow_node_peek_outline (node));
append_float_param (p, "spread", gsk_outset_shadow_node_get_spread (node));
append_float_param (p, "spread", gsk_outset_shadow_node_get_spread (node), 0.0f);
end_node (p);
}
@ -1693,10 +1697,12 @@ render_node_print (Printer *p,
case GSK_TRANSFORM_NODE:
{
GskTransform *transform = gsk_transform_node_get_transform (node);
start_node (p, "transform");
append_node_param (p, "child", gsk_transform_node_get_child (node));
append_transform_param (p, "transform", gsk_transform_node_get_transform (node));
if (gsk_transform_get_category (transform) != GSK_TRANSFORM_CATEGORY_IDENTITY)
append_transform_param (p, "transform", transform);
end_node (p);
}
@ -1707,8 +1713,10 @@ render_node_print (Printer *p,
start_node (p, "color-matrix");
append_node_param (p, "child", gsk_color_matrix_node_get_child (node));
append_matrix_param (p, "matrix", gsk_color_matrix_node_peek_color_matrix (node));
append_vec4_param (p, "offset", gsk_color_matrix_node_peek_color_offset (node));
if (!graphene_matrix_is_identity (gsk_color_matrix_node_peek_color_matrix (node)))
append_matrix_param (p, "matrix", gsk_color_matrix_node_peek_color_matrix (node));
if (!graphene_vec4_equal (gsk_color_matrix_node_peek_color_offset (node), graphene_vec4_zero ()))
append_vec4_param (p, "offset", gsk_color_matrix_node_peek_color_offset (node));
end_node (p);
}
@ -1727,8 +1735,10 @@ render_node_print (Printer *p,
n = 3;
else if (!gdk_rgba_equal (&colors[1], &colors[0]))
n = 2;
else
else if (!gdk_rgba_equal (&colors[0], &GDK_RGBA("000000")))
n = 1;
else
n = 0;
if (n > 0)
{
@ -1751,8 +1761,10 @@ render_node_print (Printer *p,
n = 3;
else if (widths[1] != widths[0])
n = 2;
else
else if (widths[0] != 1.0)
n = 1;
else
n = 0;
if (n > 0)
{
@ -1778,26 +1790,29 @@ render_node_print (Printer *p,
start_node (p, "shadow");
_indent (p);
append_node_param (p, "child", gsk_shadow_node_get_child (node));
_indent (p);
g_string_append (p->str, "shadows: ");
for (i = 0; i < n_shadows; i ++)
{
const GskShadow *s = gsk_shadow_node_peek_shadow (node, i);
char *color;
if (i > 0)
g_string_append (p->str, ", ");
color = gdk_rgba_to_string (&s->color);
g_string_append (p->str, color);
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->dx);
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->dy);
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->radius);
if (i < n_shadows - 1)
g_string_append (p->str, ", ");
if (s->radius > 0)
{
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->radius);
}
g_free (color);
}
@ -1811,14 +1826,16 @@ render_node_print (Printer *p,
case GSK_INSET_SHADOW_NODE:
{
const GdkRGBA *color = gsk_inset_shadow_node_peek_color (node);
start_node (p, "inset-shadow");
append_float_param (p, "blur", gsk_inset_shadow_node_get_blur_radius (node));
append_rgba_param (p, "color", gsk_inset_shadow_node_peek_color (node));
append_float_param (p, "dx", gsk_inset_shadow_node_get_dx (node));
append_float_param (p, "dy", gsk_inset_shadow_node_get_dy (node));
append_float_param (p, "blur", gsk_inset_shadow_node_get_blur_radius (node), 0.0f);
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
append_rgba_param (p, "color", color);
append_float_param (p, "dx", gsk_inset_shadow_node_get_dx (node), 1.0f);
append_float_param (p, "dy", gsk_inset_shadow_node_get_dy (node), 1.0f);
append_rounded_rect_param (p, "outline", gsk_inset_shadow_node_peek_outline (node));
append_float_param (p, "spread", gsk_inset_shadow_node_get_spread (node));
append_float_param (p, "spread", gsk_inset_shadow_node_get_spread (node), 0.0f);
end_node (p);
}
@ -1852,14 +1869,16 @@ render_node_print (Printer *p,
case GSK_TEXT_NODE:
{
const guint n_glyphs = gsk_text_node_get_num_glyphs (node);
const PangoGlyphInfo *glyph;
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node);
const graphene_point_t *offset = gsk_text_node_get_offset (node);
const GdkRGBA *color = gsk_text_node_peek_color (node);
PangoFontDescription *desc;
char *font_name;
guint i;
start_node (p, "text");
append_rgba_param (p, "color", gsk_text_node_peek_color (node));
if (!gdk_rgba_equal (color, &GDK_RGBA("000000")))
append_rgba_param (p, "color", color);
_indent (p);
desc = pango_font_describe ((PangoFont *)gsk_text_node_peek_font (node));;
@ -1870,18 +1889,23 @@ render_node_print (Printer *p,
_indent (p);
g_string_append (p->str, "glyphs: ");
glyph = gsk_text_node_peek_glyphs (node);
g_string_append_printf (p->str, "%u %i %i %i %i",
glyph->glyph, glyph->geometry.width,
glyph->geometry.x_offset, glyph->geometry.y_offset,
glyph->attr.is_cluster_start);
for (i = 1; i < n_glyphs; i ++)
for (i = 0; i < n_glyphs; i++)
{
glyph = gsk_text_node_peek_glyphs (node) + i;
g_string_append_printf (p->str, ", %u %i %i %i %i",
glyph->glyph, glyph->geometry.width,
glyph->geometry.x_offset, glyph->geometry.y_offset,
glyph->attr.is_cluster_start);
if (i > 0)
g_string_append (p->str, ", ");
g_string_append_printf (p->str, "%u %g",
glyphs[i].glyph,
(double) glyphs[i].geometry.width / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start ||
glyphs[i].geometry.x_offset != 0 ||
glyphs[i].geometry.y_offset != 0)
{
g_string_append_printf (p->str, "%g %g",
(double) glyphs[i].geometry.x_offset / PANGO_SCALE,
(double) glyphs[i].geometry.y_offset / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start)
g_string_append (p->str, " same-cluster");
}
}
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
@ -1895,12 +1919,17 @@ render_node_print (Printer *p,
case GSK_DEBUG_NODE:
{
const char *message = gsk_debug_node_get_message (node);
start_node (p, "debug");
_indent (p);
append_node_param (p, "child", gsk_debug_node_get_child (node));
/* TODO: We potentially need to escape certain characters in the message */
g_string_append_printf (p->str, "message: \"%s\";\n", gsk_debug_node_get_message (node));
if (message)
{
_indent (p);
g_string_append_printf (p->str, "message: \"%s\";\n", message);
}
end_node (p);
}
@ -1910,7 +1939,7 @@ render_node_print (Printer *p,
{
start_node (p, "blur");
append_float_param (p, "blur", gsk_blur_node_get_radius (node));
append_float_param (p, "blur", gsk_blur_node_get_radius (node), 1.0f);
append_node_param (p, "child", gsk_blur_node_get_child (node));
end_node (p);
@ -1919,11 +1948,16 @@ render_node_print (Printer *p,
case GSK_REPEAT_NODE:
{
GskRenderNode *child = gsk_repeat_node_get_child (node);
const graphene_rect_t *child_bounds = gsk_repeat_node_peek_child_bounds (node);
start_node (p, "repeat");
append_rect_param (p, "bounds", &node->bounds);
if (!graphene_rect_equal (&node->bounds, &child->bounds))
append_rect_param (p, "bounds", &node->bounds);
append_node_param (p, "child", gsk_repeat_node_get_child (node));
append_rect_param (p, "child-bounds", gsk_repeat_node_peek_child_bounds (node));
if (!graphene_rect_equal (child_bounds, &child->bounds))
append_rect_param (p, "child-bounds", child_bounds);
end_node (p);
}
@ -1938,13 +1972,16 @@ render_node_print (Printer *p,
append_node_param (p, "bottom", gsk_blend_node_get_bottom_child (node));
_indent (p);
for (i = 0; i < G_N_ELEMENTS (blend_modes); i++)
if (mode != GSK_BLEND_MODE_DEFAULT)
{
if (blend_modes[i].mode == mode)
_indent (p);
for (i = 0; i < G_N_ELEMENTS (blend_modes); i++)
{
g_string_append_printf (p->str, "mode: %s;\n", blend_modes[i].name);
break;
if (blend_modes[i].mode == mode)
{
g_string_append_printf (p->str, "mode: %s;\n", blend_modes[i].name);
break;
}
}
}
append_node_param (p, "top", gsk_blend_node_get_top_child (node));

View File

@ -1,4 +1,3 @@
<data>:2:9-10: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:2:17-3:1: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:3:1: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:1:1-3:1: error: GTK_CSS_PARSER_WARNING_SYNTAX

View File

@ -0,0 +1,6 @@
opacity {
child: color {
bounds: 0 0 50 50;
color: rgb(255,0,204);
}
}

View File

@ -1,5 +1,3 @@
<data>:2:3-7: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:2:15-4:1: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:4:1: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:4:1: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:1:1-4:1: error: GTK_CSS_PARSER_WARNING_SYNTAX

View File

@ -0,0 +1,10 @@
cross-fade {
end: color {
bounds: 0 0 50 50;
color: rgb(255,0,204);
}
start: color {
bounds: 0 0 50 50;
color: rgb(170,255,0);
}
}

View File

@ -2,6 +2,6 @@ blur {
blur: 40;
child: color {
bounds: 100 100 100 100;
color: rgb(0,0,0);
color: rgb(255,0,204);
}
}

View File

@ -18,48 +18,38 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 50 26 / 13;
widths: 1;
}
container {
container {
outset-shadow {
blur: 0;
color: rgba(0,0,0,0.1);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
outset-shadow {
blur: 2;
color: rgba(0,0,0,0.07);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
rounded-clip {
child: linear-gradient {
bounds: 0 0 24 24;
end: 12 24;
start: 12 0;
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
stops: 0.2 rgb(255,255,255), 0.9 rgb(246,245,244);
}
clip: -1 -1 26 26 / 13;
}
inset-shadow {
blur: 0;
color: rgb(255,255,255);
dx: 0;
dy: 1;
outline: 0 0 24 24 / 12;
spread: 0;
}
}
border {
colors: rgb(191,184,177);
outline: -1 -1 26 26 / 13;
widths: 1;
}
}
}
@ -69,7 +59,7 @@ transform {
child: text {
color: rgb(46,52,54);
font: "Cantarell 11";
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
glyphs: 37 11, 324 4, 417 7, 244 8, 272 8, 349 4, 287 8, 280 8;
offset: 145 18;
}
transform: translate(56, 0);
@ -89,26 +79,20 @@ transform {
border {
colors: rgb(24,95,180);
outline: -1 -1 50 26 / 13;
widths: 1;
}
transform {
child: container {
container {
outset-shadow {
blur: 0;
color: rgba(0,0,0,0.1);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
outset-shadow {
blur: 2;
color: rgba(0,0,0,0.07);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
rounded-clip {
child: cross-fade {
@ -116,7 +100,7 @@ transform {
bounds: 0 0 24 24;
end: 12 24;
start: 12 0;
stops: 0.1 rgb(255,255,255),0.9 rgb(255,255,255);
stops: 0.1 rgb(255,255,255), 0.9 rgb(255,255,255);
}
progress: 0.756154;
start: cross-fade {
@ -124,7 +108,7 @@ transform {
bounds: 0 0 24 24;
end: 12 24;
start: 12 0;
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
stops: 0.2 rgb(255,255,255), 0.9 rgb(246,245,244);
}
progress: 0.788575;
start: color {
@ -136,18 +120,14 @@ transform {
clip: -1 -1 26 26 / 13;
}
inset-shadow {
blur: 0;
color: rgb(255,255,255);
dx: 0;
dy: 1;
outline: 0 0 24 24 / 12;
spread: 0;
}
}
border {
colors: rgb(24,95,180);
outline: -1 -1 26 26 / 13;
widths: 1;
}
}
transform: translate(24, 0);
@ -159,7 +139,7 @@ transform {
child: text {
color: rgb(46,52,54);
font: "Cantarell 11";
glyphs: 45 9216 0 0 1, 360 8192 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
glyphs: 45 9, 360 8, 244 8, 272 8, 349 4, 287 8, 280 8;
offset: 147 18;
}
transform: translate(56, 0);
@ -181,7 +161,6 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 50 26 / 13;
widths: 1;
}
container {
rounded-clip {
@ -194,7 +173,6 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 26 26 / 13;
widths: 1;
}
}
}
@ -204,7 +182,7 @@ transform {
child: text {
color: rgb(46,52,54);
font: "Cantarell 11";
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
glyphs: 37 11, 324 4, 417 7, 244 8, 272 8, 349 4, 287 8, 280 8;
offset: 145 18;
}
transform: translate(56, 0);
@ -226,7 +204,6 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 50 26 / 13;
widths: 1;
}
transform {
child: container {
@ -240,7 +217,6 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 26 26 / 13;
widths: 1;
}
}
transform: translate(24, 0);
@ -252,7 +228,7 @@ transform {
child: text {
color: rgb(46,52,54);
font: "Cantarell 11";
glyphs: 45 9216 0 0 1, 360 8192 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
glyphs: 45 9, 360 8, 244 8, 272 8, 349 4, 287 8, 280 8;
offset: 147 18;
}
transform: translate(56, 0);
@ -274,48 +250,38 @@ transform {
border {
colors: rgb(205,199,194);
outline: -1 -1 50 26 / 13;
widths: 1;
}
container {
container {
outset-shadow {
blur: 0;
color: rgba(0,0,0,0.1);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
outset-shadow {
blur: 2;
color: rgba(0,0,0,0.07);
dx: 0;
dy: 1;
outline: -1 -1 26 26 / 13;
spread: 0;
}
rounded-clip {
child: linear-gradient {
bounds: 0 0 24 24;
end: 12 24;
start: 12 0;
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
stops: 0.2 rgb(255,255,255), 0.9 rgb(246,245,244);
}
clip: -1 -1 26 26 / 13;
}
inset-shadow {
blur: 0;
color: rgb(255,255,255);
dx: 0;
dy: 1;
outline: 0 0 24 24 / 12;
spread: 0;
}
}
border {
colors: rgb(191,184,177);
outline: -1 -1 26 26 / 13;
widths: 1;
}
}
}
@ -325,7 +291,7 @@ transform {
child: text {
color: rgb(46,52,54);
font: "Cantarell 11";
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
glyphs: 37 11, 324 4, 417 7, 244 8, 272 8, 349 4, 287 8, 280 8;
offset: 123 18;
}
transform: translate(78, 0);
@ -335,40 +301,31 @@ transform {
child: container {
container {
outset-shadow {
blur: 0;
color: rgba(0,0,0,0.1);
dx: 0;
dy: 1;
outline: -1 -1 16 16 / 3;
spread: 0;
}
outset-shadow {
blur: 2;
color: rgba(0,0,0,0.07);
dx: 0;
dy: 1;
outline: -1 -1 16 16 / 3;
spread: 0;
}
linear-gradient {
bounds: 0 0 14 14;
end: 7 14;
start: 7 0;
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
stops: 0.2 rgb(255,255,255), 0.9 rgb(246,245,244);
}
inset-shadow {
blur: 0;
color: rgb(255,255,255);
dx: 0;
dy: 1;
outline: 0 0 14 14 / 2;
spread: 0;
}
}
border {
colors: rgb(191,184,177);
outline: -1 -1 16 16 / 3;
widths: 1;
}
}
transform: translate(1, 6);

File diff suppressed because it is too large Load Diff