several small fixes
[swftools.git] / lib / gfxdevice.h
1 #ifndef __gfxdevice_h__
2 #define __gfxdevice_h__
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #define GFX_SUBPIXEL 2560
9
10 typedef double gfxcoord_t;
11     
12 typedef enum {gfx_moveTo, gfx_lineTo, gfx_splineTo} gfx_linetype;
13 typedef enum {gfx_joinMiter, gfx_joinRound, gfx_joinBevel} gfx_joinType;
14 typedef enum {gfx_capButt, gfx_capRound, gfx_capSquare} gfx_capType;
15
16 typedef struct _gfxline
17 {
18     gfx_linetype type;
19     gfxcoord_t x,y;
20     gfxcoord_t sx,sy;
21     struct _gfxline*next; /*NULL=end*/
22 } gfxline_t;
23
24 typedef struct _gfxglyph
25 {
26     gfxline_t*line;
27     gfxcoord_t advance;
28
29     int unicode; // array?
30     char*name;
31 } gfxglyph_t;
32
33 typedef struct _gfxfont
34 {
35     char*name;
36     int num_glyphs;
37     int max_unicode;
38     gfxglyph_t*glyphs;
39     int* unicode2glyph;
40 } gfxfont_t;
41
42 typedef struct _gfxcolor
43 {
44     unsigned char a;
45     unsigned char r;
46     unsigned char g;
47     unsigned char b;
48 } gfxcolor_t;
49
50 typedef struct _gfxmatrix
51 {
52     double m00,m10,tx;
53     double m01,m11,ty;
54 } gfxmatrix_t;
55
56 typedef struct _gfximage
57 {
58     gfxcolor_t*data;
59     int width;
60     int height;
61 } gfximage_t;
62
63 typedef enum {gfxgradient_radial, gfxgradient_linear} gfxgradienttype_t;
64
65 typedef struct _gfxgradient
66 {
67     gfxcolor_t color;
68     float pos; // 0.0 - 1.0
69     struct _gfxgradient*next; //NULL=end
70 } gfxgradient_t;
71
72 typedef struct _gfxcxform
73 {
74     float rr,rg,rb,ra;
75     float gr,gg,gb,ga;
76     float br,bg,bb,ba;
77     float ar,ag,ab,aa;
78     gfxcolor_t t;
79 } gfxcxform_t;
80
81 typedef struct _gfxbbox
82 {
83     gfxcoord_t xmin, ymin, xmax, ymax;
84 } gfxbbox_t;
85
86 typedef struct _gfxdevice
87 {
88     int (*setparameter)(struct _gfxdevice*dev, const char*key, const char*value);
89
90     int (*startpage)(struct _gfxdevice*dev, int xmin, int ymin, int xmax, int ymax); /*xmin/ymin?*/
91
92     void (*startclip)(struct _gfxdevice*dev, gfxline_t*line);
93     void (*endclip)(struct _gfxdevice*dev);
94     void (*stroke)(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit);
95     void (*fill)(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color);
96     void (*fillbitmap)(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform); //cxform? tiling?
97     void (*fillgradient)(struct _gfxdevice*dev, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix); //?
98
99     void (*addfont)(struct _gfxdevice*dev, char*fontid, gfxfont_t*font, gfxmatrix_t*matrix);
100     void (*drawchar)(struct _gfxdevice*dev, char*fontid, int glyph, int x, int y);
101
102     void (*drawlink)(struct _gfxdevice*dev, int x1, int y1, int x2, int y2, char*action);
103     
104     int (*endpage)(struct _gfxdevice*dev); //?
105     
106     int (*finish)(struct _gfxdevice*dev);
107
108     void* internal;
109 } gfxdevice_t;
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif //__gfxdevice_h__