diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c index 9d12e18595..4071a387bc 100644 --- a/gsk/gskcontour.c +++ b/gsk/gskcontour.c @@ -27,6 +27,13 @@ #include "gskpathpoint.h" #include "gskstrokeprivate.h" +#include + +/* This is C11 */ +#ifndef FLT_DECIMAL_DIG +#define FLT_DECIMAL_DIG 9 +#endif + typedef struct _GskContourClass GskContourClass; struct _GskContour @@ -98,15 +105,12 @@ struct _GskContourClass #define RAD_TO_DEG(x) ((x) / (G_PI / 180.f)) static void -_g_string_append_double (GString *string, - const char *prefix, - double d) +_g_string_append_float (GString *string, + const char *prefix, + float f) { - char buf[G_ASCII_DTOSTR_BUF_SIZE]; - - g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, d); g_string_append (string, prefix); - g_string_append (string, buf); + g_string_append_printf (string, "%.*g", FLT_DECIMAL_DIG, f); } static void @@ -114,8 +118,8 @@ _g_string_append_point (GString *string, const char *prefix, const graphene_point_t *pt) { - _g_string_append_double (string, prefix, pt->x); - _g_string_append_double (string, " ", pt->y); + _g_string_append_float (string, prefix, pt->x); + _g_string_append_float (string, " ", pt->y); } static gboolean @@ -481,7 +485,7 @@ foreach_print (GskPathOperation op, case GSK_PATH_CONIC: _g_string_append_point (string, " O ", &pts[1]); _g_string_append_point (string, ", ", &pts[2]); - _g_string_append_double (string, ", ", weight); + _g_string_append_float (string, ", ", weight); break; default: @@ -1363,16 +1367,16 @@ gsk_circle_contour_print (const GskContour *contour, _g_string_append_point (string, "M ", &GRAPHENE_POINT_INIT (self->center.x + radius, self->center.y)); _g_string_append_point (string, " o ", &GRAPHENE_POINT_INIT (0, radius)); _g_string_append_point (string, ", ", &GRAPHENE_POINT_INIT (radius_neg, radius)); - _g_string_append_double (string, ", ", M_SQRT1_2); + _g_string_append_float (string, ", ", M_SQRT1_2); _g_string_append_point (string, " o ", &GRAPHENE_POINT_INIT (radius_neg, 0)); _g_string_append_point (string, ", ", &GRAPHENE_POINT_INIT (radius_neg, radius_neg)); - _g_string_append_double (string, ", ", M_SQRT1_2); + _g_string_append_float (string, ", ", M_SQRT1_2); _g_string_append_point (string, " o ", &GRAPHENE_POINT_INIT (0, radius_neg)); _g_string_append_point (string, ", ", &GRAPHENE_POINT_INIT (radius, radius_neg)); - _g_string_append_double (string, ", ", M_SQRT1_2); + _g_string_append_float (string, ", ", M_SQRT1_2); _g_string_append_point (string, " o ", &GRAPHENE_POINT_INIT (radius, 0)); _g_string_append_point (string, ", ", &GRAPHENE_POINT_INIT (radius, radius)); - _g_string_append_double (string, ", ", M_SQRT1_2); + _g_string_append_float (string, ", ", M_SQRT1_2); g_string_append (string, " z"); } @@ -1803,9 +1807,9 @@ gsk_rect_contour_print (const GskContour *contour, const GskRectContour *self = (const GskRectContour *) contour; _g_string_append_point (string, "M ", &GRAPHENE_POINT_INIT (self->x, self->y)); - _g_string_append_double (string, " h ", self->width); - _g_string_append_double (string, " v ", self->height); - _g_string_append_double (string, " h ", - self->width); + _g_string_append_float (string, " h ", self->width); + _g_string_append_float (string, " v ", self->height); + _g_string_append_float (string, " h ", - self->width); g_string_append (string, " z"); } diff --git a/testsuite/gsk/nodeparser/empty-fill.node b/testsuite/gsk/nodeparser/empty-fill.node index 266c3c2455..a7770b41f4 100644 --- a/testsuite/gsk/nodeparser/empty-fill.node +++ b/testsuite/gsk/nodeparser/empty-fill.node @@ -1 +1,14 @@ -fill { } +fill { + child: color { + bounds: 1.22359 0 47.5528 45.2254; + color: rgb(255,0,204); + } + path: "\ +M 25 0\ +L 39.6946297 45.2254257\ +L 1.22358704 17.2745743\ +L 48.776413 17.2745743\ +L 10.3053684 45.2254257\ +Z"; + fill-rule: winding; +} diff --git a/testsuite/gsk/nodeparser/empty-fill.ref.node b/testsuite/gsk/nodeparser/empty-fill.ref.node index 233a990899..a7770b41f4 100644 --- a/testsuite/gsk/nodeparser/empty-fill.ref.node +++ b/testsuite/gsk/nodeparser/empty-fill.ref.node @@ -5,10 +5,10 @@ fill { } path: "\ M 25 0\ -L 39.694629669189453 45.225425720214844\ -L 1.2235870361328125 17.274574279785156\ -L 48.776412963867188 17.274574279785156\ -L 10.305368423461914 45.225425720214844\ +L 39.6946297 45.2254257\ +L 1.22358704 17.2745743\ +L 48.776413 17.2745743\ +L 10.3053684 45.2254257\ Z"; fill-rule: winding; } diff --git a/testsuite/gsk/nodeparser/empty-stroke.node b/testsuite/gsk/nodeparser/empty-stroke.node index e918806b1f..5517ce8e90 100644 --- a/testsuite/gsk/nodeparser/empty-stroke.node +++ b/testsuite/gsk/nodeparser/empty-stroke.node @@ -1 +1,16 @@ -stroke { } +stroke { + child: color { + bounds: -2.77641 -4 55.5528 53.2254; + color: rgb(255,0,204); + } + path: "\ +M 25 0\ +L 39.6946297 45.2254257\ +L 1.22358704 17.2745743\ +L 48.776413 17.2745743\ +L 10.3053684 45.2254257\ +Z"; + line-width: 1; + line-cap: butt; + line-join: miter; +} diff --git a/testsuite/gsk/nodeparser/empty-stroke.ref.node b/testsuite/gsk/nodeparser/empty-stroke.ref.node index c32daa6885..5517ce8e90 100644 --- a/testsuite/gsk/nodeparser/empty-stroke.ref.node +++ b/testsuite/gsk/nodeparser/empty-stroke.ref.node @@ -5,10 +5,10 @@ stroke { } path: "\ M 25 0\ -L 39.694629669189453 45.225425720214844\ -L 1.2235870361328125 17.274574279785156\ -L 48.776412963867188 17.274574279785156\ -L 10.305368423461914 45.225425720214844\ +L 39.6946297 45.2254257\ +L 1.22358704 17.2745743\ +L 48.776413 17.2745743\ +L 10.3053684 45.2254257\ Z"; line-width: 1; line-cap: butt; diff --git a/testsuite/gsk/path-special-cases.c b/testsuite/gsk/path-special-cases.c index 10c54ada17..211bc8512b 100644 --- a/testsuite/gsk/path-special-cases.c +++ b/testsuite/gsk/path-special-cases.c @@ -1309,7 +1309,7 @@ test_rounded_rect_plain (void) path = gsk_path_builder_free_to_path (builder); s = gsk_path_to_string (path); - g_assert_cmpstr (s, ==, "M 20 10 L 100 10 O 110 10, 110 20, 0.70710676908493042 L 110 200 O 110 210, 100 210, 0.70710676908493042 L 20 210 O 10 210, 10 200, 0.70710676908493042 L 10 20 O 10 10, 20 10, 0.70710676908493042 Z"); + g_assert_cmpstr (s, ==, "M 20 10 L 100 10 O 110 10, 110 20, 0.707106769 L 110 200 O 110 210, 100 210, 0.707106769 L 20 210 O 10 210, 10 200, 0.707106769 L 10 20 O 10 10, 20 10, 0.707106769 Z"); g_free (s); measure = gsk_path_measure_new (path); @@ -1453,7 +1453,7 @@ test_rounded_rect_tricky (void) path = gsk_path_builder_free_to_path (builder); s = gsk_path_to_string (path); - g_assert_cmpstr (s, ==, "M 10 10 L 110 10 L 110 110 L 110 210 L 20 210 O 10 210, 10 200, 0.70710676908493042 L 10 10 Z"); + g_assert_cmpstr (s, ==, "M 10 10 L 110 10 L 110 110 L 110 210 L 20 210 O 10 210, 10 200, 0.707106769 L 10 10 Z"); g_free (s); measure = gsk_path_measure_new (path); @@ -1556,13 +1556,13 @@ test_rounded_rect_parse (void) path = gsk_path_builder_free_to_path (builder); s = gsk_path_to_string (path); - g_assert_cmpstr (s, ==, "M 12 10 L 104 10 O 110 10, 110 18, 0.70710676908493042 L 110 109 O 110 121, 100 121, 0.70710676908493042 L 24 121 O 10 121, 10 105, 0.70710676908493042 L 10 14 O 10 10, 12 10, 0.70710676908493042 Z"); + g_assert_cmpstr (s, ==, "M 12 10 L 104 10 O 110 10, 110 18, 0.707106769 L 110 109 O 110 121, 100 121, 0.707106769 L 24 121 O 10 121, 10 105, 0.707106769 L 10 14 O 10 10, 12 10, 0.707106769 Z"); path2 = gsk_path_parse (s); g_free (s); s = gsk_path_to_string (path2); - g_assert_cmpstr (s, ==, "M 12 10 L 104 10 O 110 10, 110 18, 0.70710676908493042 L 110 109 O 110 121, 100 121, 0.70710676908493042 L 24 121 O 10 121, 10 105, 0.70710676908493042 L 10 14 O 10 10, 12 10, 0.70710676908493042 Z"); + g_assert_cmpstr (s, ==, "M 12 10 L 104 10 O 110 10, 110 18, 0.707106769 L 110 109 O 110 121, 100 121, 0.707106769 L 24 121 O 10 121, 10 105, 0.707106769 L 10 14 O 10 10, 12 10, 0.707106769 Z"); g_free (s); gsk_path_unref (path); @@ -1589,7 +1589,7 @@ test_circle_plain (void) path = gsk_path_builder_free_to_path (builder); s = gsk_path_to_string (path); - g_assert_cmpstr (s, ==, "M 110 100 o 0 10, -10 10, 0.70710678118654757 o -10 0, -10 -10, 0.70710678118654757 o 0 -10, 10 -10, 0.70710678118654757 o 10 0, 10 10, 0.70710678118654757 z"); + g_assert_cmpstr (s, ==, "M 110 100 o 0 10, -10 10, 0.707106769 o -10 0, -10 -10, 0.707106769 o 0 -10, 10 -10, 0.707106769 o 10 0, 10 10, 0.707106769 z"); g_free (s); measure = gsk_path_measure_new (path); @@ -1642,7 +1642,7 @@ test_circle_zero (void) path = gsk_path_builder_free_to_path (builder); s = gsk_path_to_string (path); - g_assert_cmpstr (s, ==, "M 100 100 o 0 0, 0 0, 0.70710678118654757 o 0 0, 0 0, 0.70710678118654757 o 0 0, 0 0, 0.70710678118654757 o 0 0, 0 0, 0.70710678118654757 z"); + g_assert_cmpstr (s, ==, "M 100 100 o 0 0, 0 0, 0.707106769 o 0 0, 0 0, 0.707106769 o 0 0, 0 0, 0.707106769 o 0 0, 0 0, 0.707106769 z"); g_free (s); measure = gsk_path_measure_new (path);