summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common/evas_gl_texture.c
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-11-12 13:56:17 +0900
committerDongyeon Kim <dy5.kim@samsung.com>2015-11-12 13:56:17 +0900
commit7db0e2066108c2ee78afd317727b581d1d7e8342 (patch)
tree91db9ede5484c2eb35447756efcd7d01f6fb3a5c /src/modules/evas/engines/gl_common/evas_gl_texture.c
parent16eb3942bb1f81fc56e4314f0a09b6b00b7aa0d7 (diff)
evas/gl: Bind texture with external target for tbm surface
egl images created using tbm surface for native surface set use GL_TEXTURE_EXTERNAL_OES as texture target, so we should bind to this target when rendering. Dynamic hint set using tbm surface also creates egl images, but as we only use RGB* colorspace for this we can use GL_TEXTURE_2D. So, keep track of texture target in shader array, and bind to the appropriate one. This also fixes the bug that image_data_get only worked when BOTH sec_image_map and sec_tbm_surface extensions are supported.
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c
index b848c68c9a..3107507b8b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -400,7 +400,7 @@ _pool_tex_new(Evas_Engine_GL_Context *gc, int w, int h, GLenum intformat, GLenum
400 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 400 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
401 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 401 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
402 ok = _tex_2d(gc, pt->intformat, w, h, pt->format, pt->dataformat); 402 ok = _tex_2d(gc, pt->intformat, w, h, pt->format, pt->dataformat);
403 glBindTexture(GL_TEXTURE_2D, gc->state.current.cur_tex); 403 glBindTexture(gc->state.current.tex_target, gc->state.current.cur_tex);
404 if (!ok) 404 if (!ok)
405 { 405 {
406 glDeleteTextures(1, &(pt->texture)); 406 glDeleteTextures(1, &(pt->texture));
@@ -632,7 +632,7 @@ _pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
632 } 632 }
633 633
634 glsym_glBindFramebuffer(GL_FRAMEBUFFER, fnum); 634 glsym_glBindFramebuffer(GL_FRAMEBUFFER, fnum);
635 glBindTexture(GL_TEXTURE_2D, gc->state.current.cur_tex); 635 glBindTexture(gc->state.current.tex_target, gc->state.current.cur_tex);
636 636
637 if (!ok) 637 if (!ok)
638 { 638 {
@@ -700,7 +700,7 @@ _pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
700 glTexParameteri(im->native.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 700 glTexParameteri(im->native.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
701 glTexParameteri(im->native.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 701 glTexParameteri(im->native.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
702 glBindTexture(im->native.target, 0); 702 glBindTexture(im->native.target, 0);
703 glBindTexture(im->native.target, gc->state.current.cur_tex); 703 glBindTexture(gc->state.current.tex_target, gc->state.current.cur_tex);
704 704
705 texinfo.n.num++; 705 texinfo.n.num++;
706 texinfo.n.pix += pt->w * pt->h; 706 texinfo.n.pix += pt->w * pt->h;
@@ -735,12 +735,14 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
735 735
736 _print_tex_count(); 736 _print_tex_count();
737 737
738 pt->dyn.target = GL_TEXTURE_2D;
739
738 glGenTextures(1, &(pt->texture)); 740 glGenTextures(1, &(pt->texture));
739 glBindTexture(GL_TEXTURE_2D, pt->texture); 741 glBindTexture(pt->dyn.target, pt->texture);
740 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 742 glTexParameteri(pt->dyn.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
741 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 743 glTexParameteri(pt->dyn.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
742 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 744 glTexParameteri(pt->dyn.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
743 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 745 glTexParameteri(pt->dyn.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
744 746
745 egldisplay = pt->gc->egldisp; 747 egldisplay = pt->gc->egldisp;
746 748
@@ -748,11 +750,6 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
748 { 750 {
749 tbm_format buffer_format = TBM_FORMAT_RGBA8888; 751 tbm_format buffer_format = TBM_FORMAT_RGBA8888;
750 tbm_surface_info_s info; 752 tbm_surface_info_s info;
751 int attr[] =
752 {
753 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
754 EGL_NONE,
755 };
756 753
757 switch (intformat) 754 switch (intformat)
758 { 755 {
@@ -771,7 +768,7 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
771 pt->dyn.img = secsym_eglCreateImage(egldisplay, 768 pt->dyn.img = secsym_eglCreateImage(egldisplay,
772 EGL_NO_CONTEXT, 769 EGL_NO_CONTEXT,
773 EGL_NATIVE_SURFACE_TIZEN, 770 EGL_NATIVE_SURFACE_TIZEN,
774 pt->dyn.buffer, attr); 771 pt->dyn.buffer, NULL);
775 if (!pt->dyn.img) 772 if (!pt->dyn.img)
776 { 773 {
777 secsym_tbm_surface_destroy(pt->dyn.buffer); 774 secsym_tbm_surface_destroy(pt->dyn.buffer);
@@ -848,7 +845,7 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
848 goto error; 845 goto error;
849 } 846 }
850 847
851 glBindTexture(GL_TEXTURE_2D, gc->state.current.cur_tex); 848 glBindTexture(gc->state.current.tex_target, gc->state.current.cur_tex);
852#else 849#else
853 if (gc + w + h + intformat + format) return pt; 850 if (gc + w + h + intformat + format) return pt;
854#endif 851#endif
@@ -862,7 +859,7 @@ error:
862 secsym_eglDestroyImage(egldisplay, pt->dyn.img); 859 secsym_eglDestroyImage(egldisplay, pt->dyn.img);
863 pt->dyn.img = NULL; 860 pt->dyn.img = NULL;
864 } 861 }
865 glBindTexture(GL_TEXTURE_2D, 0); 862 glBindTexture(pt->dyn.target, 0);
866 glDeleteTextures(1, &(pt->texture)); 863 glDeleteTextures(1, &(pt->texture));
867 if (pt->eina_pool) 864 if (pt->eina_pool)
868 eina_rectangle_pool_free(pt->eina_pool); 865 eina_rectangle_pool_free(pt->eina_pool);
@@ -1171,7 +1168,7 @@ evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int
1171 } 1168 }
1172 //glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 1169 //glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
1173 if (tex->pt->texture != tex->gc->state.current.cur_tex) 1170 if (tex->pt->texture != tex->gc->state.current.cur_tex)
1174 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1171 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1175} 1172}
1176 1173
1177void 1174void
@@ -1271,7 +1268,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
1271 1268
1272 if (tex->pt->texture != tex->gc->state.current.cur_tex) 1269 if (tex->pt->texture != tex->gc->state.current.cur_tex)
1273 { 1270 {
1274 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1271 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1275 } 1272 }
1276 return; 1273 return;
1277 } 1274 }
@@ -1391,7 +1388,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
1391 1388
1392 // Switch back to current texture 1389 // Switch back to current texture
1393 if (tex->ptt->texture != tex->gc->state.current.cur_tex) 1390 if (tex->ptt->texture != tex->gc->state.current.cur_tex)
1394 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1391 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1395 1392
1396 // Now prepare uploading the main texture before returning; 1393 // Now prepare uploading the main texture before returning;
1397 async = malloc(sizeof (Evas_GL_Texture_Async_Preload)); 1394 async = malloc(sizeof (Evas_GL_Texture_Async_Preload));
@@ -1529,7 +1526,7 @@ evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels,
1529 _tex_sub_2d(tex->gc, tex->x, tex->y, w, h, tex->pt->format, 1526 _tex_sub_2d(tex->gc, tex->x, tex->y, w, h, tex->pt->format,
1530 tex->pt->dataformat, pixels); 1527 tex->pt->dataformat, pixels);
1531 if (tex->pt->texture != tex->gc->state.current.cur_tex) 1528 if (tex->pt->texture != tex->gc->state.current.cur_tex)
1532 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1529 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1533} 1530}
1534 1531
1535Evas_GL_Texture * 1532Evas_GL_Texture *
@@ -1703,7 +1700,7 @@ evas_gl_common_texture_rgb_a_pair_update(Evas_GL_Texture *tex,
1703 } 1700 }
1704 } 1701 }
1705on_error: 1702on_error:
1706 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1703 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1707} 1704}
1708 1705
1709Evas_GL_Texture * 1706Evas_GL_Texture *
@@ -1886,7 +1883,7 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
1886 } 1883 }
1887 } 1884 }
1888 if (tex->pt->texture != tex->gc->state.current.cur_tex) 1885 if (tex->pt->texture != tex->gc->state.current.cur_tex)
1889 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 1886 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
1890} 1887}
1891 1888
1892static Evas_GL_Texture * 1889static Evas_GL_Texture *
@@ -2055,7 +2052,7 @@ evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
2055 } 2052 }
2056 2053
2057 if (tex->pt->texture != tex->gc->state.current.cur_tex) 2054 if (tex->pt->texture != tex->gc->state.current.cur_tex)
2058 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 2055 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
2059} 2056}
2060 2057
2061void 2058void
@@ -2110,7 +2107,7 @@ evas_gl_common_texture_nv12_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
2110 } 2107 }
2111 } 2108 }
2112 if (tex->pt->texture != tex->gc->state.current.cur_tex) 2109 if (tex->pt->texture != tex->gc->state.current.cur_tex)
2113 glBindTexture(GL_TEXTURE_2D, tex->gc->state.current.cur_tex); 2110 glBindTexture(tex->gc->state.current.tex_target, tex->gc->state.current.cur_tex);
2114} 2111}
2115 2112
2116void 2113void