From 26efe177ddc405c2a94ef363e98d71868bdc3a06 Mon Sep 17 00:00:00 2001 From: Myungjae Lee Date: Wed, 6 Oct 2010 22:19:04 +0900 Subject: [PATCH] [svn merge] applied svn update from changeset 51648 to 51677 --- src/lib/cache/evas_cache_image.c | 2 +- src/lib/canvas/evas_object_textblock.c | 14 +- src/lib/engines/common/evas_font_query.c | 4 +- src/lib/include/evas_common.h | 4 +- src/modules/engines/gl_common/evas_gl_common.h | 47 +++++- src/modules/engines/gl_common/evas_gl_context.c | 140 +++++++++------- src/modules/engines/gl_common/evas_gl_image.c | 14 +- src/modules/engines/gl_common/evas_gl_texture.c | 202 +++++++++++++++++++----- src/modules/engines/gl_x11/evas_engine.c | 171 ++++++++++++-------- 9 files changed, 416 insertions(+), 182 deletions(-) diff --git a/src/lib/cache/evas_cache_image.c b/src/lib/cache/evas_cache_image.c index bba2691..9c47946 100644 --- a/src/lib/cache/evas_cache_image.c +++ b/src/lib/cache/evas_cache_image.c @@ -727,7 +727,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char * (lo->scale_down_by == 0) && (lo->dpi == 0.0) && ((lo->w == 0) || (lo->h == 0)) && - ((lo->region.w == 0) || (lo->region.w == 0)) + ((lo->region.w == 0)) )) { lo = &prevent; diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 402011e..7c3e7eb 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -2930,14 +2930,15 @@ _layout_do_format(const Evas_Object *obj, Ctxt *c, Evas_Object_Textblock_Format_Item *fi; int x2; - x2 = (fmt->tabstops * ((c->x + fmt->tabstops) / fmt->tabstops)); - if (x2 > + x2 = c->x + fmt->tabstops; + /* Wrap lines if there's a size */ + if ((c->w > 0) && (x2 > (c->w - c->o->style_pad.l - c->o->style_pad.r - - c->marginl - c->marginr)) + c->marginl - c->marginr))) { _layout_line_advance(c, fmt); - x2 = (fmt->tabstops * ((c->x + fmt->tabstops) / fmt->tabstops)); + x2 = c->x + fmt->tabstops; } if (c->ln->items) { @@ -3918,8 +3919,9 @@ evas_object_textblock_text_markup_prepend(Evas_Textblock_Cursor *cur, const char * fancier in the future, atm it breaks if this char * is inside <> */ _prepend_text_run(o, s, p); - p += 2; /* it's also advanced later in this loop */ - s = NULL; + p += 2; /* it's also advanced later in this loop need +3 + * in total*/ + s = p + 1; /* One after the end of the replacement char */ } p++; } diff --git a/src/lib/engines/common/evas_font_query.c b/src/lib/engines/common/evas_font_query.c index 5d3b71b..7b6d06e 100644 --- a/src/lib/engines/common/evas_font_query.c +++ b/src/lib/engines/common/evas_font_query.c @@ -64,7 +64,7 @@ evas_common_font_query_kerning(RGBA_Font_Int* fi, */ EAPI void -evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int *w, int *h) +evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props __UNUSED__, int *w, int *h) { int use_kerning; int pen_x, pen_y; @@ -624,7 +624,7 @@ end: */ EAPI int -evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Eina_Unicode *in_text, const Evas_BiDi_Props *intl_props, int x, int y) +evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Eina_Unicode *in_text, const Evas_BiDi_Props *intl_props __UNUSED__, int x, int y) { int use_kerning; int pen_x, pen_y; diff --git a/src/lib/include/evas_common.h b/src/lib/include/evas_common.h index b6fd5c1..a210e71 100644 --- a/src/lib/include/evas_common.h +++ b/src/lib/include/evas_common.h @@ -850,8 +850,8 @@ struct _RGBA_Font_Source void *data; int data_size; - int current_size; - + unsigned int current_size; + struct { int orig_upem; FT_Face face; diff --git a/src/modules/engines/gl_common/evas_gl_common.h b/src/modules/engines/gl_common/evas_gl_common.h index d2c734a..b957e15 100644 --- a/src/modules/engines/gl_common/evas_gl_common.h +++ b/src/modules/engines/gl_common/evas_gl_common.h @@ -98,9 +98,6 @@ #define SHAD_TEXUV2 3 #define SHAD_TEXUV3 4 -#define MAX_CUTOUT 512 -#define MAX_PIPES 128 - typedef struct _Evas_GL_Program Evas_GL_Program; typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source; typedef struct _Evas_GL_Shared Evas_GL_Shared; @@ -138,8 +135,48 @@ struct _Evas_GL_Shared Eina_Bool tex_rect : 1; Eina_Bool sec_image_map : 1; // tuning params - per gpu/cpu combo? - int cutout_max; - int pipes_max; +#define MAX_CUTOUT 512 +#define DEF_CUTOUT 512 + +// FIXME bug with pipes > 1 right now, should default to 32 +#define MAX_PIPES 128 +#define DEF_PIPES 32 +#define DEF_PIPES_SGX_540 32 +#define DEF_PIPES_TEGRA_2 1 + +#define MIN_ATLAS_ALLOC 16 +#define MAX_ATLAS_ALLOC 1024 +#define DEF_ATLAS_ALLOC 1024 + +#define MIN_ATLAS_ALLOC_ALPHA 16 +#define MAX_ATLAS_ALLOC_ALPHA 4096 +#define DEF_ATLAS_ALLOC_ALPHA 4096 + +#define MAX_ATLAS_W 512 +#define DEF_ATLAS_W 512 + +#define MAX_ATLAS_H 512 +#define DEF_ATLAS_H 512 + +#define MIN_ATLAS_SLOT 16 +#define MAX_ATLAS_SLOT 512 +#define DEF_ATLAS_SLOT 16 + + struct { + struct { + int max; + } cutout; + struct { + int max; + } pipes; + struct { + int max_alloc_size; + int max_alloc_alpha_size; + int max_w; + int max_h; + int slot_size; + } atlas; + } tune; } info; struct { diff --git a/src/modules/engines/gl_common/evas_gl_context.c b/src/modules/engines/gl_common/evas_gl_context.c index 32c1bdc..4bc2c25 100644 --- a/src/modules/engines/gl_common/evas_gl_context.c +++ b/src/modules/engines/gl_common/evas_gl_context.c @@ -439,7 +439,8 @@ evas_gl_common_context_new(void) ext = glGetString(GL_EXTENSIONS); if (ext) { - fprintf(stderr, "EXT:\n%s\n", ext); + if (getenv("EVAS_GL_INFO")) + fprintf(stderr, "EXT:\n%s\n", ext); if ((strstr((char *)ext, "GL_ARB_texture_non_power_of_two")) || (strstr((char *)ext, "OES_texture_npot")) || (strstr((char *)ext, "GL_IMG_texture_npot"))) @@ -485,53 +486,79 @@ evas_gl_common_context_new(void) // magic numbers that are a result of imperical testing and getting // "best case" performance across a range of systems - shared->info.cutout_max = 512; - shared->info.pipes_max = 32; + shared->info.tune.cutout.max = DEF_CUTOUT; + shared->info.tune.pipes.max = DEF_PIPES; + shared->info.tune.atlas.max_alloc_size = DEF_ATLAS_ALLOC; + shared->info.tune.atlas.max_alloc_alpha_size = DEF_ATLAS_ALLOC_ALPHA; + shared->info.tune.atlas.max_w = DEF_ATLAS_W; + shared->info.tune.atlas.max_h = DEF_ATLAS_H; + shared->info.tune.atlas.slot_size = DEF_ATLAS_SLOT; // per gpu hacks. based on impirical measurement of some known gpu's s = (const char *)glGetString(GL_RENDERER); if (s) { if (strstr(s, "PowerVR SGX 540")) - shared->info.pipes_max = 32; + shared->info.tune.pipes.max = DEF_PIPES_SGX_540; else if (strstr(s, "NVIDIA Tegra")) - shared->info.pipes_max = 1; + shared->info.tune.pipes.max = DEF_PIPES_TEGRA_2; } - if (getenv("EVAS_GL_CUTOUT_MAX")) - shared->info.cutout_max = atoi(getenv("EVAS_GL_CUTOUT_MAX")); - if (getenv("EVAS_GL_PIPES_MAX")) - { - shared->info.pipes_max = atoi(getenv("EVAS_GL_PIPES_MAX")); - if (shared->info.pipes_max > MAX_PIPES) - shared->info.pipes_max = MAX_PIPES; - else if (shared->info.pipes_max < 1) - shared->info.pipes_max = 1; - } - - fprintf(stderr, - "max tex size %ix%i\n" - "max units %i\n" - "non-power-2 tex %i\n" - "rect tex %i\n" - "bgra : %i\n" - "max ansiotropic filtering: %3.3f\n" - "egl sec map image: %i\n" - "\n" - "cutout max: %i\n" - "pipes max: %i\n" - , - (int)shared->info.max_texture_size, (int)shared->info.max_texture_size, - (int)shared->info.max_texture_units, - (int)shared->info.tex_npo2, - (int)shared->info.tex_rect, - (int)shared->info.bgra, - (double)shared->info.anisotropic, - (int)shared->info.sec_image_map, - - (int)shared->info.cutout_max, - (int)shared->info.pipes_max - ); +#define GETENVOPT(name, tune_param, min, max) \ + do { \ + const char *__v = getenv(name); \ + if (__v) { \ + shared->info.tune.tune_param = atoi(__v); \ + if (shared->info.tune.tune_param > max) \ + shared->info.tune.tune_param = max; \ + else if (shared->info.tune.tune_param < min) \ + shared->info.tune.tune_param = min; \ + } \ + } while (0) + + GETENVOPT("EVAS_GL_CUTOUT_MAX", cutout.max, -1, 0x7fffffff); + GETENVOPT("EVAS_GL_PIPES_MAX", pipes.max, 1, MAX_PIPES); + GETENVOPT("EVAS_GL_ATLAS_ALLOC_SIZE", atlas.max_alloc_size, MIN_ATLAS_ALLOC, MAX_ATLAS_ALLOC); + GETENVOPT("EVAS_GL_ATLAS_ALLOC_ALPHA_SIZE", atlas.max_alloc_alpha_size, MIN_ATLAS_ALLOC_ALPHA, MAX_ATLAS_ALLOC_ALPHA); + GETENVOPT("EVAS_GL_ATLAS_MAX_W", atlas.max_w, 0, MAX_ATLAS_W); + GETENVOPT("EVAS_GL_ATLAS_MAX_H", atlas.max_h, 0, MAX_ATLAS_H); + GETENVOPT("EVAS_GL_ATLAS_SLOT_SIZE", atlas.slot_size, MIN_ATLAS_SLOT, MAX_ATLAS_SLOT); + + if (getenv("EVAS_GL_INFO")) + fprintf(stderr, + "max tex size %ix%i\n" + "max units %i\n" + "non-power-2 tex %i\n" + "rect tex %i\n" + "bgra : %i\n" + "max ansiotropic filtering: %3.3f\n" + "egl sec map image: %i\n" + "max vertex count: %i\n" + "\n" + "(can set EVAS_GL_VERTEX_MAX EVAS_GL_NO_MAP_IMAGE_SEC EVAS_GL_INFO EVAS_GL_MEMINFO )\n" + "\n" + "EVAS_GL_CUTOUT_MAX: %i\n" + "EVAS_GL_PIPES_MAX: %i\n" + "EVAS_GL_ATLAS_ALLOC_SIZE: %i\n" + "EVAS_GL_ATLAS_ALLOC_ALPHA_SIZE: %i\n" + "EVAS_GL_ATLAS_MAX_W x EVAS_GL_ATLAS_MAX_H: %i x %i\n" + "EVAS_GL_ATLAS_SLOT_SIZE: %i\n" + , + (int)shared->info.max_texture_size, (int)shared->info.max_texture_size, + (int)shared->info.max_texture_units, + (int)shared->info.tex_npo2, + (int)shared->info.tex_rect, + (int)shared->info.bgra, + (double)shared->info.anisotropic, + (int)shared->info.sec_image_map, + + (int)shared->info.tune.cutout.max, + (int)shared->info.tune.pipes.max, + (int)shared->info.tune.atlas.max_alloc_size, + (int)shared->info.tune.atlas.max_alloc_alpha_size, + (int)shared->info.tune.atlas.max_w, (int)shared->info.tune.atlas.max_h, + (int)shared->info.tune.atlas.slot_size + ); glDisable(GL_DEPTH_TEST); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -661,17 +688,17 @@ evas_gl_common_context_free(Evas_GL_Context *gc) if (gc->shared) gc->shared->references--; if (gc->def_surface) evas_gl_common_image_free(gc->def_surface); - + if (gc->shared) { - for (i = 0; i < gc->shared->info.pipes_max; i++) - { - if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex); - if (gc->pipe[i].array.color) free(gc->pipe[i].array.color); - if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv); - if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); - if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); - } + for (i = 0; i < gc->shared->info.tune.pipes.max; i++) + { + if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex); + if (gc->pipe[i].array.color) free(gc->pipe[i].array.color); + if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv); + if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); + if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); + } } if ((gc->shared) && (gc->shared->references == 0)) @@ -755,7 +782,7 @@ evas_gl_common_context_newframe(Evas_GL_Context *gc) gc->state.current.cw = 0; gc->state.current.ch = 0; - for (i = 0; i < gc->shared->info.pipes_max; i++) + for (i = 0; i < gc->shared->info.tune.pipes.max; i++) { gc->pipe[i].region.x = 0; gc->pipe[i].region.y = 0; @@ -1097,7 +1124,7 @@ again: if (!found) { pn = gc->state.top_pipe + 1; - if (pn >= gc->shared->info.pipes_max) + if (pn >= gc->shared->info.tune.pipes.max) { shader_array_flush(gc); goto again; @@ -1272,7 +1299,7 @@ again: if (!found) { pn = gc->state.top_pipe + 1; - if (pn >= gc->shared->info.pipes_max) + if (pn >= gc->shared->info.tune.pipes.max) { shader_array_flush(gc); goto again; @@ -1470,7 +1497,7 @@ again: if (!found) { pn = gc->state.top_pipe + 1; - if (pn >= gc->shared->info.pipes_max) + if (pn >= gc->shared->info.tune.pipes.max) { shader_array_flush(gc); goto again; @@ -1640,7 +1667,7 @@ again: if (!found) { pn = gc->state.top_pipe + 1; - if (pn >= gc->shared->info.pipes_max) + if (pn >= gc->shared->info.tune.pipes.max) { shader_array_flush(gc); goto again; @@ -1892,7 +1919,7 @@ again: if (!found) { pn = gc->state.top_pipe + 1; - if (pn >= gc->shared->info.pipes_max) + if (pn >= gc->shared->info.tune.pipes.max) { shader_array_flush(gc); goto again; @@ -2051,7 +2078,7 @@ shader_array_flush(Evas_GL_Context *gc) { int i; - for (i = 0; i < gc->shared->info.pipes_max; i++) + for (i = 0; i < gc->shared->info.tune.pipes.max; i++) { if (gc->pipe[i].array.num <= 0) break; @@ -2144,7 +2171,8 @@ shader_array_flush(Evas_GL_Context *gc) GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } } - if (gc->pipe[i].shader.smooth != gc->state.current.smooth) + if ((gc->pipe[i].shader.smooth != gc->state.current.smooth) || + (gc->pipe[i].shader.cur_tex != gc->state.current.cur_tex)) { if (gc->pipe[i].shader.smooth) { diff --git a/src/modules/engines/gl_common/evas_gl_image.c b/src/modules/engines/gl_common/evas_gl_image.c index 4a435ba..31e40d6 100644 --- a/src/modules/engines/gl_common/evas_gl_image.c +++ b/src/modules/engines/gl_common/evas_gl_image.c @@ -9,8 +9,14 @@ evas_gl_common_image_all_unload(Evas_GL_Context *gc) EINA_LIST_FOREACH(gc->shared->images, l, im) { if (im->im) evas_cache_image_unload_data(&im->im->cache_entry); - if (im->tex) evas_gl_common_texture_free(im->tex); - im->tex = NULL; + if (im->tex) + { + if (!im->tex->pt->dyn.img) + { + evas_gl_common_texture_free(im->tex); + im->tex = NULL; + } + } } } @@ -527,8 +533,8 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy im->tex->im = im; if ((!gc->dc->cutout.rects) || - ((gc->shared->info.cutout_max > 0) && - (gc->dc->cutout.active > gc->shared->info.cutout_max))) + ((gc->shared->info.tune.cutout.max > 0) && + (gc->dc->cutout.active > gc->shared->info.tune.cutout.max))) { if (gc->dc->clip.use) { diff --git a/src/modules/engines/gl_common/evas_gl_texture.c b/src/modules/engines/gl_common/evas_gl_texture.c index c0199ab..329b70a 100644 --- a/src/modules/engines/gl_common/evas_gl_texture.c +++ b/src/modules/engines/gl_common/evas_gl_texture.c @@ -27,6 +27,29 @@ static const GLenum alpha_ifmt = GL_ALPHA; static const GLenum lum_fmt = GL_LUMINANCE; static const GLenum lum_ifmt = GL_LUMINANCE; +static struct { + struct { + int num, pix; + } c, a, v, r, n, d; +} texinfo = {0}; + +static void +_print_tex_count(void) +{ + if (getenv("EVAS_GL_MEMINFO")) + { + fprintf(stderr, + "T: c:%i/%ik | a:%i/%ik | v:%i/%ik | r:%i/%ik | n:%i/%ik | d:%i/%ik\n", + texinfo.c.num, (texinfo.c.pix * 4) / 1024, + texinfo.a.num, (texinfo.a.pix ) / 1024, + texinfo.v.num, (texinfo.v.pix ) / 1024, + texinfo.r.num, (texinfo.r.pix * 4) / 1024, + texinfo.n.num, (texinfo.n.pix * 4) / 1024, + texinfo.d.num, (texinfo.d.pix * 4) / 1024 + ); + } +} + static int _nearest_pow2(int num) { @@ -53,7 +76,8 @@ _tex_round_slot(Evas_GL_Context *gc, int h) { if (!gc->shared->info.tex_npo2) h = _nearest_pow2(h); - return (h + 15) >> 4; + return (h + gc->shared->info.tune.atlas.slot_size - 1) / + gc->shared->info.tune.atlas.slot_size; } static int @@ -99,7 +123,7 @@ _pool_tex_new(Evas_GL_Context *gc, int w, int h, int intformat, int format) pt = calloc(1, sizeof(Evas_GL_Texture_Pool)); if (!pt) return NULL; - h = _tex_round_slot(gc, h) << 4; + h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size; _tex_adjust(gc, &w, &h); pt->gc = gc; pt->w = w; @@ -108,6 +132,25 @@ _pool_tex_new(Evas_GL_Context *gc, int w, int h, int intformat, int format) pt->format = format; pt->dataformat = GL_UNSIGNED_BYTE; pt->references = 0; + + if (format == alpha_fmt) + { + texinfo.a.num++; + texinfo.a.pix += pt->w * pt->h; + } + else if (format == lum_fmt) + { + texinfo.v.num++; + texinfo.v.pix += pt->w * pt->h; + } + else + { + texinfo.c.num++; + texinfo.c.pix += pt->w * pt->h; + } + + _print_tex_count(); + glGenTextures(1, &(pt->texture)); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); glBindTexture(GL_TEXTURE_2D, pt->texture); @@ -179,8 +222,11 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, Evas_GL_Texture_Pool *pt = NULL; Eina_List *l; int th, th2; - - if ((w > 512) || (h > 512)) + + if (atlas_w > gc->shared->info.max_texture_size) + atlas_w = gc->shared->info.max_texture_size; + if ((w > gc->shared->info.tune.atlas.max_w) || + (h > gc->shared->info.tune.atlas.max_h)) { pt = _pool_tex_new(gc, w, h, intformat, format); gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, pt); @@ -233,35 +279,43 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im) if (im->cache_entry.flags.alpha) { if (gc->shared->info.bgra) - tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2, - im->cache_entry.h + 1, bgra_ifmt, bgra_fmt, - &u, &v, &l_after, 1024); + tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2, + im->cache_entry.h + 1, bgra_ifmt, bgra_fmt, + &u, &v, &l_after, + gc->shared->info.tune.atlas.max_alloc_size); else - tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2, - im->cache_entry.h + 1, rgba_ifmt, rgba_fmt, - &u, &v, &l_after, 1024); + tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2, + im->cache_entry.h + 1, rgba_ifmt, rgba_fmt, + &u, &v, &l_after, + gc->shared->info.tune.atlas.max_alloc_size); tex->alpha = 1; } else { if (gc->shared->info.bgra) - tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, - im->cache_entry.h + 1, bgr_ifmt, bgr_fmt, - &u, &v, &l_after, 1024); + tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, + im->cache_entry.h + 1, bgr_ifmt, bgr_fmt, + &u, &v, &l_after, + gc->shared->info.tune.atlas.max_alloc_size); else #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) - tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, - im->cache_entry.h + 1, rgba_ifmt, rgba_fmt, - &u, &v, &l_after, 1024); + tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, + im->cache_entry.h + 1, rgba_ifmt, rgba_fmt, + &u, &v, &l_after, + gc->shared->info.tune.atlas.max_alloc_size); #else - tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, - im->cache_entry.h + 1, rgb_ifmt, rgb_fmt, - &u, &v, &l_after, 1024); + tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, + im->cache_entry.h + 1, rgb_ifmt, rgb_fmt, + &u, &v, &l_after, + gc->shared->info.tune.atlas.max_alloc_size); #endif } if (!tex->pt) { - memset(tex, 0x11, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x11, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -287,7 +341,7 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma pt = calloc(1, sizeof(Evas_GL_Texture_Pool)); if (!pt) return NULL; - h = _tex_round_slot(gc, h) << 4; + h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size; _tex_adjust(gc, &w, &h); pt->gc = gc; pt->w = w; @@ -312,6 +366,11 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma # define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT # endif #endif + texinfo.r.num++; + texinfo.r.pix += pt->w * pt->h; + + _print_tex_count(); + glGenTextures(1, &(pt->texture)); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); glBindTexture(GL_TEXTURE_2D, pt->texture); @@ -352,6 +411,8 @@ _pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma if (im->native.target == GL_TEXTURE_RECTANGLE_ARB) { printf("REEEEEEEEECT\n"); + pt->w = w; + pt->h = h; } else #endif @@ -365,6 +426,11 @@ _pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma pt->dataformat = GL_UNSIGNED_BYTE; pt->references = 0; pt->native = 1; + texinfo.n.num++; + texinfo.n.pix += pt->w * pt->h; + + _print_tex_count(); + glGenTextures(1, &(pt->texture)); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); glBindTexture(im->native.target, pt->texture); @@ -414,7 +480,7 @@ _pool_tex_dynamic_new(Evas_GL_Context *gc, int w, int h, int intformat, int form pt = calloc(1, sizeof(Evas_GL_Texture_Pool)); if (!pt) return NULL; - h = _tex_round_slot(gc, h) << 4; + h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size; _tex_adjust(gc, &w, &h); pt->gc = gc; pt->w = w; @@ -424,6 +490,11 @@ _pool_tex_dynamic_new(Evas_GL_Context *gc, int w, int h, int intformat, int form pt->dataformat = GL_UNSIGNED_BYTE; pt->render = 1; pt->references = 0; + texinfo.d.num++; + texinfo.d.pix += pt->w * pt->h; + + _print_tex_count(); + glGenTextures(1, &(pt->texture)); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); glBindTexture(GL_TEXTURE_2D, pt->texture); @@ -538,6 +609,40 @@ pt_unref(Evas_GL_Texture_Pool *pt) { pt->references--; if (pt->references != 0) return; + + if (pt->format == alpha_fmt) + { + texinfo.a.num--; + texinfo.a.pix -= pt->w * pt->h; + } + else if (pt->format == lum_fmt) + { + texinfo.v.num--; + texinfo.v.pix -= pt->w * pt->h; + } + else if (pt->dyn.img) + { + texinfo.d.num--; + texinfo.d.pix -= pt->w * pt->h; + } + else if (pt->render) + { + texinfo.r.num--; + texinfo.r.pix -= pt->w * pt->h; + } + else if (pt->native) + { + texinfo.n.num--; + texinfo.n.pix -= pt->w * pt->h; + } + else + { + texinfo.c.num--; + texinfo.c.pix -= pt->w * pt->h; + } + + _print_tex_count(); + if (!((pt->render) || (pt->native))) { if (pt->whole) @@ -567,7 +672,10 @@ pt_unref(Evas_GL_Texture_Pool *pt) glsym_glDeleteFramebuffers(1, &(pt->fb)); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } - memset(pt, 0x22, sizeof(Evas_GL_Texture_Pool)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(pt, 0x22, sizeof(Evas_GL_Texture_Pool)); free(pt); } @@ -598,7 +706,10 @@ evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha, } if (!tex->pt) { - memset(tex, 0x33, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x33, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -637,7 +748,10 @@ evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha) } if (!tex->pt) { - memset(tex, 0x44, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x44, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -680,7 +794,10 @@ evas_gl_common_texture_dynamic_new(Evas_GL_Context *gc, Evas_GL_Image *im) } if (!tex->pt) { - memset(tex, 0x44, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x55, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -791,7 +908,10 @@ evas_gl_common_texture_free(Evas_GL_Texture *tex) } if (tex->ptu) pt_unref(tex->ptu); if (tex->ptv) pt_unref(tex->ptv); - memset(tex, 0x55, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x66, sizeof(Evas_GL_Texture)); free(tex); } @@ -802,20 +922,21 @@ evas_gl_common_texture_alpha_new(Evas_GL_Context *gc, DATA8 *pixels, Evas_GL_Texture *tex; Eina_List *l_after = NULL; int u = 0, v = 0; - int tw = 4096; tex = calloc(1, sizeof(Evas_GL_Texture)); if (!tex) return NULL; tex->gc = gc; tex->references = 1; - if (tw > gc->shared->info.max_texture_size) - tw = gc->shared->info.max_texture_size; - tex->pt = _pool_tex_find(gc, w + 3, fh, alpha_ifmt, alpha_fmt, &u, &v, - &l_after, tw); + tex->pt = _pool_tex_find(gc, w + 3, fh, alpha_ifmt, alpha_fmt, &u, &v, + &l_after, + gc->shared->info.tune.atlas.max_alloc_alpha_size); if (!tex->pt) { - memset(tex, 0x66, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x77, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -870,7 +991,10 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h) tex->pt = _pool_tex_new(gc, w + 1, h + 1, lum_ifmt, lum_fmt); if (!tex->pt) { - memset(tex, 0x77, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x88, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -882,7 +1006,10 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h) if (!tex->ptu) { pt_unref(tex->pt); - memset(tex, 0x88, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0x99, sizeof(Evas_GL_Texture)); free(tex); return NULL; } @@ -895,7 +1022,10 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h) { pt_unref(tex->pt); pt_unref(tex->ptu); - memset(tex, 0x99, sizeof(Evas_GL_Texture)); // mark as freed + // FIXME: mark as freed for now with 0x66, but this is me TRYING to + // find some mysterious bug i simply have been unable to catch or + // reproduce - so leave a trail and see how it goes. + memset(tex, 0xaa, sizeof(Evas_GL_Texture)); free(tex); return NULL; } diff --git a/src/modules/engines/gl_x11/evas_engine.c b/src/modules/engines/gl_x11/evas_engine.c index ed368f5..f9cf45f 100755 --- a/src/modules/engines/gl_x11/evas_engine.c +++ b/src/modules/engines/gl_x11/evas_engine.c @@ -25,6 +25,8 @@ struct _Render_Engine struct { // xres - dpi int dpi; // xres - dpi } xr; // xres - dpi + + int w, h; }; static int initted = 0; @@ -204,6 +206,25 @@ eng_info_free(Evas *e __UNUSED__, void *info) } static int +_re_wincheck(Render_Engine *re) +{ + if (re->win->surf) return 1; + eng_window_resurf(re->win); + if (!re->win->surf) + { + fprintf(stderr, "ERROR: GL engine can't re-create window surface!\n"); + } + return 0; +} + +static void +_re_winfree(Render_Engine *re) +{ + if (!re->win->surf) return; + eng_window_unsurf(re->win); +} + +static int eng_setup(Evas *e, void *in) { Render_Engine *re; @@ -223,17 +244,19 @@ eng_setup(Evas *e, void *in) re->info = info; re->evas = e; e->engine.data.output = re; - re->win = eng_window_new(info->info.display, - info->info.drawable, - info->info.screen, - info->info.visual, - info->info.colormap, - info->info.depth, - e->output.w, - e->output.h, - info->indirect, - info->info.destination_alpha, - info->info.rotation); + re->w = e->output.w; + re->h = e->output.h; + re->win = eng_window_new(re->info->info.display, + re->info->info.drawable, + re->info->info.screen, + re->info->info.visual, + re->info->info.colormap, + re->info->info.depth, + re->w, + re->h, + re->info->indirect, + re->info->info.destination_alpha, + re->info->info.rotation); if (!re->win) { free(re); @@ -252,7 +275,7 @@ eng_setup(Evas *e, void *in) status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val); if ((!status) || (!type)) { - if (!re->xrdb) re->xrdb = XrmGetDatabase(info->info.display); + if (!re->xrdb) re->xrdb = XrmGetDatabase(re->info->info.display); if (re->xrdb) status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val); @@ -316,67 +339,73 @@ eng_setup(Evas *e, void *in) else { re = e->engine.data.output; - if ((info->info.display != re->win->disp) || - (info->info.drawable != re->win->win) || - (info->info.screen != re->win->screen) || - (info->info.visual != re->win->visual) || - (info->info.colormap != re->win->colormap) || - (info->info.depth != re->win->depth) || - (info->info.destination_alpha != re->win->alpha) || - (info->info.rotation != re->win->rot)) + if (_re_wincheck(re)) { - int inc = 0; - - if (re->win) + if ((re->info->info.display != re->win->disp) || + (re->info->info.drawable != re->win->win) || + (re->info->info.screen != re->win->screen) || + (re->info->info.visual != re->win->visual) || + (re->info->info.colormap != re->win->colormap) || + (re->info->info.depth != re->win->depth) || + (re->info->info.destination_alpha != re->win->alpha) || + (re->info->info.rotation != re->win->rot)) { - re->win->gl_context->references++; - eng_window_free(re->win); - inc = 1; - gl_wins--; + int inc = 0; + + if (re->win) + { + re->win->gl_context->references++; + eng_window_free(re->win); + inc = 1; + gl_wins--; + } + re->w = e->output.w; + re->h = e->output.h; + re->win = eng_window_new(re->info->info.display, + re->info->info.drawable, + re->info->info.screen, + re->info->info.visual, + re->info->info.colormap, + re->info->info.depth, + re->w, + re->h, + re->info->indirect, + re->info->info.destination_alpha, + re->info->info.rotation); + if (re->win) gl_wins++; + if ((re->win) && (inc)) + re->win->gl_context->references--; } - re->win = eng_window_new(info->info.display, - info->info.drawable, - info->info.screen, - info->info.visual, - info->info.colormap, - info->info.depth, - e->output.w, - e->output.h, - info->indirect, - info->info.destination_alpha, - info->info.rotation); - if (re->win) gl_wins++; - if ((re->win) && (inc)) - re->win->gl_context->references--; - } - else if ((re->win->w != e->output.w) || - (re->win->h != e->output.h)) - { - re->win->w = e->output.w; - re->win->h = e->output.h; - eng_window_use(re->win); - evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot); - } - // added by gl77.lee - else if (info->no_swap == 1) - { - info->num_deferred_swaps = 0; - } - else if (info->no_swap == 0) - { - if (info->num_deferred_swaps > 0) + else if ((re->win->w != e->output.w) || + (re->win->h != e->output.h)) { -#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) - if (re->win->egl_disp && re->win->egl_surface[0]) - eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]); -#else - if (re->win->disp && re->win->win) - glXSwapBuffers(re->win->disp, re->win->win); -#endif - info->num_deferred_swaps = 0; + re->w = e->output.w; + re->h = e->output.h; + re->win->w = e->output.w; + re->win->h = e->output.h; + eng_window_use(re->win); + evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot); } + // added by gl77.lee + else if (info->no_swap == 1) + { + info->num_deferred_swaps = 0; + } + else if (info->no_swap == 0) + { + if (info->num_deferred_swaps > 0) + { + #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) + if (re->win->egl_disp && re->win->egl_surface[0]) + eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]); + #else + if (re->win->disp && re->win->win) + glXSwapBuffers(re->win->disp, re->win->win); + #endif + info->num_deferred_swaps = 0; + } + } } - } if (!re->win) { @@ -520,6 +549,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i re = (Render_Engine *)data; /* get the upate rect surface - return engine data as dummy */ if (!re->win->draw.redraw) return NULL; + if (!_re_wincheck(re)) return NULL; evas_gl_common_context_flush(re->win->gl_context); eng_window_use(re->win); evas_gl_common_context_newframe(re->win->gl_context); @@ -558,6 +588,7 @@ eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x re = (Render_Engine *)data; /* put back update surface.. in this case just unflag redraw */ + if (!_re_wincheck(re)) return; re->win->draw.redraw = 0; re->win->draw.drew = 1; evas_gl_common_context_flush(re->win->gl_context); @@ -592,6 +623,7 @@ eng_output_flush(void *data) Render_Engine *re; re = (Render_Engine *)data; + if (!_re_wincheck(re)) return; if (!re->win->draw.drew) return; //x// printf("frame -> flush\n"); re->win->draw.drew = 0; @@ -708,6 +740,7 @@ eng_output_dump(void *data) evas_common_image_image_all_unload(); evas_common_font_font_all_unload(); evas_gl_common_image_all_unload(re->win->gl_context); + _re_winfree(re); } static void @@ -1096,6 +1129,7 @@ eng_image_native_set(void *data, void *image, void *native) uint32_t pmid; if (!im) return NULL; + if (ns) { vis = ns->data.x11.visual; @@ -1371,9 +1405,6 @@ eng_image_free(void *data, void *image) static void eng_image_size_get(void *data, void *image, int *w, int *h) { -// Render_Engine *re; -// -// re = (Render_Engine *)data; if (!image) { *w = 0; -- 2.7.4