diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2017-02-10 13:40:44 -0800 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2017-02-10 14:27:29 -0800 |
commit | 5ac43bb26d5214ad3a3bed877339045ecd80bbc7 (patch) | |
tree | 42eb32e36729cbaf08364684e9affd2eed668803 /src/lib/evas/common | |
parent | ee52a28d041dfb02da0f2deca0714beb5eaa51fd (diff) |
evas: use the right structure to not over allocate memory.
Eina_Trash is designed for storing cached pointer without any memory
consumption. Please be careful with EFL memory consumption.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r-- | src/lib/evas/common/evas_draw_main.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/lib/evas/common/evas_draw_main.c b/src/lib/evas/common/evas_draw_main.c index 6a7c0f75da..d7c26c73f5 100644 --- a/src/lib/evas/common/evas_draw_main.c +++ b/src/lib/evas/common/evas_draw_main.c | |||
@@ -60,8 +60,8 @@ evas_common_draw_context_cutouts_del(Cutout_Rects* rects, int idx) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | static int _init_count = 0; | 62 | static int _init_count = 0; |
63 | static Eina_Trash *_ctxt_spares = NULL; | ||
63 | static int _ctxt_spares_count = 0; | 64 | static int _ctxt_spares_count = 0; |
64 | static Eina_List *_ctxt_spares = NULL; | ||
65 | static SLK(_ctx_spares_lock); | 65 | static SLK(_ctx_spares_lock); |
66 | 66 | ||
67 | static void | 67 | static void |
@@ -81,26 +81,27 @@ _evas_common_draw_context_real_free(RGBA_Draw_Context *dc) | |||
81 | static void | 81 | static void |
82 | _evas_common_draw_context_stash(RGBA_Draw_Context *dc) | 82 | _evas_common_draw_context_stash(RGBA_Draw_Context *dc) |
83 | { | 83 | { |
84 | if (_ctxt_spares_count < 8) | 84 | if (_ctxt_spares_count >= 8) |
85 | { | 85 | { |
86 | _evas_common_draw_context_real_free(dc); | ||
87 | return ; | ||
88 | } | ||
89 | |||
86 | #ifdef HAVE_PIXMAN | 90 | #ifdef HAVE_PIXMAN |
87 | # if defined(PIXMAN_FONT) || defined(PIXMAN_RECT) || defined(PIXMAN_LINE) || defined(PIXMAN_POLY) | 91 | # if defined(PIXMAN_FONT) || defined(PIXMAN_RECT) || defined(PIXMAN_LINE) || defined(PIXMAN_POLY) |
88 | if (dc->col.pixman_color_image) | 92 | if (dc->col.pixman_color_image) |
89 | { | 93 | { |
90 | pixman_image_unref(dc->col.pixman_color_image); | 94 | pixman_image_unref(dc->col.pixman_color_image); |
91 | dc->col.pixman_color_image = NULL; | 95 | dc->col.pixman_color_image = NULL; |
92 | } | 96 | } |
93 | # endif | 97 | # endif |
94 | #endif | 98 | #endif |
95 | evas_common_draw_context_apply_clean_cutouts(&dc->cutout); | 99 | evas_common_draw_context_apply_clean_cutouts(&dc->cutout); |
96 | evas_common_draw_context_cutouts_real_free(dc->cache.rects); | 100 | evas_common_draw_context_cutouts_real_free(dc->cache.rects); |
97 | SLKL(_ctx_spares_lock); | 101 | SLKL(_ctx_spares_lock); |
98 | _ctxt_spares = eina_list_prepend(_ctxt_spares, dc); | 102 | eina_trash_push(&_ctxt_spares, dc); |
99 | _ctxt_spares_count++; | 103 | _ctxt_spares_count++; |
100 | SLKU(_ctx_spares_lock); | 104 | SLKU(_ctx_spares_lock); |
101 | return; | ||
102 | } | ||
103 | _evas_common_draw_context_real_free(dc); | ||
104 | } | 105 | } |
105 | 106 | ||
106 | static RGBA_Draw_Context * | 107 | static RGBA_Draw_Context * |
@@ -108,16 +109,18 @@ _evas_common_draw_context_find(void) | |||
108 | { | 109 | { |
109 | RGBA_Draw_Context *dc; | 110 | RGBA_Draw_Context *dc; |
110 | 111 | ||
111 | if (_ctxt_spares) | 112 | if (!_ctxt_spares) |
113 | { | ||
114 | dc = malloc(sizeof(RGBA_Draw_Context)); | ||
115 | } | ||
116 | else | ||
112 | { | 117 | { |
113 | SLKL(_ctx_spares_lock); | 118 | SLKL(_ctx_spares_lock); |
114 | dc = _ctxt_spares->data; | 119 | dc = eina_trash_pop(&_ctxt_spares); |
115 | _ctxt_spares = eina_list_remove_list(_ctxt_spares, _ctxt_spares); | ||
116 | _ctxt_spares_count--; | 120 | _ctxt_spares_count--; |
117 | SLKU(_ctx_spares_lock); | 121 | SLKU(_ctx_spares_lock); |
118 | return dc; | ||
119 | } | 122 | } |
120 | dc = malloc(sizeof(RGBA_Draw_Context)); | 123 | |
121 | return dc; | 124 | return dc; |
122 | } | 125 | } |
123 | 126 | ||