2 * This file is part of Libsvgtiny
3 * Licensed under the MIT License,
4 * http://opensource.org/licenses/mit-license.php
5 * Copyright 2008 James Bursa <james@semichrome.net>
8 #ifndef SVGTINY_INTERNAL_H
9 #define SVGTINY_INTERNAL_H
14 #include <libcss/libcss.h>
17 #define UNUSED(x) ((void) (x))
20 struct svgtiny_gradient_stop
{
25 #define svgtiny_MAX_STOPS 10
26 #define svgtiny_LINEAR_GRADIENT 0x2000000
28 struct svgtiny_parse_state_gradient
{
29 unsigned int linear_gradient_stop_count
;
30 dom_string
*gradient_x1
, *gradient_y1
, *gradient_x2
, *gradient_y2
;
31 struct svgtiny_gradient_stop gradient_stop
[svgtiny_MAX_STOPS
];
32 bool gradient_user_space_on_use
;
34 float a
, b
, c
, d
, e
, f
;
38 struct svgtiny_parse_state
{
39 struct svgtiny_diagram
*diagram
;
40 dom_document
*document
;
43 float viewport_height
;
45 /* current transformation matrix */
47 float a
, b
, c
, d
, e
, f
;
50 /* A libcss context to hold any stylesheets that are present
51 * in the SVG document. This should be pre-populated rather
52 * than on-the-fly, because, for example, a <style> sheet at
53 * the end of the document should affect the SVG elements that
55 css_select_ctx
*select_ctx
;
57 /* paint attributes */
59 svgtiny_colour stroke
;
63 struct svgtiny_parse_state_gradient fill_grad
;
64 struct svgtiny_parse_state_gradient stroke_grad
;
66 /* Interned strings */
67 #define SVGTINY_STRING_ACTION2(n,nn) dom_string *interned_##n;
68 #include "svgtiny_strings.h"
69 #undef SVGTINY_STRING_ACTION2
71 /* Where we store the interned copy of the SVG XML namespace,
73 * http://www.w3.org/2000/svg
75 * We handle it separately it has a different type
76 * (lwc_string) than those above (dom_string).
78 lwc_string
*interned_svg_xmlns
;
84 float svgtiny_parse_length(dom_string
*s
, int viewport_size
,
85 const struct svgtiny_parse_state state
);
86 void svgtiny_parse_color(dom_string
*s
, svgtiny_colour
*c
,
87 struct svgtiny_parse_state_gradient
*grad
,
88 struct svgtiny_parse_state
*state
);
89 void svgtiny_parse_transform(char *s
, float *ma
, float *mb
,
90 float *mc
, float *md
, float *me
, float *mf
);
91 struct svgtiny_shape
*svgtiny_add_shape(struct svgtiny_parse_state
*state
);
92 void svgtiny_transform_path(float *p
, unsigned int n
,
93 struct svgtiny_parse_state
*state
);
94 #if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__amigaos4__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
98 char *svgtiny_strndup(const char *s
, size_t n
);
99 #define strndup svgtiny_strndup
103 css_error
svgtiny_create_stylesheet(css_stylesheet
**sheet
,
106 /* svgtiny_gradient.c */
107 void svgtiny_find_gradient(const char *id
,
108 struct svgtiny_parse_state_gradient
*grad
,
109 struct svgtiny_parse_state
*state
);
110 svgtiny_code
svgtiny_add_path_linear_gradient(float *p
, unsigned int n
,
111 struct svgtiny_parse_state
*state
);
114 struct svgtiny_list
*svgtiny_list_create(size_t item_size
);
115 unsigned int svgtiny_list_size(struct svgtiny_list
*list
);
116 svgtiny_code
svgtiny_list_resize(struct svgtiny_list
*list
,
117 unsigned int new_size
);
118 void *svgtiny_list_get(struct svgtiny_list
*list
,
120 void *svgtiny_list_push(struct svgtiny_list
*list
);
121 void svgtiny_list_free(struct svgtiny_list
*list
);