Revert "backup filter optimization"

This reverts commit 802d575baf.
This commit is contained in:
Hermet Park 2019-12-10 19:22:01 +09:00
parent 8eef00a0e2
commit a1ea861d88
4 changed files with 5 additions and 304 deletions

View File

@ -3,8 +3,9 @@
#include <math.h>
#include <assert.h>
#ifdef EVAS_RENDER_DEBUG_TIMING
#include <sys/time.h>
#endif
// FIXME: Ugly!
#define EFL_CANVAS_FILTER_INTERNAL_PROTECTED
@ -3232,14 +3233,6 @@ _evas_planes(Evas_Public_Data *evas)
}
}
double
_ttime_get(void)
{
struct timeval timev;
gettimeofday(&timev, NULL);
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
}
static Eina_Bool
evas_render_updates_internal(Evas *eo_e,
unsigned char make_updates,
@ -3290,10 +3283,6 @@ evas_render_updates_internal(Evas *eo_e,
double start_time = _time_get();
#endif
double time1, time2;
double taccum = 0.06;
time1 = _ttime_get();
evas_render_pre(eo_e, evas);
_evas_planes(e);
@ -3805,10 +3794,6 @@ evas_render_updates_internal(Evas *eo_e,
_accumulate_time(start_time, do_async);
#endif
time2 = _ttime_get();
taccum = (taccum + (time2 - time1)) * 0.5;
ERR("elapsed = %f", taccum);
if (!do_async) _evas_render_cleanup();
eina_evlog("-render_end", eo_e, 0.0, NULL);
return rendering;

View File

@ -1768,6 +1768,7 @@ evas_filter_font_draw(Evas_Filter_Context *ctx,
Eina_Bool async_unref;
Evas_Filter_Buffer *fb;
void *surface = NULL;
fb = _filter_buffer_get(ctx, bufid);
EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);

View File

@ -20,84 +20,6 @@ typedef struct _Evas_Ector_GL_Buffer_Data Evas_Ector_GL_Buffer_Data;
static int _map_id = 0;
typedef struct _Buffer_Cache
{
char *buffer;
int len;
Eina_Bool use;
} Buffer_Cache;
////////////////////////////////////////////////////////////////////////////////////////////////
Buffer_Cache _buffer_cache[20];
static int _ector_cnt = 0;
char * _ector_buffer_get(int len)
{
for (int i = 0; i < 10; i++)
{
if (_buffer_cache[i].use) continue;
if (_buffer_cache[i].len == 0)
{
_buffer_cache[i].use = 1;
_buffer_cache[i].buffer = malloc(len);
_buffer_cache[i].len = len;
printf("malloc = %d\n", len);
return _buffer_cache[i].buffer;
}
if (_buffer_cache[i].len >= len)
{
_buffer_cache[i].use = 1;
return _buffer_cache[i].buffer;
}
else
{
free(_buffer_cache[i].buffer);
_buffer_cache[i].use = 1;
_buffer_cache[i].buffer = malloc(len);
_buffer_cache[i].len = len;
printf("malloc = %d\n", len);
return _buffer_cache[i].buffer;
}
printf("What?!\n");
}
return NULL;
}
void _ector_buffer_return(char *buffer)
{
for (int i = 0; i < 10; i++)
{
if (_buffer_cache[i].buffer == buffer)
{
_buffer_cache[i].use = 0;
return;
}
}
printf("What?!\n");
}
static void _ector_buffer_term()
{
for (int i = 0; i < 10; i++)
{
free(_buffer_cache[i].buffer);
_buffer_cache[i].buffer = NULL;
_buffer_cache[i].use = 0;
_buffer_cache[i].len = 0;
}
}
static void _ector_buffer_init()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////
struct _Ector_GL_Buffer_Map
{
EINA_INLIST;
@ -119,10 +41,6 @@ struct _Evas_Ector_GL_Buffer_Data
Evas_GL_Image *glim;
Eina_Bool alpha_only, was_render;
Ector_GL_Buffer_Map *maps;
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used */
int w, h;
void *image_data;
/* END */
};
void *eng_image_data_put(void *data, void *image, DATA32 *image_data);
@ -192,33 +110,20 @@ _evas_ector_gl_buffer_gl_buffer_prepare(Eo *obj, Evas_Ector_GL_Buffer_Data *pd,
Ector_Buffer_Flag flags EINA_UNUSED)
{
Render_Engine_GL_Generic *re = engine;
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
Evas_Engine_GL_Context *gc;
Evas_GL_Image *im;
// this is meant to be called only once
EINA_SAFETY_ON_FALSE_GOTO(!pd->re, on_fail);
EINA_SAFETY_ON_FALSE_GOTO(!efl_finalized_get(obj), on_fail);
*/
EINA_SAFETY_ON_FALSE_RETURN(!pd->re);
EINA_SAFETY_ON_FALSE_RETURN(!efl_finalized_get(obj));
/* END */
if (cspace == EFL_GFX_COLORSPACE_ARGB8888)
pd->alpha_only = EINA_FALSE;
else if (cspace == EFL_GFX_COLORSPACE_GRY8)
pd->alpha_only = EINA_TRUE;
else
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
fail("Unsupported colorspace: %u", cspace);
*/
{
ERR("Unsupported colorspace: %u", cspace);
return;
}
/* END */
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
pd->re = re;
gc = gl_generic_context_find(re, 1);
im = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
@ -230,13 +135,6 @@ _evas_ector_gl_buffer_gl_buffer_prepare(Eo *obj, Evas_Ector_GL_Buffer_Data *pd,
on_fail:
evas_gl_common_image_free(pd->glim);
pd->glim = NULL;
*/
pd->image_data = calloc(1, w * h * 4);
pd->w = w;
pd->h = h;
pd->re = re;
pd->glim = NULL;
/* END */
}
static inline void *
@ -245,44 +143,8 @@ _image_get(Evas_Ector_GL_Buffer_Data *pd, Eina_Bool render)
if (pd->maps != NULL)
fail("Image is currently mapped!");
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (!pd->glim || !pd->glim->tex || !pd->glim->tex->pt)
fail("Image has no texture!");
*/
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used */
if (pd->glim == NULL)
{
Evas_Engine_GL_Context *gc = gl_generic_context_find(pd->re, 1);
if (render)
{
Evas_GL_Image *old_glim = NULL, *im = NULL;
Eina_Bool tofree = EINA_FALSE;
DATA32 *data = NULL;
int err;
pd->glim = evas_gl_common_image_surface_new(gc, pd->w, pd->h, EINA_TRUE, EINA_FALSE);
im = eng_image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree);
old_glim = pd->glim;
memcpy(data, pd->image_data, pd->w * pd->h * 4);
pd->glim = evas_gl_common_image_surface_update(im);
if (tofree)
evas_gl_common_image_free(old_glim);
free(pd->image_data);
pd->image_data = NULL;
}
else
{
gc = gl_generic_context_find(pd->re, 1);
pd->glim = evas_gl_common_image_new_from_data(gc, pd->w, pd->h, pd->image_data, EINA_TRUE, EFL_GFX_COLORSPACE_ARGB8888);
evas_gl_common_image_dirty(pd->glim, 0, 0, 0, 0);
evas_gl_common_image_update(gc, pd->glim);
}
}
/* END */
evas_gl_common_image_ref(pd->glim);
if (render)
@ -332,13 +194,8 @@ _evas_ector_gl_buffer_ector_buffer_size_get(const Eo *obj EINA_UNUSED,
Evas_Ector_GL_Buffer_Data *pd,
int *w, int *h)
{
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (w) *w = pd->glim->w;
if (h) *h = pd->glim->h;
*/
if (w) *w = pd->w;
if (h) *h = pd->h;
/* END */
}
EOLIAN static Efl_Gfx_Colorspace
@ -375,18 +232,12 @@ _evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer
uint32_t *data;
int pxs;
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
W = pd->glim->w;
H = pd->glim->h;
*/
W = pd->w;
H = pd->h;
/* END */
if (!w) w = W - x;
if (!h) h = H - y;
if ((x + w > W) || (y + h > H)) return NULL;
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (write && _evas_gl_image_is_fbo(pd->glim))
{
// Can not open FBO data to write!
@ -398,27 +249,6 @@ _evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer
im = eng_image_data_get(ENC, pd->glim, write, &data, &err, &tofree);
if (!im) return NULL;
}
*/
if (pd->glim)
{
if (write && _evas_gl_image_is_fbo(pd->glim))
{
// Can not open FBO data to write!
im = eng_image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree);
if (!im) return NULL;
}
else
{
im = eng_image_data_get(ENC, pd->glim, write, &data, &err, &tofree);
if (!im) return NULL;
}
}
else
{
data = pd->image_data;
tofree = EINA_FALSE;
}
/* END */
map = calloc(1, sizeof(*map));
map->mode = mode;
@ -433,8 +263,8 @@ _evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer
len = W * H;
if (cspace == EFL_GFX_COLORSPACE_GRY8)
{
// uint8_t *data8 = _ector_buffer_get(len);
uint8_t *data8 = malloc(len);
if (!data8) goto on_fail;
_pixels_argb_to_gry8_convert(data8, data, len);
map->allocated = EINA_TRUE;
@ -483,18 +313,12 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
Evas_GL_Image *old_glim = pd->glim;
int W, H;
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
W = pd->glim->w;
H = pd->glim->h;
*/
W = pd->w;
H = pd->h;
/* END */
if (map->cspace == EFL_GFX_COLORSPACE_GRY8)
_pixels_gry8_to_argb_convert(map->image_data, map->base_data, W * H);
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (map->im)
{
MAP_DUMP(map->im, "out_w_free");
@ -506,61 +330,9 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
MAP_DUMP(old_glim, "out_w_nofree");
pd->glim = evas_gl_common_image_surface_update(old_glim);
}
*/
if (pd->glim)
{
if (pd->was_render)
{
if (map->im)
{
MAP_DUMP(map->im, "out_w_free");
pd->glim = evas_gl_common_image_surface_update(map->im);
evas_gl_common_image_free(old_glim);
}
else
{
MAP_DUMP(old_glim, "out_w_nofree");
pd->glim = evas_gl_common_image_surface_update(old_glim);
}
}
else
{
if (map->im)
{
MAP_DUMP(map->im, "out_w_free");
pd->glim = eng_image_data_put(ENC, map->im, map->image_data);
if (pd->image_data != map->image_data)
{
free(pd->image_data);
pd->image_data = map->image_data;
}
evas_gl_common_image_free(old_glim);
evas_gl_common_image_dirty(pd->glim, 0, 0, 0, 0);
evas_gl_common_image_update(pd->glim->gc, pd->glim);
}
else
{
MAP_DUMP(old_glim, "out_w_nofree");
pd->glim = eng_image_data_put(ENC, pd->glim, map->image_data);
if (pd->image_data != map->image_data)
{
free(pd->image_data);
pd->image_data = map->image_data;
}
evas_gl_common_image_dirty(pd->glim, 0, 0, 0, 0);
evas_gl_common_image_update(pd->glim->gc, pd->glim);
}
}
}
/* END */
}
else
{
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (map->im)
{
MAP_DUMP(map->im, "out_ro_free");
@ -571,51 +343,9 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
MAP_DUMP(pd->glim, "out_ro_nofree");
pd->glim = eng_image_data_put(ENC, pd->glim, map->image_data);
}
*/
if (pd->glim)
{
if (pd->was_render)
{
if (map->im)
{
MAP_DUMP(map->im, "out_ro_free");
eng_image_free(ENC, map->im);
}
else
{
MAP_DUMP(pd->glim, "out_ro_nofree");
pd->glim = eng_image_data_put(ENC, pd->glim, map->image_data);
}
}
else
{
if (map->im)
{
MAP_DUMP(map->im, "out_ro_free");
eng_image_free(ENC, map->im);
}
else
{
MAP_DUMP(pd->glim, "out_ro_nofree");
pd->glim = eng_image_data_put(ENC, pd->glim, map->image_data);
if (pd->image_data != map->image_data)
{
free(pd->image_data);
pd->image_data = map->image_data;
}
evas_gl_common_image_dirty(pd->glim, 0, 0, 0, 0);
evas_gl_common_image_update(pd->glim->gc, pd->glim);
}
}
}
/* END */
}
if (map->allocated)
{
free(map->base_data);
}
free(map->base_data);
free(map);
return;
}
@ -627,31 +357,18 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
EOLIAN static Efl_Object *
_evas_ector_gl_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
{
if (_ector_cnt == 0)
_ector_buffer_init();
++_ector_cnt;
// printf("ector_cnt = %d", _ector_cnt);
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
if (!pd->glim)
{
ERR("Buffer was not initialized properly!");
return NULL;
}
*/
/* END */
return efl_finalize(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_evas_ector_gl_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
{
--_ector_cnt;
evas_gl_common_image_free(pd->glim);
/* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used */
free(pd->image_data);
pd->image_data = NULL;
/* END */
efl_destructor(efl_super(obj, MY_CLASS));
}

View File

@ -3115,8 +3115,6 @@ eng_image_surface_noscale_new(void *engine, int w, int h, int alpha)
static GL_Filter_Apply_Func
_gfx_filter_func_get(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
{
return NULL;
GL_Filter_Apply_Func funcptr = NULL;
switch (cmd->mode)