summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-05-06 10:40:37 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-06 10:40:37 +0100
commit4976097bd427c09b493e428ce476b83d6427199e (patch)
tree2f6cd997ee2b7a690bf38d88b18aaf820321cb4d
parent0cfbedca07ff3c9ac3934439888cbe05469584c7 (diff)
evas_textblock: clear paragraphs during markup_set
Summary: Clear paragraph during markup set, instead of waiting until next text layout to happen, this will release unused memory right away Reviewers: woohyun, zmike, bu5hm4n, raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11773
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 932e4dd41a..ea48a10fe7 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -899,8 +899,7 @@ _image_safe_unref(Evas_Public_Data *e, void *image, Eina_Bool async)
899 * @param it the layout item to be freed 899 * @param it the layout item to be freed
900 */ 900 */
901static void 901static void
902_item_free(Evas_Public_Data *evas, 902_item_free(Efl_Canvas_Textblock_Data *o,
903 Efl_Canvas_Textblock_Data *o,
904 Evas_Object_Protected_Data *evas_o, 903 Evas_Object_Protected_Data *evas_o,
905 Evas_Object_Textblock_Line *ln, Evas_Object_Textblock_Item *it) 904 Evas_Object_Textblock_Line *ln, Evas_Object_Textblock_Item *it)
906{ 905{
@@ -917,7 +916,7 @@ _item_free(Evas_Public_Data *evas,
917 //Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); 916 //Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
918 Eina_Bool async = ti->gfx_filter->do_async; 917 Eina_Bool async = ti->gfx_filter->do_async;
919 918
920 _image_safe_unref(evas, ti->gfx_filter->output, async); 919 _image_safe_unref(evas_o->layer->evas, ti->gfx_filter->output, async);
921 ti->gfx_filter->output = NULL; 920 ti->gfx_filter->output = NULL;
922 } 921 }
923 EINA_INLIST_REMOVE(o->gfx_filter.text_items, ti->gfx_filter); 922 EINA_INLIST_REMOVE(o->gfx_filter.text_items, ti->gfx_filter);
@@ -4190,8 +4189,8 @@ _layout_update_bidi_props(const Efl_Canvas_Textblock_Data *o,
4190 * Free the visual lines in the paragraph (logical items are kept) 4189 * Free the visual lines in the paragraph (logical items are kept)
4191 */ 4190 */
4192static void 4191static void
4193_paragraph_clear(Evas_Public_Data *evas, 4192_paragraph_clear(Efl_Canvas_Textblock_Data *o,
4194 Efl_Canvas_Textblock_Data *o, Evas_Object_Protected_Data *obj, 4193 Evas_Object_Protected_Data *obj,
4195 Evas_Object_Textblock_Paragraph *par) 4194 Evas_Object_Textblock_Paragraph *par)
4196{ 4195{
4197 while (par->lines) 4196 while (par->lines)
@@ -4213,7 +4212,7 @@ _paragraph_clear(Evas_Public_Data *evas,
4213 if (ti->parent.ln == ln) 4212 if (ti->parent.ln == ln)
4214 { 4213 {
4215 o->hyphen_items = eina_list_remove_list(o->hyphen_items, i); 4214 o->hyphen_items = eina_list_remove_list(o->hyphen_items, i);
4216 _item_free(evas, o, obj, NULL, _ITEM(ti)); 4215 _item_free(o, obj, NULL, _ITEM(ti));
4217 } 4216 }
4218 } 4217 }
4219 } 4218 }
@@ -4227,17 +4226,17 @@ _paragraph_clear(Evas_Public_Data *evas,
4227 * Free the layout paragraph and all of it's lines and logical items. 4226 * Free the layout paragraph and all of it's lines and logical items.
4228 */ 4227 */
4229static void 4228static void
4230_paragraph_free(Evas_Public_Data *evas, 4229_paragraph_free(Efl_Canvas_Textblock_Data *o,
4231 Efl_Canvas_Textblock_Data *o, Evas_Object_Protected_Data *obj, 4230 Evas_Object_Protected_Data *obj,
4232 Evas_Object_Textblock_Paragraph *par) 4231 Evas_Object_Textblock_Paragraph *par)
4233{ 4232{
4234 _paragraph_clear(evas, o, obj, par); 4233 _paragraph_clear(o, obj, par);
4235 4234
4236 { 4235 {
4237 Evas_Object_Textblock_Item *it; 4236 Evas_Object_Textblock_Item *it;
4238 EINA_LIST_FREE(par->logical_items, it) 4237 EINA_LIST_FREE(par->logical_items, it)
4239 { 4238 {
4240 _item_free(evas, o, obj, NULL, it); 4239 _item_free(o, obj, NULL, it);
4241 } 4240 }
4242 } 4241 }
4243#ifdef BIDI_SUPPORT 4242#ifdef BIDI_SUPPORT
@@ -4267,7 +4266,7 @@ _paragraphs_clear(Ctxt *c)
4267 4266
4268 EINA_INLIST_FOREACH(EINA_INLIST_GET(c->paragraphs), par) 4267 EINA_INLIST_FOREACH(EINA_INLIST_GET(c->paragraphs), par)
4269 { 4268 {
4270 _paragraph_clear(c->evas, c->o, c->evas_o, par); 4269 _paragraph_clear(c->o, c->evas_o, par);
4271 } 4270 }
4272} 4271}
4273 4272
@@ -4280,8 +4279,8 @@ _paragraphs_clear(Ctxt *c)
4280 * @param c the context - Not NULL. 4279 * @param c the context - Not NULL.
4281 */ 4280 */
4282static void 4281static void
4283_paragraphs_free(Evas_Public_Data *evas, 4282_paragraphs_free(Efl_Canvas_Textblock_Data *o,
4284 Efl_Canvas_Textblock_Data *o, Evas_Object_Protected_Data *obj, 4283 Evas_Object_Protected_Data *obj,
4285 Evas_Object_Textblock_Paragraph *pars) 4284 Evas_Object_Textblock_Paragraph *pars)
4286{ 4285{
4287 o->num_paragraphs = 0; 4286 o->num_paragraphs = 0;
@@ -4292,7 +4291,7 @@ _paragraphs_free(Evas_Public_Data *evas,
4292 4291
4293 par = (Evas_Object_Textblock_Paragraph *) pars; 4292 par = (Evas_Object_Textblock_Paragraph *) pars;
4294 pars = (Evas_Object_Textblock_Paragraph *)eina_inlist_remove(EINA_INLIST_GET(pars), EINA_INLIST_GET(par)); 4293 pars = (Evas_Object_Textblock_Paragraph *)eina_inlist_remove(EINA_INLIST_GET(pars), EINA_INLIST_GET(par));
4295 _paragraph_free(evas, o, obj, par); 4294 _paragraph_free(o, obj, par);
4296 } 4295 }
4297} 4296}
4298 4297
@@ -5139,7 +5138,7 @@ _layout_item_merge_and_free(Ctxt *c,
5139 item1->parent.merge = EINA_FALSE; 5138 item1->parent.merge = EINA_FALSE;
5140 item1->parent.visually_deleted = EINA_FALSE; 5139 item1->parent.visually_deleted = EINA_FALSE;
5141 5140
5142 _item_free(c->evas, c->o, c->evas_o, NULL, _ITEM(item2)); 5141 _item_free(c->o, c->evas_o, NULL, _ITEM(item2));
5143} 5142}
5144 5143
5145/** 5144/**
@@ -5916,7 +5915,7 @@ _layout_get_hyphenationwrap(Ctxt *c, Evas_Object_Textblock_Format *fmt,
5916 } 5915 }
5917 else 5916 else
5918 { 5917 {
5919 _item_free(c->evas, c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti)); 5918 _item_free(c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti));
5920 c->hyphen_ti = NULL; 5919 c->hyphen_ti = NULL;
5921 } 5920 }
5922 } 5921 }
@@ -6021,7 +6020,7 @@ _layout_get_hyphenationwrap(Ctxt *c, Evas_Object_Textblock_Format *fmt,
6021 /* hyphen item cleanup */ 6020 /* hyphen item cleanup */
6022 if (!found_hyphen && c->hyphen_ti) 6021 if (!found_hyphen && c->hyphen_ti)
6023 { 6022 {
6024 _item_free(c->evas, c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti)); 6023 _item_free(c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti));
6025 c->hyphen_ti = NULL; 6024 c->hyphen_ti = NULL;
6026 } 6025 }
6027 6026
@@ -6177,7 +6176,7 @@ _layout_ellipsis_item_new(Ctxt *c, const Evas_Object_Textblock_Item *cur_it)
6177 size_t len = 1; /* The length of _ellip_str */ 6176 size_t len = 1; /* The length of _ellip_str */
6178 6177
6179 /* We can free it here, cause there's only one ellipsis item per tb. */ 6178 /* We can free it here, cause there's only one ellipsis item per tb. */
6180 if (c->o->ellip_ti) _item_free(c->evas, c->o, c->evas_o, NULL, _ITEM(c->o->ellip_ti)); 6179 if (c->o->ellip_ti) _item_free(c->o, c->evas_o, NULL, _ITEM(c->o->ellip_ti));
6181 c->o->ellip_ti = ellip_ti = _layout_text_item_new(c, cur_it->format); 6180 c->o->ellip_ti = ellip_ti = _layout_text_item_new(c, cur_it->format);
6182 ellip_ti->parent.text_node = cur_it->text_node; 6181 ellip_ti->parent.text_node = cur_it->text_node;
6183 ellip_ti->parent.text_pos = cur_it->text_pos; 6182 ellip_ti->parent.text_pos = cur_it->text_pos;
@@ -6576,7 +6575,7 @@ _layout_par(Ctxt *c)
6576 { 6575 {
6577 Eina_List *itr, *itr_next; 6576 Eina_List *itr, *itr_next;
6578 Evas_Object_Textblock_Item *ititr, *prev_it = NULL; 6577 Evas_Object_Textblock_Item *ititr, *prev_it = NULL;
6579 _paragraph_clear(c->evas, c->o, c->evas_o, c->par); 6578 _paragraph_clear(c->o, c->evas_o, c->par);
6580 EINA_LIST_FOREACH_SAFE(c->par->logical_items, itr, itr_next, ititr) 6579 EINA_LIST_FOREACH_SAFE(c->par->logical_items, itr, itr_next, ititr)
6581 { 6580 {
6582 if (ititr->merge && prev_it && 6581 if (ititr->merge && prev_it &&
@@ -7242,7 +7241,7 @@ _layout_pre(Ctxt *c)
7242 c->paragraphs = (Evas_Object_Textblock_Paragraph *) 7241 c->paragraphs = (Evas_Object_Textblock_Paragraph *)
7243 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs), 7242 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs),
7244 EINA_INLIST_GET(c->par)); 7243 EINA_INLIST_GET(c->par));
7245 _paragraph_free(c->evas, c->o, c->evas_o, c->par); 7244 _paragraph_free(c->o, c->evas_o, c->par);
7246 7245
7247 c->par = tmp_par; 7246 c->par = tmp_par;
7248 } 7247 }
@@ -7258,7 +7257,7 @@ _layout_pre(Ctxt *c)
7258 c->paragraphs = (Evas_Object_Textblock_Paragraph *) 7257 c->paragraphs = (Evas_Object_Textblock_Paragraph *)
7259 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs), 7258 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs),
7260 EINA_INLIST_GET(prev_par)); 7259 EINA_INLIST_GET(prev_par));
7261 _paragraph_free(c->evas, c->o, c->evas_o, prev_par); 7260 _paragraph_free(c->o, c->evas_o, prev_par);
7262 } 7261 }
7263 else 7262 else
7264 { 7263 {
@@ -7381,7 +7380,7 @@ _layout_pre(Ctxt *c)
7381 c->paragraphs = (Evas_Object_Textblock_Paragraph *) 7380 c->paragraphs = (Evas_Object_Textblock_Paragraph *)
7382 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs), 7381 eina_inlist_remove(EINA_INLIST_GET(c->paragraphs),
7383 EINA_INLIST_GET(c->par)); 7382 EINA_INLIST_GET(c->par));
7384 _paragraph_free(c->evas, c->o, c->evas_o, c->par); 7383 _paragraph_free(c->o, c->evas_o, c->par);
7385 7384
7386 c->par = tmp_par; 7385 c->par = tmp_par;
7387 } 7386 }
@@ -7514,7 +7513,7 @@ _layout_visual(Ctxt *c)
7514 while (c->par) 7513 while (c->par)
7515 { 7514 {
7516 c->par->visible = 0; 7515 c->par->visible = 0;
7517 _paragraph_clear(c->evas, c->o, c->evas_o, c->par); 7516 _paragraph_clear(c->o, c->evas_o, c->par);
7518 c->par = (Evas_Object_Textblock_Paragraph *) 7517 c->par = (Evas_Object_Textblock_Paragraph *)
7519 EINA_INLIST_GET(c->par)->next; 7518 EINA_INLIST_GET(c->par)->next;
7520 } 7519 }
@@ -8733,6 +8732,11 @@ _evas_object_textblock_text_markup_set(Eo *eo_obj, Efl_Canvas_Textblock_Data *o,
8733 } 8732 }
8734 } 8733 }
8735 8734
8735 if (o->paragraphs)
8736 {
8737 _paragraphs_free(o, obj, o->paragraphs);
8738 o->paragraphs = NULL;
8739 }
8736 _nodes_clear(eo_obj); 8740 _nodes_clear(eo_obj);
8737 8741
8738 Efl_Text_Cursor_Handle *co = o->cursor; 8742 Efl_Text_Cursor_Handle *co = o->cursor;
@@ -9471,7 +9475,7 @@ _layout_hyphen_item_new(Ctxt *c, const Evas_Object_Textblock_Text_Item *cur_ti)
9471 9475
9472 if (c->hyphen_ti) 9476 if (c->hyphen_ti)
9473 { 9477 {
9474 _item_free(c->evas, c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti)); 9478 _item_free(c->o, c->evas_o, NULL, _ITEM(c->hyphen_ti));
9475 } 9479 }
9476 c->hyphen_ti = hyphen_ti = _layout_text_item_new(c, cur_ti->parent.format); 9480 c->hyphen_ti = hyphen_ti = _layout_text_item_new(c, cur_ti->parent.format);
9477 hyphen_ti->parent.text_node = cur_ti->parent.text_node; 9481 hyphen_ti->parent.text_node = cur_ti->parent.text_node;
@@ -14153,17 +14157,13 @@ _evas_object_textblock_clear(Evas_Object *eo_obj)
14153 Eina_List *l; 14157 Eina_List *l;
14154 Efl_Text_Cursor_Handle *cur; 14158 Efl_Text_Cursor_Handle *cur;
14155 Efl_Text_Cursor_Handle *co; 14159 Efl_Text_Cursor_Handle *co;
14156 Evas *eo_e;
14157 Evas_Public_Data *evas;
14158 14160
14159 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 14161 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
14160 eo_e = evas_object_evas_get(eo_obj);
14161 evas = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
14162 evas_object_async_block(obj); 14162 evas_object_async_block(obj);
14163 Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); 14163 Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS);
14164 if (o->paragraphs) 14164 if (o->paragraphs)
14165 { 14165 {
14166 _paragraphs_free(evas, o, obj, o->paragraphs); 14166 _paragraphs_free(o, obj, o->paragraphs);
14167 o->paragraphs = NULL; 14167 o->paragraphs = NULL;
14168 } 14168 }
14169 14169
@@ -14622,11 +14622,7 @@ evas_object_textblock_free(Evas_Object *eo_obj)
14622 if (o->repch) eina_stringshare_del(o->repch); 14622 if (o->repch) eina_stringshare_del(o->repch);
14623 if (o->ellip_ti) 14623 if (o->ellip_ti)
14624 { 14624 {
14625 Evas *eo_e; 14625 _item_free(o, obj, NULL, _ITEM(o->ellip_ti));
14626 Evas_Public_Data *evas;
14627 eo_e = evas_object_evas_get(eo_obj);
14628 evas = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
14629 _item_free(evas, o, obj, NULL, _ITEM(o->ellip_ti));
14630 } 14626 }
14631 if (o->bidi_delimiters) eina_stringshare_del(o->bidi_delimiters); 14627 if (o->bidi_delimiters) eina_stringshare_del(o->bidi_delimiters);
14632 _format_command_shutdown(); 14628 _format_command_shutdown();