summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-12-10 19:21:38 +0900
committerHermet Park <hermetpark@gmail.com>2019-12-10 19:21:38 +0900
commit8eef00a0e237c728dba6b0a6111b061398bc4c0f (patch)
treef741301a68d1a9a1d43086517b4b2bf2e14151cb
parent3329beef660f4722548e22a854a74b8572ebaee3 (diff)
Revert "evas ector: applied some memory buffer cache mechanism."
This reverts commit 3329beef660f4722548e22a854a74b8572ebaee3.
-rw-r--r--src/lib/evas/canvas/evas_render.c4
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl.h3
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c159
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c5
4 files changed, 72 insertions, 99 deletions
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c
index 0aea827..5a627a3 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -3289,6 +3289,7 @@ evas_render_updates_internal(Evas *eo_e,
3289#ifdef EVAS_RENDER_DEBUG_TIMING 3289#ifdef EVAS_RENDER_DEBUG_TIMING
3290 double start_time = _time_get(); 3290 double start_time = _time_get();
3291#endif 3291#endif
3292
3292 double time1, time2; 3293 double time1, time2;
3293 double taccum = 0.06; 3294 double taccum = 0.06;
3294 time1 = _ttime_get(); 3295 time1 = _ttime_get();
@@ -3805,7 +3806,8 @@ evas_render_updates_internal(Evas *eo_e,
3805#endif 3806#endif
3806 3807
3807 time2 = _ttime_get(); 3808 time2 = _ttime_get();
3808 ERR("elapsed = %f", time2 - time1); 3809 taccum = (taccum + (time2 - time1)) * 0.5;
3810 ERR("elapsed = %f", taccum);
3809 3811
3810 if (!do_async) _evas_render_cleanup(); 3812 if (!do_async) _evas_render_cleanup();
3811 eina_evlog("-render_end", eo_e, 0.0, NULL); 3813 eina_evlog("-render_end", eo_e, 0.0, NULL);
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl.h b/src/modules/evas/engines/gl_generic/evas_ector_gl.h
index 5a48292..6e4c46e 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl.h
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl.h
@@ -29,9 +29,6 @@
29#include "evas_ector_gl_buffer.eo.h" 29#include "evas_ector_gl_buffer.eo.h"
30#include "evas_ector_gl_image_buffer.eo.h" 30#include "evas_ector_gl_image_buffer.eo.h"
31 31
32void tizen_vd_ecache_init();
33void tizen_vd_ecache_term();
34
35#undef EAPI 32#undef EAPI
36#define EAPI 33#define EAPI
37 34
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
index 638bc94..2c6c745 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
@@ -20,110 +20,82 @@ typedef struct _Evas_Ector_GL_Buffer_Data Evas_Ector_GL_Buffer_Data;
20 20
21static int _map_id = 0; 21static int _map_id = 0;
22 22
23//////////////////////////////////////////////////////////////////////// 23typedef struct _Buffer_Cache
24/* OPTIMIZATION: A Basic Cache Buffer to save memory allocations. */
25/* This first-aid method is applied for VD caption text filter effect */
26////////////////////////////////////////////////////////////////////////
27typedef struct _Ector_Cache_Buffer
28{ 24{
29 void *buffer; 25 char *buffer;
30 int len; 26 int len;
31 Eina_Bool use : 1; 27 Eina_Bool use;
32} Ector_Cache_Buffer; 28} Buffer_Cache;
33 29
34#define BUFFER_CNT 40 30////////////////////////////////////////////////////////////////////////////////////////////////
35static Eina_Inarray *_ecache_list; 31Buffer_Cache _buffer_cache[20];
32static int _ector_cnt = 0;
36 33
37void 34char * _ector_buffer_get(int len)
38tizen_vd_ecache_init()
39{ 35{
40 _ecache_list = eina_inarray_new(sizeof(Ector_Cache_Buffer), 10); 36 for (int i = 0; i < 10; i++)
41
42 //Why 40? a experimental number of text filters.
43 eina_inarray_resize(_ecache_list, 40);
44}
45
46void
47tizen_vd_ecache_term()
48{
49 Ector_Cache_Buffer *ecb;
50 EINA_INARRAY_FOREACH(_ecache_list, ecb)
51 free(ecb->buffer);
52
53 eina_inarray_free(_ecache_list);
54 _ecache_list = NULL;
55}
56
57static void *
58_ecache_buffer_request(int len, Eina_Bool clear)
59{
60 //Get Requested size
61 Ector_Cache_Buffer *ecb;
62 EINA_INARRAY_FOREACH(_ecache_list, ecb)
63 { 37 {
64 if (ecb->use) continue; 38 if (_buffer_cache[i].use) continue;
65 39 if (_buffer_cache[i].len == 0)
66 //Get a new buffer
67 if (ecb->len == 0)
68 { 40 {
69 len = (int)(((float) len) * 1.25f); 41 _buffer_cache[i].use = 1;
70 ecb->use = EINA_TRUE; 42 _buffer_cache[i].buffer = malloc(len);
71 ecb->buffer = malloc(len); 43 _buffer_cache[i].len = len;
72 ecb->len = len; 44 printf("malloc = %d\n", len);
73 if (clear) memset(ecb->buffer, 0x0, len); 45 return _buffer_cache[i].buffer;
74 return ecb->buffer;
75 } 46 }
76 47
77 //Get an idle buffer 48 if (_buffer_cache[i].len >= len)
78 if (ecb->len >= len)
79 { 49 {
80 ecb->use = EINA_TRUE; 50 _buffer_cache[i].use = 1;
81 if (clear) memset(ecb->buffer, 0x0, ecb->len); 51 return _buffer_cache[i].buffer;
82 return ecb->buffer;
83 } 52 }
53 else
54 {
55 free(_buffer_cache[i].buffer);
56 _buffer_cache[i].use = 1;
57 _buffer_cache[i].buffer = malloc(len);
58 _buffer_cache[i].len = len;
59 printf("malloc = %d\n", len);
84 60
85 //Get an idle buffer after resizing 61 return _buffer_cache[i].buffer;
86 len = (int)(((float) len) * 1.25f); 62 }
87 ecb->buffer = realloc(ecb->buffer, len); 63 printf("What?!\n");
88 ecb->use = EINA_TRUE;
89 ecb->len = len;
90 if (clear) memset(ecb->buffer, 0x0, len);
91 return ecb->buffer;
92 } 64 }
93 65
94 //Need to push a new item 66 return NULL;
95 Ector_Cache_Buffer necb;
96 len = (int)(((float) len) * 1.25f);
97 necb.use = EINA_TRUE;
98 necb.buffer = malloc(len);
99 if (clear) memset(necb.buffer, 0x0, len);
100 necb.len = len;
101 eina_inarray_push(_ecache_list, &necb);
102
103 return necb.buffer;
104} 67}
105 68
106static Eina_Bool 69void _ector_buffer_return(char *buffer)
107_ecache_buffer_return(void *buffer)
108{ 70{
109 //Get Requested size 71 for (int i = 0; i < 10; i++)
110 Ector_Cache_Buffer *ecb;
111
112 EINA_INARRAY_FOREACH(_ecache_list, ecb)
113 { 72 {
114 if (ecb->buffer == buffer) 73 if (_buffer_cache[i].buffer == buffer)
115 { 74 {
116 ecb->use = EINA_FALSE; 75 _buffer_cache[i].use = 0;
117 return EINA_TRUE; 76 return;
118 } 77 }
119 } 78 }
79 printf("What?!\n");
80}
120 81
121 printf("what?!\n"); 82static void _ector_buffer_term()
122 return EINA_FALSE; 83{
84 for (int i = 0; i < 10; i++)
85 {
86 free(_buffer_cache[i].buffer);
87 _buffer_cache[i].buffer = NULL;
88 _buffer_cache[i].use = 0;
89 _buffer_cache[i].len = 0;
90 }
123} 91}
124//////////////////////////////////////////////////////////////////////// 92
125/* End of OPTIMIZATION */ 93static void _ector_buffer_init()
126//////////////////////////////////////////////////////////////////////// 94{
95}
96///////////////////////////////////////////////////////////////////////////////////////////////
97
98
127 99
128 100
129struct _Ector_GL_Buffer_Map 101struct _Ector_GL_Buffer_Map
@@ -259,7 +231,7 @@ on_fail:
259 evas_gl_common_image_free(pd->glim); 231 evas_gl_common_image_free(pd->glim);
260 pd->glim = NULL; 232 pd->glim = NULL;
261 */ 233 */
262 pd->image_data = _ecache_buffer_request((w * h * 4), EINA_TRUE); 234 pd->image_data = calloc(1, w * h * 4);
263 pd->w = w; 235 pd->w = w;
264 pd->h = h; 236 pd->h = h;
265 pd->re = re; 237 pd->re = re;
@@ -299,7 +271,7 @@ _image_get(Evas_Ector_GL_Buffer_Data *pd, Eina_Bool render)
299 if (tofree) 271 if (tofree)
300 evas_gl_common_image_free(old_glim); 272 evas_gl_common_image_free(old_glim);
301 273
302 _ecache_buffer_return(pd->image_data); 274 free(pd->image_data);
303 pd->image_data = NULL; 275 pd->image_data = NULL;
304 } 276 }
305 else 277 else
@@ -461,7 +433,8 @@ _evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer
461 len = W * H; 433 len = W * H;
462 if (cspace == EFL_GFX_COLORSPACE_GRY8) 434 if (cspace == EFL_GFX_COLORSPACE_GRY8)
463 { 435 {
464 uint8_t *data8 = _ecache_buffer_request(len, EINA_FALSE); 436// uint8_t *data8 = _ector_buffer_get(len);
437 uint8_t *data8 = malloc(len);
465 if (!data8) goto on_fail; 438 if (!data8) goto on_fail;
466 _pixels_argb_to_gry8_convert(data8, data, len); 439 _pixels_argb_to_gry8_convert(data8, data, len);
467 map->allocated = EINA_TRUE; 440 map->allocated = EINA_TRUE;
@@ -559,7 +532,7 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
559 532
560 if (pd->image_data != map->image_data) 533 if (pd->image_data != map->image_data)
561 { 534 {
562 _ecache_buffer_return(pd->image_data); 535 free(pd->image_data);
563 pd->image_data = map->image_data; 536 pd->image_data = map->image_data;
564 } 537 }
565 538
@@ -574,7 +547,7 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
574 547
575 if (pd->image_data != map->image_data) 548 if (pd->image_data != map->image_data)
576 { 549 {
577 _ecache_buffer_return(pd->image_data); 550 free(pd->image_data);
578 pd->image_data = map->image_data; 551 pd->image_data = map->image_data;
579 } 552 }
580 553
@@ -628,7 +601,7 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
628 601
629 if (pd->image_data != map->image_data) 602 if (pd->image_data != map->image_data)
630 { 603 {
631 _ecache_buffer_return(pd->image_data); 604 free(pd->image_data);
632 pd->image_data = map->image_data; 605 pd->image_data = map->image_data;
633 } 606 }
634 607
@@ -641,7 +614,7 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
641 } 614 }
642 if (map->allocated) 615 if (map->allocated)
643 { 616 {
644 _ecache_buffer_return(map->base_data); 617 free(map->base_data);
645 } 618 }
646 free(map); 619 free(map);
647 return; 620 return;
@@ -652,8 +625,13 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff
652} 625}
653 626
654EOLIAN static Efl_Object * 627EOLIAN static Efl_Object *
655_evas_ector_gl_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Buffer_Data *pd EINA_UNUSED) 628_evas_ector_gl_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
656{ 629{
630 if (_ector_cnt == 0)
631 _ector_buffer_init();
632
633 ++_ector_cnt;
634// printf("ector_cnt = %d", _ector_cnt);
657 /* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used 635 /* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used
658 if (!pd->glim) 636 if (!pd->glim)
659 { 637 {
@@ -668,9 +646,10 @@ _evas_ector_gl_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Buffer_Data *pd
668EOLIAN static void 646EOLIAN static void
669_evas_ector_gl_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Buffer_Data *pd) 647_evas_ector_gl_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
670{ 648{
649 --_ector_cnt;
671 evas_gl_common_image_free(pd->glim); 650 evas_gl_common_image_free(pd->glim);
672 /* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used */ 651 /* TIZEN_ONLY(20181130): evas ector - create a gl image when only it is going to be used */
673 _ecache_buffer_return(pd->image_data); 652 free(pd->image_data);
674 pd->image_data = NULL; 653 pd->image_data = NULL;
675 /* END */ 654 /* END */
676 efl_destructor(efl_super(obj, MY_CLASS)); 655 efl_destructor(efl_super(obj, MY_CLASS));
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 6ff9413..202ce6a 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -3340,17 +3340,12 @@ module_open(Evas_Module *em)
3340 3340
3341 /* now advertise out own api */ 3341 /* now advertise out own api */
3342 em->functions = (void *)(&func); 3342 em->functions = (void *)(&func);
3343
3344 tizen_vd_ecache_init();
3345
3346 return 1; 3343 return 1;
3347} 3344}
3348 3345
3349static void 3346static void
3350module_close(Evas_Module *em EINA_UNUSED) 3347module_close(Evas_Module *em EINA_UNUSED)
3351{ 3348{
3352 tizen_vd_ecache_term();
3353
3354 ector_shutdown(); 3349 ector_shutdown();
3355 if (_evas_engine_GL_log_dom >= 0) 3350 if (_evas_engine_GL_log_dom >= 0)
3356 { 3351 {