diff options
author | Jody Northup | 2009-07-13 19:45:25 +0000 |
---|---|---|
committer | Jody Northup | 2009-07-13 19:45:25 +0000 |
commit | f7a2a9170ff9cbb3b71025c51b4fd870294b5a13 (patch) | |
tree | b9df5f8b2fa7c6dd0d43fdc2a397523522ac9431 | |
parent | 79e03a92a5782797dd5beacef3a63ed3dbdee68d (diff) | |
download | scummvm-rg350-f7a2a9170ff9cbb3b71025c51b4fd870294b5a13.tar.gz scummvm-rg350-f7a2a9170ff9cbb3b71025c51b4fd870294b5a13.tar.bz2 scummvm-rg350-f7a2a9170ff9cbb3b71025c51b4fd870294b5a13.zip |
Fixed logic error in Graphics::crossBlit which would result in no blit occuring if src and dst have the same format. Converted Graphics::crossBlit to take PixelFormats by reference, instead of copying them for each call.
svn-id: r42451
-rw-r--r-- | graphics/conversion.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/graphics/conversion.cpp b/graphics/conversion.cpp index aa544ac718..1863814c1d 100644 --- a/graphics/conversion.cpp +++ b/graphics/conversion.cpp @@ -30,7 +30,7 @@ namespace Graphics { // Function to blit a rect from one color format to another bool crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch, - int w, int h, Graphics::PixelFormat dstFmt, Graphics::PixelFormat srcFmt) { + int w, int h, const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt) { // Error out if conversion is impossible if ((srcFmt.bytesPerPixel == 1) || (dstFmt.bytesPerPixel == 1) || (!srcFmt.bytesPerPixel) || (!dstFmt.bytesPerPixel) @@ -38,8 +38,21 @@ bool crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch, return false; // Don't perform unnecessary conversion - if (srcFmt == dstFmt) - return true; + if (srcFmt == dstFmt) { + if (dst == src) + return true; + if (dstpitch == srcpitch && ((w * dstFmt.bytesPerPixel) == dstpitch)) { + memcpy(dst,src,dstpitch * h); + return true; + } else { + for (int i = 0; i < h; i++) { + memcpy(dst,src,w * dstFmt.bytesPerPixel); + dst += dstpitch; + src += srcpitch; + } + return true; + } + } // Faster, but larger, to provide optimized handling for each case. int srcDelta, dstDelta; |