summaryrefslogtreecommitdiff
path: root/src/cairo-output-stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-output-stream.c')
-rw-r--r--[-rwxr-xr-x]src/cairo-output-stream.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index facc182f6..c29ea0e39 100755..100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -43,7 +43,6 @@
#include "cairo-compiler-private.h"
#include <stdio.h>
-#include <locale.h>
#include <errno.h>
/* Numbers printed with %f are printed with this number of significant
@@ -303,7 +302,6 @@ _cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
static void
_cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precision)
{
- struct lconv *locale_data;
const char *decimal_point;
int decimal_point_len;
char *p;
@@ -314,8 +312,7 @@ _cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precisi
if (d == 0.0)
d = 0.0;
- locale_data = localeconv ();
- decimal_point = locale_data->decimal_point;
+ decimal_point = cairo_get_locale_decimal_point ();
decimal_point_len = strlen (decimal_point);
assert (decimal_point_len != 0);
@@ -530,6 +527,45 @@ _cairo_output_stream_printf (cairo_output_stream_t *stream,
va_end (ap);
}
+/* Matrix elements that are smaller than the value of the largest element * MATRIX_ROUNDING_TOLERANCE
+ * are rounded down to zero. */
+#define MATRIX_ROUNDING_TOLERANCE 1e-12
+
+void
+_cairo_output_stream_print_matrix (cairo_output_stream_t *stream,
+ const cairo_matrix_t *matrix)
+{
+ cairo_matrix_t m;
+ double s, e;
+
+ m = *matrix;
+ s = fabs (m.xx);
+ if (fabs (m.xy) > s)
+ s = fabs (m.xy);
+ if (fabs (m.yx) > s)
+ s = fabs (m.yx);
+ if (fabs (m.yy) > s)
+ s = fabs (m.yy);
+
+ e = s * MATRIX_ROUNDING_TOLERANCE;
+ if (fabs(m.xx) < e)
+ m.xx = 0;
+ if (fabs(m.xy) < e)
+ m.xy = 0;
+ if (fabs(m.yx) < e)
+ m.yx = 0;
+ if (fabs(m.yy) < e)
+ m.yy = 0;
+ if (fabs(m.x0) < e)
+ m.x0 = 0;
+ if (fabs(m.y0) < e)
+ m.y0 = 0;
+
+ _cairo_output_stream_printf (stream,
+ "%f %f %f %f %f %f",
+ m.xx, m.yx, m.xy, m.yy, m.x0, m.y0);
+}
+
long
_cairo_output_stream_get_position (cairo_output_stream_t *stream)
{