summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:49:59 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:49:59 -0700
commit326ff87216967cb5aa544adc88cebdc5564cc290 (patch)
treef065365b0dbb9a8674d0d64e2a594c8cc9806a4b /src/modules
parent28397e7206322f2d31234d4ef77a588f7c0ba5e7 (diff)
evas: refactor gl_generic use of window_use with context_get.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c89
1 files 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;
49# endif 49# endif
50#endif 50#endif
51 51
52static Evas_Engine_GL_Context *
53gl_generic_context_get(Render_Output_GL_Generic *output)
54{
55 if (!output->software.ob) return NULL;
56 output->window_use(output->software.ob);
57 return output->window_gl_context_get(output->software.ob);
58
59}
60
52static int eng_gl_image_direct_get(void *data, void *image); 61static int eng_gl_image_direct_get(void *data, void *image);
53static int eng_gl_surface_destroy(void *data, void *surface); 62static int eng_gl_surface_destroy(void *data, void *surface);
54static Eina_Bool eng_gl_surface_lock(void *data, void *surface); 63static Eina_Bool eng_gl_surface_lock(void *data, void *surface);
@@ -83,7 +92,6 @@ _context_store(void *data, void *surface, void *context)
83 if (rsc->id == evgl_engine->main_tid) 92 if (rsc->id == evgl_engine->main_tid)
84 { 93 {
85 _need_context_restore = EINA_FALSE; 94 _need_context_restore = EINA_FALSE;
86
87 rsc->stored.data = data; 95 rsc->stored.data = data;
88 rsc->stored.surface = surface; 96 rsc->stored.surface = surface;
89 rsc->stored.context = context; 97 rsc->stored.context = context;
@@ -113,8 +121,7 @@ eng_rectangle_draw(void *engine EINA_UNUSED, void *data, void *context, void *su
113 Evas_Engine_GL_Context *gl_context; 121 Evas_Engine_GL_Context *gl_context;
114 Render_Output_GL_Generic *re = data; 122 Render_Output_GL_Generic *re = data;
115 123
116 re->window_use(re->software.ob); 124 gl_context = gl_generic_context_get(re);
117 gl_context = re->window_gl_context_get(re->software.ob);
118 evas_gl_common_context_target_surface_set(gl_context, surface); 125 evas_gl_common_context_target_surface_set(gl_context, surface);
119 gl_context->dc = context; 126 gl_context->dc = context;
120 evas_gl_common_rect_draw(gl_context, x, y, w, h); 127 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
126 Evas_Engine_GL_Context *gl_context; 133 Evas_Engine_GL_Context *gl_context;
127 Render_Output_GL_Generic *re = data; 134 Render_Output_GL_Generic *re = data;
128 135
129 re->window_use(re->software.ob); 136 gl_context = gl_generic_context_get(re);
130 gl_context = re->window_gl_context_get(re->software.ob);
131 evas_gl_common_context_target_surface_set(gl_context, surface); 137 evas_gl_common_context_target_surface_set(gl_context, surface);
132 gl_context->dc = context; 138 gl_context->dc = context;
133 evas_gl_common_line_draw(gl_context, p1x, p1y, p2x, p2y); 139 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
151 Evas_Engine_GL_Context *gl_context; 157 Evas_Engine_GL_Context *gl_context;
152 Render_Output_GL_Generic *re = data; 158 Render_Output_GL_Generic *re = data;
153 159
154 re->window_use(re->software.ob); 160 gl_context = gl_generic_context_get(re);
155 gl_context = re->window_gl_context_get(re->software.ob);
156 evas_gl_common_context_target_surface_set(gl_context, surface); 161 evas_gl_common_context_target_surface_set(gl_context, surface);
157 gl_context->dc = context; 162 gl_context->dc = context;
158 evas_gl_common_poly_draw(gl_context, polygon, x, y); 163 evas_gl_common_poly_draw(gl_context, polygon, x, y);
@@ -388,7 +393,7 @@ eng_image_native_set(void *engine, void *image, void *native)
388 unsigned int tex = 0; 393 unsigned int tex = 0;
389 unsigned int fbo = 0; 394 unsigned int fbo = 0;
390 395
391 gl_context = re->window_gl_context_get(re->software.ob); 396 gl_context = gl_generic_context_get(re);
392 397
393 if (!im) 398 if (!im)
394 { 399 {
@@ -506,8 +511,7 @@ eng_image_load(void *engine, const char *file, const char *key, int *error, Evas
506 Render_Output_GL_Generic *re = engine; 511 Render_Output_GL_Generic *re = engine;
507 512
508 *error = EVAS_LOAD_ERROR_NONE; 513 *error = EVAS_LOAD_ERROR_NONE;
509 re->window_use(re->software.ob); 514 gl_context = gl_generic_context_get(re);
510 gl_context = re->window_gl_context_get(re->software.ob);
511 return evas_gl_common_image_load(gl_context, file, key, lo, error); 515 return evas_gl_common_image_load(gl_context, file, key, lo, error);
512} 516}
513 517
@@ -518,8 +522,7 @@ eng_image_mmap(void *engine, Eina_File *f, const char *key, int *error, Evas_Ima
518 Render_Output_GL_Generic *re = engine; 522 Render_Output_GL_Generic *re = engine;
519 523
520 *error = EVAS_LOAD_ERROR_NONE; 524 *error = EVAS_LOAD_ERROR_NONE;
521 re->window_use(re->software.ob); 525 gl_context = gl_generic_context_get(re);
522 gl_context = re->window_gl_context_get(re->software.ob);
523 return evas_gl_common_image_mmap(gl_context, f, key, lo, error); 526 return evas_gl_common_image_mmap(gl_context, f, key, lo, error);
524} 527}
525 528
@@ -529,8 +532,7 @@ eng_image_new_from_data(void *engine, int w, int h, DATA32 *image_data, int alph
529 Evas_Engine_GL_Context *gl_context; 532 Evas_Engine_GL_Context *gl_context;
530 Render_Output_GL_Generic *re = engine; 533 Render_Output_GL_Generic *re = engine;
531 534
532 re->window_use(re->software.ob); 535 gl_context = gl_generic_context_get(re);
533 gl_context = re->window_gl_context_get(re->software.ob);
534 return evas_gl_common_image_new_from_data(gl_context, w, h, image_data, alpha, cspace); 536 return evas_gl_common_image_new_from_data(gl_context, w, h, image_data, alpha, cspace);
535} 537}
536 538
@@ -540,8 +542,7 @@ eng_image_new_from_copied_data(void *engine, int w, int h, DATA32 *image_data, i
540 Evas_Engine_GL_Context *gl_context; 542 Evas_Engine_GL_Context *gl_context;
541 Render_Output_GL_Generic *re = engine; 543 Render_Output_GL_Generic *re = engine;
542 544
543 re->window_use(re->software.ob); 545 gl_context = gl_generic_context_get(re);
544 gl_context = re->window_gl_context_get(re->software.ob);
545 return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace); 546 return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace);
546} 547}
547 548
@@ -606,8 +607,7 @@ eng_image_size_set(void *engine, void *image, int w, int h)
606 evas_gl_common_image_native_enable(im); 607 evas_gl_common_image_native_enable(im);
607 return image; 608 return image;
608 } 609 }
609 re->window_use(re->software.ob); 610 gl_context = gl_generic_context_get(re);
610 gl_context = re->window_gl_context_get(re->software.ob);
611 if ((im->tex) && (im->tex->pt->dyn.img)) 611 if ((im->tex) && (im->tex->pt->dyn.img))
612 { 612 {
613 evas_gl_common_texture_free(im->tex, EINA_TRUE); 613 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)
665 RGBA_Draw_Context *dc; 665 RGBA_Draw_Context *dc;
666 int w, h; 666 int w, h;
667 667
668 re->window_use(re->software.ob); 668 gl_context = gl_generic_context_get(re);
669 gl_context = re->window_gl_context_get(re->software.ob);
670 669
671 w = im1->w; 670 w = im1->w;
672 h = im1->h; 671 h = im1->h;
@@ -1101,8 +1100,7 @@ eng_image_data_preload_request(void *engine EINA_UNUSED, void *image, const Eo *
1101 { 1100 {
1102 Evas_Engine_GL_Context *gl_context; 1101 Evas_Engine_GL_Context *gl_context;
1103 1102
1104 re->window_use(re->software.ob); 1103 gl_context = gl_generic_context_get(re);
1105 gl_context = re->window_gl_context_get(re->software.ob);
1106 gim->tex = evas_gl_common_texture_new(gl_context, gim->im, EINA_FALSE); 1104 gim->tex = evas_gl_common_texture_new(gl_context, gim->im, EINA_FALSE);
1107 EINA_SAFETY_ON_NULL_RETURN(gim->tex); 1105 EINA_SAFETY_ON_NULL_RETURN(gim->tex);
1108 gim->tex->im = gim; 1106 gim->tex->im = gim;
@@ -1144,8 +1142,7 @@ eng_image_draw(void *engine EINA_UNUSED, void *data, void *context, void *surfac
1144 if (!im) return EINA_FALSE; 1142 if (!im) return EINA_FALSE;
1145 n = im->native.data; 1143 n = im->native.data;
1146 1144
1147 gl_context = re->window_gl_context_get(re->software.ob); 1145 gl_context = gl_generic_context_get(re);
1148 re->window_use(re->software.ob);
1149 1146
1150 if (eng_gl_image_direct_get(data, image)) 1147 if (eng_gl_image_direct_get(data, image))
1151 { 1148 {
@@ -1233,8 +1230,7 @@ eng_image_map_draw(void *engine, void *data, void *context, void *surface, void
1233 Render_Output_GL_Generic *re = data; 1230 Render_Output_GL_Generic *re = data;
1234 1231
1235 if (!image) return EINA_FALSE; 1232 if (!image) return EINA_FALSE;
1236 re->window_use(re->software.ob); 1233 gl_context = gl_generic_context_get(re);
1237 gl_context = re->window_gl_context_get(re->software.ob);
1238 evas_gl_common_context_target_surface_set(gl_context, surface); 1234 evas_gl_common_context_target_surface_set(gl_context, surface);
1239 gl_context->dc = context; 1235 gl_context->dc = context;
1240 1236
@@ -1286,8 +1282,7 @@ eng_image_map_surface_new(void *engine, int w, int h, int alpha)
1286 Render_Output_GL_Generic *re = engine; 1282 Render_Output_GL_Generic *re = engine;
1287 Evas_Engine_GL_Context *gl_context; 1283 Evas_Engine_GL_Context *gl_context;
1288 1284
1289 re->window_use(re->software.ob); 1285 gl_context = gl_generic_context_get(re);
1290 gl_context = re->window_gl_context_get(re->software.ob);
1291 return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE); 1286 return evas_gl_common_image_surface_new(gl_context, w, h, alpha, EINA_FALSE);
1292} 1287}
1293 1288
@@ -1323,8 +1318,7 @@ eng_image_cache_flush(void *engine)
1323 Render_Output_GL_Generic *re = engine; 1318 Render_Output_GL_Generic *re = engine;
1324 int tmp_size; 1319 int tmp_size;
1325 1320
1326 re->window_use(re->software.ob); 1321 gl_context = gl_generic_context_get(re);
1327 gl_context = re->window_gl_context_get(re->software.ob);
1328 if (!gl_context) return; 1322 if (!gl_context) return;
1329 1323
1330 tmp_size = evas_common_image_get_cache(); 1324 tmp_size = evas_common_image_get_cache();
@@ -1340,8 +1334,7 @@ eng_image_cache_set(void *engine, int bytes)
1340 Evas_Engine_GL_Context *gl_context; 1334 Evas_Engine_GL_Context *gl_context;
1341 Render_Output_GL_Generic *re = engine; 1335 Render_Output_GL_Generic *re = engine;
1342 1336
1343 re->window_use(re->software.ob); 1337 gl_context = gl_generic_context_get(re);
1344 gl_context = re->window_gl_context_get(re->software.ob);
1345 1338
1346 evas_common_image_set_cache(bytes); 1339 evas_common_image_set_cache(bytes);
1347 evas_common_rgba_image_scalecache_size_set(bytes); 1340 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
1442 Evas_Engine_GL_Context *gl_context; 1435 Evas_Engine_GL_Context *gl_context;
1443 Render_Output_GL_Generic *re = data; 1436 Render_Output_GL_Generic *re = data;
1444 1437
1445 re->window_use(re->software.ob); 1438 gl_context = gl_generic_context_get(re);
1446 gl_context = re->window_gl_context_get(re->software.ob);
1447 1439
1448 evas_gl_common_context_target_surface_set(gl_context, surface); 1440 evas_gl_common_context_target_surface_set(gl_context, surface);
1449 gl_context->dc = context; 1441 gl_context->dc = context;
@@ -1551,11 +1543,10 @@ eng_gl_make_current(void *engine, void *surface, void *context)
1551 { 1543 {
1552 Evas_Engine_GL_Context *gl_context; 1544 Evas_Engine_GL_Context *gl_context;
1553 1545
1554 gl_context = re->window_gl_context_get(re->software.ob); 1546 gl_context = gl_generic_context_get(re);
1555 if ((gl_context->havestuff) || 1547 if ((gl_context->havestuff) ||
1556 (gl_context->master_clip.used)) 1548 (gl_context->master_clip.used))
1557 { 1549 {
1558 re->window_use(re->software.ob);
1559 evas_gl_common_context_flush(gl_context); 1550 evas_gl_common_context_flush(gl_context);
1560 if (gl_context->master_clip.used) 1551 if (gl_context->master_clip.used)
1561 evas_gl_common_context_done(gl_context); 1552 evas_gl_common_context_done(gl_context);
@@ -1637,7 +1628,7 @@ eng_gl_api_get(void *engine, int version)
1637 Evas_Engine_GL_Context *gl_context; 1628 Evas_Engine_GL_Context *gl_context;
1638 EVGLINIT(re, NULL); 1629 EVGLINIT(re, NULL);
1639 1630
1640 gl_context = re->window_gl_context_get(re->software.ob); 1631 gl_context = gl_generic_context_get(re);
1641 if (!gl_context) 1632 if (!gl_context)
1642 { 1633 {
1643 ERR("Invalid context!"); 1634 ERR("Invalid context!");
@@ -1685,7 +1676,7 @@ eng_gl_surface_direct_renderable_get(void *engine, Evas_Native_Surface *ns, Eina
1685 if ((re->software.outbuf_get_rot(re->software.ob) != 0) && (!client_side_rotation)) 1676 if ((re->software.outbuf_get_rot(re->software.ob) != 0) && (!client_side_rotation))
1686 return EINA_FALSE; 1677 return EINA_FALSE;
1687 1678
1688 gl_context = re->window_gl_context_get(re->software.ob); 1679 gl_context = gl_generic_context_get(re);
1689 if (gl_context->def_surface != sfc) 1680 if (gl_context->def_surface != sfc)
1690 return EINA_FALSE; 1681 return EINA_FALSE;
1691 1682
@@ -2047,7 +2038,7 @@ eng_image_max_size_get(void *engine, int *maxw, int *maxh)
2047 Evas_Engine_GL_Context *gl_context; 2038 Evas_Engine_GL_Context *gl_context;
2048 Render_Output_GL_Generic *re = engine; 2039 Render_Output_GL_Generic *re = engine;
2049 2040
2050 gl_context = re->window_gl_context_get(re->software.ob); 2041 gl_context = gl_generic_context_get(re);
2051 if (maxw) *maxw = gl_context->shared->info.max_texture_size; 2042 if (maxw) *maxw = gl_context->shared->info.max_texture_size;
2052 if (maxh) *maxh = gl_context->shared->info.max_texture_size; 2043 if (maxh) *maxh = gl_context->shared->info.max_texture_size;
2053} 2044}
@@ -2147,12 +2138,11 @@ eng_context_flush(void *engine)
2147 Evas_Engine_GL_Context *gl_context; 2138 Evas_Engine_GL_Context *gl_context;
2148 Render_Output_GL_Generic *re = engine; 2139 Render_Output_GL_Generic *re = engine;
2149 2140
2150 gl_context = re->window_gl_context_get(re->software.ob); 2141 gl_context = gl_generic_context_get(re);
2151 2142
2152 if ((gl_context->havestuff) || 2143 if ((gl_context->havestuff) ||
2153 (gl_context->master_clip.used)) 2144 (gl_context->master_clip.used))
2154 { 2145 {
2155 re->window_use(re->software.ob);
2156 evas_gl_common_context_flush(gl_context); 2146 evas_gl_common_context_flush(gl_context);
2157 if (gl_context->master_clip.used) 2147 if (gl_context->master_clip.used)
2158 evas_gl_common_context_done(gl_context); 2148 evas_gl_common_context_done(gl_context);
@@ -2314,8 +2304,7 @@ eng_drawable_scene_render(void *engine, void *data EINA_UNUSED, void *drawable,
2314 Render_Output_GL_Generic *re = engine; 2304 Render_Output_GL_Generic *re = engine;
2315 E3D_Renderer *renderer = NULL; 2305 E3D_Renderer *renderer = NULL;
2316 2306
2317 re->window_use(re->software.ob); 2307 gl_context = gl_generic_context_get(re);
2318 gl_context = re->window_gl_context_get(re->software.ob);
2319 evas_gl_common_context_flush(gl_context); 2308 evas_gl_common_context_flush(gl_context);
2320 2309
2321 eng_context_3d_use(engine); 2310 eng_context_3d_use(engine);
@@ -2349,8 +2338,7 @@ eng_drawable_scene_render_to_texture(void *engine, void *drawable, void *scene_d
2349 Render_Output_GL_Generic *re = engine; 2338 Render_Output_GL_Generic *re = engine;
2350 E3D_Renderer *renderer = NULL; 2339 E3D_Renderer *renderer = NULL;
2351 2340
2352 re->window_use(re->software.ob); 2341 gl_context = gl_generic_context_get(re);
2353 gl_context = re->window_gl_context_get(re->software.ob);
2354 evas_gl_common_context_flush(gl_context); 2342 evas_gl_common_context_flush(gl_context);
2355 2343
2356 eng_context_3d_use(engine); 2344 eng_context_3d_use(engine);
@@ -2417,8 +2405,7 @@ eng_texture_image_set(void *engine, void *texture, void *image)
2417 Evas_Engine_GL_Context *gl_context; 2405 Evas_Engine_GL_Context *gl_context;
2418 Render_Output_GL_Generic *re = engine; 2406 Render_Output_GL_Generic *re = engine;
2419 2407
2420 re->window_use(re->software.ob); 2408 gl_context = gl_generic_context_get(re);
2421 gl_context = re->window_gl_context_get(re->software.ob);
2422 2409
2423 e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image); 2410 e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image);
2424} 2411}
@@ -2598,8 +2585,7 @@ eng_ector_begin(void *engine, void *context EINA_UNUSED, Ector_Surface *ector,
2598 Evas_GL_Ector *buffer = engine_data; 2585 Evas_GL_Ector *buffer = engine_data;
2599 int w, h; 2586 int w, h;
2600 2587
2601 re->window_use(re->software.ob); 2588 gl_context = gl_generic_context_get(re);
2602 gl_context = re->window_gl_context_get(re->software.ob);
2603 evas_gl_common_context_target_surface_set(gl_context, surface); 2589 evas_gl_common_context_target_surface_set(gl_context, surface);
2604 gl_context->dc = context; 2590 gl_context->dc = context;
2605 2591
@@ -2654,7 +2640,7 @@ eng_ector_end(void *engine, void *context EINA_UNUSED, Ector_Surface *ector,
2654 2640
2655 if (use_cairo || !use_gl) 2641 if (use_cairo || !use_gl)
2656 { 2642 {
2657 gl_context = re->window_gl_context_get(re->software.ob); 2643 gl_context = gl_generic_context_get(re);
2658 w = gl_context->w; h = gl_context->h; 2644 w = gl_context->w; h = gl_context->h;
2659 mul_use = gl_context->dc->mul.use; 2645 mul_use = gl_context->dc->mul.use;
2660 2646
@@ -3025,8 +3011,7 @@ eng_image_surface_noscale_new(void *engine, int w, int h, int alpha)
3025 Evas_Engine_GL_Context *gl_context; 3011 Evas_Engine_GL_Context *gl_context;
3026 Render_Output_GL_Generic *re = engine; 3012 Render_Output_GL_Generic *re = engine;
3027 3013
3028 re->window_use(re->software.ob); 3014 gl_context = gl_generic_context_get(re);
3029 gl_context = re->window_gl_context_get(re->software.ob);
3030 return evas_gl_common_image_surface_noscale_new(gl_context, w, h, alpha); 3015 return evas_gl_common_image_surface_noscale_new(gl_context, w, h, alpha);
3031} 3016}
3032 3017