diff --git a/legacy/evas/src/modules/engines/gl_common/Makefile.am b/legacy/evas/src/modules/engines/gl_common/Makefile.am index adb3e3005b..41f78e53ca 100644 --- a/legacy/evas/src/modules/engines/gl_common/Makefile.am +++ b/legacy/evas/src/modules/engines/gl_common/Makefile.am @@ -32,6 +32,10 @@ shader/yuv_frag.h \ shader/yuv_frag_bin_s3c6410.h \ shader/yuv_vert.h \ shader/yuv_vert_bin_s3c6410.h \ +shader/tex_frag.h \ +shader/tex_frag_bin_s3c6410.h \ +shader/tex_vert.h \ +shader/tex_vert_bin_s3c6410.h \ evas_gl_rectangle.c \ evas_gl_texture.c \ evas_gl_image.c \ @@ -63,4 +67,7 @@ shader/font_frag_s3c6410.asm \ shader/font_vert.shd \ shader/yuv_frag.shd \ shader/yuv_frag_s3c6410.asm \ -shader/yuv_vert.shd +shader/yuv_vert.shd \ +shader/tex_frag.shd \ +shader/tex_frag_s3c6410.asm \ +shader/tex_vert.shd 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 7206a6a38d..e155ede702 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 @@ -91,7 +91,7 @@ struct _Evas_GL_Shared } tex; struct { - Evas_GL_Program rect, img, font, yuv; + Evas_GL_Program rect, img, font, yuv, tex; } shader; int references; int w, h; @@ -109,13 +109,16 @@ struct _Evas_GL_Context Eina_Bool active : 1; } clip; struct { + Evas_GL_Image *surface; GLuint cur_prog; GLuint cur_tex, cur_texu, cur_texv; + int render_op; Eina_Bool smooth : 1; Eina_Bool blend : 1; struct { GLuint cur_prog; GLuint cur_tex, cur_texum, cur_texv; + int render_op; Eina_Bool smooth : 1; Eina_Bool blend : 1; } current; @@ -132,12 +135,14 @@ struct _Evas_GL_Context struct { Eina_Bool size : 1; } change; + + Evas_GL_Image *def_surface; }; struct _Evas_GL_Texture_Pool { Evas_GL_Context *gc; - GLuint texture; + GLuint texture, fb; GLuint intformat, format, dataformat; int w, h; int references; @@ -162,6 +167,8 @@ struct _Evas_GL_Image Evas_GL_Texture *tex; RGBA_Image_Loadopts load_opts; int references; + // if im->im == NULL, it's a render-surface so these here are used + int w, h; struct { int space; void *data; @@ -169,6 +176,8 @@ struct _Evas_GL_Image } cs; unsigned char dirty : 1; unsigned char cached : 1; + unsigned char alpha : 1; + unsigned char tex_only : 1; }; struct _Evas_GL_Font_Texture @@ -213,6 +222,8 @@ extern Evas_GL_Program_Source shader_font_frag_src; extern Evas_GL_Program_Source shader_font_vert_src; extern Evas_GL_Program_Source shader_yuv_frag_src; extern Evas_GL_Program_Source shader_yuv_vert_src; +extern Evas_GL_Program_Source shader_tex_frag_src; +extern Evas_GL_Program_Source shader_tex_vert_src; void glerr(const char *file, const char *func, int line, const char *op); @@ -220,7 +231,8 @@ Evas_GL_Context *evas_gl_common_context_new(void); void evas_gl_common_context_free(Evas_GL_Context *gc); void evas_gl_common_context_use(Evas_GL_Context *gc); void evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h); - +void evas_gl_common_context_target_surface_set(Evas_GL_Context *gc, Evas_GL_Image *surface); + void evas_gl_common_context_rectangle_push(Evas_GL_Context *gc, int x, int y, int w, int h, int r, int g, int b, int a); @@ -246,7 +258,8 @@ void evas_gl_common_context_image_map4_push(Evas_GL_Context *gc, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, int r, int g, int b, int a, - Eina_Bool smooth); + Eina_Bool smooth, + Eina_Bool tex_only); void evas_gl_common_context_flush(Evas_GL_Context *gc); void evas_gl_common_shader_program_init(Evas_GL_Program *p, @@ -257,6 +270,7 @@ void evas_gl_common_shader_program_init(Evas_GL_Program *p, void evas_gl_common_rect_draw(Evas_GL_Context *gc, int x, int y, int w, int h); Evas_GL_Texture *evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im); +Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha); void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); void evas_gl_common_texture_free(Evas_GL_Texture *tex); Evas_GL_Texture *evas_gl_common_texture_alpha_new(Evas_GL_Context *gc, DATA8 *pixels, int w, int h, int fh); @@ -269,6 +283,7 @@ Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace); Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace); void evas_gl_common_image_free(Evas_GL_Image *im); +Evas_GL_Image *evas_gl_common_image_surface_new(Evas_GL_Context *gc, int w, int h, int alpha); void evas_gl_common_image_dirty(Evas_GL_Image *im); void evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im, RGBA_Map_Point *p, int smooth, int level); void evas_gl_common_image_draw(Evas_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); 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 34394266dd..d9c74ee103 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 @@ -40,7 +40,10 @@ matrix_ident(GLfloat *m) } static void -matrix_ortho(GLfloat *m, GLfloat l, GLfloat r, GLfloat t, GLfloat b, GLfloat near, GLfloat far) +matrix_ortho(GLfloat *m, + GLfloat l, GLfloat r, + GLfloat t, GLfloat b, + GLfloat near, GLfloat far) { m[0] = 2.0 / (r - l); m[1] = m[2] = m[3] = 0.0; @@ -63,18 +66,35 @@ static void _evas_gl_common_viewport_set(Evas_GL_Context *gc) { GLfloat proj[16]; + int w = 1, h = 1, m = 1; + if ((gc->shader.surface == gc->def_surface) || + (!gc->shader.surface)) + { + w = gc->w; + h = gc->h; + } + else + { + w = gc->shader.surface->w; + h = gc->shader.surface->h; + m = -1; + } + if ((!gc->change.size) || - ((gc->shared->w == gc->w) && (gc->shared->h == gc->h))) + ((gc->shared->w == w) && (gc->shared->h == gc->h))) return; - gc->shared->w = gc->w; - gc->shared->h = gc->h; + gc->shared->w = w; + gc->shared->h = h; gc->change.size = 0; - glViewport(0, 0, gc->w, gc->h); + glViewport(0, 0, w, h); matrix_ident(proj); - matrix_ortho(proj, 0, gc->w, 0, gc->h, -1.0, 1.0); + if (m == 1) + matrix_ortho(proj, 0, w, 0, h, -1.0, 1.0); + else + matrix_ortho(proj, 0, w, h, 0, -1.0, 1.0); glUseProgram(gc->shared->shader.rect.prog); glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.rect.prog, "mvp"), 1, @@ -88,6 +108,9 @@ _evas_gl_common_viewport_set(Evas_GL_Context *gc) glUseProgram(gc->shared->shader.yuv.prog); glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv.prog, "mvp"), 1, GL_FALSE, proj); + glUseProgram(gc->shared->shader.tex.prog); + glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.tex.prog, "mvp"), 1, + GL_FALSE, proj); } Evas_GL_Context * @@ -150,7 +173,9 @@ evas_gl_common_context_new(void) glEnable(GL_DITHER); glDisable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); -// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // no dest alpha +// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha +// glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ??? glDepthMask(GL_FALSE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -181,6 +206,10 @@ evas_gl_common_context_new(void) &(shader_yuv_vert_src), &(shader_yuv_frag_src), "yuv"); + evas_gl_common_shader_program_init(&(shared->shader.tex), + &(shader_tex_vert_src), + &(shader_tex_frag_src), + "tex"); glUseProgram(shared->shader.yuv.prog); glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "tex"), 0); glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texu"), 1); @@ -197,6 +226,8 @@ evas_gl_common_context_new(void) gc->shared->references++; _evas_gl_common_viewport_set(gc); + gc->def_surface = evas_gl_common_image_surface_new(gc, 1, 1, 1); + return gc; } @@ -223,13 +254,16 @@ evas_gl_common_context_free(Evas_GL_Context *gc) for (j = 0; j < 3; j++) { while (gc->shared->tex.atlas[i][j]) - evas_gl_common_texture_free(gc->shared->tex.atlas[i][j]); + evas_gl_common_texture_free + ((Evas_GL_Texture *)gc->shared->tex.atlas[i][j]); } } free(gc->shared); shared = NULL; } + evas_gl_common_image_free(gc->def_surface); + free(gc->array.vertex); free(gc->array.color); free(gc->array.texuv); @@ -258,6 +292,32 @@ evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h) if (_evas_gl_common_context == gc) _evas_gl_common_viewport_set(gc); } +void +evas_gl_common_context_target_surface_set(Evas_GL_Context *gc, + Evas_GL_Image *surface) +{ + if (surface == gc->shader.surface) return; + + evas_gl_common_context_flush(gc); + + gc->shader.surface = surface; +#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) + // FIXME: XXX render-to-texture for gles2 +#else + // FIXME: viewport goopies + gc->change.size = 1; + if (gc->shader.surface == gc->def_surface) + { + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + } + else + { + glBindFramebuffer(GL_FRAMEBUFFER_EXT, surface->tex->pt->fb); + } + _evas_gl_common_viewport_set(gc); +#endif +} + #define PUSH_VERTEX(x, y, z) \ gc->array.vertex[nv++] = x; \ gc->array.vertex[nv++] = y; \ @@ -303,15 +363,18 @@ evas_gl_common_context_rectangle_push(Evas_GL_Context *gc, Eina_Bool blend = 0; if (a < 255) blend = 1; + if (gc->dc->render_op == EVAS_RENDER_COPY) blend = 0; if ((gc->shader.cur_tex != 0) || (gc->shader.cur_prog != gc->shared->shader.rect.prog) || (gc->shader.blend != blend) + || (gc->shader.render_op != gc->dc->render_op) ) { shader_array_flush(gc); gc->shader.cur_tex = 0; gc->shader.cur_prog = gc->shared->shader.rect.prog; gc->shader.blend = blend; + gc->shader.render_op = gc->dc->render_op; } pnum = gc->array.num; @@ -356,6 +419,7 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc, || (gc->shader.cur_prog != gc->shared->shader.img.prog) || (gc->shader.smooth != smooth) || (gc->shader.blend != blend) + || (gc->shader.render_op != gc->dc->render_op) ) { shader_array_flush(gc); @@ -363,6 +427,7 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc, gc->shader.cur_prog = gc->shared->shader.img.prog; gc->shader.smooth = smooth; gc->shader.blend = blend; + gc->shader.render_op = gc->dc->render_op; } pnum = gc->array.num; @@ -411,6 +476,7 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc, || (gc->shader.cur_prog != gc->shared->shader.font.prog) || (gc->shader.smooth != 0) || (gc->shader.blend != 1) + || (gc->shader.render_op != gc->dc->render_op) ) { shader_array_flush(gc); @@ -418,6 +484,7 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc, gc->shader.cur_prog = gc->shared->shader.font.prog; gc->shader.smooth = 0; gc->shader.blend = 1; + gc->shader.render_op = gc->dc->render_op; } pnum = gc->array.num; @@ -480,6 +547,7 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc, || (gc->shader.cur_prog != gc->shared->shader.yuv.prog) || (gc->shader.smooth != smooth) || (gc->shader.blend != blend) + || (gc->shader.render_op != gc->dc->render_op) ) { shader_array_flush(gc); @@ -489,6 +557,7 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc, gc->shader.cur_prog = gc->shared->shader.yuv.prog; gc->shader.smooth = smooth; gc->shader.blend = blend; + gc->shader.render_op = gc->dc->render_op; } pnum = gc->array.num; @@ -551,7 +620,7 @@ evas_gl_common_context_image_map4_push(Evas_GL_Context *gc, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, int r, int g, int b, int a, - Eina_Bool smooth) + Eina_Bool smooth, Eina_Bool tex_only) { int pnum, nv, nc, nu, nt, i; const int points[6] = { 0, 1, 2, 0, 2, 3 }; @@ -566,16 +635,22 @@ evas_gl_common_context_image_map4_push(Evas_GL_Context *gc, // if (a < 255) blend = 1; if ((gc->shader.cur_tex != tex->pt->texture) - || (gc->shader.cur_prog != gc->shared->shader.img.prog) + || ((tex_only) && (gc->shader.cur_prog != gc->shared->shader.tex.prog)) + || ((!tex_only) && (gc->shader.cur_prog != gc->shared->shader.img.prog)) || (gc->shader.smooth != smooth) || (gc->shader.blend != blend) + || (gc->shader.render_op != gc->dc->render_op) ) { shader_array_flush(gc); gc->shader.cur_tex = tex->pt->texture; - gc->shader.cur_prog = gc->shared->shader.img.prog; + if (tex_only) + gc->shader.cur_prog = gc->shared->shader.tex.prog; + else + gc->shader.cur_prog =gc->shared->shader.img.prog; gc->shader.smooth = smooth; gc->shader.blend = blend; + gc->shader.render_op = gc->dc->render_op; } pnum = gc->array.num; @@ -635,6 +710,33 @@ shader_array_flush(Evas_GL_Context *gc) else glDisable(GL_BLEND); } + if (gc->shader.render_op != gc->shader.current.render_op) + { + switch (gc->shader.render_op) + { + case EVAS_RENDER_BLEND: /**< default op: d = d*(1-sa) + s */ + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + case EVAS_RENDER_COPY: /**< d = s */ + glDisable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + break; + // FIXME: fix blend funcs below! + case EVAS_RENDER_BLEND_REL: /**< d = d*(1 - sa) + s*da */ + case EVAS_RENDER_COPY_REL: /**< d = s*da */ + case EVAS_RENDER_ADD: /**< d = d + s */ + case EVAS_RENDER_ADD_REL: /**< d = d + s*da */ + case EVAS_RENDER_SUB: /**< d = d - s */ + case EVAS_RENDER_SUB_REL: /**< d = d - s*da */ + case EVAS_RENDER_TINT: /**< d = d*s + d*(1 - sa) + s*(1 - da) */ + case EVAS_RENDER_TINT_REL: /**< d = d*(1 - sa + s) */ + case EVAS_RENDER_MASK: /**< d = d*sa */ + case EVAS_RENDER_MUL: /**< d = d*s */ + default: + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + } + } if (gc->shader.smooth != gc->shader.current.smooth) { if (gc->shader.smooth) @@ -685,6 +787,7 @@ shader_array_flush(Evas_GL_Context *gc) gc->shader.current.cur_tex = gc->shader.cur_tex; gc->shader.current.blend = gc->shader.blend; gc->shader.current.smooth = gc->shader.smooth; + gc->shader.current.render_op = gc->shader.render_op; free(gc->array.vertex); free(gc->array.color); diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c index 22b202d5cb..6ec984a25c 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c @@ -30,6 +30,9 @@ evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key im->references = 1; im->cached = 1; im->cs.space = EVAS_COLORSPACE_ARGB8888; + im->alpha = im->im->cache_entry.flags.alpha; + im->w = im->im->cache_entry.w; + im->h = im->im->cache_entry.h; if (lo) im->load_opts = *lo; gc->shared->images = eina_list_prepend(gc->shared->images, im); return im; @@ -65,6 +68,9 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *da } im->gc = gc; im->cs.space = cspace; + im->alpha = im->im->cache_entry.flags.alpha; + im->w = im->im->cache_entry.w; + im->h = im->im->cache_entry.h; switch (cspace) { case EVAS_COLORSPACE_ARGB8888: @@ -104,6 +110,9 @@ evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DAT } im->gc = gc; im->cs.space = cspace; + im->alpha = im->im->cache_entry.flags.alpha; + im->w = im->im->cache_entry.w; + im->h = im->im->cache_entry.h; switch (cspace) { case EVAS_COLORSPACE_ARGB8888: @@ -139,8 +148,11 @@ evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspac return NULL; } im->gc = gc; - im->cs.space = cspace; im->im->cache_entry.flags.alpha = alpha ? 1 : 0; + im->cs.space = cspace; + im->alpha = im->im->cache_entry.flags.alpha; + im->w = im->im->cache_entry.w; + im->h = im->im->cache_entry.h; evas_cache_image_colorspace(&im->im->cache_entry, cspace); im->im = (RGBA_Image *) evas_cache_image_size_set(&im->im->cache_entry, w, h); switch (cspace) @@ -177,16 +189,38 @@ evas_gl_common_image_free(Evas_GL_Image *im) free(im); } +Evas_GL_Image * +evas_gl_common_image_surface_new(Evas_GL_Context *gc, int w, int h, int alpha) +{ + Evas_GL_Image *im; + + im = calloc(1, sizeof(Evas_GL_Image)); + if (!im) return NULL; + im->references = 1; + im->gc = gc; + im->cs.space = EVAS_COLORSPACE_ARGB8888; + im->alpha = alpha; + im->w = w; + im->h = h; + im->tex = evas_gl_common_texture_render_new(gc, w, h, alpha); + im->tex_only = 1; + return im; +} + void evas_gl_common_image_dirty(Evas_GL_Image *im) { - im->im = (RGBA_Image *) evas_cache_image_dirty(&im->im->cache_entry, 0, 0, im->im->cache_entry.w, im->im->cache_entry.h); + if (im->im) + { + im->im = (RGBA_Image *) evas_cache_image_dirty(&im->im->cache_entry, 0, 0, im->im->cache_entry.w, im->im->cache_entry.h); + } im->dirty = 1; } static void -image_update(Evas_GL_Context *gc, Evas_GL_Image *im) +_evas_gl_common_image_update(Evas_GL_Context *gc, Evas_GL_Image *im) { + if (!im->im) return; /* if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) || (im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL)) @@ -266,14 +300,16 @@ evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im, r = g = b = a = 255; } - image_update(gc, im); + _evas_gl_common_image_update(gc, im); + + glFlush(); c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h; evas_gl_common_context_image_map4_push(gc, im->tex, p, c, cx, cy, cw, ch, - r, g, b, a, smooth); + r, g, b, a, smooth, im->tex_only); } void @@ -303,8 +339,8 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy r = g = b = a = 255; } - image_update(gc, im); - + _evas_gl_common_image_update(gc, im); + if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) || (im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL)) yuv = 1; diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_rectangle.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_rectangle.c index cd3368e17d..459a6bf6ac 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_rectangle.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_rectangle.c @@ -13,7 +13,7 @@ evas_gl_common_rect_draw(Evas_GL_Context *gc, int x, int y, int w, int h) c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h; ca = (gc->dc->col.col >> 24) & 0xff; - if (ca <= 0) return; +// if (ca <= 0) return; cr = (gc->dc->col.col >> 16) & 0xff; cg = (gc->dc->col.col >> 8 ) & 0xff; cb = (gc->dc->col.col ) & 0xff; diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_shader.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_shader.c index bb76469fa4..4ef99ca775 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_shader.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_shader.c @@ -160,6 +160,46 @@ Evas_GL_Program_Source shader_yuv_vert_src = #endif }; +///////////////////////////////////////////// +#if defined (GLES_VARIETY_S3C6410) +const unsigned int tex_frag_bin[] = +{ +# include "shader/tex_frag_bin_s3c6410.h" +}; +#endif + +const char tex_frag_glsl[] = +#include "shader/tex_frag.h" + ; +Evas_GL_Program_Source shader_tex_frag_src = +{ + tex_frag_glsl, +#if defined (GLES_VARIETY_S3C6410) + tex_frag_bin, sizeof(tex_frag_bin) +#else + NULL, 0 +#endif +}; + +#if defined (GLES_VARIETY_S3C6410) +const unsigned int tex_vert_bin[] = +{ +# include "shader/tex_vert_bin_s3c6410.h" +}; +#endif +const char tex_vert_glsl[] = +#include "shader/tex_vert.h" + ; +Evas_GL_Program_Source shader_tex_vert_src = +{ + tex_vert_glsl, +#if defined (GLES_VARIETY_S3C6410) + tex_vert_bin, sizeof(tex_vert_bin) +#else + NULL, 0 +#endif +}; + diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c index 62a78ff4e4..b1a09ab952 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c @@ -252,6 +252,67 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im) return tex; } +static Evas_GL_Texture_Pool * +_pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int format) +{ + Evas_GL_Texture_Pool *pt; + + pt = calloc(1, sizeof(Evas_GL_Texture_Pool)); + if (!pt) return NULL; + h = _tex_round_slot(gc, h) << 4; + _tex_adjust(gc, &w, &h); + pt->gc = gc; + pt->w = w; + pt->h = h; + pt->intformat = intformat; + pt->format = format; + pt->dataformat = GL_UNSIGNED_BYTE; + pt->references = 0; +#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) + // FIXME: XXX render-to-texture for gles2 +#else + glGenTextures(1, &(pt->texture)); + glBindTexture(GL_TEXTURE_2D, pt->texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + _tex_2d(pt->intformat, w, h, pt->format, pt->dataformat); + glGenFramebuffers(1, &(pt->fb)); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, pt->fb); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pt->texture, 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); +#endif + return pt; +} + +Evas_GL_Texture * +evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha) +{ + Evas_GL_Texture *tex; + Eina_List *l_after = NULL; + int u = 0, v = 0; + + tex = calloc(1, sizeof(Evas_GL_Texture)); + if (!tex) return NULL; + + tex->gc = gc; + tex->references = 1; + tex->pt = _pool_tex_render_new(gc, w, h, rgba_ifmt, rgba_fmt); + if (!tex->pt) + { + free(tex); + return NULL; + } + tex->x = 0; + tex->y = 0; + tex->w = w; + tex->h = h; + tex->pt->references++; + return tex; +} + void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im) { diff --git a/legacy/evas/src/modules/engines/gl_common/shader/compile-s3c6410.sh b/legacy/evas/src/modules/engines/gl_common/shader/compile-s3c6410.sh index acca29e59c..0de88d4cea 100755 --- a/legacy/evas/src/modules/engines/gl_common/shader/compile-s3c6410.sh +++ b/legacy/evas/src/modules/engines/gl_common/shader/compile-s3c6410.sh @@ -33,3 +33,4 @@ compile rect compile img compile font compile yuv +compile tex diff --git a/legacy/evas/src/modules/engines/gl_common/shader/compile-sgx.sh b/legacy/evas/src/modules/engines/gl_common/shader/compile-sgx.sh index 4b23af7753..b14d69cfa6 100755 --- a/legacy/evas/src/modules/engines/gl_common/shader/compile-sgx.sh +++ b/legacy/evas/src/modules/engines/gl_common/shader/compile-sgx.sh @@ -11,3 +11,4 @@ compile rect compile img compile font compile yuv +compile tex diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.h b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.h new file mode 100644 index 0000000000..29449f244a --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.h @@ -0,0 +1,10 @@ +"#ifdef GL_ES\n" +"precision mediump float;\n" +"#endif\n" +"uniform sampler2D tex;\n" +"varying vec4 col;\n" +"varying vec2 tex_c;\n" +"void main()\n" +"{\n" +" gl_FragColor = texture2D(tex, tex_c.xy) * col;\n" +"}\n" diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.shd b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.shd new file mode 100644 index 0000000000..eb65760016 --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag.shd @@ -0,0 +1,10 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform sampler2D tex; +varying vec4 col; +varying vec2 tex_c; +void main() +{ + gl_FragColor = texture2D(tex, tex_c.xy) * col; +} diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_bin_s3c6410.h b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_bin_s3c6410.h new file mode 100644 index 0000000000..24af537dbb --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_bin_s3c6410.h @@ -0,0 +1,9 @@ +0x20205350, 0xffff0008, 0x00000048, 0x01020000, 0x00000003, 0x00000000, +0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000001, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000e, 0x00000000, +0x00000000, 0x0000e407, 0x307820e4, 0x00000000, 0x01000000, 0x0100e400, +0x237a10e4, 0x00000000, 0x00000000, 0x00000000, 0x1e000000, 0x00000000, +0x00000004, 0x00000003, 0x00000009, 0x00000000, 0x00000004, 0x00000008, +0x00000005, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000003, +0x0000000f, 0x00030005, 0x00000000, 0x00786574, 0x006c6f63, 0x5f786574, +0x00000063, \ No newline at end of file diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_s3c6410.asm b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_s3c6410.asm new file mode 100644 index 0000000000..14bbfa1cff --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_frag_s3c6410.asm @@ -0,0 +1,26 @@ + +#------------------------------------------------- +# ORION - OpenGL ES 2.0 Shading Language Compiler +# SAMSUNG INDIA SOFTWARE OPERATIONS PVT. LTD. +# Compiler Version : v04.00.09 +# Release Date : 19.01.2009 +# FIMG VERSION : FIMGv1.5 +# Optimizer Options : -O --nolodcalc +#------------------------------------------------- + +# hand optimised - removed useless ops + +ps_3_0 + +fimg_version 0x01020000 + +dcl_s2_tex s0 +dcl_f4_col v1.x +dcl_f2_tex_c v0.x + +label start +label main_ +texld r0.xyzw, v0.xyzw, s0 # tex=s0 +mul_sat oColor.xyzw, r0.xyzw, v1.xyzw # gl_FragColor=oColor.xyzw, col=v1.xyzw +label main_end +ret diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.h b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.h new file mode 100644 index 0000000000..ef035c8980 --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.h @@ -0,0 +1,15 @@ +"#ifdef GL_ES\n" +"precision mediump float;\n" +"#endif\n" +"attribute vec4 vertex;\n" +"attribute vec4 color;\n" +"attribute vec2 tex_coord;\n" +"uniform mat4 mvp;\n" +"varying vec4 col;\n" +"varying vec2 tex_c;\n" +"void main()\n" +"{\n" +" gl_Position = mvp * vertex;\n" +" col = color;\n" +" tex_c = tex_coord;\n" +"}\n" diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.shd b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.shd new file mode 100644 index 0000000000..cf98501839 --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert.shd @@ -0,0 +1,15 @@ +#ifdef GL_ES +precision mediump float; +#endif +attribute vec4 vertex; +attribute vec4 color; +attribute vec2 tex_coord; +uniform mat4 mvp; +varying vec4 col; +varying vec2 tex_c; +void main() +{ + gl_Position = mvp * vertex; + col = color; + tex_c = tex_coord; +} diff --git a/legacy/evas/src/modules/engines/gl_common/shader/tex_vert_bin_s3c6410.h b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert_bin_s3c6410.h new file mode 100644 index 0000000000..1402448052 --- /dev/null +++ b/legacy/evas/src/modules/engines/gl_common/shader/tex_vert_bin_s3c6410.h @@ -0,0 +1,20 @@ +0x20205356, 0xffff0008, 0x00000048, 0x01020000, 0x00000007, 0x00000006, +0x00000000, 0x00000000, 0x00000003, 0x00000003, 0x00000001, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000031, 0x00000000, +0x00000000, 0x02020000, 0x237820e4, 0x00000000, 0x00e40100, 0x02035500, +0x2ef820e4, 0x00000000, 0x00e40100, 0x0204aa00, 0x2ef820e4, 0x00000000, +0x00e40100, 0x0205ff00, 0x2ef800e4, 0x00000000, 0x00000000, 0x00010000, +0x20f801e4, 0x00000000, 0x00000000, 0x00020000, 0x20980254, 0x00000000, +0x00000000, 0x00000000, 0x1e000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x00000006, +0x00000009, 0x00000000, 0x00000000, 0x00000013, 0x00000005, 0x00000009, +0x00000000, 0x00000004, 0x00000019, 0x00000009, 0x00000003, 0x00000000, +0x00000008, 0x00000000, 0x0000000b, 0x00000009, 0x00010004, 0x00000000, +0x00000027, 0x00000003, 0x00000009, 0x00010004, 0x00000004, 0x0000002b, +0x00000005, 0x00000003, 0x00010004, 0x00000008, 0x00000023, 0x00000003, +0x0000000e, 0x00020001, 0x00000008, 0x505f6c67, 0x7469736f, 0x006e6f69, +0x74726576, 0x63007865, 0x726f6c6f, 0x78657400, 0x6f6f635f, 0x6d006472, +0x63007076, 0x74006c6f, 0x635f7865, 0x00000000, \ No newline at end of file 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 c3c6c49d3f..29146973f0 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -250,7 +250,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i // glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // glClear(GL_COLOR_BUFFER_BIT); //x// printf("frame -> new\n"); - return re; + return re->win->gl_context->def_surface; } static void @@ -333,23 +333,25 @@ eng_context_cutout_clear(void *data, void *context) } static void -eng_rectangle_draw(void *data, void *context, void *surface __UNUSED__, int x, int y, int w, int h) +eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h) { Render_Engine *re; re = (Render_Engine *)data; eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); re->win->gl_context->dc = context; evas_gl_common_rect_draw(re->win->gl_context, x, y, w, h); } static void -eng_line_draw(void *data, void *context, void *surface __UNUSED__, int x1, int y1, int x2, int y2) +eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2) { Render_Engine *re; re = (Render_Engine *)data; eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); re->win->gl_context->dc = context; //-// evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2); } @@ -375,12 +377,13 @@ eng_polygon_points_clear(void *data, void *context __UNUSED__, void *polygon) } static void -eng_polygon_draw(void *data, void *context, void *surface __UNUSED__, void *polygon) +eng_polygon_draw(void *data, void *context, void *surface, void *polygon) { Render_Engine *re; re = (Render_Engine *)data; eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); re->win->gl_context->dc = context; //--// evas_gl_common_poly_draw(re->win->gl_context, polygon); } @@ -1006,13 +1009,14 @@ eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *ta } static void -eng_image_draw(void *data, void *context, void *surface __UNUSED__, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth) +eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth) { Render_Engine *re; re = (Render_Engine *)data; if (!image) return; eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); re->win->gl_context->dc = context; evas_gl_common_image_draw(re->win->gl_context, image, src_x, src_y, src_w, src_h, @@ -1031,20 +1035,25 @@ eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *i Render_Engine *re; re = (Render_Engine *)data; + eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); + re->win->gl_context->dc = context; evas_gl_common_image_map4_draw(re->win->gl_context, image, p, smooth, level); } static void * eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha) { - // XXX - return NULL; + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha); } static void eng_image_map_surface_free(void *data __UNUSED__, void *surface) { - // XXX + evas_gl_common_image_free(surface); } static int @@ -1054,12 +1063,14 @@ eng_image_scale_hint_get(void *data __UNUSED__, void *image) } static void -eng_font_draw(void *data, void *context, void *surface __UNUSED__, void *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const char *text) +eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const char *text) { Render_Engine *re; re = (Render_Engine *)data; eng_window_use(re->win); + evas_gl_common_context_target_surface_set(re->win->gl_context, surface); + re->win->gl_context->dc = context; { // FIXME: put im into context so we can free it static RGBA_Image *im = NULL;