summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-25 14:34:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-12-22 22:33:11 +0900
commitdf8dc15bb9141843ea4d0a1f9bfaa75a80cd578f (patch)
tree147975cd2725354ec14e3b5112b4edb74429dd11
parent4b01f33bcbc2e6cae677eb263474f2c07e712bf6 (diff)
Evas masking: Font masking for GL
-rw-r--r--src/Makefile_Evas.am2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h7
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c103
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_font.c37
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_enum.x1
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x59
-rw-r--r--src/modules/evas/engines/gl_common/shader/font_mask_frag.shd17
-rw-r--r--src/modules/evas/engines/gl_common/shader/font_mask_vert.shd19
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c58
9 files changed, 299 insertions, 4 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index d96d4e435e..e04f4c30c6 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -594,6 +594,8 @@ modules/evas/engines/gl_common/evas_gl_3d_shader.c
594GL_SHADERS_GEN = \ 594GL_SHADERS_GEN = \
595modules/evas/engines/gl_common/shader/font_frag.shd \ 595modules/evas/engines/gl_common/shader/font_frag.shd \
596modules/evas/engines/gl_common/shader/font_vert.shd \ 596modules/evas/engines/gl_common/shader/font_vert.shd \
597modules/evas/engines/gl_common/shader/font_mask_frag.shd \
598modules/evas/engines/gl_common/shader/font_mask_vert.shd \
597modules/evas/engines/gl_common/shader/img_12_bgra_frag.shd \ 599modules/evas/engines/gl_common/shader/img_12_bgra_frag.shd \
598modules/evas/engines/gl_common/shader/img_12_bgra_nomul_frag.shd \ 600modules/evas/engines/gl_common/shader/img_12_bgra_nomul_frag.shd \
599modules/evas/engines/gl_common/shader/img_12_bgra_nomul_vert.shd \ 601modules/evas/engines/gl_common/shader/img_12_bgra_nomul_vert.shd \
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 eda2b8bc98..c314e4d88e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -729,6 +729,13 @@ void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
729 double sx, double sy, double sw, double sh, 729 double sx, double sy, double sw, double sh,
730 int x, int y, int w, int h, 730 int x, int y, int w, int h,
731 int r, int g, int b, int a); 731 int r, int g, int b, int a);
732void evas_gl_common_context_masked_font_push(Evas_Engine_GL_Context *gc,
733 Evas_GL_Texture *tex,
734 double sx, double sy, double sw, double sh,
735 int x, int y, int w, int h,
736 int r, int g, int b, int a,
737 Evas_GL_Texture *texa,
738 int mx, int my, int mw, int mh);
732void evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc, 739void evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
733 Evas_GL_Texture *tex, 740 Evas_GL_Texture *tex,
734 double sx, double sy, double sw, double sh, 741 double sx, double sy, double sw, double sh,
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 08ccbb6ec9..abe448e21b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -856,6 +856,9 @@ evas_gl_common_context_new(void)
856 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, tex); 856 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, tex);
857 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, texa); 857 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, texa);
858 858
859 SHADER_TEXTURE_ADD(shared, FONT_MASK, tex);
860 SHADER_TEXTURE_ADD(shared, FONT_MASK, texa);
861
859 if (gc->state.current.cur_prog == PRG_INVALID) 862 if (gc->state.current.cur_prog == PRG_INVALID)
860 glUseProgram(shared->shader[0].prog); 863 glUseProgram(shared->shader[0].prog);
861 else glUseProgram(gc->state.current.cur_prog); 864 else glUseProgram(gc->state.current.cur_prog);
@@ -1900,6 +1903,106 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1900} 1903}
1901 1904
1902void 1905void
1906evas_gl_common_context_masked_font_push(Evas_Engine_GL_Context *gc,
1907 Evas_GL_Texture *tex,
1908 double sx, double sy, double sw, double sh,
1909 int x, int y, int w, int h,
1910 int r, int g, int b, int a,
1911 Evas_GL_Texture *texa,
1912 int mx, int my, int mw, int mh)
1913{
1914 int pnum, nv, nc, nu, na, i;
1915 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
1916 GLuint prog = gc->shared->shader[SHADER_FONT_MASK].prog;
1917 int pn = 0;
1918
1919 pn = _evas_gl_common_context_push(RTYPE_FONT,
1920 gc, tex,
1921 prog,
1922 x, y, w, h,
1923 1,
1924 0,
1925 0, 0, 0, 0, 0);
1926
1927 gc->pipe[pn].region.type = RTYPE_FONT;
1928 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
1929 gc->pipe[pn].shader.cur_texa = texa->pt->texture;
1930 gc->pipe[pn].shader.cur_prog = prog;
1931 gc->pipe[pn].shader.smooth = 0;
1932 gc->pipe[pn].shader.blend = 1;
1933 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1934 gc->pipe[pn].shader.clip = 0;
1935 gc->pipe[pn].shader.cx = 0;
1936 gc->pipe[pn].shader.cy = 0;
1937 gc->pipe[pn].shader.cw = 0;
1938 gc->pipe[pn].shader.ch = 0;
1939 gc->pipe[pn].array.line = 0;
1940 gc->pipe[pn].array.use_vertex = 1;
1941 gc->pipe[pn].array.use_color = 1;
1942 gc->pipe[pn].array.use_texuv = 1;
1943 gc->pipe[pn].array.use_texuv2 = 0;
1944 gc->pipe[pn].array.use_texuv3 = 0;
1945 gc->pipe[pn].array.use_texa = 1; //
1946 gc->pipe[pn].array.use_texsam = 0;
1947
1948 pipe_region_expand(gc, pn, x, y, w, h);
1949
1950 pnum = gc->pipe[pn].array.num;
1951 nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2;
1952 gc->pipe[pn].array.num += 6;
1953 array_alloc(gc, pn);
1954
1955 if (sw == 0.0)
1956 {
1957 tx1 = tex->sx1;
1958 ty1 = tex->sy1;
1959 tx2 = tex->sx2;
1960 ty2 = tex->sy2;
1961 }
1962 else
1963 {
1964 tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w;
1965 ty1 = ((double)(tex->y) + sy) / (double)tex->pt->h;
1966 tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
1967 ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
1968 }
1969
1970 t2x1 = (texa->x + mx) / (double)texa->pt->w;
1971 t2y1 = (texa->y + my) / (double)texa->pt->h;
1972 t2x2 = (texa->x + mx + mw) / (double)texa->pt->w;
1973 t2y2 = (texa->y + my + mh) / (double)texa->pt->h;
1974
1975 PUSH_VERTEX(pn, x , y , 0);
1976 PUSH_VERTEX(pn, x + w, y , 0);
1977 PUSH_VERTEX(pn, x , y + h, 0);
1978
1979 PUSH_TEXUV(pn, tx1, ty1);
1980 PUSH_TEXUV(pn, tx2, ty1);
1981 PUSH_TEXUV(pn, tx1, ty2);
1982
1983 PUSH_TEXA(pn, t2x1, t2y1);
1984 PUSH_TEXA(pn, t2x2, t2y1);
1985 PUSH_TEXA(pn, t2x1, t2y2);
1986
1987 PUSH_VERTEX(pn, x + w, y , 0);
1988 PUSH_VERTEX(pn, x + w, y + h, 0);
1989 PUSH_VERTEX(pn, x , y + h, 0);
1990
1991 PUSH_TEXUV(pn, tx2, ty1);
1992 PUSH_TEXUV(pn, tx2, ty2);
1993 PUSH_TEXUV(pn, tx1, ty2);
1994
1995 PUSH_TEXA(pn, t2x2, t2y1);
1996 PUSH_TEXA(pn, t2x2, t2y2);
1997 PUSH_TEXA(pn, t2x1, t2y2);
1998
1999 for (i = 0; i < 6; i++)
2000 {
2001 PUSH_COLOR(pn, r, g, b, a);
2002 }
2003}
2004
2005void
1903evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, 2006evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
1904 Evas_GL_Texture *tex, 2007 Evas_GL_Texture *tex,
1905 double sx, double sy, double sw, double sh, 2008 double sx, double sy, double sw, double sh,
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 33c1f58561..b7663a2b44 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_font.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_font.c
@@ -68,6 +68,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
68 int c, cx, cy, cw, ch; 68 int c, cx, cy, cw, ch;
69 int i; 69 int i;
70 int sx, sy, sw, sh; 70 int sx, sy, sw, sh;
71 double mx, my, mw, mh, mmx, mmy, mmw, mmh;
71 72
72 if (dc != gc->dc) return; 73 if (dc != gc->dc) return;
73 tex = fg->ext_dat; 74 tex = fg->ext_dat;
@@ -78,6 +79,42 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c
78 g = (dc->col.col >> 8 ) & 0xff; 79 g = (dc->col.col >> 8 ) & 0xff;
79 b = (dc->col.col ) & 0xff; 80 b = (dc->col.col ) & 0xff;
80 sx = 0; sy = 0; sw = tex->w, sh = tex->h; 81 sx = 0; sy = 0; sw = tex->w, sh = tex->h;
82
83 if (gc->dc->clip.mask && (sw > 0) && (sh > 0))
84 {
85 // FIXME: This code path does not handle half the stuff the other path does...
86 Evas_GL_Image *mask = gc->dc->clip.mask;
87 int nx, ny, nw, nh, dx, dy, dw, dh;
88
89 nx = x; ny = y; nw = tex->w; nh = tex->h;
90 RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
91 gc->dc->clip.x, gc->dc->clip.y,
92 gc->dc->clip.w, gc->dc->clip.h);
93 if ((nw < 1) || (nh < 1)) return;
94
95 ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w));
96 ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
97 ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
98 ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
99
100 dx = x; dy = y; dw = sw; dh = sh;
101 mx = gc->dc->clip.mask_x; my = gc->dc->clip.mask_y; mw = mask->w; mh = mask->h;
102 //RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch);
103 RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh);
104
105 mmx = (double)(mx - gc->dc->clip.mask_x) + ((double)(mw * (nx - dx)) / (double)(dw));
106 mmy = (double)(my - gc->dc->clip.mask_y) + ((double)(mh * (ny - dy)) / (double)(dh));
107 mmw = ((double)mw * (double)(nw)) / (double)(dw);
108 mmh = ((double)mh * (double)(nh)) / (double)(dh);
109
110 evas_gl_common_context_masked_font_push(gc, tex,
111 ssx, ssy, ssw, ssh,
112 nx, ny, nw, nh,
113 r, g, b, a,
114 mask->tex, mmx, mmy, mmw, mmh);
115 return;
116 }
117
81 if ((!gc->dc->cutout.rects) || 118 if ((!gc->dc->cutout.rects) ||
82 ((gc->shared->info.tune.cutout.max > 0) && 119 ((gc->shared->info.tune.cutout.max > 0) &&
83 (gc->dc->cutout.active > gc->shared->info.tune.cutout.max))) 120 (gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
index 74af14d6d9..04614ac134 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
@@ -3,6 +3,7 @@
3 3
4typedef enum { 4typedef enum {
5 SHADER_FONT, 5 SHADER_FONT,
6 SHADER_FONT_MASK,
6 SHADER_IMG_12_BGRA_NOMUL, 7 SHADER_IMG_12_BGRA_NOMUL,
7 SHADER_IMG_12_BGRA, 8 SHADER_IMG_12_BGRA,
8 SHADER_IMG_12_NOMUL, 9 SHADER_IMG_12_NOMUL,
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 8ee9ea920f..9916ef0f0f 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
@@ -48,6 +48,56 @@ Evas_GL_Program_Source shader_font_vert_src =
48 NULL, 0 48 NULL, 0
49}; 49};
50 50
51/* Source: modules/evas/engines/gl_common/shader/font_mask_frag.shd */
52static const char const font_mask_frag_glsl[] =
53 "#ifdef GL_ES\n"
54 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
55 "precision highp float;\n"
56 "#else\n"
57 "precision mediump float;\n"
58 "#endif\n"
59 "#endif\n"
60 "uniform sampler2D tex;\n"
61 "uniform sampler2D texa;\n"
62 "varying vec4 col;\n"
63 "varying vec2 tex_c;\n"
64 "varying vec2 tex_a;\n"
65 "void main()\n"
66 "{\n"
67 " gl_FragColor = texture2D(tex, tex_c.xy).aaaa * texture2D(texa, tex_a.xy).aaaa * col;\n"
68 "}\n";
69Evas_GL_Program_Source shader_font_mask_frag_src =
70{
71 font_mask_frag_glsl,
72 NULL, 0
73};
74
75/* Source: modules/evas/engines/gl_common/shader/font_mask_vert.shd */
76static const char const font_mask_vert_glsl[] =
77 "#ifdef GL_ES\n"
78 "precision highp float;\n"
79 "#endif\n"
80 "attribute vec4 vertex;\n"
81 "attribute vec4 color;\n"
82 "attribute vec2 tex_coord;\n"
83 "attribute vec2 tex_coorda;\n"
84 "uniform mat4 mvp;\n"
85 "varying vec4 col;\n"
86 "varying vec2 tex_c;\n"
87 "varying vec2 tex_a;\n"
88 "void main()\n"
89 "{\n"
90 " gl_Position = mvp * vertex;\n"
91 " col = color;\n"
92 " tex_c = tex_coord;\n"
93 " tex_a = tex_coorda;\n"
94 "}\n";
95Evas_GL_Program_Source shader_font_mask_vert_src =
96{
97 font_mask_vert_glsl,
98 NULL, 0
99};
100
51/* Source: modules/evas/engines/gl_common/shader/img_12_bgra_frag.shd */ 101/* Source: modules/evas/engines/gl_common/shader/img_12_bgra_frag.shd */
52static const char const img_12_bgra_frag_glsl[] = 102static const char const img_12_bgra_frag_glsl[] =
53 "#ifdef GL_ES\n" 103 "#ifdef GL_ES\n"
@@ -2182,7 +2232,7 @@ Evas_GL_Program_Source shader_yuy2_vert_src =
2182}; 2232};
2183 2233
2184/* Source: modules/evas/engines/gl_common/shader/img_mask_frag.shd */ 2234/* Source: modules/evas/engines/gl_common/shader/img_mask_frag.shd */
2185static const char img_mask_frag_glsl[] = 2235static const char const img_mask_frag_glsl[] =
2186 "#ifdef GL_ES\n" 2236 "#ifdef GL_ES\n"
2187 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" 2237 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2188 "precision highp float;\n" 2238 "precision highp float;\n"
@@ -2207,7 +2257,7 @@ Evas_GL_Program_Source shader_img_mask_frag_src =
2207}; 2257};
2208 2258
2209/* Source: modules/evas/engines/gl_common/shader/img_mask_vert.shd */ 2259/* Source: modules/evas/engines/gl_common/shader/img_mask_vert.shd */
2210static const char img_mask_vert_glsl[] = 2260static const char const img_mask_vert_glsl[] =
2211 "#ifdef GL_ES\n" 2261 "#ifdef GL_ES\n"
2212 "precision highp float;\n" 2262 "precision highp float;\n"
2213 "#endif\n" 2263 "#endif\n"
@@ -2233,7 +2283,7 @@ Evas_GL_Program_Source shader_img_mask_vert_src =
2233}; 2283};
2234 2284
2235/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd */ 2285/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd */
2236static const char img_mask_nomul_frag_glsl[] = 2286static const char const img_mask_nomul_frag_glsl[] =
2237 "#ifdef GL_ES\n" 2287 "#ifdef GL_ES\n"
2238 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" 2288 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2239 "precision highp float;\n" 2289 "precision highp float;\n"
@@ -2257,7 +2307,7 @@ Evas_GL_Program_Source shader_img_mask_nomul_frag_src =
2257}; 2307};
2258 2308
2259/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd */ 2309/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd */
2260static const char img_mask_nomul_vert_glsl[] = 2310static const char const img_mask_nomul_vert_glsl[] =
2261 "#ifdef GL_ES\n" 2311 "#ifdef GL_ES\n"
2262 "precision highp float;\n" 2312 "precision highp float;\n"
2263 "#endif\n" 2313 "#endif\n"
@@ -2286,6 +2336,7 @@ static const struct {
2286 const char *name; 2336 const char *name;
2287} _shaders_source[] = { 2337} _shaders_source[] = {
2288 { SHADER_FONT, &(shader_font_vert_src), &(shader_font_frag_src), "font" }, 2338 { SHADER_FONT, &(shader_font_vert_src), &(shader_font_frag_src), "font" },
2339 { SHADER_FONT_MASK, &(shader_font_mask_vert_src), &(shader_font_mask_frag_src), "font_mask" },
2289 { SHADER_IMG_12_BGRA_NOMUL, &(shader_img_12_bgra_nomul_vert_src), &(shader_img_12_bgra_nomul_frag_src), "img_12_bgra_nomul" }, 2340 { SHADER_IMG_12_BGRA_NOMUL, &(shader_img_12_bgra_nomul_vert_src), &(shader_img_12_bgra_nomul_frag_src), "img_12_bgra_nomul" },
2290 { SHADER_IMG_12_BGRA, &(shader_img_12_bgra_vert_src), &(shader_img_12_bgra_frag_src), "img_12_bgra" }, 2341 { SHADER_IMG_12_BGRA, &(shader_img_12_bgra_vert_src), &(shader_img_12_bgra_frag_src), "img_12_bgra" },
2291 { SHADER_IMG_12_NOMUL, &(shader_img_12_nomul_vert_src), &(shader_img_12_nomul_frag_src), "img_12_nomul" }, 2342 { SHADER_IMG_12_NOMUL, &(shader_img_12_nomul_vert_src), &(shader_img_12_nomul_frag_src), "img_12_nomul" },
diff --git a/src/modules/evas/engines/gl_common/shader/font_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/font_mask_frag.shd
new file mode 100644
index 0000000000..950431e8c5
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/font_mask_frag.shd
@@ -0,0 +1,17 @@
1#ifdef GL_ES
2#ifdef GL_FRAGMENT_PRECISION_HIGH
3precision highp float;
4#else
5precision mediump float;
6#endif
7#endif
8uniform sampler2D tex;
9uniform sampler2D texa;
10varying vec4 col;
11varying vec2 tex_c;
12varying vec2 tex_a;
13void main()
14{
15 gl_FragColor = texture2D(tex, tex_c.xy).aaaa * texture2D(texa, tex_a.xy).aaaa * col;
16}
17
diff --git a/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd
new file mode 100644
index 0000000000..3b5ea7430d
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd
@@ -0,0 +1,19 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec4 color;
6attribute vec2 tex_coord;
7attribute vec2 tex_coorda;
8uniform mat4 mvp;
9varying vec4 col;
10varying vec2 tex_c;
11varying vec2 tex_a;
12void main()
13{
14 gl_Position = mvp * vertex;
15 col = color;
16 tex_c = tex_coord;
17 tex_a = tex_coorda;
18}
19
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 45d35ea587..ed628e40d9 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1696,6 +1696,60 @@ eng_context_flush(void *data)
1696} 1696}
1697 1697
1698static void 1698static void
1699eng_context_clip_image_unset(void *data EINA_UNUSED, void *context)
1700{
1701 RGBA_Draw_Context *ctx = context;
1702 Evas_GL_Image *im = ctx->clip.mask;
1703
1704 if (im && im->im)
1705 {
1706#ifdef EVAS_CSERVE2
1707 if (evas_cserve2_use_get())
1708 evas_cache2_image_close(&im->im->cache_entry);
1709 else
1710#endif
1711 evas_cache_image_drop(&im->im->cache_entry);
1712 // Is the above code safe? Hmmm...
1713 //evas_unref_queue_image_put(EVAS???, &ctx->clip.ie->cache_entry);
1714 }
1715 ctx->clip.mask = NULL;
1716}
1717
1718static void
1719eng_context_clip_image_set(void *data EINA_UNUSED, void *context, void *surface, int x, int y)
1720{
1721 RGBA_Draw_Context *ctx = context;
1722 Evas_GL_Image *im = surface;
1723
1724 if (ctx->clip.mask && ctx->clip.mask != surface)
1725 eng_context_clip_image_unset(data, context);
1726
1727 ctx->clip.mask = surface;
1728 ctx->clip.mask_x = x;
1729 ctx->clip.mask_y = y;
1730
1731 if (im && im->im)
1732 {
1733#ifdef EVAS_CSERVE2
1734 if (evas_cserve2_use_get())
1735 evas_cache2_image_ref(&im->im->cache_entry);
1736 else
1737#endif
1738 evas_cache_image_ref(&im->im->cache_entry);
1739 }
1740}
1741
1742static void
1743eng_context_clip_image_get(void *data EINA_UNUSED, void *context, void **ie, int *x, int *y)
1744{
1745 RGBA_Draw_Context *ctx = context;
1746
1747 if (ie) *ie = ctx->clip.mask;
1748 if (x) *x = ctx->clip.mask_x;
1749 if (y) *y = ctx->clip.mask_y;
1750}
1751
1752static void
1699eng_context_3d_use(void *data) 1753eng_context_3d_use(void *data)
1700{ 1754{
1701 Render_Engine_GL_Generic *re = data; 1755 Render_Engine_GL_Generic *re = data;
@@ -1885,6 +1939,10 @@ module_open(Evas_Module *em)
1885 func = pfunc; 1939 func = pfunc;
1886 /* now to override methods */ 1940 /* now to override methods */
1887#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) 1941#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
1942 ORD(context_clip_image_set);
1943 ORD(context_clip_image_unset);
1944 ORD(context_clip_image_get);
1945
1888 ORD(rectangle_draw); 1946 ORD(rectangle_draw);
1889 ORD(line_draw); 1947 ORD(line_draw);
1890 ORD(polygon_point_add); 1948 ORD(polygon_point_add);