jaehwan pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7cce8ae40d7b9d607448135f0384605395537c32
commit 7cce8ae40d7b9d607448135f0384605395537c32 Author: Jaehwan Kim <[email protected]> Date: Tue Nov 29 14:03:20 2016 +0900 edje_calc: round the scaled value when it is casted to int type. It rounds the value for the more precious calculation when the scaled value is casted to int type. --- src/lib/edje/edje_calc.c | 16 ++++++++-------- src/lib/edje/edje_private.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 1d97be9..251dad5 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -2266,7 +2266,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, } *minw = mnw; - if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw)); + if (ep->part->scale) *minw = TO_INT_ROUND(SCALE(sc, *minw)); if ((ep->type == EDJE_RP_TYPE_SWALLOW) && (ep->typedata.swallow)) { @@ -2293,7 +2293,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxw = mxw; if (*maxw > 0) { - if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (ep->part->scale) *maxw = TO_INT_ROUND(SCALE(sc, *maxw)); if (*maxw < 1) *maxw = 1; } } @@ -2306,7 +2306,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxw = mxw; if (*maxw > 0) { - if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (ep->part->scale) *maxw = TO_INT_ROUND(SCALE(sc, *maxw)); if (*maxw < 1) *maxw = 1; } if (ep->typedata.swallow->swallow_params.max.w < *maxw) @@ -2319,7 +2319,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxw = mxw; if (*maxw > 0) { - if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (ep->part->scale) *maxw = TO_INT_ROUND(SCALE(sc, *maxw)); if (*maxw < 1) *maxw = 1; } } @@ -2331,7 +2331,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, } *minh = mnh; - if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh)); + if (ep->part->scale) *minh = TO_INT_ROUND(SCALE(sc, *minh)); if ((ep->type == EDJE_RP_TYPE_SWALLOW) && (ep->typedata.swallow)) { @@ -2358,7 +2358,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxh = mxh; if (*maxh > 0) { - if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (ep->part->scale) *maxh = TO_INT_ROUND(SCALE(sc, *maxh)); if (*maxh < 1) *maxh = 1; } } @@ -2371,7 +2371,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxh = mxh; if (*maxh > 0) { - if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (ep->part->scale) *maxh = TO_INT_ROUND(SCALE(sc, *maxh)); if (*maxh < 1) *maxh = 1; } if (ep->typedata.swallow->swallow_params.max.h < *maxh) @@ -2384,7 +2384,7 @@ _edje_part_recalc_single_min_max(FLOAT_T sc, *maxh = mxh; if (*maxh > 0) { - if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (ep->part->scale) *maxh = TO_INT_ROUND(SCALE(sc, *maxh)); if (*maxh < 1) *maxh = 1; } } diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 3e610d2..9a0fd21 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -148,6 +148,7 @@ EAPI extern int _edje_default_log_dom ; #define FROM_DOUBLE(a) eina_f32p32_double_from(a) #define FROM_INT(a) eina_f32p32_int_from(a) #define TO_INT(a) eina_f32p32_int_to(a) +#define TO_INT_ROUND(a) eina_f32p32_int_to(ADD(a, FROM_DOUBLE(0.5))) #define ZERO 0 #define COS(a) eina_f32p32_cos(a) #define SIN(a) eina_f32p32_sin(a) @@ -168,6 +169,7 @@ EAPI extern int _edje_default_log_dom ; #define FROM_DOUBLE(a) (a) #define FROM_INT(a) (double)(a) #define TO_INT(a) (int)(a) +#define TO_INT_ROUND(a) (int)(a + 0.5) #define ZERO 0.0 #define COS(a) cos(a) #define SIN(a) sin(a) --
