filters: Linear Convolution make use of the TempAllocator.
[gfxprim.git] / pylib / templates / filter.c.t
blob335ffbc2947b1b73b1760518b3c0ca55d010b0f3
1 %% extends "common.c.t"
3 %% macro filter_include()
4 #include "core/GP_Context.h"
5 #include "core/GP_Pixel.h"
6 #include "core/GP_GetPutPixel.h"
7 #include "core/GP_Debug.h"
8 #include "GP_Filter.h"
9 %% endmacro
12  * Value clamping macro
13  */
14 %% macro filter_clamp_val(var, size)
15                         if ({{ var }} < 0)
16                                 {{ var }} = 0;
18                         if ({{ var }} > {{ 2 ** size - 1}})
19                                 {{ var }} = {{ 2 ** size - 1}};
20 %% endmacro 
23  * Load parameters from params structure into variables
24  */
25 %% macro filter_params(pt, params, c_type, suffix, id)
26         GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0,
27                   "Invalid params channels for context pixel type");
28         
29         %% for chann in pt.chanslist
30         {{ c_type }}{{ chann[0] }}{{ suffix }} = (GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"))->val.{{ id }};
31         %% endfor
32 %% endmacro
34 %% macro filter_params_raw(pt, params, suffix)
35         GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0,
36                   "Invalid params channels for context pixel type");
37         
38         %% for chann in pt.chanslist
39         GP_FilterParam *{{ chann[0] }}{{ suffix }} = GP_FilterParamChannel({{ params }}, "{{ chann[0] }}");
40         %% endfor
41 %% endmacro
44  * Load parameters from params structure into variable
45  */
46 %% macro filter_param(ps, params, c_type, suffix, id)
47         GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1,
48                   "Expected only one channel");
50         {{ c_type }}pix{{ suffix }} = {{ params }}[0].val.{{ id }};
51 %% endmacro
53 %% macro filter_param_raw(ps, params, suffix)
54         GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1,
55                   "Expected only one channel");
57         GP_FilterParam *pix{{ suffix }} = &{{ params }}[0];
58 %% endmacro