diff options
-rw-r--r-- | engines/tsage/graphics.cpp | 43 | ||||
-rw-r--r-- | engines/tsage/graphics.h | 12 |
2 files changed, 25 insertions, 30 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index 4db898662f..8436afe2e8 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -659,7 +659,7 @@ void GfxSurface::mergeDirtyRects() { rInner = rOuter; while (++rInner != _dirtyRects.end()) { - if (looseIntersectRectangle(*rOuter, *rInner)) { + if ((*rOuter).intersects(*rInner)) { // these two rectangles overlap or // are next to each other - merge them @@ -676,22 +676,6 @@ void GfxSurface::mergeDirtyRects() { } /** - * Check if the two rectangles are next to each other. - * @param pSrc1 a source rectangle - * @param pSrc2 a source rectangle - */ -bool GfxSurface::looseIntersectRectangle(const Rect &src1, const Rect &src2) { - Rect destRect; - - destRect.left = MAX(src1.left, src2.left); - destRect.top = MAX(src1.top, src2.top); - destRect.right = MIN(src1.right, src2.right); - destRect.bottom = MIN(src1.bottom, src2.bottom); - - return destRect.isValidRect(); -} - -/** * Creates the union of two rectangles. * Returns True if there is a union. * @param pDest destination rectangle that is to receive the new union @@ -699,10 +683,8 @@ bool GfxSurface::looseIntersectRectangle(const Rect &src1, const Rect &src2) { * @param pSrc2 a source rectangle */ bool GfxSurface::unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2) { - destRect.left = MIN(src1.left, src2.left); - destRect.top = MIN(src1.top, src2.top); - destRect.right = MAX(src1.right, src2.right); - destRect.bottom = MAX(src1.bottom, src2.bottom); + destRect = src1; + destRect.extend(src2); return !destRect.isEmpty(); } @@ -1319,6 +1301,25 @@ int GfxManager::getAngle(const Common::Point &p1, const Common::Point &p2) { return result; } } + + +void GfxManager::copyFrom(GfxSurface &src, Rect destBounds, Region *priorityRegion) { + if (&_surface == &(GLOBALS._screenSurface)) + _surface.setBounds(Rect(0, 0, _bounds.width(), _bounds.height())); + else + _surface.setBounds(_bounds); + + _surface.copyFrom(src, destBounds, priorityRegion); +} +void GfxManager::copyFrom(GfxSurface &src, int destX, int destY) { + if (&_surface == &(GLOBALS._screenSurface)) + _surface.setBounds(Rect(0, 0, _bounds.width(), _bounds.height())); + else + _surface.setBounds(_bounds); + + _surface.copyFrom(src, destX, destY); +} + /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h index ba4090317b..9c6f13e407 100644 --- a/engines/tsage/graphics.h +++ b/engines/tsage/graphics.h @@ -83,7 +83,6 @@ private: Common::List<Rect> _dirtyRects; void mergeDirtyRects(); - bool looseIntersectRectangle(const Rect &src1, const Rect &src2); bool unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2); public: @@ -302,14 +301,9 @@ public: virtual void set(byte *dest, int size, byte val) { Common::fill(dest, dest + size, val); } - void copyFrom(GfxSurface &src, Rect destBounds, Region *priorityRegion = NULL) { - _surface.setBounds(_bounds); - _surface.copyFrom(src, destBounds, priorityRegion); - } - void copyFrom(GfxSurface &src, int destX, int destY) { - _surface.setBounds(_bounds); - _surface.copyFrom(src, destX, destY); - } + void copyFrom(GfxSurface &src, Rect destBounds, Region *priorityRegion = NULL); + void copyFrom(GfxSurface &src, int destX, int destY); + GfxSurface &getSurface() { _surface.setBounds(_bounds); return _surface; |