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