From 379c0054dcefa0ef379e8e9ef0932786693616fd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 18 Oct 2013 00:47:22 -0700 Subject: [PATCH] Fixed bug 2123 - SDL_BlitScaled crashes in src/video/SDL_blit_N.c:2145 We need to reset the blit function when switching between scaled and unscaled blits. --- src/video/SDL_surface.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 1c4631c40..8418bc302 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -596,6 +596,12 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, h -= dy; } + /* Switch back to a fast blit if we were previously stretching */ + if (src->map->info.flags & SDL_COPY_NEAREST) { + src->map->info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } + if (w > 0 && h > 0) { SDL_Rect sr; sr.x = srcx; @@ -747,7 +753,10 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, return 0; } - src->map->info.flags |= SDL_COPY_NEAREST; + if (!(src->map->info.flags & SDL_COPY_NEAREST)) { + src->map->info.flags |= SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format &&