cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=16cb5f7af90ea8a47261d0ae48fbbaa4ad2a847f
commit 16cb5f7af90ea8a47261d0ae48fbbaa4ad2a847f Author: Subhransu Mohanty <sub.moha...@samsung.com> Date: Wed Nov 16 13:14:48 2016 -0800 evas/gl: Added support for stencil buffer creation while creating gl Surface. Reviewers: jpeg, cedric Reviewed By: jpeg, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4404 Signed-off-by: Cedric BAIL <ced...@osg.samsung.com> --- .../evas/engines/gl_common/evas_gl_common.h | 6 +++--- .../evas/engines/gl_common/evas_gl_context.c | 2 +- src/modules/evas/engines/gl_common/evas_gl_image.c | 4 ++-- .../evas/engines/gl_common/evas_gl_texture.c | 22 ++++++++++++++++++---- src/modules/evas/engines/gl_generic/evas_engine.c | 6 +++--- 5 files changed, 27 insertions(+), 13 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 d044c16..8b56abe 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -351,7 +351,7 @@ struct _Evas_Engine_GL_Context struct _Evas_GL_Texture_Pool { Evas_Engine_GL_Context *gc; - GLuint texture, fb; + GLuint texture, fb, stencil; GLuint intformat, format, dataformat; int w, h; int references; @@ -650,7 +650,7 @@ void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, in void evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt); Evas_GL_Texture *evas_gl_common_texture_new(Evas_Engine_GL_Context *gc, RGBA_Image *im, Eina_Bool disable_atlas); Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_GL_Image *im); -Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha); +Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil); Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count); @@ -679,7 +679,7 @@ Evas_GL_Image *evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha); void evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint); void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint); void evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc); -Evas_GL_Image *evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha); +Evas_GL_Image *evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil); void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h); 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); 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 df2cad2..fbe3b26 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -1050,7 +1050,7 @@ 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); + gc->def_surface = evas_gl_common_image_surface_new(gc, 1, 1, 1, EINA_FALSE); return gc; 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 b863bce..99f75be 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -722,7 +722,7 @@ evas_gl_common_image_free(Evas_GL_Image *im) } Evas_GL_Image * -evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha) +evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil) { Evas_GL_Image *im; @@ -738,7 +738,7 @@ evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, uns im->alpha = alpha; im->w = w; im->h = h; - im->tex = evas_gl_common_texture_render_new(gc, w, h, alpha); + im->tex = evas_gl_common_texture_render_new(gc, w, h, alpha, stencil); im->tex_only = 1; return im; } diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c index 273adc1..ff2737f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_texture.c +++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c @@ -590,7 +590,7 @@ evas_gl_common_texture_new(Evas_Engine_GL_Context *gc, RGBA_Image *im, Eina_Bool } static Evas_GL_Texture_Pool * -_pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format) +_pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format, int stencil) { Evas_GL_Texture_Pool *pt; int fnum; @@ -646,6 +646,15 @@ _pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in // note: should check fbo completeness } + if (stencil) + { + glGenRenderbuffers(1, &(pt->stencil)); + glBindRenderbuffer(GL_RENDERBUFFER, pt->stencil); + glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, pt->w, pt->h); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, pt->stencil); + } + glsym_glBindFramebuffer(GL_FRAMEBUFFER, fnum); glBindTexture(gc->state.current.tex_target, gc->state.current.cur_tex); @@ -949,6 +958,11 @@ evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt) glDeleteTextures(1, &(pt->texture)); if (pt->gc->state.current.cur_tex == pt->texture) pt->gc->state.current.cur_tex = 0; + if (pt->stencil) + { + glDeleteRenderbuffers(1, &(pt->stencil)); + pt->stencil = 0; + } if (pt->fb) { glsym_glDeleteFramebuffers(1, &(pt->fb)); @@ -1018,7 +1032,7 @@ evas_gl_common_texture_native_new(Evas_Engine_GL_Context *gc, unsigned int w, un } Evas_GL_Texture * -evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha) +evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil) { Evas_GL_Texture *tex; int lformat; @@ -1030,7 +1044,7 @@ evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, un if (!tex) return NULL; tex->pt = _pool_tex_render_new(gc, w, h, *matching_format[lformat].intformat, - *matching_format[lformat].format); + *matching_format[lformat].format, stencil); if (!tex->pt) { evas_gl_common_texture_light_free(tex); @@ -1205,7 +1219,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im) // FIXME: why a 'render' new here ??? Should already have been allocated, quite a weird path. tex->pt = _pool_tex_render_new(tex->gc, tex->w, tex->h, *matching_format[lformat].intformat, - *matching_format[lformat].format); + *matching_format[lformat].format, EINA_FALSE); } // If image was preloaded then we need a ptt if (!tex->pt) return; diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 61b4a60..899a2a7 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -677,7 +677,7 @@ _rotate_image_data(Render_Engine_GL_Generic *re, Evas_GL_Image *im1) h = im1->w; } - im2 = evas_gl_common_image_surface_new(gl_context, w, h, alpha); + im2 = evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE); evas_gl_common_context_target_surface_set(gl_context, im2); @@ -1267,7 +1267,7 @@ eng_image_map_surface_new(void *data, int w, int h, int alpha) re->window_use(re->software.ob); gl_context = re->window_gl_context_get(re->software.ob); - return evas_gl_common_image_surface_new(gl_context, w, h, alpha); + return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE); } static void * @@ -2589,7 +2589,7 @@ eng_ector_buffer_new(void *data, Evas *evas, void *pixels, WRN("Borders are not supported by Evas surfaces!"); gc = re->window_gl_context_get(re->software.ob); - im = evas_gl_common_image_surface_new(gc, iw, ih, EINA_TRUE); + im = evas_gl_common_image_surface_new(gc, iw, ih, EINA_TRUE, EINA_FALSE); buf = efl_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas, evas_ector_buffer_engine_image_set(efl_added, evas, im)); im->references--; } --