From 91d69c7dc151fabdc17b240e525181485c99b807 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 21:24:42 -0400 Subject: SHERLOCK: Simplify blitFrom methods --- engines/sherlock/surface.cpp | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'engines/sherlock/surface.cpp') diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 3e82f1dc5b..2dfbdef77f 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -62,28 +62,7 @@ void Surface::blitFrom(const Graphics::Surface &src) { * Draws a surface at a given position within this surface */ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { - Common::Rect drawRect(0, 0, src.w, src.h); - Common::Point destPt = pt; - - if (destPt.x < 0) { - drawRect.left += -destPt.x; - destPt.x = 0; - } - if (destPt.y < 0) { - drawRect.top += -destPt.y; - destPt.y = 0; - } - int right = destPt.x + src.w; - if (right > this->w) { - drawRect.right -= (right - this->w); - } - int bottom = destPt.y + src.h; - if (bottom > this->h) { - drawRect.bottom -= (bottom - this->h); - } - - if (drawRect.isValidRect()) - blitFrom(src, destPt, drawRect); + blitFrom(src, pt, Common::Rect(0, 0, src.w, src.h)); } /** @@ -91,11 +70,10 @@ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { */ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt, const Common::Rect &srcBounds) { - Common::Rect destRect(pt.x, pt.y, pt.x + srcBounds.width(), - pt.y + srcBounds.height()); Common::Rect srcRect = srcBounds; + Common::Rect destRect(pt.x, pt.y, pt.x + srcRect.width(), pt.y + srcRect.height()); - if (clip(srcRect, destRect)) { + if (srcRect.isValidRect() && clip(srcRect, destRect)) { // Surface is at least partially or completely on-screen addDirtyRect(destRect); copyRectToSurface(src, destRect.left, destRect.top, srcRect); -- cgit v1.2.3