From 0b338bffe6017509ab6b783594cdd3c211020454 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 28 Jan 2021 15:33:47 +0100 Subject: [PATCH] Fixed bug 5510 - simplify the scaling functions --- src/video/SDL_blit_slow.c | 21 +++++---------------- src/video/sdlgenblit.pl | 21 ++++++--------------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c index c0c185619..3ef33197c 100644 --- a/src/video/SDL_blit_slow.c +++ b/src/video/SDL_blit_slow.c @@ -40,7 +40,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; SDL_PixelFormat *src_fmt = info->src_fmt; SDL_PixelFormat *dst_fmt = info->dst_fmt; @@ -49,7 +49,6 @@ SDL_Blit_Slow(SDL_BlitInfo * info) Uint32 rgbmask = ~src_fmt->Amask; Uint32 ckey = info->colorkey & rgbmask; - srcy = 0; posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; @@ -58,21 +57,11 @@ SDL_Blit_Slow(SDL_BlitInfo * info) Uint8 *src = 0; Uint8 *dst = info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = 0; + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = - (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); - } + srcx = posx >> 16; + src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); if (src_fmt->Amask) { DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB, srcA); diff --git a/src/video/sdlgenblit.pl b/src/video/sdlgenblit.pl index e26730249..63d6dc9b4 100755 --- a/src/video/sdlgenblit.pl +++ b/src/video/sdlgenblit.pl @@ -452,13 +452,12 @@ __EOF__ if ( $scale ) { print FILE <<__EOF__; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; __EOF__ print FILE <<__EOF__; - srcy = 0; posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; @@ -467,22 +466,14 @@ __EOF__ $format_type{$src} *src = 0; $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = 0; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); + srcx = posx >> 16; + src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); __EOF__ print FILE <<__EOF__; - } __EOF__ output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); print FILE <<__EOF__;