aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorMax Horn2004-11-27 00:55:48 +0000
committerMax Horn2004-11-27 00:55:48 +0000
commit573cac958021b520f4bb9eaa8e3a59066bbbb5a6 (patch)
treea61db4e715048ae42563e11051e3149343faeb03 /graphics
parent876e738dce6e3725ce28d8caf1520e71edfe09f0 (diff)
downloadscummvm-rg350-573cac958021b520f4bb9eaa8e3a59066bbbb5a6.tar.gz
scummvm-rg350-573cac958021b520f4bb9eaa8e3a59066bbbb5a6.tar.bz2
scummvm-rg350-573cac958021b520f4bb9eaa8e3a59066bbbb5a6.zip
do clipping
svn-id: r15902
Diffstat (limited to 'graphics')
-rw-r--r--graphics/font.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp
index 20a604eb73..228f3b6318 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -36,9 +36,9 @@ int NewFont::getCharWidth(byte chr) const {
return desc.width[chr - desc.firstchar];
}
-void NewFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const {
+void NewFont::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);
assert(desc.bits != 0 && desc.maxwidth <= 16);
assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2);
@@ -54,19 +54,22 @@ void NewFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color)
chr -= desc.firstchar;
const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height));
- for (y = 0; y < desc.height; y++) {
+ for (int y = 0; y < desc.height; y++, ptr += dst->pitch) {
const bitmap_t buffer = *tmp++;
bitmap_t mask = 0x8000;
- for (x = 0; x < w; x++) {
+ if (ty + y < 0 || ty + y >= dst->h)
+ continue;
+
+ for (int x = 0; x < w; x++, mask >>= 1) {
+ if (tx + x < 0 || tx + x >= dst->w)
+ continue;
if ((buffer & mask) != 0) {
if (dst->bytesPerPixel == 1)
ptr[x] = color;
else if (dst->bytesPerPixel == 2)
((uint16 *)ptr)[x] = color;
}
- mask >>= 1;
}
- ptr += dst->pitch;
}
}