1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
#include "fitz_base.h"
#include "fitz_tree.h"
/*
* Over
*/
fz_error *
fz_newovernode(fz_node **nodep)
{
fz_node *node;
node = *nodep = fz_malloc(sizeof (fz_overnode));
if (!node)
return fz_outofmem;
fz_initnode(node, FZ_NOVER);
return fz_okay;
}
fz_rect
fz_boundovernode(fz_overnode *node, fz_matrix ctm)
{
fz_node *child;
fz_rect bbox;
fz_rect temp;
child = node->super.first;
if (!child)
return fz_emptyrect;
bbox = fz_boundnode(child, ctm);
child = child->next;
while (child)
{
temp = fz_boundnode(child, ctm);
bbox = fz_mergerects(temp, bbox);
child = child->next;
}
return bbox;
}
/*
* Mask
*/
fz_error *
fz_newmasknode(fz_node **nodep)
{
fz_node *node;
node = *nodep = fz_malloc(sizeof (fz_masknode));
if (!node)
return fz_outofmem;
fz_initnode(node, FZ_NMASK);
return fz_okay;
}
fz_rect
fz_boundmasknode(fz_masknode *node, fz_matrix ctm)
{
fz_node *shape;
fz_node *color;
fz_rect one, two;
shape = node->super.first;
color = shape->next;
one = fz_boundnode(shape, ctm);
two = fz_boundnode(color, ctm);
return fz_intersectrects(one, two);
}
/*
* Blend
*/
fz_error *
fz_newblendnode(fz_node **nodep, fz_blendkind b, int k, int i)
{
fz_blendnode *node;
node = fz_malloc(sizeof (fz_blendnode));
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NBLEND);
node->mode = b;
node->knockout = k;
node->isolated = i;
return fz_okay;
}
fz_rect
fz_boundblendnode(fz_blendnode *node, fz_matrix ctm)
{
fz_node *child;
fz_rect bbox;
fz_rect temp;
child = node->super.first;
if (!child)
return fz_emptyrect;
bbox = fz_boundnode(child, ctm);
child = child->next;
while (child)
{
temp = fz_boundnode(child, ctm);
bbox = fz_mergerects(temp, bbox);
child = child->next;
}
return bbox;
}
void
fz_dropblendnode(fz_blendnode *node)
{
fz_dropcolorspace(node->cs);
}
/*
* Transform
*/
fz_error *
fz_newtransformnode(fz_node **nodep, fz_matrix m)
{
fz_transformnode *node;
node = fz_malloc(sizeof (fz_transformnode));
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NTRANSFORM);
node->m = m;
return fz_okay;
}
fz_rect
fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm)
{
if (!node->super.first)
return fz_emptyrect;
return fz_boundnode(node->super.first, fz_concat(node->m, ctm));
}
/*
* Link to tree
*/
fz_error *
fz_newlinknode(fz_node **nodep, fz_tree *subtree)
{
fz_linknode *node;
node = fz_malloc(sizeof (fz_linknode));
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NLINK);
node->tree = fz_keeptree(subtree);
return fz_okay;
}
void
fz_droplinknode(fz_linknode *node)
{
fz_droptree(node->tree);
}
fz_rect
fz_boundlinknode(fz_linknode *node, fz_matrix ctm)
{
return fz_boundtree(node->tree, ctm);
}
/*
* Solid color
*/
fz_error *
fz_newsolidnode(fz_node **nodep, float a, fz_colorspace *cs, int n, float *v)
{
fz_solidnode *node;
int i;
node = fz_malloc(sizeof(fz_solidnode) + sizeof(float) * n);
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NCOLOR);
node->a = a;
node->cs = fz_keepcolorspace(cs);
node->n = n;
for (i = 0; i < n; i++)
node->samples[i] = v[i];
return fz_okay;
}
fz_rect
fz_boundsolidnode(fz_solidnode *node, fz_matrix ctm)
{
return fz_infiniterect;
}
void
fz_dropsolidnode(fz_solidnode *node)
{
fz_dropcolorspace(node->cs);
}
/*
* Image node
*/
fz_error *
fz_newimagenode(fz_node **nodep, fz_image *image)
{
fz_imagenode *node;
node = fz_malloc(sizeof (fz_imagenode));
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NIMAGE);
node->image = fz_keepimage(image);
return fz_okay;
}
void
fz_dropimagenode(fz_imagenode *node)
{
fz_dropimage(node->image);
}
fz_rect
fz_boundimagenode(fz_imagenode *node, fz_matrix ctm)
{
fz_rect bbox;
bbox.x0 = 0;
bbox.y0 = 0;
bbox.x1 = 1;
bbox.y1 = 1;
return fz_transformaabb(ctm, bbox);
}
/*
* Shade node
*/
fz_error *
fz_newshadenode(fz_node **nodep, fz_shade *shade)
{
fz_shadenode *node;
node = fz_malloc(sizeof (fz_shadenode));
if (!node)
return fz_outofmem;
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NSHADE);
node->shade = fz_keepshade(shade);
return fz_okay;
}
void
fz_dropshadenode(fz_shadenode *node)
{
fz_dropshade(node->shade);
}
fz_rect
fz_boundshadenode(fz_shadenode *node, fz_matrix ctm)
{
return fz_boundshade(node->shade, ctm);
}
|