summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBrett Nash <nash@nash.id.au>2011-04-06 05:38:38 +0000
committerBrett Nash <nash@nash.id.au>2011-04-06 05:38:38 +0000
commitb96d2273347560cb415ffb2df3b059dc2229dd50 (patch)
tree6253ca2e3ff8f920036572e87322ba20244a135c /legacy
parenta5d83e3cbe92df04e13e5f59b4c0885615bfd169 (diff)
Masking: Push a bit more arbitrary clipping
This seems to have got lost in my big messup before. This pushes enough of mask/arbitrary clip to be somewhat useful. I need to push a little more soon for it to be 100% happy, but this is useful level. SVN revision: 58373
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/canvas/evas_clip.c15
-rw-r--r--legacy/evas/src/lib/canvas/evas_render.c14
-rw-r--r--legacy/evas/src/lib/engines/common/evas_draw_main.c20
-rw-r--r--legacy/evas/src/lib/engines/common/evas_scale_sample.c25
-rw-r--r--legacy/evas/src/lib/engines/common/evas_scale_smooth_scaler_noscale.c34
-rw-r--r--legacy/evas/src/lib/include/evas_common.h10
-rw-r--r--legacy/evas/src/lib/include/evas_inline.x2
-rw-r--r--legacy/evas/src/lib/include/evas_private.h4
-rw-r--r--legacy/evas/src/modules/engines/gl_common/evas_gl_common.h22
-rw-r--r--legacy/evas/src/modules/engines/gl_common/evas_gl_context.c325
-rw-r--r--legacy/evas/src/modules/engines/gl_x11/evas_engine.c15
-rw-r--r--legacy/evas/src/modules/engines/software_generic/evas_engine.c46
12 files changed, 522 insertions, 10 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_clip.c b/legacy/evas/src/lib/canvas/evas_clip.c
index 08bd86e440..d556cb1113 100644
--- a/legacy/evas/src/lib/canvas/evas_clip.c
+++ b/legacy/evas/src/lib/canvas/evas_clip.c
@@ -265,6 +265,21 @@ evas_object_clip_set(Evas_Object *obj, Evas_Object *clip)
265 obj->cur.clipper = clip; 265 obj->cur.clipper = clip;
266 clip->clip.clipees = eina_list_append(clip->clip.clipees, obj); 266 clip->clip.clipees = eina_list_append(clip->clip.clipees, obj);
267 if (clip->clip.clipees) clip->cur.have_clipees = 1; 267 if (clip->clip.clipees) clip->cur.have_clipees = 1;
268
269 /* If it's NOT a rectangle set the mask bits too */
270 /* FIXME: Optmz ths chck */
271 if (strcmp(evas_object_type_get(clip),"rectangle") == 0)
272 obj->cur.mask = NULL;
273 else
274 {
275 void *engdata;
276 obj->cur.mask = clip;
277 engdata = clip->func->engine_data_get(clip);
278 /* FIXME: Images only */
279 clip->layer->evas->engine.func->image_mask_create(
280 clip->layer->evas->engine.data.output,
281 engdata);
282 }
268 evas_object_change(clip); 283 evas_object_change(clip);
269 evas_object_change(obj); 284 evas_object_change(obj);
270 evas_object_clip_dirty(obj); 285 evas_object_clip_dirty(obj);
diff --git a/legacy/evas/src/lib/canvas/evas_render.c b/legacy/evas/src/lib/canvas/evas_render.c
index 56bfa9d1e8..5d497a0993 100644
--- a/legacy/evas/src/lib/canvas/evas_render.c
+++ b/legacy/evas/src/lib/canvas/evas_render.c
@@ -1336,6 +1336,17 @@ evas_render_updates_internal(Evas *e,
1336 obj->cur.cache.clip.w, 1336 obj->cur.cache.clip.w,
1337 obj->cur.cache.clip.h); 1337 obj->cur.cache.clip.h);
1338 } 1338 }
1339 if (obj->cur.mask)
1340 e->engine.func->context_mask_set(e->engine.data.output,
1341 e->engine.data.context,
1342 obj->cur.mask->func->engine_data_get(obj->cur.mask),
1343 obj->cur.mask->cur.geometry.x,
1344 obj->cur.mask->cur.geometry.y,
1345 obj->cur.mask->cur.geometry.w,
1346 obj->cur.mask->cur.geometry.h);
1347 else
1348 e->engine.func->context_mask_unset(e->engine.data.output,
1349 e->engine.data.context);
1339 if (obj->cur.clipper) 1350 if (obj->cur.clipper)
1340 e->engine.func->context_clip_set(e->engine.data.output, 1351 e->engine.func->context_clip_set(e->engine.data.output,
1341 e->engine.data.context, 1352 e->engine.data.context,
@@ -1382,6 +1393,9 @@ evas_render_updates_internal(Evas *e,
1382 } 1393 }
1383 } 1394 }
1384#endif 1395#endif
1396 e->engine.func->context_clip_set(e->engine.data.output,
1397 e->engine.data.context,
1398 x, y, w, h);
1385 clean_them |= evas_render_mapped(e, obj, e->engine.data.context, 1399 clean_them |= evas_render_mapped(e, obj, e->engine.data.context,
1386 surface, off_x, off_y, 0, 1400 surface, off_x, off_y, 0,
1387 cx, cy, cw, ch 1401 cx, cy, cw, ch
diff --git a/legacy/evas/src/lib/engines/common/evas_draw_main.c b/legacy/evas/src/lib/engines/common/evas_draw_main.c
index 8b8511ab16..e2d4568114 100644
--- a/legacy/evas/src/lib/engines/common/evas_draw_main.c
+++ b/legacy/evas/src/lib/engines/common/evas_draw_main.c
@@ -153,6 +153,26 @@ evas_common_draw_context_unset_multiplier(RGBA_Draw_Context *dc)
153} 153}
154 154
155EAPI void 155EAPI void
156evas_common_draw_context_set_mask(RGBA_Draw_Context *dc, RGBA_Image *mask, int x, int y, int w, int h)
157{
158 dc->mask.mask = mask;
159 dc->mask.x = x;
160 dc->mask.y = y;
161 dc->mask.w = w;
162 dc->mask.h = h;
163}
164
165EAPI void
166evas_common_draw_context_unset_mask(RGBA_Draw_Context *dc)
167{
168 dc->mask.mask = NULL;
169}
170
171
172
173
174
175EAPI void
156evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h) 176evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h)
157{ 177{
158// if (dc->cutout.rects > 512) return; 178// if (dc->cutout.rects > 512) return;
diff --git a/legacy/evas/src/lib/engines/common/evas_scale_sample.c b/legacy/evas/src/lib/engines/common/evas_scale_sample.c
index c6fa9f21c1..1ee1960649 100644
--- a/legacy/evas/src/lib/engines/common/evas_scale_sample.c
+++ b/legacy/evas/src/lib/engines/common/evas_scale_sample.c
@@ -94,6 +94,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
94 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h; 94 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
95 int src_w, src_h, dst_w, dst_h; 95 int src_w, src_h, dst_w, dst_h;
96 RGBA_Gfx_Func func; 96 RGBA_Gfx_Func func;
97 RGBA_Image *maskobj;
98 DATA8 *mask = NULL;
97 99
98 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) 100 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
99 return; 101 return;
@@ -235,7 +237,20 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
235 /* figure out dest start ptr */ 237 /* figure out dest start ptr */
236 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w); 238 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w);
237 239
238 if (dc->mul.use) 240 if (dc->mask.mask)
241 {
242 func = evas_common_gfx_func_composite_pixel_mask_span_get(src, dst, dst_clip_w, dc->render_op);
243 maskobj = dc->mask.mask;
244 mask = maskobj->mask.mask;
245 if (1 || dst_region_w > src_region_w || dst_region_h > src_region_h){
246 printf("Mask w/h: %d/%d\n",maskobj->cache_entry.w,
247 maskobj->cache_entry.h);
248 printf("Warning: Unscaled mask (%d/%d) // (%d/%d)\n",
249 dst_region_w,src_region_w,
250 dst_region_h,src_region_h);
251 }
252 }
253 else if (dc->mul.use)
239 func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op); 254 func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
240 else 255 else
241 func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op); 256 func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op);
@@ -246,14 +261,20 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
246 for (y = 0; y < dst_clip_h; y++) 261 for (y = 0; y < dst_clip_h; y++)
247 { 262 {
248 /* * blend here [clip_w *] ptr -> dst_ptr * */ 263 /* * blend here [clip_w *] ptr -> dst_ptr * */
264 if (mask)
265 {
266 mask += dst_clip_x - dc->mask.x;
267 mask += (dst_clip_y - dc->mask.y) * maskobj->cache_entry.w;
268 }
249#ifdef EVAS_SLI 269#ifdef EVAS_SLI
250 if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y) 270 if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y)
251#endif 271#endif
252 { 272 {
253 func(ptr, NULL, dc->mul.col, dst_ptr, dst_clip_w); 273 func(ptr, mask, dc->mul.col, dst_ptr, dst_clip_w);
254 } 274 }
255 ptr += src_w; 275 ptr += src_w;
256 dst_ptr += dst_w; 276 dst_ptr += dst_w;
277 if (mask) mask += maskobj->cache_entry.w;
257 } 278 }
258 } 279 }
259 else 280 else
diff --git a/legacy/evas/src/lib/engines/common/evas_scale_smooth_scaler_noscale.c b/legacy/evas/src/lib/engines/common/evas_scale_smooth_scaler_noscale.c
index 957b6a3331..3d9e4f6a06 100644
--- a/legacy/evas/src/lib/engines/common/evas_scale_smooth_scaler_noscale.c
+++ b/legacy/evas/src/lib/engines/common/evas_scale_smooth_scaler_noscale.c
@@ -1,16 +1,46 @@
1{ 1{
2 DATA32 *ptr; 2 DATA32 *ptr;
3 RGBA_Gfx_Func func; 3 RGBA_Gfx_Func func;
4 RGBA_Image *maskobj;
5 DATA8 *mask = NULL;
4#ifdef EVAS_SLI 6#ifdef EVAS_SLI
5 int ysli = dst_clip_y; 7 int ysli = dst_clip_y;
6#endif 8#endif
7 9
8 ptr = src->image.data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x; 10 ptr = src->image.data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x;
9 if (dc->mul.use) 11 if (dc->mask.mask)
12 {
13 func = evas_common_gfx_func_composite_pixel_mask_span_get(NULL, NULL, dst_clip_w, dc->render_op);
14 maskobj = dc->mask.mask;
15 mask = maskobj->mask.mask;
16 }
17 else if (dc->mul.use)
10 func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op); 18 func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
11 else 19 else
12 func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op); 20 func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op);
13 while (dst_clip_h--) 21
22 if (mask)
23 {
24 mask += dst_clip_x - dc->mask.x;
25 mask += (dst_clip_y - dc->mask.y) * maskobj->cache_entry.w;
26 while (dst_clip_h--)
27 {
28
29#ifdef EVAS_SLI
30 if (((ysli) % dc->sli.h) == dc->sli.y)
31#endif
32 {
33 func(ptr, mask, dc->mul.col, dst_ptr, dst_clip_w);
34 }
35#ifdef EVAS_SLI
36 ysli++;
37#endif
38 ptr += src_w;
39 dst_ptr += dst_w;
40 mask += maskobj->cache_entry.w;
41 }
42 }
43 else
14 { 44 {
15#ifdef EVAS_SLI 45#ifdef EVAS_SLI
16 if (((ysli) % dc->sli.h) == dc->sli.y) 46 if (((ysli) % dc->sli.h) == dc->sli.y)
diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h
index 6ba910acb0..db8fbd8336 100644
--- a/legacy/evas/src/lib/include/evas_common.h
+++ b/legacy/evas/src/lib/include/evas_common.h
@@ -675,10 +675,13 @@ struct _RGBA_Draw_Context
675 DATA32 col; 675 DATA32 col;
676 } col; 676 } col;
677 struct RGBA_Draw_Context_clip { 677 struct RGBA_Draw_Context_clip {
678 DATA8 *mask;
679 int x, y, w, h; 678 int x, y, w, h;
680 Eina_Bool use : 1; 679 Eina_Bool use : 1;
681 } clip; 680 } clip;
681 struct {
682 int x, y, w, h;
683 RGBA_Image *mask;
684 } mask;
682 Cutout_Rects cutout; 685 Cutout_Rects cutout;
683 struct { 686 struct {
684 struct { 687 struct {
@@ -789,6 +792,11 @@ struct _RGBA_Image
789 } image; 792 } image;
790 793
791 struct { 794 struct {
795 DATA8 *mask;
796 Eina_Bool dirty: 1;
797 } mask;
798
799 struct {
792 LK(lock); 800 LK(lock);
793 Eina_List *list; 801 Eina_List *list;
794 unsigned long long orig_usage; 802 unsigned long long orig_usage;
diff --git a/legacy/evas/src/lib/include/evas_inline.x b/legacy/evas/src/lib/include/evas_inline.x
index f1d131df04..31375790da 100644
--- a/legacy/evas/src/lib/include/evas_inline.x
+++ b/legacy/evas/src/lib/include/evas_inline.x
@@ -57,6 +57,8 @@ static inline int
57evas_object_is_opaque(Evas_Object *obj) 57evas_object_is_opaque(Evas_Object *obj)
58{ 58{
59 if (obj->smart.smart) return 0; 59 if (obj->smart.smart) return 0;
60 /* If a mask: Assume alpha */
61 if (obj->cur.mask) return 0;
60 if (obj->cur.cache.clip.a == 255) 62 if (obj->cur.cache.clip.a == 255)
61 { 63 {
62 if (obj->func->is_opaque) 64 if (obj->func->is_opaque)
diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h
index f5586e5311..8f1dc16cab 100644
--- a/legacy/evas/src/lib/include/evas_private.h
+++ b/legacy/evas/src/lib/include/evas_private.h
@@ -393,6 +393,7 @@ struct _Evas_Object
393 struct { 393 struct {
394 Evas_Map *map; 394 Evas_Map *map;
395 Evas_Object *clipper; 395 Evas_Object *clipper;
396 Evas_Object *mask;
396 Evas_Object *map_parent; 397 Evas_Object *map_parent;
397 double scale; 398 double scale;
398 Evas_Coord_Rectangle geometry; 399 Evas_Coord_Rectangle geometry;
@@ -593,6 +594,8 @@ struct _Evas_Func
593 void (*context_clip_clip) (void *data, void *context, int x, int y, int w, int h); 594 void (*context_clip_clip) (void *data, void *context, int x, int y, int w, int h);
594 void (*context_clip_unset) (void *data, void *context); 595 void (*context_clip_unset) (void *data, void *context);
595 int (*context_clip_get) (void *data, void *context, int *x, int *y, int *w, int *h); 596 int (*context_clip_get) (void *data, void *context, int *x, int *y, int *w, int *h);
597 void (*context_mask_set) (void *data, void *context, void *mask, int x, int y, int w, int h);
598 void (*context_mask_unset) (void *data, void *context);
596 void (*context_color_set) (void *data, void *context, int r, int g, int b, int a); 599 void (*context_color_set) (void *data, void *context, int r, int g, int b, int a);
597 int (*context_color_get) (void *data, void *context, int *r, int *g, int *b, int *a); 600 int (*context_color_get) (void *data, void *context, int *r, int *g, int *b, int *a);
598 void (*context_multiplier_set) (void *data, void *context, int r, int g, int b, int a); 601 void (*context_multiplier_set) (void *data, void *context, int r, int g, int b, int a);
@@ -636,6 +639,7 @@ struct _Evas_Func
636 char *(*image_format_get) (void *data, void *image); 639 char *(*image_format_get) (void *data, void *image);
637 void (*image_colorspace_set) (void *data, void *image, int cspace); 640 void (*image_colorspace_set) (void *data, void *image, int cspace);
638 int (*image_colorspace_get) (void *data, void *image); 641 int (*image_colorspace_get) (void *data, void *image);
642 void (*image_mask_create) (void *data, void *image);
639 void *(*image_native_set) (void *data, void *image, void *native); 643 void *(*image_native_set) (void *data, void *image, void *native);
640 void *(*image_native_get) (void *data, void *image); 644 void *(*image_native_get) (void *data, void *image);
641 645
diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h
index 477bd7fda1..0318bcb459 100644
--- a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h
+++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h
@@ -93,6 +93,7 @@
93#define SHAD_TEXUV 2 93#define SHAD_TEXUV 2
94#define SHAD_TEXUV2 3 94#define SHAD_TEXUV2 3
95#define SHAD_TEXUV3 4 95#define SHAD_TEXUV3 4
96#define SHAD_TEXM 5
96 97
97typedef struct _Evas_GL_Program Evas_GL_Program; 98typedef struct _Evas_GL_Program Evas_GL_Program;
98typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source; 99typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source;
@@ -192,6 +193,7 @@ struct _Evas_GL_Shared
192 193
193 Evas_GL_Program img, img_nomul; 194 Evas_GL_Program img, img_nomul;
194 Evas_GL_Program img_bgra, img_bgra_nomul; 195 Evas_GL_Program img_bgra, img_bgra_nomul;
196 Evas_GL_Program img_mask;
195 Evas_GL_Program yuv, yuv_nomul; 197 Evas_GL_Program yuv, yuv_nomul;
196 Evas_GL_Program tex, tex_nomul; 198 Evas_GL_Program tex, tex_nomul;
197 } shader; 199 } shader;
@@ -209,6 +211,7 @@ struct _Evas_GL_Shared
209#define RTYPE_FONT 3 211#define RTYPE_FONT 3
210#define RTYPE_YUV 4 212#define RTYPE_YUV 4
211#define RTYPE_MAP 5 /* need to merge with image */ 213#define RTYPE_MAP 5 /* need to merge with image */
214#define RTYPE_IMASK 6
212 215
213 216
214 217
@@ -228,6 +231,7 @@ struct _Evas_Engine_GL_Context
228 struct { 231 struct {
229 GLuint cur_prog; 232 GLuint cur_prog;
230 GLuint cur_tex, cur_texu, cur_texv; 233 GLuint cur_tex, cur_texu, cur_texv;
234 GLuint cur_texm, cur_texmu, cur_texmv;
231 int render_op; 235 int render_op;
232 int cx, cy, cw, ch; 236 int cx, cy, cw, ch;
233 int smooth; 237 int smooth;
@@ -248,7 +252,7 @@ struct _Evas_Engine_GL_Context
248 struct { 252 struct {
249 Evas_GL_Image *surface; 253 Evas_GL_Image *surface;
250 GLuint cur_prog; 254 GLuint cur_prog;
251 GLuint cur_tex, cur_texu, cur_texv; 255 GLuint cur_tex, cur_texu, cur_texv, cur_texm;
252 int render_op; 256 int render_op;
253 int cx, cy, cw, ch; 257 int cx, cy, cw, ch;
254 int smooth; 258 int smooth;
@@ -262,12 +266,14 @@ struct _Evas_Engine_GL_Context
262 GLfloat *texuv; 266 GLfloat *texuv;
263 GLfloat *texuv2; 267 GLfloat *texuv2;
264 GLfloat *texuv3; 268 GLfloat *texuv3;
265 Eina_Bool line : 1; 269 GLfloat *texm;
270 Eina_Bool line: 1;
266 Eina_Bool use_vertex : 1; 271 Eina_Bool use_vertex : 1;
267 Eina_Bool use_color : 1; 272 Eina_Bool use_color : 1;
268 Eina_Bool use_texuv : 1; 273 Eina_Bool use_texuv : 1;
269 Eina_Bool use_texuv2 : 1; 274 Eina_Bool use_texuv2 : 1;
270 Eina_Bool use_texuv3 : 1; 275 Eina_Bool use_texuv3 : 1;
276 Eina_Bool use_texm : 1;
271 Evas_GL_Image *im; 277 Evas_GL_Image *im;
272 } array; 278 } array;
273 } pipe[MAX_PIPES]; 279 } pipe[MAX_PIPES];
@@ -386,6 +392,8 @@ extern Evas_GL_Program_Source shader_img_bgra_frag_src;
386extern Evas_GL_Program_Source shader_img_bgra_vert_src; 392extern Evas_GL_Program_Source shader_img_bgra_vert_src;
387extern Evas_GL_Program_Source shader_img_bgra_nomul_frag_src; 393extern Evas_GL_Program_Source shader_img_bgra_nomul_frag_src;
388extern Evas_GL_Program_Source shader_img_bgra_nomul_vert_src; 394extern Evas_GL_Program_Source shader_img_bgra_nomul_vert_src;
395extern Evas_GL_Program_Source shader_img_mask_frag_src;
396extern Evas_GL_Program_Source shader_img_mask_vert_src;
389 397
390extern Evas_GL_Program_Source shader_yuv_frag_src; 398extern Evas_GL_Program_Source shader_yuv_frag_src;
391extern Evas_GL_Program_Source shader_yuv_vert_src; 399extern Evas_GL_Program_Source shader_yuv_vert_src;
@@ -419,6 +427,16 @@ void evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
419 int x, int y, int w, int h, 427 int x, int y, int w, int h,
420 int r, int g, int b, int a, 428 int r, int g, int b, int a,
421 Eina_Bool smooth, Eina_Bool tex_only); 429 Eina_Bool smooth, Eina_Bool tex_only);
430void evas_gl_common_context_image_mask_push(Evas_Engine_GL_Context *gc,
431 Evas_GL_Texture *tex,
432 Evas_GL_Texture *texm,
433 double sx, double sy, double sw, double sh,
434 double sxm, double sym, double swm, double shm,
435 int x, int y, int w, int h,
436 int r, int g, int b, int a,
437 Eina_Bool smooth);
438
439
422void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, 440void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
423 Evas_GL_Texture *tex, 441 Evas_GL_Texture *tex,
424 double sx, double sy, double sw, double sh, 442 double sx, double sy, double sw, double sh,
diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
index cf2fa1ac93..e87d31797b 100644
--- a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
+++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
@@ -465,6 +465,13 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
465 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_bgra_nomul.prog, "mvp"), 1, 465 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_bgra_nomul.prog, "mvp"), 1,
466 GL_FALSE, proj); 466 GL_FALSE, proj);
467 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 467 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
468 glUseProgram(gc->shared->shader.img_mask.prog);
469 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
470 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_mask.prog, "mvp"), 1,
471 GL_FALSE, proj);
472 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
473
474
468 475
469 glUseProgram(gc->pipe[0].shader.cur_prog); 476 glUseProgram(gc->pipe[0].shader.cur_prog);
470 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 477 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
@@ -696,6 +703,10 @@ evas_gl_common_context_new(void)
696 &(shader_img_bgra_nomul_vert_src), 703 &(shader_img_bgra_nomul_vert_src),
697 &(shader_img_bgra_nomul_frag_src), 704 &(shader_img_bgra_nomul_frag_src),
698 "img_bgra_nomul")) goto error; 705 "img_bgra_nomul")) goto error;
706 if (!evas_gl_common_shader_program_init(&(shared->shader.img_mask),
707 &(shader_img_mask_vert_src),
708 &(shader_img_mask_frag_src),
709 "img_mask")) goto error;
699 if (!evas_gl_common_shader_program_init(&(shared->shader.tex), 710 if (!evas_gl_common_shader_program_init(&(shared->shader.tex),
700 &(shader_tex_vert_src), 711 &(shader_tex_vert_src),
701 &(shader_tex_frag_src), 712 &(shader_tex_frag_src),
@@ -730,7 +741,16 @@ evas_gl_common_context_new(void)
730 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 741 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
731 glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "texv"), 2); 742 glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "texv"), 2);
732 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 743 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
733 744
745 glUseProgram(shared->shader.img_mask.prog);
746 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
747 glUniform1i(glGetUniformLocation(shared->shader.img_mask.prog, "tex"), 0);
748 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
749 glUniform1i(glGetUniformLocation(shared->shader.img_mask.prog, "texm"), 1);
750 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
751
752
753
734 glUseProgram(gc->pipe[0].shader.cur_prog); 754 glUseProgram(gc->pipe[0].shader.cur_prog);
735 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 755 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
736 756
@@ -777,6 +797,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
777 if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex); 797 if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex);
778 if (gc->pipe[i].array.color) free(gc->pipe[i].array.color); 798 if (gc->pipe[i].array.color) free(gc->pipe[i].array.color);
779 if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv); 799 if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv);
800 if (gc->pipe[i].array.texm) free(gc->pipe[i].array.texm);
780 if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); 801 if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2);
781 if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); 802 if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3);
782 } 803 }
@@ -792,6 +813,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
792 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_nomul)); 813 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_nomul));
793 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra)); 814 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra));
794 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra_nomul)); 815 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra_nomul));
816 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_mask));
795 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv)); 817 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv));
796 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv_nomul)); 818 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv_nomul));
797 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.tex)); 819 evas_gl_common_shader_program_shutdown(&(gc->shared->shader.tex));
@@ -846,6 +868,9 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
846 gc->state.current.cur_tex = 0; 868 gc->state.current.cur_tex = 0;
847 gc->state.current.cur_texu = 0; 869 gc->state.current.cur_texu = 0;
848 gc->state.current.cur_texv = 0; 870 gc->state.current.cur_texv = 0;
871 gc->state.current.cur_texm = 0;
872 gc->state.current.cur_texmu = 0;
873 gc->state.current.cur_texmv = 0;
849 gc->state.current.render_op = 0; 874 gc->state.current.render_op = 0;
850 gc->state.current.smooth = 0; 875 gc->state.current.smooth = 0;
851 gc->state.current.blend = 0; 876 gc->state.current.blend = 0;
@@ -872,6 +897,7 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
872 gc->pipe[i].shader.cur_tex = 0; 897 gc->pipe[i].shader.cur_tex = 0;
873 gc->pipe[i].shader.cur_texu = 0; 898 gc->pipe[i].shader.cur_texu = 0;
874 gc->pipe[i].shader.cur_texv = 0; 899 gc->pipe[i].shader.cur_texv = 0;
900 gc->pipe[i].shader.cur_texm = 0;
875 gc->pipe[i].shader.render_op = EVAS_RENDER_BLEND; 901 gc->pipe[i].shader.render_op = EVAS_RENDER_BLEND;
876 gc->pipe[i].shader.smooth = 0; 902 gc->pipe[i].shader.smooth = 0;
877 gc->pipe[i].shader.blend = 0; 903 gc->pipe[i].shader.blend = 0;
@@ -1008,6 +1034,10 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
1008#define PUSH_TEXUV3(n, u, v) \ 1034#define PUSH_TEXUV3(n, u, v) \
1009 gc->pipe[n].array.texuv3[nu3++] = u; \ 1035 gc->pipe[n].array.texuv3[nu3++] = u; \
1010 gc->pipe[n].array.texuv3[nu3++] = v 1036 gc->pipe[n].array.texuv3[nu3++] = v
1037#define PUSH_TEXM(n, u, v) \
1038 gc->pipe[n].array.texm[nm++] = u; \
1039 gc->pipe[n].array.texm[nm++] = v
1040
1011 1041
1012static inline void 1042static inline void
1013array_alloc(Evas_Engine_GL_Context *gc, int n) 1043array_alloc(Evas_Engine_GL_Context *gc, int n)
@@ -1024,6 +1054,9 @@ array_alloc(Evas_Engine_GL_Context *gc, int n)
1024 if (gc->pipe[n].array.use_texuv) 1054 if (gc->pipe[n].array.use_texuv)
1025 gc->pipe[n].array.texuv = realloc(gc->pipe[n].array.texuv, 1055 gc->pipe[n].array.texuv = realloc(gc->pipe[n].array.texuv,
1026 gc->pipe[n].array.alloc * sizeof(GLfloat) * 2); 1056 gc->pipe[n].array.alloc * sizeof(GLfloat) * 2);
1057 if (gc->pipe[n].array.use_texm)
1058 gc->pipe[n].array.texm = realloc(gc->pipe[n].array.texm,
1059 gc->pipe[n].array.alloc * sizeof(GLfloat) * 2);
1027 if (gc->pipe[n].array.use_texuv2) 1060 if (gc->pipe[n].array.use_texuv2)
1028 gc->pipe[n].array.texuv2 = realloc(gc->pipe[n].array.texuv2, 1061 gc->pipe[n].array.texuv2 = realloc(gc->pipe[n].array.texuv2,
1029 gc->pipe[n].array.alloc * sizeof(GLfloat) * 2); 1062 gc->pipe[n].array.alloc * sizeof(GLfloat) * 2);
@@ -1177,7 +1210,20 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
1177 Eina_Bool blend = 0; 1210 Eina_Bool blend = 0;
1178 GLuint prog = gc->shared->shader.rect.prog; 1211 GLuint prog = gc->shared->shader.rect.prog;
1179 int pn = 0; 1212 int pn = 0;
1180 1213
1214 if (gc->dc->mask.mask)
1215 {
1216 RGBA_Draw_Context *dc;
1217 dc = gc->dc;
1218 Evas_GL_Image *im;
1219 im = (void *)dc->mask.mask;
1220 evas_gl_common_context_font_push(gc, im->tex,
1221 x - dc->mask.x,y - dc->mask.y,
1222 dc->mask.w,dc->mask.h,
1223 x,y,w,h,r,g,b,a);
1224 return;
1225 }
1226
1181 if (a < 255) blend = 1; 1227 if (a < 255) blend = 1;
1182 if (gc->dc->render_op == EVAS_RENDER_COPY) blend = 0; 1228 if (gc->dc->render_op == EVAS_RENDER_COPY) blend = 0;
1183 1229
@@ -1493,6 +1539,7 @@ again:
1493 // if nomul... dont need this 1539 // if nomul... dont need this
1494 gc->pipe[pn].array.use_color = 1; 1540 gc->pipe[pn].array.use_color = 1;
1495 gc->pipe[pn].array.use_texuv = 1; 1541 gc->pipe[pn].array.use_texuv = 1;
1542 gc->pipe[pn].array.use_texuvm = 0;
1496 gc->pipe[pn].array.use_texuv2 = 0; 1543 gc->pipe[pn].array.use_texuv2 = 0;
1497 gc->pipe[pn].array.use_texuv3 = 0; 1544 gc->pipe[pn].array.use_texuv3 = 0;
1498#endif 1545#endif
@@ -1544,6 +1591,253 @@ again:
1544} 1591}
1545 1592
1546void 1593void
1594evas_gl_common_context_image_mask_push(Evas_Engine_GL_Context *gc,
1595 Evas_GL_Texture *tex,
1596 Evas_GL_Texture *texm,
1597 double sx, double sy, double sw, double sh,
1598 double sxm, double sym, double swm,double shm,
1599 int x, int y, int w, int h,
1600 int r, int g, int b, int a,
1601 Eina_Bool smooth)
1602{
1603 int pnum, nv, nc, nu, nm, nt, i;
1604 GLfloat tx1, tx2, ty1, ty2;
1605 GLfloat txm1, txm2, tym1, tym2;
1606 Eina_Bool blend = 1;
1607 GLuint prog = gc->shared->shader.img_mask.prog;
1608 int pn = 0;
1609
1610#if 0
1611 if (tex->gc->shared->info.bgra)
1612 {
1613 prog = gc->shared->shader.img_mask.prog;
1614 }
1615 else
1616 {
1617#warning Nash: FIXME: Need two shaders?
1618 printf("Not good: Need other texture\n");
1619 prog = gc->shared->shader.img.prog;
1620 }
1621#endif
1622
1623again:
1624 vertex_array_size_check(gc, gc->state.top_pipe, 6);
1625 pn = gc->state.top_pipe;
1626#ifdef GLPIPES
1627 if ((pn == 0) && (gc->pipe[pn].array.num == 0))
1628 {
1629 gc->pipe[pn].region.type = RTYPE_IMASK;
1630 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
1631 gc->pipe[pn].shader.cur_texm = texm->pt->texture;
1632 gc->pipe[pn].shader.cur_prog = prog;
1633 gc->pipe[pn].shader.smooth = smooth;
1634 gc->pipe[pn].shader.blend = blend;
1635 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1636 gc->pipe[pn].shader.clip = 0;
1637 gc->pipe[pn].shader.cx = 0;
1638 gc->pipe[pn].shader.cy = 0;
1639 gc->pipe[pn].shader.cw = 0;
1640 gc->pipe[pn].shader.ch = 0;
1641 gc->pipe[pn].array.line = 0;
1642 gc->pipe[pn].array.use_vertex = 1;
1643 // if nomul... dont need this
1644 gc->pipe[pn].array.use_color = 1;
1645 gc->pipe[pn].array.use_texuv = 1;
1646 gc->pipe[pn].array.use_texuv2 = 0;
1647 gc->pipe[pn].array.use_texuv3 = 0;
1648 gc->pipe[pn].array.use_texm = 1;
1649 }
1650 else
1651 {
1652 int found = 0;
1653
1654 for (i = pn; i >= 0; i--)
1655 {
1656 if ((gc->pipe[i].region.type == RTYPE_IMASK)
1657 && (gc->pipe[i].shader.cur_tex == tex->pt->texture)
1658 && (gc->pipe[i].shader.cur_texm == texm->pt->texture)
1659 && (gc->pipe[i].shader.cur_prog == prog)
1660 && (gc->pipe[i].shader.smooth == smooth)
1661 && (gc->pipe[i].shader.blend == blend)
1662 && (gc->pipe[i].shader.render_op == gc->dc->render_op)
1663 && (gc->pipe[i].shader.clip == 0)
1664 )
1665 {
1666 found = 1;
1667 pn = i;
1668 break;
1669 }
1670 if (pipe_region_intersects(gc, i, x, y, w, h)) break;
1671 }
1672 if (!found)
1673 {
1674 pn = gc->state.top_pipe + 1;
1675 if (pn >= gc->shared->info.tune.pipes.max)
1676 {
1677 shader_array_flush(gc);
1678 goto again;
1679 }
1680 gc->state.top_pipe = pn;
1681 gc->pipe[pn].region.type = RTYPE_IMASK;
1682 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
1683 gc->pipe[pn].shader.cur_texm = texm->pt->texture;
1684 gc->pipe[pn].shader.cur_prog = prog;
1685 gc->pipe[pn].shader.smooth = smooth;
1686 gc->pipe[pn].shader.blend = blend;
1687 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1688 gc->pipe[pn].shader.clip = 0;
1689 gc->pipe[pn].shader.cx = 0;
1690 gc->pipe[pn].shader.cy = 0;
1691 gc->pipe[pn].shader.cw = 0;
1692 gc->pipe[pn].shader.ch = 0;
1693 gc->pipe[pn].array.line = 0;
1694 gc->pipe[pn].array.use_vertex = 1;
1695 gc->pipe[pn].array.use_color = 1;
1696 gc->pipe[pn].array.use_texuv = 1;
1697 gc->pipe[pn].array.use_texuv2 = 0;
1698 gc->pipe[pn].array.use_texuv3 = 0;
1699 gc->pipe[pn].array.use_texm = 1;
1700
1701 }
1702 }
1703 if ((tex->im) && (tex->im->native.data))
1704 {
1705 if (gc->pipe[pn].array.im != tex->im)
1706 {
1707 shader_array_flush(gc);
1708 pn = gc->state.top_pipe;
1709 gc->pipe[pn].array.im = tex->im;
1710 goto again;
1711 }
1712 }
1713 if (tex->pt->dyn.img)
1714 {
1715 if (gc->pipe[pn].array.im != tex->im)
1716 {
1717 shader_array_flush(gc);
1718 pn = gc->state.top_pipe;
1719 gc->pipe[pn].array.im = tex->im;
1720 goto again;
1721 }
1722 }
1723#else
1724 if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
1725 || (gc->pipe[pn].shader.cur_prog != prog)
1726 || (gc->pipe[pn].shader.smooth != smooth)
1727 || (gc->pipe[pn].shader.blend != blend)
1728 || (gc->pipe[pn].shader.render_op != gc->dc->render_op)
1729 || (gc->pipe[pn].shader.clip != 0)
1730 )
1731 {
1732 shader_array_flush(gc);
1733 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
1734 gc->pipe[pn].shader.cur_texm = texm->pt->texture;
1735 gc->pipe[pn].shader.cur_prog = prog;
1736 gc->pipe[pn].shader.smooth = smooth;
1737 gc->pipe[pn].shader.blend = blend;
1738 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1739 gc->pipe[pn].shader.clip = 0;
1740 gc->pipe[pn].shader.cx = 0;
1741 gc->pipe[pn].shader.cy = 0;
1742 gc->pipe[pn].shader.cw = 0;
1743 gc->pipe[pn].shader.ch = 0;
1744 }
1745 if ((tex->im) && (tex->im->native.data))
1746 {
1747 if (gc->pipe[pn].array.im != tex->im)
1748 {
1749 shader_array_flush(gc);
1750 gc->pipe[pn].array.im = tex->im;
1751 }
1752 }
1753 if (tex->pt->dyn.img)
1754 {
1755 if (gc->pipe[pn].array.im != tex->im)
1756 {
1757 shader_array_flush(gc);
1758 gc->pipe[pn].array.im = tex->im;
1759 }
1760 }
1761
1762 gc->pipe[pn].array.line = 0;
1763 gc->pipe[pn].array.use_vertex = 1;
1764 gc->pipe[pn].array.use_color = 1;
1765 gc->pipe[pn].array.use_texuv = 1;
1766 gc->pipe[pn].array.use_texuv2 = 0;
1767 gc->pipe[pn].array.use_texuv3 = 0;
1768 gc->pipe[pn].array.use_texm = 1;
1769#endif
1770
1771 pipe_region_expand(gc, pn, x, y, w, h);
1772
1773 pnum = gc->pipe[pn].array.num;
1774 nv = pnum * 3; nc = pnum * 4; nm = pnum * 2; nu = pnum * 2;
1775 nt = pnum * 4;
1776 gc->pipe[pn].array.num += 6;
1777 array_alloc(gc, pn);
1778
1779 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert))
1780 {
1781 tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w;
1782 ty1 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
1783 tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
1784 ty2 = ((double)(tex->y) + sy) / (double)tex->pt->h;
1785
1786 txm1 = ((double)(texm->x) + sxm) / (double)texm->pt->w;
1787 tym1 = ((double)(texm->y) + sym + shm) / (double)texm->pt->h;
1788 txm2 = ((double)(texm->x) + sxm + swm) / (double)texm->pt->w;
1789 tym2 = ((double)(texm->y) + sym) / (double)texm->pt->h;
1790 }
1791 else
1792 {
1793 tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w;
1794 ty1 = ((double)(tex->y) + sy) / (double)tex->pt->h;
1795 tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
1796 ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
1797
1798 txm1 = (texm->x + sxm) / (double)texm->pt->w;
1799 tym1 = (texm->y + sym) / (double)texm->pt->h;
1800 txm2 = (texm->x + sxm + swm) / (double)texm->pt->w;
1801 tym2 = (texm->y + sym + shm) / (double)texm->pt->h;
1802 }
1803 // printf(" %3.6lf %3.6lf %3.6lf %3.6lf\n",sx,sy,sw,sh);
1804 // printf("m%3.6lf %3.6lf %3.6lf %3.6lf\n",sxm,sym,swm,shm);
1805 // printf(" %3f %3f %3f %3f\n",tx1,ty1,tx2,ty2);
1806 // printf("m%3f %3f %3f %3f\n",txm1,tym1,txm2,tym2);
1807
1808 PUSH_VERTEX(pn, x , y , 0);
1809 PUSH_VERTEX(pn, x + w, y , 0);
1810 PUSH_VERTEX(pn, x , y + h, 0);
1811
1812 PUSH_TEXUV(pn, tx1, ty1);
1813 PUSH_TEXUV(pn, tx2, ty1);
1814 PUSH_TEXUV(pn, tx1, ty2);
1815
1816 PUSH_TEXM(pn, txm1, tym1);
1817 PUSH_TEXM(pn, txm2, tym1);
1818 PUSH_TEXM(pn, txm1, tym2);
1819
1820 PUSH_VERTEX(pn, x + w, y , 0);
1821 PUSH_VERTEX(pn, x + w, y + h, 0);
1822 PUSH_VERTEX(pn, x , y + h, 0);
1823
1824 PUSH_TEXUV(pn, tx2, ty1);
1825 PUSH_TEXUV(pn, tx2, ty2);
1826 PUSH_TEXUV(pn, tx1, ty2);
1827
1828 PUSH_TEXM(pn, txm2, tym1);
1829 PUSH_TEXM(pn, txm2, tym2);
1830 PUSH_TEXM(pn, txm1, tym2);
1831
1832 // if nomul... dont need this
1833 for (i = 0; i < 6; i++)
1834 {
1835 PUSH_COLOR(pn, r, g, b, a);
1836 }
1837}
1838
1839
1840void
1547evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, 1841evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
1548 Evas_GL_Texture *tex, 1842 Evas_GL_Texture *tex,
1549 double sx, double sy, double sw, double sh, 1843 double sx, double sy, double sw, double sh,
@@ -2492,7 +2786,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
2492 { 2786 {
2493 glDisableVertexAttribArray(SHAD_TEXUV); 2787 glDisableVertexAttribArray(SHAD_TEXUV);
2494 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 2788 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2495 glDisableVertexAttribArray(SHAD_TEXUV2); 2789 glDisableVertexAttribArray(SHAD_TEXUV2);
2496 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 2790 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2497 glDisableVertexAttribArray(SHAD_TEXUV3); 2791 glDisableVertexAttribArray(SHAD_TEXUV3);
2498 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 2792 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
@@ -2501,6 +2795,24 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
2501 } 2795 }
2502 else 2796 else
2503 { 2797 {
2798 if (gc->pipe[i].array.use_texm)
2799 {
2800 printf("using tex m (%d)\n",gc->pipe[i].shader.cur_texm);
2801 glEnableVertexAttribArray(SHAD_TEXM);
2802 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2803 glVertexAttribPointer(SHAD_TEXM, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texm);
2804 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2805 glActiveTexture(GL_TEXTURE1);
2806 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2807 glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texm);
2808 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2809 glActiveTexture(GL_TEXTURE0);
2810 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2811 }
2812 else
2813 {
2814 glDisableVertexAttribArray(SHAD_TEXM);
2815 }
2504 if ((gc->pipe[i].array.use_texuv2) && (gc->pipe[i].array.use_texuv3)) 2816 if ((gc->pipe[i].array.use_texuv2) && (gc->pipe[i].array.use_texuv3))
2505 { 2817 {
2506 glEnableVertexAttribArray(SHAD_TEXUV2); 2818 glEnableVertexAttribArray(SHAD_TEXUV2);
@@ -2528,6 +2840,11 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
2528 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 2840 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2529 glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2); 2841 glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2);
2530 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 2842 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2843 glActiveTexture(GL_TEXTURE1);
2844 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2845 glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu);
2846 glActiveTexture(GL_TEXTURE0);
2847 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2531 } 2848 }
2532 else 2849 else
2533 { 2850 {
@@ -2579,12 +2896,14 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
2579 if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex); 2896 if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex);
2580 if (gc->pipe[i].array.color) free(gc->pipe[i].array.color); 2897 if (gc->pipe[i].array.color) free(gc->pipe[i].array.color);
2581 if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv); 2898 if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv);
2899 if (gc->pipe[i].array.texm) free(gc->pipe[i].array.texm);
2582 if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); 2900 if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2);
2583 if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); 2901 if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3);
2584 2902
2585 gc->pipe[i].array.vertex = NULL; 2903 gc->pipe[i].array.vertex = NULL;
2586 gc->pipe[i].array.color = NULL; 2904 gc->pipe[i].array.color = NULL;
2587 gc->pipe[i].array.texuv = NULL; 2905 gc->pipe[i].array.texuv = NULL;
2906 gc->pipe[i].array.texm = NULL;
2588 gc->pipe[i].array.texuv2 = NULL; 2907 gc->pipe[i].array.texuv2 = NULL;
2589 gc->pipe[i].array.texuv3 = NULL; 2908 gc->pipe[i].array.texuv3 = NULL;
2590 2909
diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
index af48bf03c3..ae4c303531 100644
--- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
+++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
@@ -906,6 +906,20 @@ eng_image_colorspace_get(void *data __UNUSED__, void *image)
906 return im->cs.space; 906 return im->cs.space;
907} 907}
908 908
909static void
910eng_image_mask_create(void *data __UNUSED__, void *image)
911{
912 Evas_GL_Image *im;
913
914 if (!image) return;
915 im = image;
916 if (!im->im->image.data)
917 evas_cache_image_load_data(&im->im->cache_entry);
918 if (!im->tex)
919 im->tex = evas_gl_common_texture_new(im->gc, im->im);
920}
921
922
909static void * 923static void *
910eng_image_alpha_set(void *data, void *image, int has_alpha) 924eng_image_alpha_set(void *data, void *image, int has_alpha)
911{ 925{
@@ -2574,6 +2588,7 @@ module_open(Evas_Module *em)
2574 ORD(image_format_get); 2588 ORD(image_format_get);
2575 ORD(image_colorspace_set); 2589 ORD(image_colorspace_set);
2576 ORD(image_colorspace_get); 2590 ORD(image_colorspace_get);
2591 ORD(image_mask_create);
2577 ORD(image_native_set); 2592 ORD(image_native_set);
2578 ORD(image_native_get); 2593 ORD(image_native_get);
2579 2594
diff --git a/legacy/evas/src/modules/engines/software_generic/evas_engine.c b/legacy/evas/src/modules/engines/software_generic/evas_engine.c
index e3c607b074..772a23720e 100644
--- a/legacy/evas/src/modules/engines/software_generic/evas_engine.c
+++ b/legacy/evas/src/modules/engines/software_generic/evas_engine.c
@@ -97,6 +97,24 @@ eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g,
97} 97}
98 98
99static void 99static void
100eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
101{
102 evas_common_draw_context_set_mask(context, mask, x, y, w, h);
103}
104
105static void
106eng_context_mask_unset(void *data __UNUSED__, void *context)
107{
108 evas_common_draw_context_unset_mask(context);
109}
110
111static void *
112eng_context_mask_get(void *data __UNUSED__, void *context)
113{
114 return ((RGBA_Draw_Context *)context)->mask.mask;
115}
116
117static void
100eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h) 118eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
101{ 119{
102 evas_common_draw_context_add_cutout(context, x, y, w, h); 120 evas_common_draw_context_add_cutout(context, x, y, w, h);
@@ -239,6 +257,31 @@ eng_image_colorspace_get(void *data __UNUSED__, void *image)
239 return im->space; 257 return im->space;
240} 258}
241 259
260static void
261eng_image_mask_create(void *data __UNUSED__, void *image)
262{
263 RGBA_Image *im;
264 int sz;
265 uint8_t *dst,*end;
266 uint32_t *src;
267
268 if (!image) return;
269 im = image;
270 if (im->mask.mask && !im->mask.dirty) return;
271
272 if (im->mask.mask) free(im->mask.mask);
273 sz = im->cache_entry.w * im->cache_entry.h;
274 im->mask.mask = malloc(sz);
275 dst = im->mask.mask;
276 if (!im->image.data)
277 evas_cache_image_load_data(&im->cache_entry);
278 src = im->image.data;
279 for (end = dst + sz ; dst < end ; dst ++, src ++)
280 *dst = *src >> 24;
281 im->mask.dirty = 0;
282}
283
284
242static void * 285static void *
243eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha) 286eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
244{ 287{
@@ -848,6 +891,8 @@ static Evas_Func func =
848 eng_context_clip_clip, 891 eng_context_clip_clip,
849 eng_context_clip_unset, 892 eng_context_clip_unset,
850 eng_context_clip_get, 893 eng_context_clip_get,
894 eng_context_mask_set,
895 eng_context_mask_unset,
851 eng_context_color_set, 896 eng_context_color_set,
852 eng_context_color_get, 897 eng_context_color_get,
853 eng_context_multiplier_set, 898 eng_context_multiplier_set,
@@ -891,6 +936,7 @@ static Evas_Func func =
891 eng_image_format_get, 936 eng_image_format_get,
892 eng_image_colorspace_set, 937 eng_image_colorspace_set,
893 eng_image_colorspace_get, 938 eng_image_colorspace_get,
939 eng_image_mask_create,
894 eng_image_native_set, 940 eng_image_native_set,
895 eng_image_native_get, 941 eng_image_native_get,
896 /* image cache funcs */ 942 /* image cache funcs */