filters: point: Remove the FilterArea.
[gfxprim/pasky.git] / pylib / templates / filter.point.c.t
blob155870e60cd44a88f3a32f77d8d5b2cfd2aeb90e
1 %% extends "filter.c.t"
3 %% macro filter_point_include()
4 #include <errno.h>
6 #include "core/GP_Debug.h"
8 #include "filters/GP_ApplyTables.h"
9 #include "filters/GP_Point.h"
10 %% endmacro
12 %% macro filter_point_ex(op_name, filter_op, fopts)
13 int GP_Filter{{ op_name }}Ex(const GP_Context *const src,
14                              GP_Coord x_src, GP_Coord y_src,
15                              GP_Size w_src, GP_Size h_src,
16                              GP_Context *dst,
17                              GP_Coord x_dst, GP_Coord y_dst,
18                              {{ maybe_opts_r(fopts) }}
19                              GP_ProgressCallback *callback)
21         const GP_PixelTypeDescription *desc;
22         GP_FilterTables tables;
23         unsigned int i;
24         GP_Pixel j;
25         int ret, err;
27         if (GP_FilterTablesInit(&tables, src))
28                 return 1;
30         desc = GP_PixelTypeDesc(src->pixel_type);
32         for (i = 0; i < desc->numchannels; i++) {
33                 GP_Pixel chan_max = (1 << desc->channels[i].size);
34                 GP_Pixel *table = tables.table[i];
36                 for (j = 0; j < chan_max; j++)
37                         table[j] = {{ filter_op('((signed)j)', '((signed)chan_max - 1)') }};
38         }
40         ret = GP_FilterTablesApply(src, x_src, y_src, w_src, h_src,
41                                    dst, x_dst, y_dst, &tables, callback);
43         err = errno;
44         GP_FilterTablesFree(&tables);
45         errno = err;
47         return ret;
49 %% endmacro
51 %% macro filter_point_ex_alloc(op_name, fopts, opts)
52 GP_Context *GP_Filter{{ op_name }}ExAlloc(const GP_Context *const src,
53                                           GP_Coord x_src, GP_Coord y_src,
54                                           GP_Size w_src, GP_Size h_src,
55                                           {{ maybe_opts_r(fopts) }}
56                                           GP_ProgressCallback *callback)
58         GP_Context *new = GP_ContextAlloc(w_src, h_src,
59                                           src->pixel_type);
61         if (GP_Filter{{ op_name }}Ex(src, x_src, y_src, w_src, h_src, new, 0, 0,
62                                      {{ maybe_opts_r(opts) }}callback)) {
63                 int err = errno;
64                 GP_ContextFree(new);
65                 errno = err;
66                 return NULL;
67         }
69         return new;
71 %% endmacro
73 %% macro filter_point(op_name, filter_op, fopts="", opts="")
74 {{ filter_point_include() }}
75 {{ filter_point_ex(op_name, filter_op, fopts) }}
76 {{ filter_point_ex_alloc(op_name, fopts, opts) }}
77 %% endmacro