From fb5e2f56109e825ce3c446f80e075ee3dde81c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 4 Sep 2020 16:23:00 +0200 Subject: Cleanup: Clang-Tidy bugprone-incorrect-roundings fixes Should cause no noticeable difference. --- source/blender/imbuf/intern/scaling.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source/blender/imbuf/intern/scaling.c') diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 1fd9bba68f3..fbd50374711 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -22,6 +22,8 @@ * \ingroup imbuf */ +#include + #include "BLI_math_color.h" #include "BLI_math_interp.h" #include "BLI_utildefines.h" @@ -1000,10 +1002,10 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) val[3] = rect[3]; rect += 4; - newrect[0] = ((nval[0] + sample * val[0]) / add + 0.5f); - newrect[1] = ((nval[1] + sample * val[1]) / add + 0.5f); - newrect[2] = ((nval[2] + sample * val[2]) / add + 0.5f); - newrect[3] = ((nval[3] + sample * val[3]) / add + 0.5f); + newrect[0] = roundf((nval[0] + sample * val[0]) / add); + newrect[1] = roundf((nval[1] + sample * val[1]) / add); + newrect[2] = roundf((nval[2] + sample * val[2]) / add); + newrect[3] = roundf((nval[3] + sample * val[3]) / add); newrect += 4; } @@ -1142,10 +1144,10 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) val[3] = rect[3]; rect += skipx; - newrect[0] = ((nval[0] + sample * val[0]) / add + 0.5f); - newrect[1] = ((nval[1] + sample * val[1]) / add + 0.5f); - newrect[2] = ((nval[2] + sample * val[2]) / add + 0.5f); - newrect[3] = ((nval[3] + sample * val[3]) / add + 0.5f); + newrect[0] = roundf((nval[0] + sample * val[0]) / add); + newrect[1] = roundf((nval[1] + sample * val[1]) / add); + newrect[2] = roundf((nval[2] + sample * val[2]) / add); + newrect[3] = roundf((nval[3] + sample * val[3]) / add); newrect += skipx; } @@ -1573,8 +1575,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) return; } - stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5; - stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5; + stepx = round(65536.0 * (ibuf->x - 1.0) / (newx - 1.0)); + stepy = round(65536.0 * (ibuf->y - 1.0) / (newy - 1.0)); ofsy = 32768; newzbuf = _newzbuf; @@ -1713,8 +1715,8 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy newrectf = _newrectf; } - stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5; - stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5; + stepx = round(65536.0 * (ibuf->x - 1.0) / (newx - 1.0)); + stepy = round(65536.0 * (ibuf->y - 1.0) / (newy - 1.0)); ofsy = 32768; for (y = newy; y > 0; y--, ofsy += stepy) { -- cgit v1.2.3