diff options
author | Andre Heider | 2010-04-20 20:22:33 +0000 |
---|---|---|
committer | Andre Heider | 2010-04-20 20:22:33 +0000 |
commit | 74c0db4548afbc879bbe48bd0eee228917d8ff8a (patch) | |
tree | 4d607f231cf4851fb7cacfcbefda9a293fc8b069 /graphics | |
parent | 2242ee33ac8847d503ec52bada4503830f60708a (diff) | |
download | scummvm-rg350-74c0db4548afbc879bbe48bd0eee228917d8ff8a.tar.gz scummvm-rg350-74c0db4548afbc879bbe48bd0eee228917d8ff8a.tar.bz2 scummvm-rg350-74c0db4548afbc879bbe48bd0eee228917d8ff8a.zip |
Use the faster memset() in Surface::fillRect() for 16bit modes when possible.
svn-id: r48756
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/surface.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 263a4fd23b..353803c23a 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -135,23 +135,30 @@ void Surface::fillRect(Common::Rect r, uint32 color) { return; int width = r.width(); + int lineLen = width; int height = r.height(); -// int i; + bool useMemset = true; - if (bytesPerPixel == 1) { + if (bytesPerPixel == 2) { + lineLen *= 2; + if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8)) + useMemset = false; + } else if (bytesPerPixel != 1) { + error("Surface::fillRect: bytesPerPixel must be 1 or 2"); + } + + if (useMemset) { byte *ptr = (byte *)getBasePtr(r.left, r.top); while (height--) { - memset(ptr, (byte)color, width); + memset(ptr, (byte)color, lineLen); ptr += pitch; } - } else if (bytesPerPixel == 2) { + } else { uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); while (height--) { Common::set_to(ptr, ptr + width, (uint16)color); ptr += pitch/2; } - } else { - error("Surface::fillRect: bytesPerPixel must be 1 or 2"); } } |