summaryrefslogtreecommitdiff
path: root/include/fitz/tree.h
blob: 080e55bf2cebefca91297f530dbdb82e050b62df (plain)
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
typedef struct fz_tree_s fz_tree;
typedef struct fz_node_s fz_node;

typedef enum fz_nodekind_e fz_nodekind;
typedef enum fz_blendkind_e fz_blendkind;

typedef struct fz_transform_s fz_transform;
typedef struct fz_over_s fz_over;
typedef struct fz_mask_s fz_mask;
typedef struct fz_blend_s fz_blend;
typedef struct fz_path_s fz_path;
typedef struct fz_text_s fz_text;
typedef struct fz_solid_s fz_solid;
typedef struct fz_image_s fz_image;
typedef struct fz_shade_s fz_shade;
typedef struct fz_form_s fz_form;
typedef struct fz_meta_s fz_meta;
typedef struct fz_halftone_s fz_halftone;

enum fz_nodekind_e
{
	FZ_NTRANSFORM,
	FZ_NOVER,
	FZ_NMASK,
	FZ_NBLEND,
	FZ_NPATH,
	FZ_NTEXT,
	FZ_NSOLID,
	FZ_NIMAGE,
	FZ_NSHADE,
	FZ_NFORM,
	FZ_NMETA,
	FZ_NHALFTONE
};

enum fz_blendkind_e
{
	/* PDF 1.4 -- standard separable */
	FZ_BNORMAL,
	FZ_BMULTIPLY,
	FZ_BSCREEN,
	FZ_BOVERLAY,
	FZ_BDARKEN,
	FZ_BLIGHTEN,
	FZ_BCOLORDODGE,
	FZ_BCOLORBURN,
	FZ_BHARDLIGHT,
	FZ_BSOFTLIGHT,
	FZ_BDIFFERENCE,
	FZ_BEXCLUSION,

	/* PDF 1.4 -- standard non-separable */
	FZ_BHUE,
	FZ_BSATURATION,
	FZ_BCOLOR,
	FZ_BLUMINOSITY,

	FZ_BOVERPRINT,
};

struct fz_tree_s
{
	fz_node *root;
	fz_node *head;
};

struct fz_node_s
{
	fz_nodekind kind;
	fz_node *parent;
	fz_node *next;
};

struct fz_meta_s
{
	fz_node super;
	fz_node *child;
	fz_obj *info;
};

struct fz_over_s
{
	fz_node super;
	fz_node *child;
};

struct fz_mask_s
{
	fz_node super;
	fz_node *child;
};

struct fz_blend_s
{
	fz_node super;
	fz_node *child;
	fz_blendkind mode;
	int isolated;
	int knockout;
};

struct fz_transform_s
{
	fz_node super;
	fz_node *child;
	fz_matrix m;
};

struct fz_form_s
{
	fz_node super;
	fz_tree *tree;
};

struct fz_solid_s
{
	fz_node super;
	float r, g, b;
};

/* tree operations */
fz_error *fz_newtree(fz_tree **treep);
void fz_freetree(fz_tree *tree);
fz_rect fz_boundtree(fz_tree *tree, fz_matrix ctm);

void fz_debugtree(fz_tree *tree);
void fz_insertnode(fz_node *node, fz_node *child);

/* common to all nodes */
void fz_initnode(fz_node *node, fz_nodekind kind);
fz_rect fz_boundnode(fz_node *node, fz_matrix ctm);
void fz_freenode(fz_node *node);

/* branch nodes */
fz_error *fz_newmeta(fz_node **nodep, fz_obj *info);
fz_error *fz_newover(fz_node **nodep);
fz_error *fz_newmask(fz_node **nodep);
fz_error *fz_newblend(fz_node **nodep, fz_blendkind b, int k, int i);
fz_error *fz_newtransform(fz_node **nodep, fz_matrix m);

int fz_ismeta(fz_node *node);
int fz_isover(fz_node *node);
int fz_ismask(fz_node *node);
int fz_isblend(fz_node *node);
int fz_istransform(fz_node *node);

/* leaf nodes */
fz_error *fz_newform(fz_node **nodep, fz_tree *subtree);
fz_error *fz_newsolid(fz_node **nodep, float r, float g, float b);

int fz_isform(fz_node *node);
int fz_issolid(fz_node *node);
int fz_ispath(fz_node *node);
int fz_istext(fz_node *node);
int fz_isimage(fz_node *node);