[Scummvm-cvs-logs] SF.net SVN: scummvm:[47098] scummvm/trunk/engines/teenagent/surface.cpp
megath at users.sourceforge.net
megath at users.sourceforge.net
Wed Jan 6 22:16:12 CET 2010
Revision: 47098
http://scummvm.svn.sourceforge.net/scummvm/?rev=47098&view=rev
Author: megath
Date: 2010-01-06 21:16:11 +0000 (Wed, 06 Jan 2010)
Log Message:
-----------
better clipping for left/top sides
Modified Paths:
--------------
scummvm/trunk/engines/teenagent/surface.cpp
Modified: scummvm/trunk/engines/teenagent/surface.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/surface.cpp 2010-01-06 21:03:52 UTC (rev 47097)
+++ scummvm/trunk/engines/teenagent/surface.cpp 2010-01-06 21:16:11 UTC (rev 47098)
@@ -69,12 +69,16 @@
{
int left = x + dx, right = left + src_rect.width();
int top = y + dy, bottom = top + src_rect.height();
- if (left < 0)
- src_rect.left -= left;
+ if (left < 0) {
+ src_rect.left = -left;
+ dx = -x;
+ }
if (right > surface->w)
src_rect.right -= right - surface->w;
- if (top < 0)
+ if (top < 0) {
src_rect.top -= top;
+ dy = -y;
+ }
if (bottom > surface->h)
src_rect.bottom -= bottom - surface->h;
if (src_rect.isEmpty())
@@ -82,19 +86,22 @@
}
if (zoom == 256) {
- assert(x + dx + src_rect.width() <= surface->w);
- assert(y + dy + src_rect.height() <= surface->h);
+ assert(x + dx >= 0 && x + dx + src_rect.width() <= surface->w);
+ assert(y + dy >= 0 && y + dy + src_rect.height() <= surface->h);
- byte *src = (byte *)getBasePtr(src_rect.left, src_rect.top);
- byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y);
+ byte *src = (byte *)getBasePtr(0, src_rect.top);
+ byte *dst_base = (byte *)surface->getBasePtr(dx + x, dy + y);
for (int i = src_rect.top; i < src_rect.bottom; ++i) {
- for (int j = 0; j < src_rect.width(); ++j) {
- byte p = src[j];
+ byte *dst = dst_base;
+ for (int j = src_rect.left; j < src_rect.right; ++j) {
+ byte p = src[(mirror? w - j - 1: j)];
if (p != 0xff)
- dst[(mirror? src_rect.width() - j - 1: j)] = p;
+ *dst++ = p;
+ else
+ ++dst;
}
- dst += surface->pitch;
+ dst_base += surface->pitch;
src += pitch;
}
src_rect.translate(x + dx, y + dy);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list