diff options
author | Dongyeon Kim <dy5.kim@samsung.com> | 2015-01-19 12:28:32 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-02-10 14:48:22 +0900 |
commit | 72f3e684d90e115aacaa62f49c66821c4e90782f (patch) | |
tree | fa16ee2b81b9cf6eb28dab97a77a3727a317bc3a /src/modules/evas/engines/gl_x11/evas_engine.c | |
parent | 5df768a43aee6a53d1bd44155bdd08f59908aabf (diff) |
evas/gl_x11: introduce tbm native surface type
Summary:
This native surface type is based on the tbm surface used for the tizen platform.
EGL_TIZEN_image_native_surface EGL extension is used to map
tbm surface to an egl image
@feature
Reviewers: raster, cedric, jpeg
Subscribers: cedric, wonsik
Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
Diffstat (limited to '')
-rw-r--r-- | src/modules/evas/engines/gl_x11/evas_engine.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index 3721d31f00..cdbe5d297d 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c | |||
@@ -1841,6 +1841,7 @@ struct _Native | |||
1841 | Evas_Native_Surface ns; | 1841 | Evas_Native_Surface ns; |
1842 | Pixmap pixmap; | 1842 | Pixmap pixmap; |
1843 | Visual *visual; | 1843 | Visual *visual; |
1844 | void *buffer; | ||
1844 | 1845 | ||
1845 | #ifdef GL_GLES | 1846 | #ifdef GL_GLES |
1846 | void *egl_surface; | 1847 | void *egl_surface; |
@@ -1899,6 +1900,22 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) | |||
1899 | glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); | 1900 | glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); |
1900 | GLERR(__FUNCTION__, __FILE__, __LINE__, ""); | 1901 | GLERR(__FUNCTION__, __FILE__, __LINE__, ""); |
1901 | } | 1902 | } |
1903 | else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) | ||
1904 | { | ||
1905 | #ifdef GL_GLES | ||
1906 | if (n->egl_surface) | ||
1907 | { | ||
1908 | if (glsym_glEGLImageTargetTexture2DOES) | ||
1909 | { | ||
1910 | glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->egl_surface); | ||
1911 | if (eglGetError() != EGL_SUCCESS) | ||
1912 | ERR("glEGLImageTargetTexture2DOES() failed."); | ||
1913 | } | ||
1914 | else | ||
1915 | ERR("Try glEGLImageTargetTexture2DOES on EGL with no support"); | ||
1916 | } | ||
1917 | #endif | ||
1918 | } | ||
1902 | } | 1919 | } |
1903 | 1920 | ||
1904 | static void | 1921 | static void |
@@ -1931,6 +1948,10 @@ _native_unbind_cb(void *data EINA_UNUSED, void *image) | |||
1931 | glBindTexture(GL_TEXTURE_2D, 0); | 1948 | glBindTexture(GL_TEXTURE_2D, 0); |
1932 | GLERR(__FUNCTION__, __FILE__, __LINE__, ""); | 1949 | GLERR(__FUNCTION__, __FILE__, __LINE__, ""); |
1933 | } | 1950 | } |
1951 | else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) | ||
1952 | { | ||
1953 | // nothing | ||
1954 | } | ||
1934 | } | 1955 | } |
1935 | 1956 | ||
1936 | static void | 1957 | static void |
@@ -1994,6 +2015,28 @@ _native_free_cb(void *data, void *image) | |||
1994 | texid = n->ns.data.opengl.texture_id; | 2015 | texid = n->ns.data.opengl.texture_id; |
1995 | eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tex_hash, &texid, im); | 2016 | eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tex_hash, &texid, im); |
1996 | } | 2017 | } |
2018 | else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) | ||
2019 | { | ||
2020 | eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->buffer, im); | ||
2021 | #ifdef GL_GLES | ||
2022 | if (n->egl_surface) | ||
2023 | { | ||
2024 | int err; | ||
2025 | if (glsym_eglDestroyImage) | ||
2026 | { | ||
2027 | glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, | ||
2028 | n->egl_surface); | ||
2029 | if ((err = eglGetError()) != EGL_SUCCESS) | ||
2030 | { | ||
2031 | ERR("eglDestroyImage() failed."); | ||
2032 | glsym_evas_gl_common_error_set(err - EGL_SUCCESS); | ||
2033 | } | ||
2034 | } | ||
2035 | else | ||
2036 | ERR("Try eglDestroyImage on EGL with no support"); | ||
2037 | } | ||
2038 | #endif | ||
2039 | } | ||
1997 | im->native.data = NULL; | 2040 | im->native.data = NULL; |
1998 | im->native.func.data = NULL; | 2041 | im->native.func.data = NULL; |
1999 | im->native.func.bind = NULL; | 2042 | im->native.func.bind = NULL; |
@@ -2014,6 +2057,7 @@ eng_image_native_set(void *data, void *image, void *native) | |||
2014 | uint32_t pmid, texid; | 2057 | uint32_t pmid, texid; |
2015 | unsigned int tex = 0; | 2058 | unsigned int tex = 0; |
2016 | unsigned int fbo = 0; | 2059 | unsigned int fbo = 0; |
2060 | void *buffer = NULL; | ||
2017 | 2061 | ||
2018 | if (!im) | 2062 | if (!im) |
2019 | { | 2063 | { |
@@ -2055,6 +2099,16 @@ eng_image_native_set(void *data, void *image, void *native) | |||
2055 | return im; | 2099 | return im; |
2056 | } | 2100 | } |
2057 | } | 2101 | } |
2102 | else if (ns->type == EVAS_NATIVE_SURFACE_TBM) | ||
2103 | { | ||
2104 | buffer = ns->data.tbm.buffer; | ||
2105 | if (im->native.data) | ||
2106 | { | ||
2107 | Evas_Native_Surface *ens = im->native.data; | ||
2108 | if (ens->data.tbm.buffer == buffer) | ||
2109 | return im; | ||
2110 | } | ||
2111 | } | ||
2058 | } | 2112 | } |
2059 | if ((!ns) && (!im->native.data)) return im; | 2113 | if ((!ns) && (!im->native.data)) return im; |
2060 | 2114 | ||
@@ -2102,6 +2156,21 @@ eng_image_native_set(void *data, void *image, void *native) | |||
2102 | } | 2156 | } |
2103 | 2157 | ||
2104 | } | 2158 | } |
2159 | else if (ns->type == EVAS_NATIVE_SURFACE_TBM) | ||
2160 | { | ||
2161 | im2 = eina_hash_find(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer); | ||
2162 | if (im2 == im) return im; | ||
2163 | if (im2) | ||
2164 | { | ||
2165 | n = im2->native.data; | ||
2166 | if (n) | ||
2167 | { | ||
2168 | glsym_evas_gl_common_image_ref(im2); | ||
2169 | glsym_evas_gl_common_image_free(im); | ||
2170 | return im2; | ||
2171 | } | ||
2172 | } | ||
2173 | } | ||
2105 | im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context, | 2174 | im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context, |
2106 | im->w, im->h, NULL, im->alpha, | 2175 | im->w, im->h, NULL, im->alpha, |
2107 | EVAS_COLORSPACE_ARGB8888); | 2176 | EVAS_COLORSPACE_ARGB8888); |
@@ -2432,6 +2501,42 @@ eng_image_native_set(void *data, void *image, void *native) | |||
2432 | } | 2501 | } |
2433 | 2502 | ||
2434 | } | 2503 | } |
2504 | else if (ns->type == EVAS_NATIVE_SURFACE_TBM) | ||
2505 | { | ||
2506 | #ifdef GL_GLES | ||
2507 | if (native) | ||
2508 | { | ||
2509 | n = calloc(1, sizeof(Native)); | ||
2510 | if (n) | ||
2511 | { | ||
2512 | eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer, im); | ||
2513 | |||
2514 | memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); | ||
2515 | n->buffer = buffer; | ||
2516 | if (glsym_eglCreateImage) | ||
2517 | n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, | ||
2518 | EGL_NO_CONTEXT, | ||
2519 | EGL_NATIVE_SURFACE_TIZEN, | ||
2520 | (void *)buffer, | ||
2521 | NULL); | ||
2522 | else | ||
2523 | ERR("Try eglCreateImage on EGL with no support"); | ||
2524 | if (!n->egl_surface) | ||
2525 | ERR("eglCreateImage() for %p failed", buffer); | ||
2526 | im->native.yinvert = 1; | ||
2527 | im->native.loose = 0; | ||
2528 | im->native.data = n; | ||
2529 | im->native.func.data = re; | ||
2530 | im->native.func.bind = _native_bind_cb; | ||
2531 | im->native.func.unbind = _native_unbind_cb; | ||
2532 | im->native.func.free = _native_free_cb; | ||
2533 | im->native.target = GL_TEXTURE_EXTERNAL_OES; | ||
2534 | im->native.mipmap = 0; | ||
2535 | glsym_evas_gl_common_image_native_enable(im); | ||
2536 | } | ||
2537 | } | ||
2538 | #endif | ||
2539 | } | ||
2435 | return im; | 2540 | return im; |
2436 | } | 2541 | } |
2437 | 2542 | ||