aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2010-01-06 20:25:07 +0000
committerVladimir Menshakov2010-01-06 20:25:07 +0000
commitb6b8a23cee82a7011b4007fa1506d42e64e0c284 (patch)
tree31d88c4ad46a4676393d18438c9d2965e499e24a
parentf32aeb01bfc905ce2fdbc5b2f79e6f91a3f7b769 (diff)
downloadscummvm-rg350-b6b8a23cee82a7011b4007fa1506d42e64e0c284.tar.gz
scummvm-rg350-b6b8a23cee82a7011b4007fa1506d42e64e0c284.tar.bz2
scummvm-rg350-b6b8a23cee82a7011b4007fa1506d42e64e0c284.zip
implemented clipping for mark
svn-id: r47092
-rw-r--r--engines/teenagent/actor.cpp20
-rw-r--r--engines/teenagent/surface.cpp21
2 files changed, 16 insertions, 25 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp
index 7872b33d9e..8385c82985 100644
--- a/engines/teenagent/actor.cpp
+++ b/engines/teenagent/actor.cpp
@@ -55,16 +55,6 @@ Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &
///\todo remove copy-paste here and below
int xp = position.x - s->w * zoom / 512 - s->x, yp = position.y - s->h * zoom / 256 - s->y;
- if (xp < 0)
- xp = 0;
- if (xp + s->w > 320)
- xp = 320 - s->w;
-
- if (yp < 0)
- yp = 0;
- if (yp + s->h > 200)
- yp = 200 - s->h;
-
return s->render(surface, xp, yp, mirror, Common::Rect(), zoom);
}
@@ -156,16 +146,6 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
clip.top = head->h;
int xp = position.x - s->w * zoom / 512 - s->x, yp = position.y - s->h * zoom / 256 - s->y;
- if (xp < 0)
- xp = 0;
- if (xp + s->w > 320)
- xp = 320 - s->w;
-
- if (yp < 0)
- yp = 0;
- if (yp + clip.top + clip.height() > 200)
- yp = 200 - clip.top - clip.height();
-
dirty = s->render(surface, xp, yp + clip.top * zoom / 256, mirror, clip, zoom);
if (head != NULL)
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index efcb294038..10bdfa7783 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -65,11 +65,22 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) {
Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect, uint zoom) const {
if (src_rect.isEmpty()) {
src_rect = Common::Rect(0, 0, w, h);
- } else if (src_rect.right > w)
- src_rect.right = w;
- else if (src_rect.bottom > h)
- src_rect.bottom = h;
-
+ }
+ {
+ 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 (right > surface->w)
+ src_rect.right -= right - surface->w;
+ if (top < 0)
+ src_rect.top -= top;
+ if (bottom > surface->h)
+ src_rect.bottom -= bottom - surface->h;
+ if (src_rect.isEmpty())
+ return Common::Rect();
+ }
+
if (zoom == 256) {
assert(x + dx + src_rect.width() <= surface->w);
assert(y + dy + src_rect.height() <= surface->h);