-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdrawable.h
228 lines (191 loc) · 6.03 KB
/
drawable.h
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
/* -*- c -*- */
/*
* drawable.h
*
* MathMap
*
* Copyright (C) 2007-2008 Mark Probst
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __DRAWABLE_H__
#define __DRAWABLE_H__
#include <glib.h>
#ifndef OPENSTEP
#include <libgimp/gimp.h>
#endif
#ifdef MOVIES
#include <quicktime.h>
#endif
#include "color.h"
#include "userval.h"
#include "mmpools.h"
#define INPUT_DRAWABLE_GIMP 1
#define INPUT_DRAWABLE_CMDLINE_IMAGE 2
#define INPUT_DRAWABLE_CMDLINE_MOVIE 3
#define INPUT_DRAWABLE_OPENSTEP 4
struct _cache_entry_t;
/* TEMPLATE image_types */
#define IMAGE_DRAWABLE 1
#define IMAGE_CLOSURE 2
#define IMAGE_FLOATMAP 3
#define IMAGE_RESIZE 4
/* END */
struct _mathmap_frame_t;
struct _mathmap_slice_t;
/* TEMPLATE filter_funcs */
typedef void (*init_frame_func_t) (struct _mathmap_frame_t*, struct _image_t*);
typedef void (*init_slice_func_t) (struct _mathmap_slice_t*, struct _image_t*);
typedef void (*calc_lines_func_t) (struct _mathmap_slice_t*, struct _image_t*, int, int, void*, int);
typedef float* (*filter_func_t) (struct _mathmap_invocation_t*,
struct _image_t*,
float, float, float,
mathmap_pools_t*);
/* FIXME: just for LLVM - remove eventually */
typedef void* (*llvm_init_frame_func_t) (struct _mathmap_invocation_t*,
struct _image_t*,
float,
mathmap_pools_t*);
typedef float* (*llvm_filter_func_t) (struct _mathmap_slice_t*,
struct _image_t*,
void*, void*,
float, float, float,
mathmap_pools_t*);
typedef void* (*init_x_or_y_func_t) (struct _mathmap_slice_t*,
struct _image_t*,
float, float);
/* END */
struct _input_drawable_t;
/* TEMPLATE num_floatmap_channels */
#define NUM_FLOATMAP_CHANNELS 4
/* END */
struct _mathfuncs_t;
/* TEMPLATE image */
typedef struct _image_t
{
int type;
int id; /* globally unique */
int pixel_width;
int pixel_height;
union
{
struct _input_drawable_t *drawable;
struct {
/* for rendering */
struct _mathfuncs_t *funcs;
/* for getting single pixels - never called for the root closure */
filter_func_t func;
mathmap_pools_t *pools;
void *xy_vars;
int num_args;
userval_t args[];
} closure;
struct {
float ax;
float bx;
float ay;
float by;
float *data;
} floatmap;
struct {
struct _image_t *original;
float x_factor;
float y_factor;
} resize;
} v;
} image_t;
/* END */
#define FLOATMAP_VALUE_I(img,i,c) ((img)->v.floatmap.data[(i)*NUM_FLOATMAP_CHANNELS + (c)])
#define FLOATMAP_VALUE_XY(img,x,y,c) FLOATMAP_VALUE_I((img), ((y)*(img)->pixel_width + (x)), (c))
typedef struct _input_drawable_t {
gboolean used;
int kind;
float scale_x;
float scale_y;
float middle_x;
float middle_y;
union
{
#ifdef OPENSTEP
struct
{
int row_stride;
unsigned char *data;
} openstep;
#else
struct
{
GimpDrawable *drawable;
gboolean has_selection; /* only used for copying the drawable */
gint x0, y0; /* is honored whatever the value of has_selection */
gint bpp;
gint row;
gint col;
GimpTile *tile;
int fast_image_source_width;
int fast_image_source_height;
color_t *fast_image_source;
} gimp;
#endif
struct
{
int num_frames;
struct _cache_entry_t **cache_entries;
char *image_filename;
#ifdef MOVIES
quicktime_t *movie;
#endif
} cmdline;
} v;
image_t image;
} input_drawable_t;
/* TEMPLATE image_new_id */
int image_new_id (void);
/* END */
input_drawable_t* alloc_input_drawable (int kind, int width, int height);
void free_input_drawable (input_drawable_t *drawable);
input_drawable_t* copy_input_drawable (input_drawable_t *drawable);
void for_each_input_drawable (void (*) (input_drawable_t *drawable));
int get_num_input_drawables (void);
input_drawable_t* get_nth_input_drawable (int n);
#ifndef OPENSTEP
input_drawable_t* alloc_gimp_input_drawable (GimpDrawable *drawable, gboolean honor_selection);
GimpDrawable* get_gimp_input_drawable (input_drawable_t *drawable);
input_drawable_t* get_default_input_drawable (void);
#endif
input_drawable_t* alloc_cmdline_image_input_drawable (const char *filename);
#ifdef MOVIES
input_drawable_t* alloc_cmdline_movie_input_drawable (const char *filename);
#endif
image_t* floatmap_alloc (int width, int height, mathmap_pools_t *pools);
image_t* floatmap_copy (image_t *floatmap, mathmap_pools_t *pools);
/* TEMPLATE make_resize_image */
image_t* make_resize_image (image_t *image, float x_factor, float y_factor, mathmap_pools_t *pools);
/* END */
void floatmap_get_channel_column (float *dst, image_t *img, int col, int channel);
void floatmap_get_channel_row (float *dst, image_t *img, int row, int channel);
void floatmap_set_channel_column (image_t *img, int col, int channel, float *src);
void floatmap_set_channel_row (image_t *img, int row, int channel, float *src);
void floatmap_get_column (float *dst, image_t *img, int col);
void floatmap_get_row (float *dst, image_t *img, int row);
void floatmap_set_column (image_t *img, int col, float *src);
void floatmap_set_row (image_t *img, int row, float *src);
void floatmap_write (image_t *img, const char *filename);
/* FIXME: remove filter func */
image_t* closure_image_alloc (struct _mathfuncs_t *mathfuncs, filter_func_t filter_func,
int num_uservals, userval_t *uservals,
int pixel_width, int pixel_height);
void closure_image_free (image_t *closure);
#endif