aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
authorGregory Montoir2007-07-31 21:19:45 +0000
committerGregory Montoir2007-07-31 21:19:45 +0000
commit9bdbb470c031273a56a519de5e13136ad846a22e (patch)
treecaa0c361799fc87a6491363b4fdce309126ed7cd /engines/touche
parentd4999255b7e66cd263a203c140d4372568837c6f (diff)
downloadscummvm-rg350-9bdbb470c031273a56a519de5e13136ad846a22e.tar.gz
scummvm-rg350-9bdbb470c031273a56a519de5e13136ad846a22e.tar.bz2
scummvm-rg350-9bdbb470c031273a56a519de5e13136ad846a22e.zip
add missing clipping
svn-id: r28371
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/graphics.cpp64
1 files changed, 44 insertions, 20 deletions
diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp
index 51fdcbd89a..2ca11a1f95 100644
--- a/engines/touche/graphics.cpp
+++ b/engines/touche/graphics.cpp
@@ -177,34 +177,58 @@ void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2
}
void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) {
- if (w != 0 && h != 0) {
- dst += dstY * dstPitch + dstX;
- src += srcY * srcPitch + srcX;
- while (h--) {
- for (int i = 0; i < w; ++i) {
- if ((flags & kTransparent) == 0 || src[i] != 0) {
- dst[i] = src[i];
- }
+ if (dstX < 0) {
+ w += dstX;
+ dstX = 0;
+ }
+ if (w <= 0) {
+ return;
+ }
+ if (dstY < 0) {
+ h += dstY;
+ dstY = 0;
+ }
+ if (h <= 0) {
+ return;
+ }
+ dst += dstY * dstPitch + dstX;
+ src += srcY * srcPitch + srcX;
+ while (h--) {
+ for (int i = 0; i < w; ++i) {
+ if ((flags & kTransparent) == 0 || src[i] != 0) {
+ dst[i] = src[i];
}
- dst += dstPitch;
- src += srcPitch;
}
+ dst += dstPitch;
+ src += srcPitch;
}
}
void Graphics::copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor) {
- if (w != 0 && h != 0) {
- dst += dstY * dstPitch + dstX;
- src += srcY * srcPitch + srcX;
- while (h--) {
- for (int i = 0; i < w; ++i) {
- if (src[i] != 0) {
- dst[i] = fillColor;
- }
+ if (dstX < 0) {
+ w += dstX;
+ dstX = 0;
+ }
+ if (w <= 0) {
+ return;
+ }
+ if (dstY < 0) {
+ h += dstY;
+ dstY = 0;
+ }
+ if (h <= 0) {
+ return;
+ }
+ dst += dstY * dstPitch + dstX;
+ src += srcY * srcPitch + srcX;
+ while (h--) {
+ for (int i = 0; i < w; ++i) {
+ if (src[i] != 0) {
+ dst[i] = fillColor;
}
- dst += dstPitch;
- src += srcPitch;
}
+ dst += dstPitch;
+ src += srcPitch;
}
}