summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_calc.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-08-20 10:57:02 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-08-21 20:02:23 +0100
commitd436971958c144d17189a23bafaace4a4a172765 (patch)
tree24c4d3f407bc62117d880abf3b1fbca73d5bad85 /src/lib/edje/edje_calc.c
parentcfa8224140de350e24370ca4d39f5691af8555d7 (diff)
edje calc - merge 2 switch statements that are doing 2 phases
we have nigh identical switch logic, so merge these to avoid multiple switches and type matches. it localises per-type logic too which is nicer.
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_calc.c97
1 files changed, 41 insertions, 56 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 3dcdc73426..174033c925 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2815,8 +2815,8 @@ _edje_part_recalc_single_physics(Edje_Calc_Params *params,
2815#endif 2815#endif
2816 2816
2817static void 2817static void
2818_edje_part_calc_single_fixed_info(Edje *ed, Edje_Real_Part *ep, 2818_edje_part_recalc_single_fixed_info(Edje *ed, Edje_Real_Part *ep,
2819 Eina_Bool fixedw, Eina_Bool fixedh) 2819 Eina_Bool fixedw, Eina_Bool fixedh)
2820{ 2820{
2821 INF("file %s, group %s has a non-fixed part '%s'. You should add " 2821 INF("file %s, group %s has a non-fixed part '%s'. You should add "
2822 "'fixed: %d %d'. But in order to optimize the edje calc, we " 2822 "'fixed: %d %d'. But in order to optimize the edje calc, we "
@@ -2825,10 +2825,10 @@ _edje_part_calc_single_fixed_info(Edje *ed, Edje_Real_Part *ep,
2825} 2825}
2826 2826
2827static void 2827static void
2828_edje_part_calc_single_image0(Edje *ed, Edje_Real_Part *ep, 2828_edje_part_recalc_single_image0(Edje *ed, Edje_Real_Part *ep,
2829 Edje_Calc_Params *params, 2829 Edje_Calc_Params *params,
2830 Edje_Part_Description_Image *img_desc, 2830 Edje_Part_Description_Image *img_desc,
2831 FLOAT_T pos) 2831 FLOAT_T pos)
2832{ 2832{
2833 Edje_Real_Part_Set *set; 2833 Edje_Real_Part_Set *set;
2834 2834
@@ -2857,9 +2857,9 @@ _edje_part_calc_single_image0(Edje *ed, Edje_Real_Part *ep,
2857} 2857}
2858 2858
2859static void 2859static void
2860_edje_part_calc_single_text0(Edje_Calc_Params *params, 2860_edje_part_recalc_single_text0(Edje_Calc_Params *params,
2861 Edje_Part_Description_Text *text_desc, 2861 Edje_Part_Description_Text *text_desc,
2862 Edje_Color_Class *cc) 2862 Edje_Color_Class *cc)
2863{ 2863{
2864 _edje_calc_params_need_type_text(params); 2864 _edje_calc_params_need_type_text(params);
2865 /* text.align */ 2865 /* text.align */
@@ -2893,8 +2893,8 @@ _edje_part_calc_single_text0(Edje_Calc_Params *params,
2893} 2893}
2894 2894
2895static void 2895static void
2896_edje_part_calc_single_light0(Edje_Calc_Params *params, 2896_edje_part_recalc_single_light0(Edje_Calc_Params *params,
2897 Edje_Part_Description_Light *light_desc) 2897 Edje_Part_Description_Light *light_desc)
2898{ 2898{
2899 _edje_calc_params_need_type_node(params); 2899 _edje_calc_params_need_type_node(params);
2900 params->type.node->data[0] = light_desc->light.orientation.data[0]; 2900 params->type.node->data[0] = light_desc->light.orientation.data[0];
@@ -2904,8 +2904,8 @@ _edje_part_calc_single_light0(Edje_Calc_Params *params,
2904} 2904}
2905 2905
2906static void 2906static void
2907_edje_part_calc_single_camera0(Edje_Calc_Params *params, 2907_edje_part_recalc_single_camera0(Edje_Calc_Params *params,
2908 Edje_Part_Description_Camera *camera_desc) 2908 Edje_Part_Description_Camera *camera_desc)
2909{ 2909{
2910 _edje_calc_params_need_type_node(params); 2910 _edje_calc_params_need_type_node(params);
2911 params->type.node->data[0] = camera_desc->camera.orientation.data[0]; 2911 params->type.node->data[0] = camera_desc->camera.orientation.data[0];
@@ -2915,8 +2915,8 @@ _edje_part_calc_single_camera0(Edje_Calc_Params *params,
2915} 2915}
2916 2916
2917static void 2917static void
2918_edje_part_calc_single_mesh0(Edje_Calc_Params *params, 2918_edje_part_recalc_single_mesh0(Edje_Calc_Params *params,
2919 Edje_Part_Description_Mesh_Node *mesh_desc) 2919 Edje_Part_Description_Mesh_Node *mesh_desc)
2920{ 2920{
2921 _edje_calc_params_need_type_node(params); 2921 _edje_calc_params_need_type_node(params);
2922 params->type.node->frame = mesh_desc->mesh_node.mesh.frame; 2922 params->type.node->frame = mesh_desc->mesh_node.mesh.frame;
@@ -2986,7 +2986,7 @@ _edje_part_recalc_single(Edje *ed,
2986 fixedh = EINA_TRUE; 2986 fixedh = EINA_TRUE;
2987 } 2987 }
2988 if (fixedw || fixedh) 2988 if (fixedw || fixedh)
2989 _edje_part_calc_single_fixed_info(ed, ep, fixedw, fixedh); 2989 _edje_part_recalc_single_fixed_info(ed, ep, fixedw, fixedh);
2990 2990
2991 /* colors */ 2991 /* colors */
2992 if (ep->part->type != EDJE_PART_TYPE_SPACER) 2992 if (ep->part->type != EDJE_PART_TYPE_SPACER)
@@ -3034,63 +3034,33 @@ _edje_part_recalc_single(Edje *ed,
3034 // set parameters, some are required for recalc_single_text[block] 3034 // set parameters, some are required for recalc_single_text[block]
3035 switch (ep->part->type) 3035 switch (ep->part->type)
3036 { 3036 {
3037 case EDJE_PART_TYPE_IMAGE:
3038 _edje_part_calc_single_image0(ed, ep, params, (Edje_Part_Description_Image *)desc, pos);
3039 break;
3040 case EDJE_PART_TYPE_TEXT: 3037 case EDJE_PART_TYPE_TEXT:
3041 case EDJE_PART_TYPE_TEXTBLOCK: 3038 _edje_part_recalc_single_text0(params, (Edje_Part_Description_Text *)desc, cc);
3042 _edje_part_calc_single_text0(params, (Edje_Part_Description_Text *)desc, cc); 3039 // limit size if needed
3043 break; 3040 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text *)desc, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
3044 case EDJE_PART_TYPE_SPACER: 3041 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos);
3045 case EDJE_PART_TYPE_RECTANGLE:
3046 case EDJE_PART_TYPE_BOX:
3047 case EDJE_PART_TYPE_TABLE:
3048 case EDJE_PART_TYPE_SWALLOW:
3049 case EDJE_PART_TYPE_GROUP:
3050 case EDJE_PART_TYPE_PROXY:
3051 case EDJE_PART_TYPE_SNAPSHOT:
3052 case EDJE_PART_TYPE_VECTOR:
3053 break;
3054 case EDJE_PART_TYPE_LIGHT:
3055 _edje_part_calc_single_light0(params, (Edje_Part_Description_Light *)desc);
3056 break;
3057 case EDJE_PART_TYPE_CAMERA:
3058 _edje_part_calc_single_camera0(params, (Edje_Part_Description_Camera *)desc);
3059 break;
3060 case EDJE_PART_TYPE_MESH_NODE:
3061 _edje_part_calc_single_mesh0(params, (Edje_Part_Description_Mesh_Node *)desc);
3062 break;
3063 case EDJE_PART_TYPE_GRADIENT:
3064 // FIXME: THIS ONE SHOULD NEVER BE TRIGGERED
3065 break;
3066 default:
3067 break; 3042 break;
3068 }
3069
3070 // limit size if needed
3071 switch (ep->part->type)
3072 {
3073 // if we have text that wants to make the min size the text size...
3074 case EDJE_PART_TYPE_TEXTBLOCK: 3043 case EDJE_PART_TYPE_TEXTBLOCK:
3044 _edje_part_recalc_single_text0(params, (Edje_Part_Description_Text *)desc, cc);
3045 // limit size if needed
3075 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh); 3046 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
3076 break; 3047 break;
3077 case EDJE_PART_TYPE_TEXT:
3078 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text *)desc, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
3079 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos);
3080 break;
3081 // or table/box containers that want to do the same 3048 // or table/box containers that want to do the same
3082 case EDJE_PART_TYPE_TABLE: 3049 case EDJE_PART_TYPE_TABLE:
3050 // limit size if needed
3083 if (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) || 3051 if (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) ||
3084 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v))) 3052 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)))
3085 _edje_part_recalc_single_table(ep, chosen_desc, &minw, &minh); 3053 _edje_part_recalc_single_table(ep, chosen_desc, &minw, &minh);
3086 break; 3054 break;
3087 case EDJE_PART_TYPE_BOX: 3055 case EDJE_PART_TYPE_BOX:
3056 // limit size if needed
3088 if ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) || 3057 if ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) ||
3089 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)) 3058 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v))
3090 _edje_part_recalc_single_box(ep, chosen_desc, &minw, &minh); 3059 _edje_part_recalc_single_box(ep, chosen_desc, &minw, &minh);
3091 break; 3060 break;
3092 // or an image that also wants to do this
3093 case EDJE_PART_TYPE_IMAGE: 3061 case EDJE_PART_TYPE_IMAGE:
3062 _edje_part_recalc_single_image0(ed, ep, params, (Edje_Part_Description_Image *)desc, pos);
3063 // limit size if needed
3094 if (chosen_desc->min.limit || chosen_desc->max.limit) 3064 if (chosen_desc->min.limit || chosen_desc->max.limit)
3095 _edje_part_recalc_single_image(ed, ep, chosen_desc, pos, &minw, &minh, &maxw, &maxh); 3065 _edje_part_recalc_single_image(ed, ep, chosen_desc, pos, &minw, &minh, &maxw, &maxh);
3096 EINA_FALLTHROUGH; 3066 EINA_FALLTHROUGH;
@@ -3099,6 +3069,21 @@ _edje_part_recalc_single(Edje *ed,
3099 // image. proxy, snapshot share this filter recalc, so fall through 3069 // image. proxy, snapshot share this filter recalc, so fall through
3100 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos); 3070 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos);
3101 break; 3071 break;
3072 case EDJE_PART_TYPE_LIGHT:
3073 _edje_part_recalc_single_light0(params, (Edje_Part_Description_Light *)desc);
3074 break;
3075 case EDJE_PART_TYPE_CAMERA:
3076 _edje_part_recalc_single_camera0(params, (Edje_Part_Description_Camera *)desc);
3077 break;
3078 case EDJE_PART_TYPE_MESH_NODE:
3079 _edje_part_recalc_single_mesh0(params, (Edje_Part_Description_Mesh_Node *)desc);
3080 break;
3081 case EDJE_PART_TYPE_SPACER:
3082 case EDJE_PART_TYPE_RECTANGLE:
3083 case EDJE_PART_TYPE_SWALLOW:
3084 case EDJE_PART_TYPE_GROUP:
3085 case EDJE_PART_TYPE_VECTOR:
3086 case EDJE_PART_TYPE_GRADIENT: // FIXME: THIS ONE SHOULD NEVER BE TRIGGERED
3102 default: 3087 default:
3103 break; 3088 break;
3104 } 3089 }