summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:54:19 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:54:19 -0700
commit545c1a70f4d09a147949b00b06f4bc15a572bce0 (patch)
tree96b4f0ecb9ffcab99052f8a6b5db379ea7147fe1 /src/modules
parent7f8bbe497275ae229562fbf50ac682c1a983b476 (diff)
evas: make Evas_GL work with multi output.
Diffstat (limited to 'src/modules')
-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.c174
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c1
3 files changed, 142 insertions, 41 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 043d7f7..7fdea30 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
@@ -22,11 +22,15 @@ struct _Render_Engine_GL_Generic
22{ 22{
23 Render_Engine_Software_Generic software; 23 Render_Engine_Software_Generic software;
24 24
25 Render_Output_GL_Generic *current;
26
25 struct { 27 struct {
26 Evas_Object_Image_Pixels_Get_Cb get_pixels; 28 Evas_Object_Image_Pixels_Get_Cb get_pixels;
27 void *get_pixels_data; 29 void *get_pixels_data;
28 Evas_Object *obj; 30 Evas_Object *obj;
29 } func; 31 } func;
32
33 Eina_Bool evgl_initted : 1;
30}; 34};
31 35
32struct _Render_Output_GL_Generic 36struct _Render_Output_GL_Generic
@@ -42,8 +46,6 @@ struct _Render_Output_GL_Generic
42 Context_3D *context_3d; 46 Context_3D *context_3d;
43 E3D_Renderer *renderer_3d; 47 E3D_Renderer *renderer_3d;
44 const EVGL_Interface *evgl_funcs; 48 const EVGL_Interface *evgl_funcs;
45
46 Eina_Bool evgl_initted : 1;
47}; 49};
48 50
49static inline Eina_Bool 51static inline Eina_Bool
@@ -96,8 +98,6 @@ evas_render_engine_gl_generic_init(Render_Engine_Software_Generic *engine,
96 re->renderer_3d = NULL; 98 re->renderer_3d = NULL;
97 re->evgl_funcs = evgl_funcs; 99 re->evgl_funcs = evgl_funcs;
98 100
99 re->evgl_initted = EINA_FALSE;
100
101 evas_render_engine_software_generic_tile_strict_set(&re->software, EINA_TRUE); 101 evas_render_engine_software_generic_tile_strict_set(&re->software, EINA_TRUE);
102 102
103 return EINA_TRUE; 103 return EINA_TRUE;
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 67b5890..60f65ef 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -57,6 +57,37 @@ static Eina_Bool eng_gl_surface_read_pixels(void *data, void *surface, int x, in
57 57
58Eina_Bool _need_context_restore = EINA_FALSE; 58Eina_Bool _need_context_restore = EINA_FALSE;
59 59
60static Render_Output_GL_Generic *
61_evgl_output_find(Render_Engine_GL_Generic *engine)
62{
63 Render_Output_GL_Generic *output = NULL;
64 EVGL_Resource *rsc;
65 Eina_List *l;
66
67 if (engine->current)
68 {
69 output = engine->current;
70 goto picked;
71 }
72
73 rsc = _evgl_tls_resource_get();
74 if (rsc &&
75 rsc->stored.data)
76 {
77 EINA_LIST_FOREACH(engine->software.outputs, l, output)
78 if (output == rsc->stored.data) goto picked;
79 }
80
81 EINA_LIST_FOREACH(engine->software.outputs, l, output)
82 {
83 if (output->software.ob) goto picked;
84 }
85 return NULL;
86
87 picked:
88 return output;
89}
90
60static Evas_Func func, pfunc; 91static Evas_Func func, pfunc;
61 92
62void 93void
@@ -1434,24 +1465,65 @@ eng_font_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface
1434 1465
1435//--------------------------------// 1466//--------------------------------//
1436// Evas GL Related Code 1467// Evas GL Related Code
1437static int 1468static inline Eina_Bool
1438evgl_init(Render_Output_GL_Generic *re) 1469evgl_init_do(Render_Engine_GL_Generic *engine,
1470 Render_Output_GL_Generic *output)
1439{ 1471{
1440 if (re->evgl_initted) return 1; 1472 if (engine->evgl_initted) return EINA_TRUE;
1441 if (!evgl_engine_init(re, re->evgl_funcs)) return 0; 1473 if (!evgl_engine_init(output, output->evgl_funcs))
1442 re->evgl_initted = EINA_TRUE; 1474 return EINA_FALSE;
1443 return 1; 1475 engine->current = output;
1476 engine->evgl_initted = EINA_TRUE;
1477 return EINA_TRUE;
1444} 1478}
1445 1479
1446#define EVGLINIT(_re, _ret) if (!evgl_init(_re)) return _ret 1480static Render_Output_GL_Generic *
1481evgl_init(Render_Engine_GL_Generic *engine)
1482{
1483 Render_Output_GL_Generic *output = NULL;
1484 Eina_List *l;
1485
1486 if (engine->evgl_initted)
1487 {
1488 if (engine->current) return engine->current;
1489
1490 EINA_LIST_FOREACH(engine->software.outputs, l, output)
1491 if (output->software.ob) return output;
1492
1493 ERR("Evas_GL backend initializeod, but no window found !");
1494 return NULL;
1495 }
1496
1497 EINA_LIST_FOREACH(engine->software.outputs, l, output)
1498 {
1499 if (!output->software.ob) continue;
1500 if (evgl_init_do(engine, output))
1501 return output;
1502 }
1503
1504 return NULL;
1505}
1506
1507#define EVGLINIT(_ret) Render_Output_GL_Generic *re; if ((re = evgl_init(engine)) == NULL) return _ret
1508
1509static void *
1510eng_gl_output_set(void *eng, void *output)
1511{
1512 Render_Engine_GL_Generic *engine = eng;
1513 Render_Output_GL_Generic *previous = engine->current;
1514
1515 engine->current = output;
1516
1517 return previous;
1518}
1447 1519
1448static void * 1520static void *
1449eng_gl_surface_create(void *engine, void *config, int w, int h) 1521eng_gl_surface_create(void *engine, void *config, int w, int h)
1450{ 1522{
1451 Evas_GL_Config *cfg = (Evas_GL_Config *)config; 1523 Evas_GL_Config *cfg = (Evas_GL_Config *)config;
1452 1524
1453 EVGLINIT(engine, NULL); 1525 EVGLINIT(NULL);
1454 return evgl_surface_create(engine, cfg, w, h); 1526 return evgl_surface_create(re, cfg, w, h);
1455} 1527}
1456 1528
1457static void * 1529static void *
@@ -1459,18 +1531,20 @@ eng_gl_pbuffer_surface_create(void *engine, void *config, int w, int h, const in
1459{ 1531{
1460 Evas_GL_Config *cfg = (Evas_GL_Config *)config; 1532 Evas_GL_Config *cfg = (Evas_GL_Config *)config;
1461 1533
1462 EVGLINIT(engine, NULL); 1534 EVGLINIT(NULL);
1463 return evgl_pbuffer_surface_create(engine, cfg, w, h, attrib_list); 1535 return evgl_pbuffer_surface_create(re, cfg, w, h, attrib_list);
1464} 1536}
1465 1537
1466static int 1538static int
1467eng_gl_surface_destroy(void *engine, void *surface) 1539eng_gl_surface_destroy(void *engine, void *surface)
1468{ 1540{
1469 EVGL_Surface *sfc = (EVGL_Surface *)surface; 1541 EVGL_Surface *sfc = (EVGL_Surface *)surface;
1542 Render_Engine_GL_Generic *e;
1470 1543
1471 EVGLINIT(engine, 0); 1544 EVGLINIT(0);
1472 CONTEXT_STORED_RESET(engine, surface); 1545 if (e->current == re) e->current = NULL;
1473 return evgl_surface_destroy(engine, sfc); 1546 CONTEXT_STORED_RESET(re, surface);
1547 return evgl_surface_destroy(re, sfc);
1474} 1548}
1475 1549
1476static void * 1550static void *
@@ -1480,8 +1554,8 @@ eng_gl_context_create(void *engine, void *share_context, int version,
1480{ 1554{
1481 EVGL_Context *sctx = (EVGL_Context *)share_context; 1555 EVGL_Context *sctx = (EVGL_Context *)share_context;
1482 1556
1483 EVGLINIT(engine, NULL); 1557 EVGLINIT(NULL);
1484 return evgl_context_create(engine, sctx, version, native_context_get, engine_data_get); 1558 return evgl_context_create(re, sctx, version, native_context_get, engine_data_get);
1485} 1559}
1486 1560
1487static int 1561static int
@@ -1489,15 +1563,17 @@ eng_gl_context_destroy(void *engine, void *context)
1489{ 1563{
1490 EVGL_Context *ctx = (EVGL_Context *)context; 1564 EVGL_Context *ctx = (EVGL_Context *)context;
1491 1565
1492 EVGLINIT(engine, 0); 1566 EVGLINIT(0);
1493 return evgl_context_destroy(engine, ctx); 1567 return evgl_context_destroy(re, ctx);
1494} 1568}
1495 1569
1496static int 1570static int
1497eng_gl_make_current(void *engine, void *surface, void *context) 1571eng_gl_make_current(void *eng, void *surface, void *context)
1498{ 1572{
1573 Render_Engine_GL_Generic *engine = eng;
1499 EVGL_Surface *sfc = (EVGL_Surface *)surface; 1574 EVGL_Surface *sfc = (EVGL_Surface *)surface;
1500 EVGL_Context *ctx = (EVGL_Context *)context; 1575 EVGL_Context *ctx = (EVGL_Context *)context;
1576 Render_Output_GL_Generic *output;
1501 int ret = 0; 1577 int ret = 0;
1502 1578
1503 // TODO: Add check for main thread before flush 1579 // TODO: Add check for main thread before flush
@@ -1516,8 +1592,11 @@ eng_gl_make_current(void *engine, void *surface, void *context)
1516 } 1592 }
1517 } 1593 }
1518 1594
1519 ret = evgl_make_current(engine, sfc, ctx); 1595 output = _evgl_output_find(engine);
1520 CONTEXT_STORE(engine, surface, context); 1596 if (!output) return ret;
1597
1598 ret = evgl_make_current(output, sfc, ctx);
1599 CONTEXT_STORE(output, surface, context);
1521 1600
1522 return ret; 1601 return ret;
1523} 1602}
@@ -1537,25 +1616,32 @@ eng_gl_current_surface_get(void *engine EINA_UNUSED)
1537} 1616}
1538 1617
1539static int 1618static int
1540eng_gl_rotation_angle_get(void *engine) 1619eng_gl_rotation_angle_get(void *eng)
1541{ 1620{
1621 Render_Engine_GL_Generic *engine = eng;
1622 Render_Output_GL_Generic *output;
1623
1542 if (!evgl_engine->funcs->rotation_angle_get) return 0; 1624 if (!evgl_engine->funcs->rotation_angle_get) return 0;
1543 if (!_evgl_direct_enabled()) return 0; 1625 if (!_evgl_direct_enabled()) return 0;
1544 return evgl_engine->funcs->rotation_angle_get(engine); 1626
1627 // It would be better if that this API was called Evas Output
1628 output = _evgl_output_find(engine);
1629 if (!output) return 0;
1630
1631 return evgl_engine->funcs->rotation_angle_get(output);
1545} 1632}
1546 1633
1547static const char * 1634static const char *
1548eng_gl_string_query(void *engine, int name) 1635eng_gl_string_query(void *engine, int name)
1549{ 1636{
1550 EVGLINIT(engine, NULL); 1637 EVGLINIT(NULL);
1551 return evgl_string_query(name); 1638 return evgl_string_query(name);
1552} 1639}
1553 1640
1554static void * 1641static void *
1555eng_gl_proc_address_get(void *engine, const char *name) 1642eng_gl_proc_address_get(void *engine, const char *name)
1556{ 1643{
1557 Render_Output_GL_Generic *re = engine; 1644 EVGLINIT(NULL);
1558 EVGLINIT(engine, NULL);
1559 void *fun = NULL; 1645 void *fun = NULL;
1560 1646
1561 if (!evgl_safe_extension_get(name, &fun)) 1647 if (!evgl_safe_extension_get(name, &fun))
@@ -1586,9 +1672,10 @@ eng_gl_native_surface_get(void *engine EINA_UNUSED, void *surface, void *native_
1586static void * 1672static void *
1587eng_gl_api_get(void *engine, int version) 1673eng_gl_api_get(void *engine, int version)
1588{ 1674{
1589 void *ret; 1675 Render_Output_GL_Generic *output;
1590 Evas_Engine_GL_Context *gl_context; 1676 Evas_Engine_GL_Context *gl_context;
1591 EVGLINIT(engine, NULL); 1677 void *ret;
1678 EVGLINIT(NULL);
1592 1679
1593 gl_context = gl_generic_context_find(engine); 1680 gl_context = gl_generic_context_find(engine);
1594 if (!gl_context) 1681 if (!gl_context)
@@ -1601,7 +1688,9 @@ eng_gl_api_get(void *engine, int version)
1601 ERR("Version not supported!"); 1688 ERR("Version not supported!");
1602 return NULL; 1689 return NULL;
1603 } 1690 }
1604 ret = evgl_api_get(engine, version, EINA_TRUE); 1691
1692 output = _evgl_output_find(engine);
1693 ret = evgl_api_get(output, version, EINA_TRUE);
1605 1694
1606 //Disable GLES3 support if symbols not present 1695 //Disable GLES3 support if symbols not present
1607 if ((!ret) && (version == EVAS_GL_GLES_3_X)) 1696 if ((!ret) && (version == EVAS_GL_GLES_3_X))
@@ -1614,20 +1703,22 @@ eng_gl_api_get(void *engine, int version)
1614static void 1703static void
1615eng_gl_direct_override_get(void *engine, Eina_Bool *override, Eina_Bool *force_off) 1704eng_gl_direct_override_get(void *engine, Eina_Bool *override, Eina_Bool *force_off)
1616{ 1705{
1617 EVGLINIT(engine, ); 1706 EVGLINIT();
1618 evgl_direct_override_get(override, force_off); 1707 evgl_direct_override_get(override, force_off);
1619} 1708}
1620 1709
1621static Eina_Bool 1710static Eina_Bool
1622eng_gl_surface_direct_renderable_get(void *engine, void *output, Evas_Native_Surface *ns, Eina_Bool *override, void *surface) 1711eng_gl_surface_direct_renderable_get(void *eng, void *output, Evas_Native_Surface *ns, Eina_Bool *override, void *surface)
1623{ 1712{
1713 Render_Engine_GL_Generic *engine = eng;
1624 Render_Output_GL_Generic *re = output; 1714 Render_Output_GL_Generic *re = output;
1625 Eina_Bool direct_render, client_side_rotation; 1715 Eina_Bool direct_render, client_side_rotation;
1626 Evas_Engine_GL_Context *gl_context; 1716 Evas_Engine_GL_Context *gl_context;
1627 Evas_GL_Image *sfc = surface; 1717 Evas_GL_Image *sfc = surface;
1628 1718
1629 if (!re) return EINA_FALSE; 1719 if (!re) return EINA_FALSE;
1630 EVGLINIT(engine, EINA_FALSE); 1720 if (!evgl_init_do(engine, re))
1721 return EINA_FALSE;
1631 if (!ns) return EINA_FALSE; 1722 if (!ns) return EINA_FALSE;
1632 if (!evgl_native_surface_direct_opts_get(ns, &direct_render, &client_side_rotation, override)) 1723 if (!evgl_native_surface_direct_opts_get(ns, &direct_render, &client_side_rotation, override))
1633 return EINA_FALSE; 1724 return EINA_FALSE;
@@ -1656,14 +1747,18 @@ eng_gl_get_pixels_set(void *eng, void *get_pixels, void *get_pixels_data, void *
1656} 1747}
1657 1748
1658static void 1749static void
1659eng_gl_get_pixels_pre(void *engine) 1750eng_gl_get_pixels_pre(void *e, void *o)
1660{ 1751{
1661 EVGLINIT(engine, ); 1752 Render_Engine_GL_Generic *engine = e;
1753 Render_Output_GL_Generic *output = o;
1754
1755 if (!evgl_init_do(engine, output))
1756 return ;
1662 evgl_get_pixels_pre(); 1757 evgl_get_pixels_pre();
1663} 1758}
1664 1759
1665static void 1760static void
1666eng_gl_get_pixels_post(void *engine EINA_UNUSED) 1761eng_gl_get_pixels_post(void *e EINA_UNUSED, void *o EINA_UNUSED)
1667{ 1762{
1668 evgl_get_pixels_post(); 1763 evgl_get_pixels_post();
1669} 1764}
@@ -1759,11 +1854,15 @@ eng_gl_surface_read_pixels(void *engine EINA_UNUSED, void *surface,
1759} 1854}
1760 1855
1761static Eina_Bool 1856static Eina_Bool
1762eng_gl_surface_query(void *engine, void *surface, int attr, void *value) 1857eng_gl_surface_query(void *eng, void *surface, int attr, void *value)
1763{ 1858{
1764 Render_Output_GL_Generic *re = engine; 1859 Render_Engine_GL_Generic *engine = eng;
1860 Render_Output_GL_Generic *re;
1765 EVGL_Surface *sfc = surface; 1861 EVGL_Surface *sfc = surface;
1766 1862
1863 re = _evgl_output_find(engine);
1864 if (!re) return EINA_FALSE;
1865
1767#ifdef GL_GLES 1866#ifdef GL_GLES
1768 if (sfc->pbuffer.is_pbuffer) 1867 if (sfc->pbuffer.is_pbuffer)
1769 { 1868 {
@@ -3112,6 +3211,7 @@ module_open(Evas_Module *em)
3112 ORD(font_cache_set); 3211 ORD(font_cache_set);
3113 ORD(font_cache_get); 3212 ORD(font_cache_get);
3114 3213
3214 ORD(gl_output_set);
3115 ORD(gl_surface_create); 3215 ORD(gl_surface_create);
3116 ORD(gl_pbuffer_surface_create); 3216 ORD(gl_pbuffer_surface_create);
3117 ORD(gl_surface_destroy); 3217 ORD(gl_surface_destroy);
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index ade91f4..d7253de 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -4799,6 +4799,7 @@ static Evas_Func func =
4799 eng_font_pen_coords_get, 4799 eng_font_pen_coords_get,
4800 eng_font_text_props_info_create, 4800 eng_font_text_props_info_create,
4801 eng_font_right_inset_get, 4801 eng_font_right_inset_get,
4802 NULL, // No need to set output for software engine
4802 NULL, // need software mesa for gl rendering <- gl_surface_create 4803 NULL, // need software mesa for gl rendering <- gl_surface_create
4803 NULL, // need software mesa for gl rendering <- gl_pbuffer_surface_create 4804 NULL, // need software mesa for gl rendering <- gl_pbuffer_surface_create
4804 NULL, // need software mesa for gl rendering <- gl_surface_destroy 4805 NULL, // need software mesa for gl rendering <- gl_surface_destroy