summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common
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
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_common.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c22
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c93
3 files changed, 116 insertions, 1 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index 8b56abe7b7..44999916f7 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -651,6 +651,7 @@ void evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt);
651Evas_GL_Texture *evas_gl_common_texture_new(Evas_Engine_GL_Context *gc, RGBA_Image *im, Eina_Bool disable_atlas); 651Evas_GL_Texture *evas_gl_common_texture_new(Evas_Engine_GL_Context *gc, RGBA_Image *im, Eina_Bool disable_atlas);
652Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_GL_Image *im); 652Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_GL_Image *im);
653Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil); 653Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil);
654Evas_GL_Texture *evas_gl_common_texture_render_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha);
654Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); 655Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
655void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); 656void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im);
656void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count); 657void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count);
@@ -680,6 +681,7 @@ void evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hin
680void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint); 681void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint);
681void evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc); 682void evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc);
682Evas_GL_Image *evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil); 683Evas_GL_Image *evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil);
684Evas_GL_Image *evas_gl_common_image_surface_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha);
683void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h); 685void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
684void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); 686void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
685void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level); 687void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index 99f75be2d2..0d9a5ddb21 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -743,6 +743,28 @@ evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, uns
743 return im; 743 return im;
744} 744}
745 745
746Evas_GL_Image *
747evas_gl_common_image_surface_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha)
748{
749 Evas_GL_Image *im;
750
751 if (((int)w > gc->shared->info.max_texture_size) ||
752 ((int)h > gc->shared->info.max_texture_size))
753 return NULL;
754
755 im = calloc(1, sizeof(Evas_GL_Image));
756 if (!im) return NULL;
757 im->references = 1;
758 im->gc = gc;
759 im->cs.space = EVAS_COLORSPACE_ARGB8888;
760 im->alpha = alpha;
761 im->w = w;
762 im->h = h;
763 im->tex = evas_gl_common_texture_render_noscale_new(gc, w, h, alpha);
764 im->tex_only = 1;
765 return im;
766}
767
746void 768void
747evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h) 769evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
748{ 770{
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;