initial revision
[swftools.git] / lib / devices / dummy.c
1 /* dummy.c
2
3    Part of the swftools package.
4
5    Copyright (c) 2007 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 #include <stdlib.h>
22 #include <stdio.h>
23 #include <stdarg.h>
24 #include <unistd.h>
25 #include <memory.h>
26 #include "../types.h"
27 #include "../mem.h"
28 #include "../gfxdevice.h"
29 #include "../gfxtools.h"
30
31 typedef struct _internal {
32     gfxdevice_t*out;
33 } internal_t;
34
35 int dummy_setparameter(gfxdevice_t*dev, const char*key, const char*value)
36 {
37     internal_t*i = (internal_t*)dev->internal;
38     return i->out->setparameter(i->out,key,value);
39 }
40
41 void dummy_startpage(gfxdevice_t*dev, int width, int height)
42 {
43     internal_t*i = (internal_t*)dev->internal;
44     i->out->startpage(i->out,width,height);
45 }
46 void dummy_startclip(gfxdevice_t*dev, gfxline_t*line)
47 {
48     internal_t*i = (internal_t*)dev->internal;
49     i->out->startclip(i->out,line);
50 }
51 void dummy_endclip(gfxdevice_t*dev)
52 {
53     internal_t*i = (internal_t*)dev->internal;
54     i->out->endclip(i->out);
55 }
56 void dummy_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
57 {
58     internal_t*i = (internal_t*)dev->internal;
59     i->out->stroke(i->out, line, width, color, cap_style, joint_style, miterLimit);
60 }
61
62 void dummy_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
63 {
64     internal_t*i = (internal_t*)dev->internal;
65     i->out->fill(i->out, line, color);
66 }
67
68 void dummy_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
69 {
70     internal_t*i = (internal_t*)dev->internal;
71     i->out->fillbitmap(i->out, line, img, matrix, cxform);
72 }
73
74 void dummy_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
75 {
76     internal_t*i = (internal_t*)dev->internal;
77     i->out->fillgradient(i->out, line, gradient, type, matrix);
78 }
79
80 void dummy_addfont(gfxdevice_t*dev, gfxfont_t*font)
81 {
82     internal_t*i = (internal_t*)dev->internal;
83     i->out->addfont(i->out, font);
84 }
85
86 void dummy_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
87 {
88     internal_t*i = (internal_t*)dev->internal;
89     i->out->drawchar(i->out, font, glyphnr, color, matrix);
90 }
91
92 void dummy_drawlink(gfxdevice_t*dev, gfxline_t*line, char*action)
93 {
94     internal_t*i = (internal_t*)dev->internal;
95     i->out->drawlink(i->out, line, action);
96 }
97
98 void dummy_endpage(gfxdevice_t*dev)
99 {
100     internal_t*i = (internal_t*)dev->internal;
101     i->out->endpage(i->out);
102 }
103
104 gfxresult_t* dummy_finish(gfxdevice_t*dev)
105 {
106     internal_t*i = (internal_t*)dev->internal;
107     gfxdevice_t*out = i->out;
108     free(dev->internal);dev->internal = 0;i=0;
109     return out->finish(out);
110 }
111
112 void gfxdevice_dummy_init(gfxdevice_t*dev, gfxdevice_t*out)
113 {
114     internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
115     memset(dev, 0, sizeof(gfxdevice_t));
116
117     dev->name = "dummy";
118
119     dev->internal = i;
120
121     dev->setparameter = dummy_setparameter;
122     dev->startpage = dummy_startpage;
123     dev->startclip = dummy_startclip;
124     dev->endclip = dummy_endclip;
125     dev->stroke = dummy_stroke;
126     dev->fill = dummy_fill;
127     dev->fillbitmap = dummy_fillbitmap;
128     dev->fillgradient = dummy_fillgradient;
129     dev->addfont = dummy_addfont;
130     dev->drawchar = dummy_drawchar;
131     dev->drawlink = dummy_drawlink;
132     dev->endpage = dummy_endpage;
133     dev->finish = dummy_finish;
134
135     i->out = out;
136 }
137