diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c')
-rw-r--r-- | libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c b/libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c new file mode 100644 index 0000000..a9d18d8 --- /dev/null +++ b/libraries/evas/src/modules/engines/gl_common/evas_gl_filter.c | |||
@@ -0,0 +1,181 @@ | |||
1 | #include "evas_gl_private.h" | ||
2 | |||
3 | #if 0 // filtering disabled | ||
4 | void | ||
5 | evas_gl_common_filter_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, Evas_Filter_Info *filter) | ||
6 | { | ||
7 | RGBA_Draw_Context *dc; | ||
8 | GLuint prog; | ||
9 | int r,g,b,a; | ||
10 | int nomul, bgra; | ||
11 | |||
12 | dc = gc->dc; | ||
13 | |||
14 | if (dc->mul.use) | ||
15 | { | ||
16 | a = (dc->mul.col >> 24) & 0xff; | ||
17 | r = (dc->mul.col >> 16) & 0xff; | ||
18 | g = (dc->mul.col >> 8 ) & 0xff; | ||
19 | b = (dc->mul.col ) & 0xff; | ||
20 | } | ||
21 | else | ||
22 | { | ||
23 | r = g = b = a = 255; | ||
24 | } | ||
25 | |||
26 | nomul = (a == 255 && r == 255 && g == 255 && b == 255) ? 1 : 0; | ||
27 | bgra = (gc->shared->info.bgra) ? 1 : 0; | ||
28 | |||
29 | /* FIXME: This should so be a table */ | ||
30 | #if 0 | ||
31 | if (filter->filter == EVAS_FILTER_BLUR) | ||
32 | { | ||
33 | if (bgra) | ||
34 | { | ||
35 | if (nomul) | ||
36 | prog = gc->shared->shader.filter_blur_bgra_nomul.prog; | ||
37 | else | ||
38 | prog = gc->shared->shader.filter_blur_bgra.prog; | ||
39 | } | ||
40 | else | ||
41 | { | ||
42 | if (a == 255 && r == 255 && g == 255 && b == 255) | ||
43 | prog = gc->shared->shader.filter_blur_nomul.prog; | ||
44 | else | ||
45 | prog = gc->shared->shader.filter_blur.prog; | ||
46 | } | ||
47 | } | ||
48 | else | ||
49 | #endif | ||
50 | if (filter->filter == EVAS_FILTER_INVERT) | ||
51 | { | ||
52 | if (bgra) | ||
53 | { | ||
54 | if (nomul) | ||
55 | prog = gc->shared->shader.filter_invert_bgra_nomul.prog; | ||
56 | else | ||
57 | prog = gc->shared->shader.filter_invert_bgra.prog; | ||
58 | } | ||
59 | else | ||
60 | { | ||
61 | if (a == 255 && r == 255 && g == 255 && b == 255) | ||
62 | prog = gc->shared->shader.filter_invert_nomul.prog; | ||
63 | else | ||
64 | prog = gc->shared->shader.filter_invert.prog; | ||
65 | } | ||
66 | } | ||
67 | else if (filter->filter == EVAS_FILTER_SEPIA) | ||
68 | { | ||
69 | if (bgra) | ||
70 | { | ||
71 | if (nomul) | ||
72 | prog = gc->shared->shader.filter_sepia_bgra_nomul.prog; | ||
73 | else | ||
74 | prog = gc->shared->shader.filter_sepia_bgra.prog; | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | if (nomul) | ||
79 | prog = gc->shared->shader.filter_sepia_nomul.prog; | ||
80 | else | ||
81 | prog = gc->shared->shader.filter_sepia.prog; | ||
82 | } | ||
83 | |||
84 | } | ||
85 | else /*if (filter->filter == EVAS_FILTER_GREYSCALE)*/ | ||
86 | { | ||
87 | printf("BGRA: %s Nomul: %s\n",bgra?"true":"false",nomul?"nomul":"mul"); | ||
88 | if (bgra) | ||
89 | { | ||
90 | if (nomul) | ||
91 | prog = gc->shared->shader.filter_greyscale_bgra_nomul.prog; | ||
92 | else | ||
93 | prog = gc->shared->shader.filter_greyscale_bgra.prog; | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | if (nomul) | ||
98 | prog = gc->shared->shader.filter_greyscale_nomul.prog; | ||
99 | else | ||
100 | prog = gc->shared->shader.filter_greyscale.prog; | ||
101 | } | ||
102 | |||
103 | } | ||
104 | |||
105 | printf("Prog: %d %d %d\n",prog,im->w,im->h); | ||
106 | gc->filter_prog = prog; | ||
107 | evas_gl_common_image_update(gc, im); | ||
108 | evas_gl_common_context_image_push(gc, im->tex, 0, 0, im->w, im->h, | ||
109 | 0, 0, im->w, im->h, | ||
110 | r,g,b,a, | ||
111 | 1, im->tex_only); | ||
112 | gc->filter_prog = 0; | ||
113 | } | ||
114 | |||
115 | |||
116 | Filtered_Image * | ||
117 | evas_gl_common_image_filtered_get(Evas_GL_Image *im, uint8_t *key, size_t len) | ||
118 | { | ||
119 | Filtered_Image *fi; | ||
120 | Eina_List *l; | ||
121 | |||
122 | for (l = im->filtered ; l ; l = l->next) | ||
123 | { | ||
124 | fi = l->data; | ||
125 | if (fi->keylen != len) continue; | ||
126 | if (memcmp(key, fi->key, len) != 0) continue; | ||
127 | fi->ref ++; | ||
128 | return fi; | ||
129 | } | ||
130 | |||
131 | return NULL; | ||
132 | } | ||
133 | |||
134 | Filtered_Image * | ||
135 | evas_gl_common_image_filtered_save(Evas_GL_Image *im, Evas_GL_Image *fimage, | ||
136 | uint8_t *key, size_t keylen) | ||
137 | { | ||
138 | Filtered_Image *fi; | ||
139 | Eina_List *l; | ||
140 | |||
141 | for (l = im->filtered ; l ; l = l->next) | ||
142 | { | ||
143 | fi = l->data; | ||
144 | if (fi->keylen != keylen) continue; | ||
145 | if (memcmp(key, fi->key, keylen) != 0) continue; | ||
146 | |||
147 | fi->image = (void *)fimage; | ||
148 | fi->ref ++; | ||
149 | return fi; | ||
150 | } | ||
151 | |||
152 | fi = calloc(1,sizeof(Filtered_Image)); | ||
153 | if (!fi) return NULL; | ||
154 | |||
155 | fi->keylen = keylen; | ||
156 | fi->key = malloc(keylen); | ||
157 | memcpy(fi->key, key, keylen); | ||
158 | fi->image = (void *)fimage; | ||
159 | fi->ref = 1; | ||
160 | |||
161 | im->filtered = eina_list_prepend(im->filtered, fi); | ||
162 | |||
163 | return fi; | ||
164 | } | ||
165 | |||
166 | void | ||
167 | evas_gl_common_image_filtered_free(Evas_GL_Image *image, Filtered_Image *fi) | ||
168 | { | ||
169 | fi->ref --; | ||
170 | if (fi->ref) return; | ||
171 | |||
172 | free(fi->key); | ||
173 | evas_gl_common_image_free((void *)fi->image); | ||
174 | fi->image = NULL; | ||
175 | |||
176 | image->filtered = eina_list_remove(image->filtered, fi); | ||
177 | } | ||
178 | #endif | ||
179 | |||
180 | |||
181 | /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ | ||