summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common/evas_gl_texture.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-17 12:26:46 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-17 18:41:32 +0900
commit3eb0df10222d81cb1c9ec274b1f497f7c24163f8 (patch)
tree6b6e438b58618c5f17cc3d2d7f07b1a9bebcec57 /src/modules/evas/engines/gl_common/evas_gl_texture.c
parentf7b2ec8bff898f797654311ff54a507e25b878ce (diff)
evas engines - add more support for noscale pixel buffers esp in gl
for gl noscale buffers are texture atlases that are fbo's. the point is never to scale or transofmr them but to render them pixel for pixel and just store pre-rendered data where its cheaper to do this than rebuild every time. this is the enigne infra for sw and gl with the gl code... it SHOULD work... in theory...
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c93
1 files changed, 92 insertions, 1 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 ff2737f3d5..1d4b7b192e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -493,6 +493,7 @@ _pool_tex_find(Evas_Engine_GL_Context *gc, int w, int h,
493 if (th2 < 0) return NULL; 493 if (th2 < 0) return NULL;
494 EINA_LIST_FOREACH(gc->shared->tex.atlas[th2], l, pt) 494 EINA_LIST_FOREACH(gc->shared->tex.atlas[th2], l, pt)
495 { 495 {
496 if (pt->render) continue;
496 if ((*apt = _pool_tex_alloc(pt, w, h, u, v)) != NULL) 497 if ((*apt = _pool_tex_alloc(pt, w, h, u, v)) != NULL)
497 { 498 {
498 gc->shared->tex.atlas[th2] = 499 gc->shared->tex.atlas[th2] =
@@ -674,6 +675,65 @@ _pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
674} 675}
675 676
676static Evas_GL_Texture_Pool * 677static Evas_GL_Texture_Pool *
678_pool_tex_render_find(Evas_Engine_GL_Context *gc, int w, int h,
679 GLenum intformat, GLenum format, int *u, int *v,
680 Eina_Rectangle **apt, int atlas_w, Eina_Bool disable_atlas)
681{
682 Evas_GL_Texture_Pool *pt = NULL;
683 Eina_List *l;
684 int th2;
685 int pool_h;
686 /*Return texture unit without atlas*/
687 if (disable_atlas)
688 {
689 pt = _pool_tex_render_new(gc, w, h, intformat, format, EINA_FALSE);
690 return pt ? pt : NULL;
691 }
692 if (atlas_w > gc->shared->info.max_texture_size)
693 atlas_w = gc->shared->info.max_texture_size;
694 if ((w > gc->shared->info.tune.atlas.max_w) ||
695 (h > gc->shared->info.tune.atlas.max_h) ||
696 (!gc->shared->info.etc1_subimage && (intformat == etc1_fmt)))
697 {
698 pt = _pool_tex_render_new(gc, w, h, intformat, format, EINA_FALSE);
699 if (!pt) return NULL;
700 gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, pt);
701 pt->fslot = -1;
702 pt->whole = 1;
703 *apt = _pool_tex_alloc(pt, w, h, u, v);
704 return pt;
705 }
706
707 th2 = _tex_format_index(intformat);
708 if (th2 < 0) return NULL;
709 EINA_LIST_FOREACH(gc->shared->tex.atlas[th2], l, pt)
710 {
711 if (!pt->render) continue;
712 if ((*apt = _pool_tex_alloc(pt, w, h, u, v)) != NULL)
713 {
714 gc->shared->tex.atlas[th2] =
715 eina_list_promote_list(gc->shared->tex.atlas[th2], l);
716 return pt;
717 }
718 }
719 pool_h = atlas_w;
720 if ( h > pool_h || w > atlas_w )
721 {
722 atlas_w = gc->shared->info.tune.atlas.max_w;
723 pool_h = gc->shared->info.tune.atlas.max_h;
724 }
725 pt = _pool_tex_render_new(gc, atlas_w, pool_h, intformat, format, EINA_FALSE);
726 if (!pt) return NULL;
727 gc->shared->tex.atlas[th2] =
728 eina_list_prepend(gc->shared->tex.atlas[th2], pt);
729 pt->fslot = th2;
730
731 *apt = _pool_tex_alloc(pt, w, h, u, v);
732
733 return pt;
734}
735
736static Evas_GL_Texture_Pool *
677_pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format, Evas_GL_Image *im) 737_pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format, Evas_GL_Image *im)
678{ 738{
679 Evas_GL_Texture_Pool *pt; 739 Evas_GL_Texture_Pool *pt;
@@ -983,7 +1043,7 @@ pt_unref(Evas_GL_Texture_Pool *pt)
983 pt->references--; 1043 pt->references--;
984 if (pt->references != 0) return; 1044 if (pt->references != 0) return;
985 1045
986 if ((pt->gc) && !((pt->render) || (pt->native))) 1046 if ((pt->gc) && !(pt->native))
987 { 1047 {
988 if (pt->whole) 1048 if (pt->whole)
989 pt->gc->shared->tex.whole = 1049 pt->gc->shared->tex.whole =
@@ -1055,6 +1115,37 @@ evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, un
1055} 1115}
1056 1116
1057Evas_GL_Texture * 1117Evas_GL_Texture *
1118evas_gl_common_texture_render_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha)
1119{
1120 Evas_GL_Texture *tex;
1121 int u = 0, v = 0;
1122 int lformat;
1123
1124 lformat = _evas_gl_texture_search_format(alpha, gc->shared->info.bgra, EVAS_COLORSPACE_ARGB8888);
1125 if (lformat < 0) return NULL;
1126
1127 tex = evas_gl_common_texture_alloc(gc, w, h, alpha);
1128 if (!tex) return NULL;
1129 tex->pt = _pool_tex_render_find(gc, w, h,
1130 *matching_format[lformat].intformat,
1131 *matching_format[lformat].format,
1132 &u, &v, &tex->apt,
1133 // XXX: should this be another atlas size?
1134 gc->shared->info.tune.atlas.max_alloc_size,
1135 EINA_FALSE);
1136 if (!tex->pt)
1137 {
1138 evas_gl_common_texture_light_free(tex);
1139 return NULL;
1140 }
1141 tex->x = u;
1142 tex->y = v;
1143
1144 tex->pt->references++;
1145 return tex;
1146}
1147
1148Evas_GL_Texture *
1058evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im) 1149evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
1059{ 1150{
1060 Evas_GL_Texture *tex; 1151 Evas_GL_Texture *tex;