summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c')
-rw-r--r--src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c b/src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c
new file mode 100644
index 0000000..8319db6
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/filters/gl_filter_inverse_color.c
@@ -0,0 +1,53 @@
1#include "gl_engine_filter.h"
2
3static Eina_Bool
4_gl_filter_inverse_color(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
5{
6 Evas_Engine_GL_Context *gc;
7 Evas_GL_Image *image, *surface;
8 RGBA_Draw_Context *dc_save;
9 int w, h;
10
11 w = cmd->input->w;
12 h = cmd->input->h;
13 EINA_SAFETY_ON_FALSE_RETURN_VAL(w == cmd->output->w, EINA_FALSE);
14 EINA_SAFETY_ON_FALSE_RETURN_VAL(h == cmd->output->h, EINA_FALSE);
15
16 image = evas_ector_buffer_drawable_image_get(cmd->input->buffer);
17 EINA_SAFETY_ON_NULL_RETURN_VAL(image, EINA_FALSE);
18
19 surface = evas_ector_buffer_render_image_get(cmd->output->buffer);
20 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
21
22 gc = gl_generic_context_find(re, 1);
23 evas_gl_common_context_target_surface_set(gc, surface);
24
25 dc_save = gc->dc;
26 gc->dc = evas_common_draw_context_new();
27 evas_common_draw_context_set_multiplier(gc->dc, cmd->draw.R, cmd->draw.G, cmd->draw.B, cmd->draw.A);
28
29 if (cmd->input == cmd->output)
30 gc->dc->render_op = EVAS_RENDER_COPY;
31 else
32 gc->dc->render_op = _gfx_to_evas_render_op(cmd->draw.rop);
33
34 evas_gl_common_filter_inverse_color_push(gc, image->tex, 0, 0, w, h);
35
36 evas_common_draw_context_free(gc->dc);
37 gc->dc = dc_save;
38
39 evas_ector_buffer_engine_image_release(cmd->input->buffer, image);
40 evas_ector_buffer_engine_image_release(cmd->output->buffer, surface);
41
42 return EINA_TRUE;
43}
44
45GL_Filter_Apply_Func
46gl_filter_inverse_color_func_get(Render_Engine_GL_Generic *re EINA_UNUSED, Evas_Filter_Command *cmd)
47{
48 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd, NULL);
49 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output, NULL);
50 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input, NULL);
51
52 return _gl_filter_inverse_color;
53}