[PATCH] savage: Avoid unnecessary float calculation in video display
Matt Turner
mattst88 at gmail.com
Sat Sep 17 08:57:58 PDT 2011
On Sat, Sep 17, 2011 at 5:58 AM, Tormod Volden <lists.tormod at gmail.com> wrote:
> From: Tormod Volden <debian.tormod at gmail.com>
>
> 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 <debian.tormod at gmail.com>
> ---
> src/savage_video.c | 23 +++++++++++------------
> 1 files changed, 11 insertions(+), 12 deletions(-)
>
> 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;
> --
Reviewed-by: Matt Turner <mattst88 at gmail.com>
More information about the xorg-devel
mailing list