From b6b8a23cee82a7011b4007fa1506d42e64e0c284 Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Wed, 6 Jan 2010 20:25:07 +0000 Subject: implemented clipping for mark svn-id: r47092 --- engines/teenagent/actor.cpp | 20 -------------------- engines/teenagent/surface.cpp | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 25 deletions(-) (limited to 'engines/teenagent') 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); -- cgit v1.2.3