summaryrefslogtreecommitdiff
path: root/src/lib/evas/include/evas_filter.h
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-12-09 15:54:48 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 17:33:16 +0900
commit5a06208230571e70ddff87b1d20d079af72d5658 (patch)
tree1bfe394573e65c615180cac4484c1daa70afb3d7 /src/lib/evas/include/evas_filter.h
parentdc9d37de0b643f6c2debbc19f3bdb9fd8c69dfd2 (diff)
Evas filters: Import main header file
evas_filter.h contains the API declarations for the internal Evas Filter module: enums, functions and some documentation.
Diffstat (limited to 'src/lib/evas/include/evas_filter.h')
-rw-r--r--src/lib/evas/include/evas_filter.h186
1 files changed, 186 insertions, 0 deletions
diff --git a/src/lib/evas/include/evas_filter.h b/src/lib/evas/include/evas_filter.h
new file mode 100644
index 0000000000..f599707deb
--- /dev/null
+++ b/src/lib/evas/include/evas_filter.h
@@ -0,0 +1,186 @@
1#ifndef _EVAS_FILTER_H
2#define _EVAS_FILTER_H
3
4#include "evas_common_private.h"
5
6typedef struct _Evas_Filter_Context Evas_Filter_Context;
7typedef struct _Evas_Filter_Command Evas_Filter_Command;
8typedef struct _Evas_Filter_Program Evas_Filter_Program;
9typedef struct _Evas_Filter_Instruction Evas_Filter_Instruction;
10typedef struct _Evas_Filter_Buffer Evas_Filter_Buffer;
11typedef enum _Evas_Filter_Mode Evas_Filter_Mode;
12typedef enum _Evas_Filter_Blur_Type Evas_Filter_Blur_Type;
13typedef enum _Evas_Filter_Channel Evas_Filter_Channel;
14typedef enum _Evas_Filter_Displacement_Flags Evas_Filter_Displacement_Flags;
15typedef enum _Evas_Filter_Bump_Flags Evas_Filter_Bump_Flags;
16
17typedef Eina_Bool (* Evas_Filter_Apply_Func) (Evas_Filter_Command *cmd);
18typedef void (* Evas_Filter_Cb) (Evas_Filter_Context *ctx, void *data);
19
20#define EVAS_FILTER_BUFFER_RGBA EINA_FALSE
21#define EVAS_FILTER_BUFFER_ALPHA EINA_TRUE
22
23enum _Evas_Filter_Mode
24{
25 EVAS_FILTER_MODE_BLEND, /**< Blend with current context render_op */
26 EVAS_FILTER_MODE_BLUR, /**< @see Evas_Filter_Blur_Type */
27 EVAS_FILTER_MODE_CURVE, /**< Apply color curve */
28 EVAS_FILTER_MODE_DISPLACE, /**< Apply XY displacement based on RG mask */
29 EVAS_FILTER_MODE_MASK, /**< Apply Alpha or RGBA texture on image */
30 EVAS_FILTER_MODE_BUMP, /**< Apply bump mapping (light effect) */
31 EVAS_FILTER_MODE_LAST
32};
33
34enum _Evas_Filter_Blur_Type
35{
36 EVAS_FILTER_BLUR_GAUSSIAN = 0x0, // Gaussian or sine curve. O(nm)
37 EVAS_FILTER_BLUR_BOX = 0x1, // Optimizable. But, UGLY. O(n)
38 EVAS_FILTER_BLUR_MOTION = 0x2, // Not implemented
39 EVAS_FILTER_BLUR_LAST,
40 EVAS_FILTER_BLUR_DEFAULT = EVAS_FILTER_BLUR_GAUSSIAN
41};
42
43enum _Evas_Filter_Channel
44{
45 EVAS_FILTER_CHANNEL_ALPHA = 0,
46 EVAS_FILTER_CHANNEL_RED = 1,
47 EVAS_FILTER_CHANNEL_GREEN = 2,
48 EVAS_FILTER_CHANNEL_BLUE = 3,
49 EVAS_FILTER_CHANNEL_RGB = 4
50};
51
52enum _Evas_Filter_Displacement_Flags
53{
54 EVAS_FILTER_DISPLACE_ALPHA = 0x0, /**< Displace based on Alpha values */
55 EVAS_FILTER_DISPLACE_X = 0x1, /**< X displacement */
56 EVAS_FILTER_DISPLACE_X_ALPHA = 0x1, /**< X displacement */
57 EVAS_FILTER_DISPLACE_Y = 0x2, /**< Y displacement */
58 EVAS_FILTER_DISPLACE_Y_ALPHA = 0x2, /**< Y displacement */
59 EVAS_FILTER_DISPLACE_RG = 0x4, /**< Displace based on R(G) values */
60 EVAS_FILTER_DISPLACE_XY_ALPHA = 0x3, /**< XY displacement based on alpha */
61 EVAS_FILTER_DISPLACE_XY_RG = 0x7, /**< Full 2-D displacement based on RG values */
62 EVAS_FILTER_DISPLACE_NEAREST = 0x0, /**< Interpolate between pixels (linear interpolation) */
63 EVAS_FILTER_DISPLACE_LINEAR = 0x8, /**< Interpolate between pixels (linear interpolation) */
64 EVAS_FILTER_DISPLACE_BLACK = 0x0, /**< Use black (or transparent) when going out of bounds) */
65 EVAS_FILTER_DISPLACE_STRETCH = 0x8, /**< Stretch border pixels when going out of bounds */
66 //EVAS_FILTER_DISPLACE_WRAP = 0x10, /**< Wrap around input when displacement goes out of bounds */
67 EVAS_FILTER_DISPLACE_BITMASK = 0xf
68};
69
70enum _Evas_Filter_Bump_Flags
71{
72 EVAS_FILTER_BUMP_NORMAL = 0x0,
73 EVAS_FILTER_BUMP_COMPENSATE = 0x1 /**< Compensate for darkening (diffuse light) or brightening (specular light) of zero gradient surfaces */
74};
75
76/* Parser stuff (high level API) */
77Evas_Filter_Program *evas_filter_program_new(const char *name);
78Eina_Bool evas_filter_program_parse(Evas_Filter_Program *pgm, const char *str);
79void evas_filter_program_del(Evas_Filter_Program *pgm);
80Eina_Bool evas_filter_context_program_use(Evas_Filter_Context *ctx, Evas_Object *eo_obj, Evas_Filter_Program *pgm);
81Eina_Bool evas_filter_program_padding_get(Evas_Filter_Program *pgm, int *l, int *r, int *t, int *b);
82void evas_filter_program_proxy_source_bind(Evas_Filter_Program *pgm, const char *name, Evas_Object *object);
83Evas_Object *evas_filter_program_proxy_source_get(Evas_Filter_Program *pgm, const char *name);
84void evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj, Eina_Bool do_async);
85
86/* Filter context (low level) */
87Evas_Filter_Context *evas_filter_context_new(Evas_Public_Data *evas);
88void evas_filter_context_destroy(Evas_Filter_Context *ctx);
89void evas_filter_context_post_run_callback_set(Evas_Filter_Context *ctx, Evas_Filter_Cb cb, void *data);
90#define evas_filter_context_autodestroy(ctx) evas_filter_context_post_run_callback_set(ctx, ((Evas_Filter_Cb) evas_filter_context_destroy), ctx)
91
92int evas_filter_buffer_empty_new(Evas_Filter_Context *ctx, Eina_Bool alpha_only);
93int evas_filter_buffer_image_new(Evas_Filter_Context *ctx, RGBA_Image *image);
94int evas_filter_buffer_data_new(Evas_Filter_Context *ctx, void *data, int w, int h, Eina_Bool alpha_only);
95#define evas_filter_buffer_alloc_new(ctx, w, h, a) evas_filter_buffer_data_new(ctx, NULL, w, h, a)
96void *evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid);
97Eina_Bool evas_filter_buffer_data_set(Evas_Filter_Context *ctx, int bufid, void *data, int w, int h, Eina_Bool alpha_only);
98
99Eina_Bool evas_filter_run(Evas_Filter_Context *ctx, Eina_Bool do_async);
100
101/**
102 * @brief Blend a source buffer into a destination buffer, allowing X,Y offsets, Alpha to RGBA conversion with color
103 * @param ctx Current filter chain
104 * @param draw_context Current Evas draw context. Current color is used when inbuf is ALPHA and outbuf is RGBA.
105 * @param inbuf Source buffer: ALPHA or RGBA
106 * @param outbuf Destination buffer: ALPHA or RGBA (note: must be RGBA if inbuf is RGBA)
107 * @param ox X offset in the destination buffer
108 * @param oy Y offset in the destination buffer
109 * @return Filter command ID or -1 in case of error
110 */
111int evas_filter_command_blend_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int outbuf, int ox, int oy);
112
113/**
114 * @brief Apply a blur effect on a buffer
115 * @param ctx Current filter chain
116 * @param draw_context Current Evas draw context. Current color is used when inbuf is ALPHA and outbuf is RGBA.
117 * @param inbuf Source buffer: ALPHA or RGBA
118 * @param outbuf Destination buffer: ALPHA or RGBA (note: must be RGBA if inbuf is RGBA)
119 * @param type Type of blur: BOX, GAUSSIAN or MOTION
120 * @param dx X radius of blur. Can be negative ONLY for MOTION blur
121 * @param dy Y radius of blur. Can be negative ONLY for MOTION blur
122 * @param ox X offset in the destination buffer
123 * @param oy Y offset in the destination buffer
124 * @return Filter command ID or -1 in case of error
125 */
126int evas_filter_command_blur_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int outbuf, Evas_Filter_Blur_Type type, int dx, int dy, int ox, int oy);
127
128/**
129 * @brief Grow/Shrink an image, as defined in image processing (this is not a scale algorithm!)
130 * @param ctx Current filter chain
131 * @param draw_context Current Evas draw context. Current color is used when inbuf is ALPHA and outbuf is RGBA.
132 * @param inbuf Source buffer: ALPHA or RGBA
133 * @param outbuf Destination buffer: ALPHA or RGBA (note: must be RGBA if inbuf is RGBA)
134 * @param radius Number of pixels to grow by. If negative, shrink instead of grow
135 * @param smooth Use smooth blur and curve for grow (default: true)
136 * @return Filter command ID or -1 in case of error
137 */
138int evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int outbuf, int radius, Eina_Bool smooth);
139int evas_filter_command_curve_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int outbuf, DATA8 *curve /* 256 elements */, Evas_Filter_Channel channel);
140
141/**
142 * @brief Apply a displacement map to a buffer. This will move pixels from the source to the destination based on pixel per pixel offset, as defined in the displacement map
143 * @param ctx Current filter chain
144 * @param draw_context Current Evas draw context (ignored)
145 * @param inbuf Input buffer (Alpha or RGBA)
146 * @param outbuf Output buffer (Alpha or RGBA), same size as inbuf
147 * @param dispbuf Displacement map. Should be an RGBA buffer, where the Red and Green channels are the displacement maps for X and Y. Can be also ALPHA buffer, in which case only one dimension can be specified (X or Y).
148 * @param flags Alters how the map is interpreted, @see Evas_Filter_Displacement_Flags
149 * @param intensity Maximum offset possible, if the map's value is maximal at this point (ie. 0 or 255)
150 * @return Filter command ID or -1 in case of error
151 */
152int evas_filter_command_displacement_map_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int outbuf, int dispbuf, Evas_Filter_Displacement_Flags flags, int intensity);
153
154/**
155 * @brief Apply a texture to a buffer
156 * @param ctx Current filter chain
157 * @param draw_context Current Evas draw context (ignored)
158 * @param inbuf Input buffer (Alpha or RGBA)
159 * @param maskbuf Texture buffer (Alpha or RGBA)
160 * @param outbuf Output buffer (Alpha or RGBA)
161 * @return Filter command ID or -1 in case of error
162 * @note For the moment, inbuf can only be ALPHA, and output must be RGBA if mask is RGBA as well
163 */
164int evas_filter_command_mask_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int maskbuf, int outbuf);
165
166/**
167 * @brief Apply a relief effect based on a bump map (Z map)
168 * @param ctx Current filter chain
169 * @param draw_context Current Evas draw context (ignored)
170 * @param inbuf Input buffer (Alpha or RGBA)
171 * @param bumpbuf Bump map (Alpha only), same size as inbuf. By definition, lows are black (alpha 0) and highs are white (alpha 255).
172 * @param outbuf Output buffer (Alpha or RGBA), same size as inbuf
173 * @param azimuth CCW angle in degrees from the X axis of the light direction. 0 is light from the right, 90 from the top, 180 from the left, 270 from the bottom. All values are valid.
174 * @param elevation Angle in degrees between the XY plane and the light. Only values from 0 (light is perfectly horizontal) to 90 (light comes from the viewer herself) are acceptable.
175 * @param depth Max depth in the bump map. Default value is 10.
176 * @param specular_factor Factor for the specular light effect (shininess). Ranges from 1.0 to 1000+ with logarithmic effects
177 * @param black Darkest color, defines the ambiant light
178 * @param color Light's normal color
179 * @param white Brightest color, used in the shininess effect
180 * @param flags Optional flags: compensation for darkening
181 * @return Filter command ID or -1 in case of error
182 */
183int evas_filter_command_bump_map_add(Evas_Filter_Context *ctx, void *draw_context, int inbuf, int bumpbuf, int outbuf, float azimuth, float elevation, float depth, float specular_factor, DATA32 black, DATA32 color, DATA32 white, Evas_Filter_Bump_Flags flags);
184
185#endif
186