fixed drawlink prototype
[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     int num_glyphs;
36     int max_unicode;
37     gfxglyph_t*glyphs;
38     int* unicode2glyph;
39 } gfxfont_t;
40
41 typedef struct _gfxcolor
42 {
43     unsigned char a;
44     unsigned char r;
45     unsigned char g;
46     unsigned char b;
47 } gfxcolor_t;
48
49 typedef struct _gfxmatrix
50 {
51     double m00,m10,tx;
52     double m01,m11,ty;
53 } gfxmatrix_t;
54
55 typedef struct _gfximage
56 {
57     gfxcolor_t*data;
58     int width;
59     int height;
60 } gfximage_t;
61
62 typedef enum {gfxgradient_radial, gfxgradient_linear} gfxgradienttype_t;
63
64 typedef struct _gfxgradient
65 {
66     gfxcolor_t color;
67     float pos; // 0.0 - 1.0
68     struct _gfxgradient*next; //NULL=end
69 } gfxgradient_t;
70
71 typedef struct _gfxcxform
72 {
73     float rr,rg,rb,ra, tr;
74     float gr,gg,gb,ga, tg;
75     float br,bg,bb,ba, tb;
76     float ar,ag,ab,aa, ta;
77     gfxcolor_t t;
78 } gfxcxform_t;
79
80 typedef struct _gfxbbox
81 {
82     gfxcoord_t xmin, ymin, xmax, ymax;
83 } gfxbbox_t;
84
85 typedef struct _gfxdevice
86 {
87     int (*setparameter)(struct _gfxdevice*dev, const char*key, const char*value);
88
89     void (*startpage)(struct _gfxdevice*dev, int xmin, int ymin, int xmax, int ymax); /*xmin/ymin?*/
90
91     void (*startclip)(struct _gfxdevice*dev, gfxline_t*line);
92     void (*endclip)(struct _gfxdevice*dev);
93     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);
94     void (*fill)(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color);
95     void (*fillbitmap)(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform); //cxform? tiling?
96     void (*fillgradient)(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix); //?
97
98     void (*addfont)(struct _gfxdevice*dev, char*fontid, gfxfont_t*font);
99     void (*drawchar)(struct _gfxdevice*dev, char*fontid, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix);
100
101     void (*drawlink)(struct _gfxdevice*dev, gfxline_t*line, char*action);
102     
103     void (*endpage)(struct _gfxdevice*dev); //?
104     
105     void* (*finish)(struct _gfxdevice*dev);
106
107     void* internal;
108 } gfxdevice_t;
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif //__gfxdevice_h__