diff options
author | Gregory Montoir | 2004-12-20 00:37:20 +0000 |
---|---|---|
committer | Gregory Montoir | 2004-12-20 00:37:20 +0000 |
commit | a01abe894275dd55cb121b122f6776f54977a978 (patch) | |
tree | 007a4e1cedb87dcac1e6622b6f38d2b0b88a4eae | |
parent | 0e8d9b58d9c3586df5bbd2926c2485cef3054eb0 (diff) | |
download | scummvm-rg350-a01abe894275dd55cb121b122f6776f54977a978.tar.gz scummvm-rg350-a01abe894275dd55cb121b122f6776f54977a978.tar.bz2 scummvm-rg350-a01abe894275dd55cb121b122f6776f54977a978.zip |
added coordinates clipping to ScummFont::drawChar(), this should make valgrind happy when displaying the about window.
svn-id: r16147
-rw-r--r-- | graphics/scummfont.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/graphics/scummfont.cpp b/graphics/scummfont.cpp index 1b41bad8ee..baa7db7c39 100644 --- a/graphics/scummfont.cpp +++ b/graphics/scummfont.cpp @@ -62,16 +62,20 @@ int ScummFont::getCharWidth(byte chr) const { } //void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) { -void ScummFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const { +void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const { assert(dst != 0); - byte *ptr = (byte *)dst->pixels + x * dst->bytesPerPixel + y * dst->pitch; + byte *ptr = (byte *)dst->getBasePtr(tx, ty); const byte *tmp = guifont + 6 + guifont[4] + chr * 8; uint buffer = 0; uint mask = 0; - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + if (ty + y < 0 || ty + y >= dst->h) + continue; + for (int x = 0; x < 8; x++) { + if (tx + x < 0 || tx + x >= dst->w) + continue; unsigned char c; mask >>= 1; if (mask == 0) { |