From e267210ec863a5e7c870e15eb4e72c71e72645f1 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Tue, 18 Jun 2019 00:14:21 +0530 Subject: HDB: Clip before passing to copyRectToSurface --- engines/hdb/draw-manager.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp index 1a49b3050b..e0a4e7c36c 100644 --- a/engines/hdb/draw-manager.cpp +++ b/engines/hdb/draw-manager.cpp @@ -270,13 +270,21 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) { } void Picture::draw(int x, int y) { - g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, _surface.w, _surface.h); + Common::Rect clip(_surface.getBounds()); + clip.clip(Common::Rect(0, 0, kScreenWidth - 1 - x, kScreenHeight - 1 - y)); + if (!clip.isEmpty()) { + g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, clip.width(), clip.height()); + } // g_system->copyRectToScreen(_surface.getBasePtr(0, 0), _surface.pitch, x, y, _surface.w, _surface.h); } void Picture::drawMasked(int x, int y) { _surface.transBlitFrom(_surface, 0xf81f); - g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, _surface.w, _surface.h); + Common::Rect clip(_surface.getBounds()); + clip.clip(Common::Rect(0, 0, kScreenWidth - 1 - x, kScreenHeight - 1 - y)); + if (!clip.isEmpty()) { + g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, clip.width(), clip.height()); + } // g_system->copyRectToScreen(tempSurf.getBasePtr(0, 0), tempSurf.pitch, x, y, tempSurf.w, tempSurf.h); } @@ -305,7 +313,11 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) { } void Tile::draw(int x, int y) { - g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, _surface.w, _surface.h); + Common::Rect clip(_surface.getBounds()); + clip.clip(Common::Rect(0, 0, kScreenWidth - 1 - x, kScreenHeight - 1 - y)); + if (!clip.isEmpty()) { + g_hdb->_drawMan->_globalSurface.copyRectToSurface(_surface.getBasePtr(0, 0), _surface.pitch, x, y, clip.width(), clip.height()); + } // g_system->copyRectToScreen(_surface.getBasePtr(0, 0), _surface.pitch, x, y, _surface.w, _surface.h); } -- cgit v1.2.3