From ca6c41fd8c9fcb563ee5f97689806edcb0da54bf Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Sat, 17 Sep 2011 11:58:50 +0200 Subject: savage: Avoid unnecessary float calculation in video display There is no reason to do the division using floats as long as the result is an integer and there is no risk of intermediate overflow. This is in the code for "Old" chipsets. Integer division was already used in the parallel code for "New" chipsets. Also fixed up the whitespace in both blocks. Signed-off-by: Tormod Volden Reviewed-by: Matt Turner --- src/savage_video.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/savage_video.c b/src/savage_video.c index 7d571ad..5f08a18 100644 --- a/src/savage_video.c +++ b/src/savage_video.c @@ -1503,16 +1503,15 @@ SavageDisplayVideoOld( } if (S3_MOBILE_TWISTER_SERIES(psav->Chipset) - && psav->FPExpansion) { - drw_w = (((float)(drw_w * psav->XExp1)/(float)psav->XExp2)+1); - drw_h = (float)(drw_h * psav->YExp1)/(float)psav->YExp2+1; - dstBox->x1 = (float)(dstBox->x1 * psav->XExp1)/(float)psav->XExp2; - dstBox->y1 = (float)(dstBox->y1 * psav->YExp1)/(float)psav->YExp2; + && psav->FPExpansion) { + drw_w = (drw_w * psav->XExp1) / psav->XExp2 + 1; + drw_h = (drw_h * psav->YExp1) / psav->YExp2 + 1; + dstBox->x1 = (dstBox->x1 * psav->XExp1) / psav->XExp2; + dstBox->y1 = (dstBox->y1 * psav->YExp1) / psav->YExp2; dstBox->x2 = (dstBox->x2 * psav->XExp1) / psav->XExp2; dstBox->y2 = (dstBox->y2 * psav->YExp1) / psav->YExp2; - - dstBox->x1 += psav->displayXoffset; - dstBox->y1 += psav->displayYoffset; + dstBox->x1 += psav->displayXoffset; + dstBox->y1 += psav->displayYoffset; dstBox->x2 += psav->displayXoffset; dstBox->y2 += psav->displayYoffset; } @@ -1668,10 +1667,10 @@ SavageDisplayVideoNew( !psav->CrtOnly && !psav->TvOn) { - drw_w = (drw_w * psav->XExp1)/psav->XExp2 + 1; - drw_h = (drw_h * psav->YExp1)/psav->YExp2 + 1; - dstBox->x1 = (dstBox->x1 * psav->XExp1)/psav->XExp2; - dstBox->y1 = (dstBox->y1 * psav->YExp1)/psav->YExp2; + drw_w = (drw_w * psav->XExp1) / psav->XExp2 + 1; + drw_h = (drw_h * psav->YExp1) / psav->YExp2 + 1; + dstBox->x1 = (dstBox->x1 * psav->XExp1) / psav->XExp2; + dstBox->y1 = (dstBox->y1 * psav->YExp1) / psav->YExp2; dstBox->x2 = (dstBox->x2 * psav->XExp1) / psav->XExp2; dstBox->y2 = (dstBox->y2 * psav->YExp1) / psav->YExp2; dstBox->x1 += psav->displayXoffset; -- cgit v1.2.3