summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWoochanlee <wc0917.lee@samsung.com>2019-11-14 05:16:18 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-11-14 10:08:56 -0800
commit37b55172b0d46d71f772af8fba17e1fb1b7c6c2c (patch)
treeed54cc61ec3df037ed11d649b629d635e5845b85
parent2288c92bc5422c1a5df5fa4f6aabc2307a297e9d (diff)
edje_calc: Exception handling if no calculation is required.
If there is no object swllowed, do not run part_calc on it. This swallow will be calculated if there is an associated part, otherwise it will not need to be calculated. When the app is launched, a lot of edje calculation logic is executed. Most of the edje size is missing, so the calculation result is meaningless. Added code to prevent this. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10605
-rw-r--r--src/lib/edje/edje_calc.c37
-rw-r--r--src/lib/edje/edje_private.h1
-rw-r--r--src/lib/edje/edje_textblock.c145
3 files changed, 119 insertions, 64 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 59349b40b4..736ccb4b53 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -988,6 +988,13 @@ _edje_recalc_table_parts(Edje *ed
988 for (i = 0; i < ed->table_parts_size; i++) 988 for (i = 0; i < ed->table_parts_size; i++)
989 { 989 {
990 ep = ed->table_parts[i]; 990 ep = ed->table_parts[i];
991
992 //Ignore if the real part doesn't have swallowed object
993 if ((ep->part->type == EDJE_PART_TYPE_SWALLOW) &&
994 (ep->typedata.swallow) &&
995 (!ep->typedata.swallow->swallowed_object))
996 continue;
997
991 if (ep->calculated != FLAG_XY) // FIXME: this is always true (see for above) 998 if (ep->calculated != FLAG_XY) // FIXME: this is always true (see for above)
992 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL); 999 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
993 } 1000 }
@@ -997,6 +1004,25 @@ _edje_recalc_table_parts(Edje *ed
997} 1004}
998 1005
999void 1006void
1007_edje_recalc_textblock_style_text_set(Edje *ed)
1008{
1009 unsigned short i;
1010 Edje_Real_Part *ep;
1011 Edje_Part_Description_Text *chosen_desc;
1012
1013 for (i = 0; i < ed->table_parts_size; i++)
1014 {
1015 ep = ed->table_parts[i];
1016
1017 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1018 {
1019 _edje_part_textblock_style_text_set
1020 (ed, ep, (Edje_Part_Description_Text *)ep->chosen_description);
1021 }
1022 }
1023}
1024
1025void
1000_edje_recalc_do(Edje *ed) 1026_edje_recalc_do(Edje *ed)
1001{ 1027{
1002 unsigned short i; 1028 unsigned short i;
@@ -1005,6 +1031,17 @@ _edje_recalc_do(Edje *ed)
1005 Eina_Bool need_reinit_state = EINA_FALSE; 1031 Eina_Bool need_reinit_state = EINA_FALSE;
1006#endif 1032#endif
1007 1033
1034
1035 //Do nothing if the edje has no size, Regardless of the edje part size calc,
1036 //the text and style has to be set.
1037 if ((EINA_UNLIKELY(!ed->has_size)) && (!ed->calc_only) && (ed->w == 0) && (ed->h == 0))
1038 {
1039 _edje_recalc_textblock_style_text_set(ed);
1040
1041 return;
1042 }
1043 ed->has_size = EINA_TRUE;
1044
1008 need_calc = evas_object_smart_need_recalculate_get(ed->obj); 1045 need_calc = evas_object_smart_need_recalculate_get(ed->obj);
1009 evas_object_smart_need_recalculate_set(ed->obj, 0); 1046 evas_object_smart_need_recalculate_set(ed->obj, 0);
1010 if (!ed->dirty) return; 1047 if (!ed->dirty) return;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index c3e4e1659a..676231512f 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1807,6 +1807,7 @@ struct _Edje
1807 Eina_Bool text_part_change : 1; 1807 Eina_Bool text_part_change : 1;
1808 Eina_Bool all_part_change : 1; 1808 Eina_Bool all_part_change : 1;
1809#endif 1809#endif
1810 Eina_Bool has_size : 1;
1810}; 1811};
1811 1812
1812struct _Edje_Calc_Params_Map 1813struct _Edje_Calc_Params_Map
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index c7e58c3148..ce1015e065 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -416,91 +416,108 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
416 } 416 }
417} 417}
418 418
419void 419Eina_Bool
420_edje_part_recalc_single_textblock(FLOAT_T sc, 420_edje_part_textblock_style_text_set(Edje *ed,
421 Edje *ed, 421 Edje_Real_Part *ep,
422 Edje_Real_Part *ep, 422 Edje_Part_Description_Text *chosen_desc)
423 Edje_Part_Description_Text *chosen_desc,
424 Edje_Calc_Params *params,
425 int *minw, int *minh,
426 int *maxw, int *maxh)
427{ 423{
428 if ((ep->type != EDJE_RP_TYPE_TEXT) || 424 const char *text = "";
429 (!ep->typedata.text)) 425 const char *style = "";
430 return; 426 Evas_Textblock_Style *stl = NULL;
427 const char *tmp;
431 428
432 if (chosen_desc) 429 if (chosen_desc->text.id_source >= 0)
433 { 430 {
434 Evas_Coord tw, th; 431 Edje_Part_Description_Text *et;
435 const char *text = "";
436 const char *style = "";
437 Evas_Textblock_Style *stl = NULL;
438 const char *tmp;
439 432
440 if (chosen_desc->text.id_source >= 0) 433 ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
441 { 434
442 Edje_Part_Description_Text *et; 435 et = _edje_real_part_text_source_description_get(ep, NULL);
436 tmp = edje_string_get(&et->text.style);
437 if (tmp) style = tmp;
438 }
439 else
440 {
441 ep->typedata.text->source = NULL;
443 442
444 ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; 443 tmp = edje_string_get(&chosen_desc->text.style);
444 if (tmp) style = tmp;
445 }
445 446
446 et = _edje_real_part_text_source_description_get(ep, NULL); 447 if (chosen_desc->text.id_text_source >= 0)
447 tmp = edje_string_get(&et->text.style); 448 {
448 if (tmp) style = tmp; 449 Edje_Part_Description_Text *et;
449 } 450 Edje_Real_Part *rp;
450 else
451 {
452 ep->typedata.text->source = NULL;
453 451
454 tmp = edje_string_get(&chosen_desc->text.style); 452 ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
455 if (tmp) style = tmp;
456 }
457 453
458 if (chosen_desc->text.id_text_source >= 0) 454 et = _edje_real_part_text_text_source_description_get(ep, &rp);
455 text = edje_string_get(&et->text.text);
456
457 if (rp->typedata.text->text) text = rp->typedata.text->text;
458 }
459 else
460 {
461 ep->typedata.text->text_source = NULL;
462 text = NULL;
463 if (chosen_desc->text.domain)
459 { 464 {
460 Edje_Part_Description_Text *et; 465 if (!chosen_desc->text.text.translated)
461 Edje_Real_Part *rp; 466 chosen_desc->text.text.translated = _set_translated_string(ed, ep);
467 if (chosen_desc->text.text.translated)
468 text = chosen_desc->text.text.translated;
469 }
462 470
463 ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size]; 471 if (!text) text = edje_string_get(&chosen_desc->text.text);
464 472
465 et = _edje_real_part_text_text_source_description_get(ep, &rp); 473 if (ep->typedata.text->text) text = ep->typedata.text->text;
466 text = edje_string_get(&et->text.text); 474 }
467 475
468 if (rp->typedata.text->text) text = rp->typedata.text->text; 476 stl = _edje_textblock_style_get(ed, style);
477 if (stl)
478 {
479 if (evas_object_textblock_style_get(ep->object) != stl)
480 evas_object_textblock_style_set(ep->object, stl);
481 // FIXME: need to account for editing
482 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
483 {
484 // do nothing - should be done elsewhere
469 } 485 }
470 else 486 else
471 { 487 {
472 ep->typedata.text->text_source = NULL; 488 evas_object_textblock_text_markup_set(ep->object, text);
473 text = NULL;
474 if (chosen_desc->text.domain)
475 {
476 if (!chosen_desc->text.text.translated)
477 chosen_desc->text.text.translated = _set_translated_string(ed, ep);
478 if (chosen_desc->text.text.translated)
479 text = chosen_desc->text.text.translated;
480 }
481 if (!text)
482 text = edje_string_get(&chosen_desc->text.text);
483 if (ep->typedata.text->text) text = ep->typedata.text->text;
484 } 489 }
485 490
491 return EINA_TRUE;
492 }
493
494 return EINA_FALSE;
495}
496
497void
498_edje_part_recalc_single_textblock(FLOAT_T sc,
499 Edje *ed,
500 Edje_Real_Part *ep,
501 Edje_Part_Description_Text *chosen_desc,
502 Edje_Calc_Params *params,
503 int *minw, int *minh,
504 int *maxw, int *maxh)
505{
506 if ((ep->type != EDJE_RP_TYPE_TEXT) ||
507 (!ep->typedata.text))
508 return;
509
510 if (chosen_desc)
511 {
512 Evas_Coord tw, th;
513
486 if (ep->part->scale) 514 if (ep->part->scale)
487 evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 515 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
488 516
489 stl = _edje_textblock_style_get(ed, style); 517 //Gets textblock's style and text to set evas_object_textblock properties.
490 if (stl) 518 //If there is no style for it. don't need to calc.
519 if (_edje_part_textblock_style_text_set(ed, ep, chosen_desc))
491 { 520 {
492 if (evas_object_textblock_style_get(ep->object) != stl)
493 evas_object_textblock_style_set(ep->object, stl);
494 // FIXME: need to account for editing
495 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
496 {
497 // do nothing - should be done elsewhere
498 }
499 else
500 {
501 evas_object_textblock_text_markup_set(ep->object, text);
502 }
503
504 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y)) 521 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
505 { 522 {
506 double base_s = 1.0; 523 double base_s = 1.0;