diff options
author | Eugene Sandulenko | 2010-08-21 20:14:46 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-08-21 20:14:46 +0000 |
commit | c8a9eb9c3211fd9e2343d4759a25386658670d82 (patch) | |
tree | aabe9a9f7768833ab3599818279087b8049cd48c | |
parent | 5cd3ea41db71b4521954cd65bc9775c1bbeabb9f (diff) | |
download | scummvm-rg350-c8a9eb9c3211fd9e2343d4759a25386658670d82.tar.gz scummvm-rg350-c8a9eb9c3211fd9e2343d4759a25386658670d82.tar.bz2 scummvm-rg350-c8a9eb9c3211fd9e2343d4759a25386658670d82.zip |
GRAPHICS: Extend Surface::fill() method to support 32bits. Looks ugly
svn-id: r52268
-rw-r--r-- | graphics/surface.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 353803c23a..137ef29a4e 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -143,8 +143,10 @@ void Surface::fillRect(Common::Rect r, uint32 color) { lineLen *= 2; if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8)) useMemset = false; + } else if (bytesPerPixel == 4) { + useMemset = false; } else if (bytesPerPixel != 1) { - error("Surface::fillRect: bytesPerPixel must be 1 or 2"); + error("Surface::fillRect: bytesPerPixel must be 1, 2 or 4"); } if (useMemset) { @@ -154,10 +156,18 @@ void Surface::fillRect(Common::Rect r, uint32 color) { ptr += pitch; } } else { - uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); - while (height--) { - Common::set_to(ptr, ptr + width, (uint16)color); - ptr += pitch/2; + if (bytesPerPixel == 2) { + uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); + while (height--) { + Common::set_to(ptr, ptr + width, (uint16)color); + ptr += pitch/2; + } + } else { + uint32 *ptr = (uint32 *)getBasePtr(r.left, r.top); + while (height--) { + Common::set_to(ptr, ptr + width, color); + ptr += pitch / 4; + } } } } |