seed random from ruby interface
[swftools.git] / lib / gfxfilter.h
1 /* gfxfilter.h
2
3    Part of the swftools package.
4
5    Copyright (c) 2010 Matthias Kramm <kramm@quiss.org> 
6  
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
20
21 #ifndef __gfxfilter_h__
22 #define __gfxfilter_h__
23
24 #include "gfxdevice.h"
25 #include "types.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 typedef enum {gfxfilter_none, gfxfilter_onepass, gfxfilter_twopass} gfxfiltertype_t;
32
33 typedef struct _gfxfilterbase
34 {
35     gfxfiltertype_t type;
36 } gfxfilterbase_t;
37
38 typedef struct _gfxfilter
39 {
40     gfxfiltertype_t type;
41     int num_passes;
42     const char*name;
43
44     int pass;
45
46     int (*setparameter)(struct _gfxfilter*in, const char*key, const char*value, struct _gfxdevice*out);
47     void (*startpage)(struct _gfxfilter*in, int width, int height, struct _gfxdevice*out);
48     void (*startclip)(struct _gfxfilter*in, gfxline_t*line, struct _gfxdevice*out);
49     void (*endclip)(struct _gfxfilter*in, struct _gfxdevice*out);
50     void (*stroke)(struct _gfxfilter*in, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit, struct _gfxdevice*out);
51     void (*fill)(struct _gfxfilter*in, gfxline_t*line, gfxcolor_t*color, struct _gfxdevice*out);
52     void (*fillbitmap)(struct _gfxfilter*in, gfxline_t*line, gfximage_t*img, gfxmatrix_t*imgcoord2devcoord, gfxcxform_t*cxform, struct _gfxdevice*out); //cxform? tiling?
53     void (*fillgradient)(struct _gfxfilter*in, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*gradcoord2devcoord, struct _gfxdevice*out); //?
54     void (*addfont)(struct _gfxfilter*in, gfxfont_t*font, struct _gfxdevice*out);
55     void (*drawchar)(struct _gfxfilter*in, gfxfont_t*font, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix, struct _gfxdevice*out);
56     void (*drawlink)(struct _gfxfilter*in, gfxline_t*line, const char*action, struct _gfxdevice*out);
57     void (*endpage)(struct _gfxfilter*in, struct _gfxdevice*out);
58     gfxresult_t* (*finish)(struct _gfxfilter*in, struct _gfxdevice*out);
59
60     void (*dealloc)(struct _gfxfilter*f);
61
62     void* internal;
63 } gfxfilter_t;
64
65 typedef struct _gfxtwopassfilter
66 {
67     gfxfiltertype_t type;
68     gfxfilter_t pass1;
69     gfxfilter_t pass2;
70 } gfxtwopassfilter_t;
71
72 gfxdevice_t*gfxfilter_apply(gfxfilter_t*filter, gfxdevice_t*dev);
73 gfxdevice_t*gfxtwopassfilter_apply(gfxtwopassfilter_t*filter, gfxdevice_t*dev);
74
75 typedef struct _gfxfilterchain {
76     gfxfilterbase_t*filter;
77     struct _gfxfilterchain*next;
78 } gfxfilterchain_t;
79
80 gfxfilterchain_t* gfxfilterchain_parse(const char*filterexpr);
81 gfxdevice_t* gfxfilterchain_apply(gfxfilterchain_t*chain, gfxdevice_t*dev);
82 void gfxfilterchain_destroy(gfxfilterchain_t*chain);
83
84 #define wrap_filter(dev, name, args...) \
85     {gfxfilter_t f_##name; \
86      gfxfilter_##name##_init(&f_##name, ## args); \
87      dev = gfxfilter_apply(&f_##name, dev); \
88     }
89
90 #define wrap_filter2(dev, name, args...) \
91     {gfxtwopassfilter_t f_##name; \
92      gfxtwopassfilter_##name##_init(&f_##name, ## args); \
93      dev = gfxtwopassfilter_apply(&f_##name, dev); \
94     }
95
96 /* known filters */
97 void gfxfilter_maketransparent_init(gfxfilter_t*f, U8 alpha);
98 void gfxtwopassfilter_remove_font_transforms_init(gfxtwopassfilter_t*f);
99 void gfxtwopassfilter_one_big_font_init(gfxtwopassfilter_t*f);
100 void gfxtwopassfilter_vectors_to_glyphs_init(gfxtwopassfilter_t*f);
101
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif //__gfxfilter_h__