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 <cedric@osg.samsung.com>
This commit is contained in:
Subhransu Mohanty 2016-11-16 13:14:48 -08:00 committed by Cedric BAIL
parent 168a127c8c
commit 16cb5f7af9
5 changed files with 27 additions and 13 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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--;
}