From c8a9eb9c3211fd9e2343d4759a25386658670d82 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 21 Aug 2010 20:14:46 +0000 Subject: GRAPHICS: Extend Surface::fill() method to support 32bits. Looks ugly svn-id: r52268 --- graphics/surface.cpp | 20 +++++++++++++++----- 1 file 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; + } } } } -- cgit v1.2.3