summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:54:55 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:54:55 -0700
commit7453980ccf2acf755c37846285af01e1301b1f44 (patch)
treece3b86925321a9aa28d93dd1f6b1929d2a7e0914
parentcce4dcc58e8b9bdda8caa15ed824b0dbc23a3fb1 (diff)
evas gl: fix glview by avoiding make current
gl_generic_context_find() returns the gl shared context struct but this is not just a read-only operation. It in turn calls window_use which may call make_current. This can invalidate the work of evas gl when the API tried to switch to a specific context. This fixes evas gl with multiple outputs. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h8
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c60
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c2
3 files changed, 34 insertions, 36 deletions
diff --git a/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h b/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h
index 7fdea3021b..a7effafde0 100644
--- a/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h
+++ b/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h
@@ -104,10 +104,10 @@ evas_render_engine_gl_generic_init(Render_Engine_Software_Generic *engine,
104} 104}
105 105
106static inline Evas_Engine_GL_Context * 106static inline Evas_Engine_GL_Context *
107gl_generic_context_get(Render_Output_GL_Generic *output) 107gl_generic_context_get(Render_Output_GL_Generic *output, Eina_Bool use)
108{ 108{
109 if (!output->software.ob) return NULL; 109 if (!output->software.ob) return NULL;
110 output->window_use(output->software.ob); 110 if (use) output->window_use(output->software.ob);
111 return output->window_gl_context_get(output->software.ob); 111 return output->window_gl_context_get(output->software.ob);
112 112
113} 113}
@@ -121,7 +121,7 @@ gl_generic_window_use(void *engine)
121} 121}
122 122
123static inline Evas_Engine_GL_Context * 123static inline Evas_Engine_GL_Context *
124gl_generic_context_find(Render_Engine_GL_Generic *engine) 124gl_generic_context_find(Render_Engine_GL_Generic *engine, Eina_Bool use)
125{ 125{
126 Render_Output_GL_Generic *output; 126 Render_Output_GL_Generic *output;
127 Evas_Engine_GL_Context *r = NULL; 127 Evas_Engine_GL_Context *r = NULL;
@@ -129,7 +129,7 @@ gl_generic_context_find(Render_Engine_GL_Generic *engine)
129 129
130 EINA_LIST_FOREACH(engine->software.outputs, l, output) 130 EINA_LIST_FOREACH(engine->software.outputs, l, output)
131 { 131 {
132 r = gl_generic_context_get(output); 132 r = gl_generic_context_get(output, use);
133 if (r) return r; 133 if (r) return r;
134 } 134 }
135 135
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 60f65ef264..6872fe4007 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -165,7 +165,7 @@ eng_rectangle_draw(void *engine EINA_UNUSED, void *data, void *context, void *su
165 Evas_Engine_GL_Context *gl_context; 165 Evas_Engine_GL_Context *gl_context;
166 Render_Output_GL_Generic *re = data; 166 Render_Output_GL_Generic *re = data;
167 167
168 gl_context = gl_generic_context_get(re); 168 gl_context = gl_generic_context_get(re, 1);
169 evas_gl_common_context_target_surface_set(gl_context, surface); 169 evas_gl_common_context_target_surface_set(gl_context, surface);
170 gl_context->dc = context; 170 gl_context->dc = context;
171 evas_gl_common_rect_draw(gl_context, x, y, w, h); 171 evas_gl_common_rect_draw(gl_context, x, y, w, h);
@@ -177,7 +177,7 @@ eng_line_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface
177 Evas_Engine_GL_Context *gl_context; 177 Evas_Engine_GL_Context *gl_context;
178 Render_Output_GL_Generic *re = data; 178 Render_Output_GL_Generic *re = data;
179 179
180 gl_context = gl_generic_context_get(re); 180 gl_context = gl_generic_context_get(re, 1);
181 evas_gl_common_context_target_surface_set(gl_context, surface); 181 evas_gl_common_context_target_surface_set(gl_context, surface);
182 gl_context->dc = context; 182 gl_context->dc = context;
183 evas_gl_common_line_draw(gl_context, p1x, p1y, p2x, p2y); 183 evas_gl_common_line_draw(gl_context, p1x, p1y, p2x, p2y);
@@ -201,7 +201,7 @@ eng_polygon_draw(void *engine EINA_UNUSED, void *data, void *context, void *surf
201 Evas_Engine_GL_Context *gl_context; 201 Evas_Engine_GL_Context *gl_context;
202 Render_Output_GL_Generic *re = data; 202 Render_Output_GL_Generic *re = data;
203 203
204 gl_context = gl_generic_context_get(re); 204 gl_context = gl_generic_context_get(re, 1);
205 evas_gl_common_context_target_surface_set(gl_context, surface); 205 evas_gl_common_context_target_surface_set(gl_context, surface);
206 gl_context->dc = context; 206 gl_context->dc = context;
207 evas_gl_common_poly_draw(gl_context, polygon, x, y); 207 evas_gl_common_poly_draw(gl_context, polygon, x, y);
@@ -432,7 +432,7 @@ eng_image_native_set(void *engine, void *image, void *native)
432 unsigned int tex = 0; 432 unsigned int tex = 0;
433 unsigned int fbo = 0; 433 unsigned int fbo = 0;
434 434
435 gl_context = gl_generic_context_find(engine); 435 gl_context = gl_generic_context_find(engine, 1);
436 436
437 if (!im) 437 if (!im)
438 { 438 {
@@ -549,7 +549,7 @@ eng_image_load(void *engine, const char *file, const char *key, int *error, Evas
549 Evas_Engine_GL_Context *gl_context; 549 Evas_Engine_GL_Context *gl_context;
550 550
551 *error = EVAS_LOAD_ERROR_NONE; 551 *error = EVAS_LOAD_ERROR_NONE;
552 gl_context = gl_generic_context_find(engine); 552 gl_context = gl_generic_context_find(engine, 1);
553 return evas_gl_common_image_load(gl_context, file, key, lo, error); 553 return evas_gl_common_image_load(gl_context, file, key, lo, error);
554} 554}
555 555
@@ -559,7 +559,7 @@ eng_image_mmap(void *engine, Eina_File *f, const char *key, int *error, Evas_Ima
559 Evas_Engine_GL_Context *gl_context; 559 Evas_Engine_GL_Context *gl_context;
560 560
561 *error = EVAS_LOAD_ERROR_NONE; 561 *error = EVAS_LOAD_ERROR_NONE;
562 gl_context = gl_generic_context_find(engine); 562 gl_context = gl_generic_context_find(engine, 1);
563 return evas_gl_common_image_mmap(gl_context, f, key, lo, error); 563 return evas_gl_common_image_mmap(gl_context, f, key, lo, error);
564} 564}
565 565
@@ -568,7 +568,7 @@ eng_image_new_from_data(void *engine, int w, int h, DATA32 *image_data, int alph
568{ 568{
569 Evas_Engine_GL_Context *gl_context; 569 Evas_Engine_GL_Context *gl_context;
570 570
571 gl_context = gl_generic_context_find(engine); 571 gl_context = gl_generic_context_find(engine, 1);
572 return evas_gl_common_image_new_from_data(gl_context, w, h, image_data, alpha, cspace); 572 return evas_gl_common_image_new_from_data(gl_context, w, h, image_data, alpha, cspace);
573} 573}
574 574
@@ -577,7 +577,7 @@ eng_image_new_from_copied_data(void *engine, int w, int h, DATA32 *image_data, i
577{ 577{
578 Evas_Engine_GL_Context *gl_context; 578 Evas_Engine_GL_Context *gl_context;
579 579
580 gl_context = gl_generic_context_find(engine); 580 gl_context = gl_generic_context_find(engine, 1);
581 return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace); 581 return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace);
582} 582}
583 583
@@ -639,7 +639,7 @@ eng_image_size_set(void *engine, void *image, int w, int h)
639 evas_gl_common_image_native_enable(im); 639 evas_gl_common_image_native_enable(im);
640 return image; 640 return image;
641 } 641 }
642 gl_context = gl_generic_context_find(engine); 642 gl_context = gl_generic_context_find(engine, 1);
643 if ((im->tex) && (im->tex->pt->dyn.img)) 643 if ((im->tex) && (im->tex->pt->dyn.img))
644 { 644 {
645 evas_gl_common_texture_free(im->tex, EINA_TRUE); 645 evas_gl_common_texture_free(im->tex, EINA_TRUE);
@@ -696,7 +696,7 @@ _rotate_image_data(Render_Engine_GL_Generic *re, Evas_GL_Image *im1)
696 RGBA_Draw_Context *dc; 696 RGBA_Draw_Context *dc;
697 int w, h; 697 int w, h;
698 698
699 gl_context = gl_generic_context_find(re); 699 gl_context = gl_generic_context_find(re, 1);
700 700
701 w = im1->w; 701 w = im1->w;
702 h = im1->h; 702 h = im1->h;
@@ -1157,7 +1157,7 @@ eng_image_draw(void *eng, void *data, void *context, void *surface, void *image,
1157 1157
1158 n = im->native.data; 1158 n = im->native.data;
1159 1159
1160 gl_context = gl_generic_context_get(re); 1160 gl_context = gl_generic_context_get(re, 1);
1161 1161
1162 if (eng_gl_image_direct_get(re, image)) 1162 if (eng_gl_image_direct_get(re, image))
1163 { 1163 {
@@ -1244,7 +1244,7 @@ eng_image_map_draw(void *engine, void *data, void *context, void *surface, void
1244 Evas_GL_Image *gim = image; 1244 Evas_GL_Image *gim = image;
1245 1245
1246 if (!image) return EINA_FALSE; 1246 if (!image) return EINA_FALSE;
1247 gl_context = gl_generic_context_get(data); 1247 gl_context = gl_generic_context_get(data, 1);
1248 evas_gl_common_context_target_surface_set(gl_context, surface); 1248 evas_gl_common_context_target_surface_set(gl_context, surface);
1249 gl_context->dc = context; 1249 gl_context->dc = context;
1250 1250
@@ -1295,7 +1295,7 @@ eng_image_map_surface_new(void *engine, int w, int h, int alpha)
1295{ 1295{
1296 Evas_Engine_GL_Context *gl_context; 1296 Evas_Engine_GL_Context *gl_context;
1297 1297
1298 gl_context = gl_generic_context_find(engine); 1298 gl_context = gl_generic_context_find(engine, 1);
1299 return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE); 1299 return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE);
1300} 1300}
1301 1301
@@ -1320,7 +1320,7 @@ eng_image_cache_flush(void *engine)
1320 Evas_Engine_GL_Context *gl_context; 1320 Evas_Engine_GL_Context *gl_context;
1321 int tmp_size; 1321 int tmp_size;
1322 1322
1323 gl_context = gl_generic_context_find(engine); 1323 gl_context = gl_generic_context_find(engine, 1);
1324 if (!gl_context) return; 1324 if (!gl_context) return;
1325 1325
1326 tmp_size = evas_common_image_get_cache(); 1326 tmp_size = evas_common_image_get_cache();
@@ -1335,7 +1335,7 @@ eng_image_cache_set(void *engine, int bytes)
1335{ 1335{
1336 Evas_Engine_GL_Context *gl_context; 1336 Evas_Engine_GL_Context *gl_context;
1337 1337
1338 gl_context = gl_generic_context_find(engine); 1338 gl_context = gl_generic_context_find(engine, 1);
1339 1339
1340 evas_common_image_set_cache(bytes); 1340 evas_common_image_set_cache(bytes);
1341 evas_common_rgba_image_scalecache_size_set(bytes); 1341 evas_common_rgba_image_scalecache_size_set(bytes);
@@ -1430,8 +1430,7 @@ eng_font_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface
1430{ 1430{
1431 Evas_Engine_GL_Context *gl_context; 1431 Evas_Engine_GL_Context *gl_context;
1432 1432
1433 gl_context = gl_generic_context_get(data); 1433 gl_context = gl_generic_context_get(data, 1);
1434
1435 evas_gl_common_context_target_surface_set(gl_context, surface); 1434 evas_gl_common_context_target_surface_set(gl_context, surface);
1436 gl_context->dc = context; 1435 gl_context->dc = context;
1437 { 1436 {
@@ -1576,16 +1575,15 @@ eng_gl_make_current(void *eng, void *surface, void *context)
1576 Render_Output_GL_Generic *output; 1575 Render_Output_GL_Generic *output;
1577 int ret = 0; 1576 int ret = 0;
1578 1577
1579 // TODO: Add check for main thread before flush 1578 if (sfc && ctx && eina_main_loop_is())
1580
1581 if ((sfc) && (ctx))
1582 { 1579 {
1583 Evas_Engine_GL_Context *gl_context; 1580 Evas_Engine_GL_Context *gl_context;
1584 1581
1585 gl_context = gl_generic_context_find(engine); 1582 gl_context = gl_generic_context_find(engine, 0);
1586 if ((gl_context->havestuff) || 1583 if ((gl_context->havestuff) ||
1587 (gl_context->master_clip.used)) 1584 (gl_context->master_clip.used))
1588 { 1585 {
1586 gl_context = gl_generic_context_find(engine, 1);
1589 evas_gl_common_context_flush(gl_context); 1587 evas_gl_common_context_flush(gl_context);
1590 if (gl_context->master_clip.used) 1588 if (gl_context->master_clip.used)
1591 evas_gl_common_context_done(gl_context); 1589 evas_gl_common_context_done(gl_context);
@@ -1677,7 +1675,7 @@ eng_gl_api_get(void *engine, int version)
1677 void *ret; 1675 void *ret;
1678 EVGLINIT(NULL); 1676 EVGLINIT(NULL);
1679 1677
1680 gl_context = gl_generic_context_find(engine); 1678 gl_context = gl_generic_context_find(engine, 0);
1681 if (!gl_context) 1679 if (!gl_context)
1682 { 1680 {
1683 ERR("Invalid context!"); 1681 ERR("Invalid context!");
@@ -1729,7 +1727,7 @@ eng_gl_surface_direct_renderable_get(void *eng, void *output, Evas_Native_Surfac
1729 if ((re->software.outbuf_get_rot(re->software.ob) != 0) && (!client_side_rotation)) 1727 if ((re->software.outbuf_get_rot(re->software.ob) != 0) && (!client_side_rotation))
1730 return EINA_FALSE; 1728 return EINA_FALSE;
1731 1729
1732 gl_context = gl_generic_context_get(re); 1730 gl_context = gl_generic_context_get(re, 0);
1733 if (gl_context->def_surface != sfc) 1731 if (gl_context->def_surface != sfc)
1734 return EINA_FALSE; 1732 return EINA_FALSE;
1735 1733
@@ -2099,7 +2097,7 @@ eng_image_max_size_get(void *engine, int *maxw, int *maxh)
2099{ 2097{
2100 Evas_Engine_GL_Context *gl_context; 2098 Evas_Engine_GL_Context *gl_context;
2101 2099
2102 gl_context = gl_generic_context_find(engine); 2100 gl_context = gl_generic_context_find(engine, 0);
2103 if (maxw) *maxw = gl_context->shared->info.max_texture_size; 2101 if (maxw) *maxw = gl_context->shared->info.max_texture_size;
2104 if (maxh) *maxh = gl_context->shared->info.max_texture_size; 2102 if (maxh) *maxh = gl_context->shared->info.max_texture_size;
2105} 2103}
@@ -2198,7 +2196,7 @@ eng_context_flush(void *engine)
2198{ 2196{
2199 Evas_Engine_GL_Context *gl_context; 2197 Evas_Engine_GL_Context *gl_context;
2200 2198
2201 gl_context = gl_generic_context_find(engine); 2199 gl_context = gl_generic_context_find(engine, 1);
2202 2200
2203 if ((gl_context->havestuff) || 2201 if ((gl_context->havestuff) ||
2204 (gl_context->master_clip.used)) 2202 (gl_context->master_clip.used))
@@ -2362,7 +2360,7 @@ eng_drawable_scene_render(void *engine EINA_UNUSED, void *data, void *drawable,
2362 Evas_Engine_GL_Context *gl_context; 2360 Evas_Engine_GL_Context *gl_context;
2363 E3D_Renderer *renderer = NULL; 2361 E3D_Renderer *renderer = NULL;
2364 2362
2365 gl_context = gl_generic_context_get(data); 2363 gl_context = gl_generic_context_get(data, 1);
2366 evas_gl_common_context_flush(gl_context); 2364 evas_gl_common_context_flush(gl_context);
2367 2365
2368 eng_context_3d_use(data); 2366 eng_context_3d_use(data);
@@ -2395,7 +2393,7 @@ eng_drawable_scene_render_to_texture(void *engine, void *drawable, void *scene_d
2395 Evas_Engine_GL_Context *gl_context; 2393 Evas_Engine_GL_Context *gl_context;
2396 E3D_Renderer *renderer = NULL; 2394 E3D_Renderer *renderer = NULL;
2397 2395
2398 gl_context = gl_generic_context_get(engine); 2396 gl_context = gl_generic_context_get(engine, 1);
2399 evas_gl_common_context_flush(gl_context); 2397 evas_gl_common_context_flush(gl_context);
2400 2398
2401 eng_context_3d_use(engine); 2399 eng_context_3d_use(engine);
@@ -2461,7 +2459,7 @@ eng_texture_image_set(void *engine, void *texture, void *image)
2461{ 2459{
2462 Evas_Engine_GL_Context *gl_context; 2460 Evas_Engine_GL_Context *gl_context;
2463 2461
2464 gl_context = gl_generic_context_get(engine); 2462 gl_context = gl_generic_context_get(engine, 1);
2465 2463
2466 e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image); 2464 e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image);
2467} 2465}
@@ -2640,7 +2638,7 @@ eng_ector_begin(void *engine, void *context EINA_UNUSED, Ector_Surface *ector,
2640 Evas_GL_Ector *buffer = engine_data; 2638 Evas_GL_Ector *buffer = engine_data;
2641 int w, h; 2639 int w, h;
2642 2640
2643 gl_context = gl_generic_context_get(engine); 2641 gl_context = gl_generic_context_get(engine, 1);
2644 evas_gl_common_context_target_surface_set(gl_context, surface); 2642 evas_gl_common_context_target_surface_set(gl_context, surface);
2645 gl_context->dc = context; 2643 gl_context->dc = context;
2646 2644
@@ -2694,7 +2692,7 @@ eng_ector_end(void *engine, void *context EINA_UNUSED, Ector_Surface *ector,
2694 2692
2695 if (use_cairo || !use_gl) 2693 if (use_cairo || !use_gl)
2696 { 2694 {
2697 gl_context = gl_generic_context_get(engine); 2695 gl_context = gl_generic_context_get(engine, 1);
2698 w = gl_context->w; h = gl_context->h; 2696 w = gl_context->w; h = gl_context->h;
2699 mul_use = gl_context->dc->mul.use; 2697 mul_use = gl_context->dc->mul.use;
2700 2698
@@ -3064,7 +3062,7 @@ eng_image_surface_noscale_new(void *engine, int w, int h, int alpha)
3064{ 3062{
3065 Evas_Engine_GL_Context *gl_context; 3063 Evas_Engine_GL_Context *gl_context;
3066 3064
3067 gl_context = gl_generic_context_find(engine); 3065 gl_context = gl_generic_context_find(engine, 1);
3068 return evas_gl_common_image_surface_noscale_new(gl_context, w, h, alpha); 3066 return evas_gl_common_image_surface_noscale_new(gl_context, w, h, alpha);
3069} 3067}
3070 3068
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 46e47bb2b6..fadfe21fdf 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -2303,7 +2303,7 @@ eng_image_native_set(void *engine, void *image, void *native)
2303# endif 2303# endif
2304#endif 2304#endif
2305 2305
2306 gl_context = gl_generic_context_find(engine); 2306 gl_context = gl_generic_context_find(engine, 1);
2307 ob = gl_generic_any_output_get(engine); 2307 ob = gl_generic_any_output_get(engine);
2308 if (!im) 2308 if (!im)
2309 { 2309 {