From: subhransu mohanty Date: Tue, 22 Nov 2016 12:24:38 +0000 (+0900) Subject: evas/gl: Added support for stencil buffer creation while creating gl Surface. X-Git-Tag: accepted/tizen/common/20170102.152350~172 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48eb4b06db8b4f6015eca2dd36a9db7d76614bee;p=platform%2Fupstream%2Fefl.git 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 Change-Id: Id250d434fa3798471d8d9c3e73fb5a29b7db0bb3 --- diff --git a/src/modules/evas/engines/gl_cocoa/evas_engine.c b/src/modules/evas/engines/gl_cocoa/evas_engine.c index cb1971f..f7a4ead 100644 --- a/src/modules/evas/engines/gl_cocoa/evas_engine.c +++ b/src/modules/evas/engines/gl_cocoa/evas_engine.c @@ -949,7 +949,7 @@ eng_image_map_surface_new(void *data EINA_UNUSED, int w, int h, int alpha) Render_Engine *re; re = (Render_Engine *)data; - return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha); + return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha, EINA_FALSE); } static void 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 fed1932..fe484a3 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -356,7 +356,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); @@ -677,7 +677,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 4be8946..4e444a1 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -962,7 +962,7 @@ evas_gl_common_context_new(void) gc->shared->references++; _evas_gl_common_viewport_set(gc,1); - 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); TRACE_EFL_END(); 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 e3499ed..6bedf40 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -729,7 +729,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; @@ -745,7 +745,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 c102f19..7a9fbda 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_texture.c +++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c @@ -604,7 +604,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; @@ -660,6 +660,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); @@ -968,6 +977,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)); @@ -1037,7 +1051,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; @@ -1049,7 +1063,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); @@ -1266,7 +1280,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 f52640b..feb194b 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -653,7 +653,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); @@ -1233,7 +1233,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 *