diff options
author | Sven Hesse | 2015-05-07 00:29:34 +0200 |
---|---|---|
committer | Sven Hesse | 2015-05-07 00:34:02 +0200 |
commit | 5bec0cbb9d9b2d29e7ffab4d1c0a0db803960754 (patch) | |
tree | 30619dee6d2a1fa37e130e19b8009417f40899e4 | |
parent | 66a4b3c8058b7e36a49a143a03fc299b99d1d625 (diff) | |
download | scummvm-rg350-5bec0cbb9d9b2d29e7ffab4d1c0a0db803960754.tar.gz scummvm-rg350-5bec0cbb9d9b2d29e7ffab4d1c0a0db803960754.tar.bz2 scummvm-rg350-5bec0cbb9d9b2d29e7ffab4d1c0a0db803960754.zip |
GOB: Make coordinate parameters in Surface::fillRect() signed
And clip to [0, width), [0, height) before drawing.
This fixes bug #6864, which is a regression I introduced in
51fd528fe56e00466255d54e1e71b19f34729bfd when I changed all
the drawing code to use the Surface class.
I thought that having unsigned coordinates makes sense, but
for some reason, Fascination sets _destSpriteX (which maps
to left in fillRect()) to -1, expecting the drawing code to
clip.
-rw-r--r-- | engines/gob/surface.cpp | 7 | ||||
-rw-r--r-- | engines/gob/surface.h | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp index 42ac2b0d74..ed83e8255c 100644 --- a/engines/gob/surface.cpp +++ b/engines/gob/surface.cpp @@ -470,7 +470,7 @@ void Surface::blitScaled(const Surface &from, Common::Rational scale, int32 tran blitScaled(from, 0, 0, from._width - 1, from._height - 1, 0, 0, scale, transp); } -void Surface::fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color) { +void Surface::fillRect(int16 left, int16 top, int16 right, int16 bottom, uint32 color) { // Just in case those are swapped if (left > right) SWAP(left, right); @@ -481,6 +481,11 @@ void Surface::fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uin // Nothing to do return; + left = CLIP<int32>(left , 0, _width - 1); + top = CLIP<int32>(top , 0, _height - 1); + right = CLIP<int32>(right , 0, _width - 1); + bottom = CLIP<int32>(bottom, 0, _height - 1); + // Area to actually fill uint16 width = CLIP<int32>(right - left + 1, 0, _width - left); uint16 height = CLIP<int32>(bottom - top + 1, 0, _height - top); diff --git a/engines/gob/surface.h b/engines/gob/surface.h index c931731908..eb0a5bf1a4 100644 --- a/engines/gob/surface.h +++ b/engines/gob/surface.h @@ -121,7 +121,7 @@ public: void blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int32 transp = -1); void blitScaled(const Surface &from, Common::Rational scale, int32 transp = -1); - void fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color); + void fillRect(int16 left, int16 top, int16 right, int16 bottom, uint32 color); void fill(uint32 color); void clear(); |