aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/evas/engines/gl_common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-24 14:23:03 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-04-14 11:26:43 +0900
commit3d2f1a3d9b04d4067ebe6008d2662c46ec694d7b (patch)
treeadcdba47ffe0813684dc6379d1328102736adc67 /src/modules/evas/engines/gl_common
parentevas filters: Fix blur logic and GL buffer handling (diff)
downloadefl-3d2f1a3d9b04d4067ebe6008d2662c46ec694d7b.tar.gz
evas filters: Implement mask filter in pure GL
This reuses the existing mask infrastructure, but adds a color flag to use the whole RGBA range, rather than just the Alpha channel. Filters are still very slow (glReadPixels and non-optimized use of GL buffers...), but this is progress :)
Diffstat (limited to 'src/modules/evas/engines/gl_common')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h37
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c49
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_font.c12
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c117
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_line.c4
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_polygon.c8
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_rectangle.c10
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_shader.c38
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x25
-rw-r--r--src/modules/evas/engines/gl_common/shader/fragment.glsl25
10 files changed, 245 insertions, 80 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index 74d456e008..537361ca45 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -556,58 +556,67 @@ void evas_gl_common_context_target_surface_set(Evas_Engine_GL_Conte
void evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
int x1, int y1, int x2, int y2,
int clip, int cx, int cy, int cw, int ch,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a);
void evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
int x, int y, int w, int h,
int r, int g, int b, int a,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth);
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color);
void evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth, Eina_Bool tex_only);
void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a);
void evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth);
void evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth);
void evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth);
void evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth);
void evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth);
void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
@@ -615,7 +624,8 @@ void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *g
int npoints,
RGBA_Map_Point *p,
int clip, int cx, int cy, int cw, int ch,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth,
Eina_Bool tex_only,
@@ -632,7 +642,7 @@ Evas_GL_Program *evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
int sw, int sh, int w, int h, Eina_Bool smooth,
Evas_GL_Texture *tex, Eina_Bool tex_only,
Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
- int mw, int mh,
+ Eina_Bool mask_color, int mw, int mh,
Shader_Sampling *psam, int *pnomul,
Shader_Sampling *pmasksam);
void evas_gl_common_shader_textures_bind(Evas_GL_Program *p);
@@ -688,8 +698,9 @@ void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x,
void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level);
void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
-Evas_GL_Image *evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
-Evas_GL_Image *evas_gl_common_image_surface_detach(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
+Evas_GL_Image *evas_gl_common_image_surface_update(Evas_GL_Image *im);
+Evas_GL_Image *evas_gl_common_image_surface_detach(Evas_GL_Image *im);
+Evas_GL_Image *evas_gl_common_image_virtual_scaled_get(Evas_GL_Image *scaled, Evas_GL_Image *image, int dst_w, int dst_h, Eina_Bool smooth);
void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg);
void evas_gl_font_texture_free(void *);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index b0ddb5e0ba..df6af106f8 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1889,7 +1889,8 @@ void
evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
int x1, int y1, int x2, int y2,
int clip, int cx, int cy, int cw, int ch,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a)
{
Eina_Bool blend = EINA_FALSE;
@@ -1907,7 +1908,7 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_LINE, NULL, 0, r, g, b, a,
0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE,
- mtex, mask_smooth, mw, mh, NULL, NULL, &masksam);
+ mtex, mask_smooth, mask_color, mw, mh, NULL, NULL, &masksam);
pn = _evas_gl_common_context_push(SHD_LINE,
gc, NULL, mtex,
@@ -1958,7 +1959,7 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
int r, int g, int b, int a,
Evas_GL_Texture *mtex,
int mx, int my, int mw, int mh,
- Eina_Bool mask_smooth)
+ Eina_Bool mask_smooth, Eina_Bool mask_color)
{
Eina_Bool blend = EINA_FALSE;
Shader_Sampling masksam = SHD_SAM11;
@@ -1971,7 +1972,7 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_RECT, NULL, 0, r, g, b, a,
0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE,
- mtex, mask_smooth, mw, mh, NULL, NULL, &masksam);
+ mtex, mask_smooth, mask_color, mw, mh, NULL, NULL, &masksam);
pn = _evas_gl_common_context_push(SHD_RECT,
@@ -2130,7 +2131,8 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth, Eina_Bool tex_only)
{
@@ -2167,7 +2169,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, shd_in, NULL, 0, r, g, b, a,
sw, sh, w, h, smooth, tex, tex_only,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
&sam, &nomul, &masksam);
if (tex->ptt)
@@ -2378,7 +2380,8 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a)
{
GLfloat tx1, tx2, ty1, ty2;
@@ -2388,7 +2391,7 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_FONT, NULL, 0, r, g, b, a,
sw, sh, w, h, EINA_FALSE, tex, EINA_FALSE,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, NULL, &masksam);
pn = _evas_gl_common_context_push(SHD_FONT,
@@ -2452,7 +2455,8 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth)
{
@@ -2467,7 +2471,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_YUV, NULL, 0, r, g, b, a,
w, h, w, h, smooth, tex, 0,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
pn = _evas_gl_common_context_push(SHD_YUV,
@@ -2531,7 +2535,8 @@ evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth)
{
@@ -2546,7 +2551,7 @@ evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_YUV_709, NULL, 0, r, g, b, a,
w, h, w, h, smooth, tex, 0,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
pn = _evas_gl_common_context_push(SHD_YUV_709,
@@ -2610,7 +2615,8 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth)
{
@@ -2625,7 +2631,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_YUY2, NULL, 0, r, g, b, a,
sw, sh, w, h, smooth, tex, 0,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
pn = _evas_gl_common_context_push(SHD_YUY2,
@@ -2687,7 +2693,8 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth)
{
@@ -2702,7 +2709,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_NV12, NULL, 0, r, g, b, a,
sw, sh, w, h, smooth, tex, 0,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
pn = _evas_gl_common_context_push(SHD_NV12,
@@ -2767,7 +2774,8 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
double sx, double sy,
double sw, double sh,
int x, int y, int w, int h,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth)
@@ -2786,7 +2794,7 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
prog = evas_gl_common_shader_program_get(gc, SHD_RGB_A_PAIR, NULL, 0, r, g, b, a,
sw, sh, w, h, smooth, tex, 0,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
pn = _evas_gl_common_context_push(SHD_RGB_A_PAIR,
@@ -2851,7 +2859,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
int npoints,
RGBA_Map_Point *p,
int clip, int cx, int cy, int cw, int ch,
- Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth,
+ Evas_GL_Texture *mtex, int mx, int my, int mw, int mh,
+ Eina_Bool mask_smooth, Eina_Bool mask_color,
int r, int g, int b, int a,
Eina_Bool smooth, Eina_Bool tex_only,
Evas_Colorspace cspace)
@@ -2916,7 +2925,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
}
prog = evas_gl_common_shader_program_get(gc, type, p, npoints, r, g, b, a,
w, h, w, h, smooth, tex, tex_only,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
NULL, &nomul, &masksam);
x = w = (p[0].x >> FP);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_font.c b/src/modules/evas/engines/gl_common/evas_gl_font.c
index 5a5fdeb730..1b3e35b607 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_font.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_font.c
@@ -71,6 +71,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
int sx, sy, sw, sh;
double mx = 0.0, my = 0.0, mw = 0.0, mh = 0.0;
Eina_Bool mask_smooth = EINA_FALSE;
+ Eina_Bool mask_color = EINA_FALSE;
if (dc != gc->dc) return;
tex = fg->ext_dat;
@@ -94,6 +95,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = gc->dc->clip.mask_color;
}
else mtex = NULL;
}
@@ -117,7 +119,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
return;
}
@@ -128,7 +130,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
}
else
@@ -137,7 +139,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
}
return;
@@ -167,7 +169,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
continue;
}
@@ -178,7 +180,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
}
evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index e42203151a..4a89ff62d8 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -1042,13 +1042,14 @@ evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
}
Evas_GL_Image *
-evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
+evas_gl_common_image_surface_update(Evas_GL_Image *im)
{
+ Evas_Engine_GL_Context *gc;
Evas_GL_Image *glim = NULL;
Eina_Bool alpha;
int w, h;
- if (!gc || !im || !im->im || !im->im->image.data)
+ if (!im || !im->gc || !im->im || !im->im->image.data)
goto fail;
if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_ARGB8888)
@@ -1057,6 +1058,7 @@ evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *i
alpha = EINA_TRUE;
else goto fail;
+ gc = im->gc;
w = im->im->cache_entry.w;
h = im->im->cache_entry.h;
glim = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
@@ -1101,7 +1103,7 @@ fail:
}
Evas_GL_Image *
-evas_gl_common_image_surface_detach(Evas_Engine_GL_Context *gc EINA_UNUSED, Evas_GL_Image *im)
+evas_gl_common_image_surface_detach(Evas_GL_Image *im)
{
if (!im || !im->im) return im;
@@ -1111,6 +1113,85 @@ evas_gl_common_image_surface_detach(Evas_Engine_GL_Context *gc EINA_UNUSED, Evas
return im;
}
+Evas_GL_Image *
+evas_gl_common_image_virtual_scaled_get(Evas_GL_Image *scaled, Evas_GL_Image *image,
+ int dst_w, int dst_h, Eina_Bool smooth)
+{
+ Evas_GL_Image *dst = scaled, *newdst;
+ Evas_GL_Image *src = image;
+ Evas_Engine_GL_Context *gc;
+ Eina_Bool reffed = EINA_FALSE;
+
+ if (!src) return NULL;
+
+ // masking will work only with single texture images
+ switch (src->cs.space)
+ {
+ case EVAS_COLORSPACE_AGRY88:
+ case EVAS_COLORSPACE_ARGB8888:
+ case EVAS_COLORSPACE_GRY8:
+ case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
+ case EVAS_COLORSPACE_RGBA_S3TC_DXT1:
+ case EVAS_COLORSPACE_RGBA_S3TC_DXT2:
+ case EVAS_COLORSPACE_RGBA_S3TC_DXT3:
+ case EVAS_COLORSPACE_RGBA_S3TC_DXT4:
+ case EVAS_COLORSPACE_RGBA_S3TC_DXT5:
+ break;
+ default:
+ DBG("cspace %d can't be used for masking's fast path", src->cs.space);
+ return NULL;
+ }
+
+ gc = src->gc;
+ if (dst && (dst->scaled.origin == src) &&
+ (dst->w == dst_w) && (dst->h == dst_h))
+ return dst;
+
+ evas_gl_common_image_update(gc, src);
+ if (!src->tex)
+ {
+ ERR("No source texture.");
+ return NULL;
+ }
+
+ newdst = calloc(1, sizeof(Evas_GL_Image));
+ if (!newdst) return NULL;
+
+ if (dst)
+ {
+ if (dst->scaled.origin == src)
+ {
+ if (dst->references == 1)
+ {
+ dst->w = dst_w;
+ dst->h = dst_h;
+ dst->scaled.smooth = smooth;
+ free(newdst);
+ return dst;
+ }
+ src->references++;
+ reffed = EINA_TRUE;
+ }
+ evas_gl_common_image_free(dst);
+ }
+
+ newdst->references = 1;
+ newdst->gc = gc;
+ newdst->cs.space = src->cs.space;
+ newdst->alpha = src->alpha;
+ newdst->w = dst_w;
+ newdst->h = dst_h;
+ newdst->tex = src->tex;
+ newdst->tex->references++;
+ newdst->tex_only = 1;
+
+ if (!reffed) src->references++;
+ newdst->scaled.origin = src;
+ newdst->scaled.smooth = smooth;
+
+ return newdst;
+}
+
void
evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED)
@@ -1120,6 +1201,7 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
Eina_Bool mask_smooth = EINA_FALSE;
Evas_GL_Image *mask = dc->clip.mask;
Evas_GL_Texture *mtex = NULL;
+ Eina_Bool mask_color = EINA_FALSE;
int r, g, b, a;
int c, cx, cy, cw, ch;
@@ -1155,13 +1237,14 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = dc->clip.mask_color;
}
else mtex = NULL;
}
evas_gl_common_context_image_map_push(gc, im->tex, npoints, p,
c, cx, cy, cw, ch,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a, smooth, im->tex_only,
im->cs.space);
}
@@ -1182,6 +1265,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
double ssx, ssy, ssw, ssh;
Evas_GL_Texture *mtex = NULL;
Eina_Bool mask_smooth = EINA_FALSE;
+ Eina_Bool mask_color = EINA_FALSE;
int nx, ny, nw, nh;
nx = dx; ny = dy; nw = dw; nh = dh;
@@ -1202,6 +1286,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = gc->dc->clip.mask_color;
}
else mtex = NULL;
}
@@ -1213,7 +1298,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (yuv_709)
@@ -1221,7 +1306,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (yuy2)
@@ -1229,7 +1314,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (nv12)
@@ -1237,7 +1322,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (rgb_a_pair)
@@ -1245,7 +1330,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else
@@ -1253,7 +1338,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
sx, sy, sw, sh,
dx, dy, dw, dh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth, im->tex_only);
return;
@@ -1269,7 +1354,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (yuv_709)
@@ -1277,7 +1362,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (yuy2)
@@ -1285,7 +1370,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (nv12)
@@ -1293,7 +1378,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else if (rgb_a_pair)
@@ -1301,7 +1386,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth);
else
@@ -1309,7 +1394,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
im->tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a,
smooth, im->tex_only);
}
diff --git a/src/modules/evas/engines/gl_common/evas_gl_line.c b/src/modules/evas/engines/gl_common/evas_gl_line.c
index 1b7def125f..892be20260 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_line.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_line.c
@@ -12,6 +12,7 @@ evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int
const int OFFSET_HACK_ARM = 2;
Evas_GL_Texture *mtex = NULL;
Eina_Bool mask_smooth = EINA_FALSE;
+ Eina_Bool mask_color = EINA_FALSE;
int mx = 0, my = 0, mw = 0, mh = 0;
Evas_GL_Image *mask;
@@ -48,6 +49,7 @@ evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = gc->dc->clip.mask_color;
}
else mtex = NULL;
}
@@ -97,6 +99,6 @@ evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int
evas_gl_common_context_line_push(gc, x1, y1, x2, y2,
c, cx, cy, cw, ch,
- mtex, mx, my, mw, mh, mask_smooth,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color,
r, g, b, a);
}
diff --git a/src/modules/evas/engines/gl_common/evas_gl_polygon.c b/src/modules/evas/engines/gl_common/evas_gl_polygon.c
index 4552d663a3..839dc61339 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_polygon.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_polygon.c
@@ -133,6 +133,7 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int
int x = 0, y = 0, w = 0, h = 0;
Evas_GL_Texture *mtex = NULL;
Eina_Bool mask_smooth = EINA_FALSE;
+ Eina_Bool mask_color = EINA_FALSE;
int mx = 0, my = 0, mw = 0, mh = 0;
Evas_GL_Image *mask;
@@ -165,6 +166,7 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = gc->dc->clip.mask_color;
}
else mtex = NULL;
}
@@ -291,7 +293,8 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int
h = 1;
evas_gl_common_context_rectangle_push(gc, x, y, w, h,
cr, cg, cb, ca,
- mtex, mx, my, mw, mh, mask_smooth);
+ mtex, mx, my, mw, mh,
+ mask_smooth, mask_color);
}
}
else
@@ -315,7 +318,8 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int
if ((w > 0) && (h > 0))
evas_gl_common_context_rectangle_push(gc, x, y, w, h,
cr, cg, cb, ca,
- mtex, mx, my, mw, mh, mask_smooth);
+ mtex, mx, my, mw, mh,
+ mask_smooth, mask_color);
}
}
}
diff --git a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c
index 04bdc1ae48..a188467b58 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c
@@ -8,6 +8,7 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h)
int mx = 0, my = 0, mw = 0, mh = 0;
Eina_Bool mask_smooth = EINA_FALSE;
Evas_GL_Image *mask = gc->dc->clip.mask;
+ Eina_Bool mask_color = EINA_FALSE;
Evas_GL_Texture *mtex = NULL;
if ((w <= 0) || (h <= 0)) return;
@@ -42,6 +43,7 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h)
mw = mask->w;
mh = mask->h;
mask_smooth = mask->scaled.smooth;
+ mask_color = gc->dc->clip.mask_color;
}
else mtex = NULL;
}
@@ -50,7 +52,9 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h)
((gc->shared->info.tune.cutout.max > 0) &&
(gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
{
- evas_gl_common_context_rectangle_push(gc, x, y, w, h, cr, cg, cb, ca, mtex, mx, my, mw, mh, mask_smooth);
+ evas_gl_common_context_rectangle_push
+ (gc, x, y, w, h, cr, cg, cb, ca,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color);
}
else
{
@@ -64,7 +68,9 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h)
r = _evas_gl_common_cutout_rects->rects + i;
if ((r->w > 0) && (r->h > 0))
{
- evas_gl_common_context_rectangle_push(gc, r->x, r->y, r->w, r->h, cr, cg, cb, ca, mtex, mx, my, mw, mh, mask_smooth);
+ evas_gl_common_context_rectangle_push
+ (gc, r->x, r->y, r->w, r->h, cr, cg, cb, ca,
+ mtex, mx, my, mw, mh, mask_smooth, mask_color);
}
}
evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c
index cc22155dce..f4a8e6980c 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_shader.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c
@@ -28,19 +28,20 @@ typedef enum {
SHADER_FLAG_MASKSAM12 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 0)),
SHADER_FLAG_MASKSAM21 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 1)),
SHADER_FLAG_MASKSAM22 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 2)),
- SHADER_FLAG_IMG = (1 << 9),
- SHADER_FLAG_BIGENDIAN = (1 << 10),
- SHADER_FLAG_YUV = (1 << 11),
- SHADER_FLAG_YUY2 = (1 << 12),
- SHADER_FLAG_NV12 = (1 << 13),
- SHADER_FLAG_YUV_709 = (1 << 14),
- SHADER_FLAG_EXTERNAL = (1 << 15),
- SHADER_FLAG_AFILL = (1 << 16),
- SHADER_FLAG_NOMUL = (1 << 17),
- SHADER_FLAG_ALPHA = (1 << 18),
- SHADER_FLAG_RGB_A_PAIR = (1 << 19),
+ SHADER_FLAG_MASK_COLOR = (1 << 9),
+ SHADER_FLAG_IMG = (1 << 10),
+ SHADER_FLAG_BIGENDIAN = (1 << 11),
+ SHADER_FLAG_YUV = (1 << 12),
+ SHADER_FLAG_YUY2 = (1 << 13),
+ SHADER_FLAG_NV12 = (1 << 14),
+ SHADER_FLAG_YUV_709 = (1 << 15),
+ SHADER_FLAG_EXTERNAL = (1 << 16),
+ SHADER_FLAG_AFILL = (1 << 17),
+ SHADER_FLAG_NOMUL = (1 << 18),
+ SHADER_FLAG_ALPHA = (1 << 19),
+ SHADER_FLAG_RGB_A_PAIR = (1 << 20),
} Shader_Flag;
-#define SHADER_FLAG_COUNT 20
+#define SHADER_FLAG_COUNT 21
static const char *_shader_flags[SHADER_FLAG_COUNT] = {
"TEX",
@@ -52,6 +53,7 @@ static const char *_shader_flags[SHADER_FLAG_COUNT] = {
"MASKSAM12",
"MASKSAM21",
"MASKSAM22",
+ "MASK_COLOR",
"IMG",
"BIGENDIAN",
"YUV",
@@ -707,7 +709,7 @@ evas_gl_common_shader_flags_get(Evas_GL_Shared *shared, Shader_Type type,
int sw, int sh, int w, int h, Eina_Bool smooth,
Evas_GL_Texture *tex, Eina_Bool tex_only,
Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
- int mw, int mh,
+ Eina_Bool mask_color, int mw, int mh,
Shader_Sampling *psam, int *pnomul, Shader_Sampling *pmasksam)
{
Shader_Sampling sam = SHD_SAM11, masksam = SHD_SAM11;
@@ -740,6 +742,12 @@ evas_gl_common_shader_flags_get(Evas_GL_Shared *shared, Shader_Type type,
flags |= (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + masksam - 1));
}
+ // mask color mode
+ if (mtex && mask_color)
+ {
+ flags |= SHADER_FLAG_MASK_COLOR;
+ }
+
switch (type)
{
case SHD_RECT:
@@ -899,7 +907,7 @@ evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
int sw, int sh, int w, int h, Eina_Bool smooth,
Evas_GL_Texture *tex, Eina_Bool tex_only,
Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
- int mw, int mh,
+ Eina_Bool mask_color, int mw, int mh,
Shader_Sampling *psam, int *pnomul,
Shader_Sampling *pmasksam)
{
@@ -908,7 +916,7 @@ evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
flags = evas_gl_common_shader_flags_get(gc->shared, type, map_points, npoints, r, g, b, a,
sw, sh, w, h, smooth, tex, tex_only,
- mtex, mask_smooth, mw, mh,
+ mtex, mask_smooth, mask_color, mw, mh,
psam, pnomul, pmasksam);
p = eina_hash_find(gc->shared->shaders_hash, &flags);
if (!p)
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
index 195ed19bb6..8cae1481b5 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
@@ -131,19 +131,38 @@ static const char fragment_glsl[] =
" c = vec4(1, 1, 1, 1);\n"
"#endif\n"
"#ifdef SHD_MASK\n"
+ "# ifndef SHD_MASK_COLOR\n"
+ " // Classic mask: alpha only\n"
" float ma;\n"
- "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
+ "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
" float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
" float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
" ma = (ma00 + ma01) / maskdiv_s;\n"
- "# elif defined(SHD_MASKSAM22)\n"
+ "# elif defined(SHD_MASKSAM22)\n"
" float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
" float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
" float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;\n"
" float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;\n"
" ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n"
- "# else\n"
+ "# else\n"
" ma = texture2D(texm, tex_m).a;\n"
+ "# endif\n"
+ "# else\n"
+ " // Full color mask\n"
+ " vec4 ma;\n"
+ "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
+ " vec4 ma00 = texture2D(texm, tex_m + masktex_s[0]);\n"
+ " vec4 ma01 = texture2D(texm, tex_m + masktex_s[1]);\n"
+ " ma = (ma00 + ma01) / maskdiv_s;\n"
+ "# elif defined(SHD_MASKSAM22)\n"
+ " vec4 ma00 = texture2D(texm, tex_m + masktex_s[0]);\n"
+ " vec4 ma01 = texture2D(texm, tex_m + masktex_s[1]);\n"
+ " vec4 ma10 = texture2D(texm, tex_m + masktex_s[2]);\n"
+ " vec4 ma11 = texture2D(texm, tex_m + masktex_s[3]);\n"
+ " ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n"
+ "# else\n"
+ " ma = texture2D(texm, tex_m);\n"
+ "# endif\n"
"# endif\n"
"#endif\n"
"#ifdef SHD_AFILL\n"
diff --git a/src/modules/evas/engines/gl_common/shader/fragment.glsl b/src/modules/evas/engines/gl_common/shader/fragment.glsl
index c20dc71fc7..7de74a2e80 100644
--- a/src/modules/evas/engines/gl_common/shader/fragment.glsl
+++ b/src/modules/evas/engines/gl_common/shader/fragment.glsl
@@ -132,19 +132,38 @@ void main()
#endif
#ifdef SHD_MASK
+# ifndef SHD_MASK_COLOR
+ // Classic mask: alpha only
float ma;
-# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
+# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;
float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;
ma = (ma00 + ma01) / maskdiv_s;
-# elif defined(SHD_MASKSAM22)
+# elif defined(SHD_MASKSAM22)
float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;
float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;
float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;
float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;
ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;
-# else
+# else
ma = texture2D(texm, tex_m).a;
+# endif
+# else
+ // Full color mask
+ vec4 ma;
+# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
+ vec4 ma00 = texture2D(texm, tex_m + masktex_s[0]);
+ vec4 ma01 = texture2D(texm, tex_m + masktex_s[1]);
+ ma = (ma00 + ma01) / maskdiv_s;
+# elif defined(SHD_MASKSAM22)
+ vec4 ma00 = texture2D(texm, tex_m + masktex_s[0]);
+ vec4 ma01 = texture2D(texm, tex_m + masktex_s[1]);
+ vec4 ma10 = texture2D(texm, tex_m + masktex_s[2]);
+ vec4 ma11 = texture2D(texm, tex_m + masktex_s[3]);
+ ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;
+# else
+ ma = texture2D(texm, tex_m);
+# endif
# endif
#endif