]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - src/svgtiny_internal.h
158d23059c60c5ea69b01e71ad2fe58832cacbfb
[libsvgtiny.git] / src / svgtiny_internal.h
1 /*
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>
6 */
7
8 #ifndef SVGTINY_INTERNAL_H
9 #define SVGTINY_INTERNAL_H
10
11 #include <stdbool.h>
12
13 #include <dom/dom.h>
14
15 #ifndef UNUSED
16 #define UNUSED(x) ((void) (x))
17 #endif
18
19 struct svgtiny_gradient_stop {
20 float offset;
21 svgtiny_colour color;
22 };
23
24 #define svgtiny_MAX_STOPS 10
25 #define svgtiny_LINEAR_GRADIENT 0x2000000
26
27 struct svgtiny_parse_state_gradient {
28 unsigned int linear_gradient_stop_count;
29 dom_string *gradient_x1, *gradient_y1, *gradient_x2, *gradient_y2;
30 struct svgtiny_gradient_stop gradient_stop[svgtiny_MAX_STOPS];
31 bool gradient_user_space_on_use;
32 struct {
33 float a, b, c, d, e, f;
34 } gradient_transform;
35 };
36
37 struct svgtiny_parse_state {
38 struct svgtiny_diagram *diagram;
39 dom_document *document;
40
41 float viewport_width;
42 float viewport_height;
43
44 /* current transformation matrix */
45 struct {
46 float a, b, c, d, e, f;
47 } ctm;
48
49 /*struct css_style style;*/
50
51 /* paint attributes */
52 svgtiny_colour fill;
53 svgtiny_colour stroke;
54 int stroke_width;
55
56 /* gradients */
57 struct svgtiny_parse_state_gradient fill_grad;
58 struct svgtiny_parse_state_gradient stroke_grad;
59
60 /* Interned strings */
61 #define SVGTINY_STRING_ACTION2(n,nn) dom_string *interned_##n;
62 #include "svgtiny_strings.h"
63 #undef SVGTINY_STRING_ACTION2
64
65 };
66
67 struct svgtiny_list;
68
69 /* svgtiny.c */
70 float svgtiny_parse_length(dom_string *s, int viewport_size,
71 const struct svgtiny_parse_state state);
72 void svgtiny_parse_color(dom_string *s, svgtiny_colour *c,
73 struct svgtiny_parse_state_gradient *grad,
74 struct svgtiny_parse_state *state);
75 void svgtiny_parse_transform(char *s, float *ma, float *mb,
76 float *mc, float *md, float *me, float *mf);
77 struct svgtiny_shape *svgtiny_add_shape(struct svgtiny_parse_state *state);
78 void svgtiny_transform_path(float *p, unsigned int n,
79 struct svgtiny_parse_state *state);
80 #if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__amigaos4__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
81 #define HAVE_STRNDUP
82 #else
83 #undef HAVE_STRNDUP
84 char *svgtiny_strndup(const char *s, size_t n);
85 #define strndup svgtiny_strndup
86 #endif
87
88 /* svgtiny_gradient.c */
89 void svgtiny_find_gradient(const char *id,
90 struct svgtiny_parse_state_gradient *grad,
91 struct svgtiny_parse_state *state);
92 svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n,
93 struct svgtiny_parse_state *state);
94
95 /* svgtiny_list.c */
96 struct svgtiny_list *svgtiny_list_create(size_t item_size);
97 unsigned int svgtiny_list_size(struct svgtiny_list *list);
98 svgtiny_code svgtiny_list_resize(struct svgtiny_list *list,
99 unsigned int new_size);
100 void *svgtiny_list_get(struct svgtiny_list *list,
101 unsigned int i);
102 void *svgtiny_list_push(struct svgtiny_list *list);
103 void svgtiny_list_free(struct svgtiny_list *list);
104
105 /* colors.gperf */
106 const struct svgtiny_named_color *
107 svgtiny_color_lookup(register const char *str,
108 register unsigned int len);
109
110 #endif