diff options
author | Johannes Schickel | 2011-02-24 04:24:58 +0100 |
---|---|---|
committer | Johannes Schickel | 2011-02-24 04:24:58 +0100 |
commit | e04d983f683871d455394fcbf50e2f964aaad365 (patch) | |
tree | a67e1a1cba3a13b1e3a8845ed8c2a7439ce10780 /backends/graphics/sdl | |
parent | 9ad4ad1abc75e6393617ea9c5ca8fdfc2c8de6c4 (diff) | |
download | scummvm-rg350-e04d983f683871d455394fcbf50e2f964aaad365.tar.gz scummvm-rg350-e04d983f683871d455394fcbf50e2f964aaad365.tar.bz2 scummvm-rg350-e04d983f683871d455394fcbf50e2f964aaad365.zip |
SDL: Use the SDL_Surface's pitch in copyRectToScreen.
This fixes messed up graphics, when SDL decides to add padding bytes to the
lines of an SDL_Surface. Formerly the code always calculated the pitch via
w*bpp, which of course does not work in all cases.
Diffstat (limited to 'backends/graphics/sdl')
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 15d896c57a..d8b686e61f 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -1166,25 +1166,25 @@ void SdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int error("SDL_LockSurface failed: %s", SDL_GetError()); #ifdef USE_RGB_COLOR - byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel; - if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) { - memcpy(dst, src, h*w*_screenFormat.bytesPerPixel); + byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x * _screenFormat.bytesPerPixel; + if (_videoMode.screenWidth == w && pitch == _screen->pitch) { + memcpy(dst, src, h*pitch); } else { do { memcpy(dst, src, w * _screenFormat.bytesPerPixel); src += pitch; - dst += _videoMode.screenWidth * _screenFormat.bytesPerPixel; + dst += _screen->pitch; } while (--h); } #else - byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x; - if (_videoMode.screenWidth == pitch && pitch == w) { + byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x; + if (_screen->pitch == pitch && pitch == w) { memcpy(dst, src, h*w); } else { do { memcpy(dst, src, w); src += pitch; - dst += _videoMode.screenWidth; + dst += _screen->pitch; } while (--h); } #endif |