From 326ff87216967cb5aa544adc88cebdc5564cc290 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 25 Aug 2017 10:49:59 -0700 Subject: [PATCH] evas: refactor gl_generic use of window_use with context_get. --- src/modules/evas/engines/gl_generic/evas_engine.c | 89 ++++++++++------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 66c6322..0de805d 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -49,6 +49,15 @@ int _evas_engine_GL_log_dom = -1; # endif #endif +static Evas_Engine_GL_Context * +gl_generic_context_get(Render_Output_GL_Generic *output) +{ + if (!output->software.ob) return NULL; + output->window_use(output->software.ob); + return output->window_gl_context_get(output->software.ob); + +} + static int eng_gl_image_direct_get(void *data, void *image); static int eng_gl_surface_destroy(void *data, void *surface); static Eina_Bool eng_gl_surface_lock(void *data, void *surface); @@ -83,7 +92,6 @@ _context_store(void *data, void *surface, void *context) if (rsc->id == evgl_engine->main_tid) { _need_context_restore = EINA_FALSE; - rsc->stored.data = data; rsc->stored.surface = surface; rsc->stored.context = context; @@ -113,8 +121,7 @@ eng_rectangle_draw(void *engine EINA_UNUSED, void *data, void *context, void *su Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = data; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; evas_gl_common_rect_draw(gl_context, x, y, w, h); @@ -126,8 +133,7 @@ eng_line_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = data; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; evas_gl_common_line_draw(gl_context, p1x, p1y, p2x, p2y); @@ -151,8 +157,7 @@ eng_polygon_draw(void *engine EINA_UNUSED, void *data, void *context, void *surf Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = data; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; evas_gl_common_poly_draw(gl_context, polygon, x, y); @@ -388,7 +393,7 @@ eng_image_native_set(void *engine, void *image, void *native) unsigned int tex = 0; unsigned int fbo = 0; - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if (!im) { @@ -506,8 +511,7 @@ eng_image_load(void *engine, const char *file, const char *key, int *error, Evas Render_Output_GL_Generic *re = engine; *error = EVAS_LOAD_ERROR_NONE; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_load(gl_context, file, key, lo, error); } @@ -518,8 +522,7 @@ eng_image_mmap(void *engine, Eina_File *f, const char *key, int *error, Evas_Ima Render_Output_GL_Generic *re = engine; *error = EVAS_LOAD_ERROR_NONE; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_mmap(gl_context, f, key, lo, error); } @@ -529,8 +532,7 @@ eng_image_new_from_data(void *engine, int w, int h, DATA32 *image_data, int alph Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_new_from_data(gl_context, w, h, image_data, alpha, cspace); } @@ -540,8 +542,7 @@ eng_image_new_from_copied_data(void *engine, int w, int h, DATA32 *image_data, i Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace); } @@ -606,8 +607,7 @@ eng_image_size_set(void *engine, void *image, int w, int h) evas_gl_common_image_native_enable(im); return image; } - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if ((im->tex) && (im->tex->pt->dyn.img)) { evas_gl_common_texture_free(im->tex, EINA_TRUE); @@ -665,8 +665,7 @@ _rotate_image_data(Render_Output_GL_Generic *re, Evas_GL_Image *im1) RGBA_Draw_Context *dc; int w, h; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); w = im1->w; h = im1->h; @@ -1101,8 +1100,7 @@ eng_image_data_preload_request(void *engine EINA_UNUSED, void *image, const Eo * { Evas_Engine_GL_Context *gl_context; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); gim->tex = evas_gl_common_texture_new(gl_context, gim->im, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN(gim->tex); gim->tex->im = gim; @@ -1144,8 +1142,7 @@ eng_image_draw(void *engine EINA_UNUSED, void *data, void *context, void *surfac if (!im) return EINA_FALSE; n = im->native.data; - gl_context = re->window_gl_context_get(re->software.ob); - re->window_use(re->software.ob); + gl_context = gl_generic_context_get(re); if (eng_gl_image_direct_get(data, image)) { @@ -1233,8 +1230,7 @@ eng_image_map_draw(void *engine, void *data, void *context, void *surface, void Render_Output_GL_Generic *re = data; if (!image) return EINA_FALSE; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; @@ -1286,8 +1282,7 @@ eng_image_map_surface_new(void *engine, int w, int h, int alpha) Render_Output_GL_Generic *re = engine; Evas_Engine_GL_Context *gl_context; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE); } @@ -1323,8 +1318,7 @@ eng_image_cache_flush(void *engine) Render_Output_GL_Generic *re = engine; int tmp_size; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if (!gl_context) return; tmp_size = evas_common_image_get_cache(); @@ -1340,8 +1334,7 @@ eng_image_cache_set(void *engine, int bytes) Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_common_image_set_cache(bytes); evas_common_rgba_image_scalecache_size_set(bytes); @@ -1442,8 +1435,7 @@ eng_font_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = data; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; @@ -1551,11 +1543,10 @@ eng_gl_make_current(void *engine, void *surface, void *context) { Evas_Engine_GL_Context *gl_context; - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if ((gl_context->havestuff) || (gl_context->master_clip.used)) { - re->window_use(re->software.ob); evas_gl_common_context_flush(gl_context); if (gl_context->master_clip.used) evas_gl_common_context_done(gl_context); @@ -1637,7 +1628,7 @@ eng_gl_api_get(void *engine, int version) Evas_Engine_GL_Context *gl_context; EVGLINIT(re, NULL); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if (!gl_context) { ERR("Invalid context!"); @@ -1685,7 +1676,7 @@ eng_gl_surface_direct_renderable_get(void *engine, Evas_Native_Surface *ns, Eina if ((re->software.outbuf_get_rot(re->software.ob) != 0) && (!client_side_rotation)) return EINA_FALSE; - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if (gl_context->def_surface != sfc) return EINA_FALSE; @@ -2047,7 +2038,7 @@ eng_image_max_size_get(void *engine, int *maxw, int *maxh) Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if (maxw) *maxw = gl_context->shared->info.max_texture_size; if (maxh) *maxh = gl_context->shared->info.max_texture_size; } @@ -2147,12 +2138,11 @@ eng_context_flush(void *engine) Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); if ((gl_context->havestuff) || (gl_context->master_clip.used)) { - re->window_use(re->software.ob); evas_gl_common_context_flush(gl_context); if (gl_context->master_clip.used) evas_gl_common_context_done(gl_context); @@ -2314,8 +2304,7 @@ eng_drawable_scene_render(void *engine, void *data EINA_UNUSED, void *drawable, Render_Output_GL_Generic *re = engine; E3D_Renderer *renderer = NULL; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_flush(gl_context); eng_context_3d_use(engine); @@ -2349,8 +2338,7 @@ eng_drawable_scene_render_to_texture(void *engine, void *drawable, void *scene_d Render_Output_GL_Generic *re = engine; E3D_Renderer *renderer = NULL; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_flush(gl_context); eng_context_3d_use(engine); @@ -2417,8 +2405,7 @@ eng_texture_image_set(void *engine, void *texture, void *image) Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image); } @@ -2598,8 +2585,7 @@ eng_ector_begin(void *engine, void *context EINA_UNUSED, Ector_Surface *ector, Evas_GL_Ector *buffer = engine_data; int w, h; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); evas_gl_common_context_target_surface_set(gl_context, surface); gl_context->dc = context; @@ -2654,7 +2640,7 @@ eng_ector_end(void *engine, void *context EINA_UNUSED, Ector_Surface *ector, if (use_cairo || !use_gl) { - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); w = gl_context->w; h = gl_context->h; mul_use = gl_context->dc->mul.use; @@ -3025,8 +3011,7 @@ eng_image_surface_noscale_new(void *engine, int w, int h, int alpha) Evas_Engine_GL_Context *gl_context; Render_Output_GL_Generic *re = engine; - re->window_use(re->software.ob); - gl_context = re->window_gl_context_get(re->software.ob); + gl_context = gl_generic_context_get(re); return evas_gl_common_image_surface_noscale_new(gl_context, w, h, alpha); } -- 2.7.4