diff options
author | Johannes Schickel | 2006-04-11 16:05:59 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-04-11 16:05:59 +0000 |
commit | 4b8b7e2aedf23d5100c5197a46c4052919a7f8ce (patch) | |
tree | 48202981b32fc8260c21b3ac345cf2030766948c | |
parent | 3ac923ba580c2fa61baf381b38027c3d133dcd3c (diff) | |
download | scummvm-rg350-4b8b7e2aedf23d5100c5197a46c4052919a7f8ce.tar.gz scummvm-rg350-4b8b7e2aedf23d5100c5197a46c4052919a7f8ce.tar.bz2 scummvm-rg350-4b8b7e2aedf23d5100c5197a46c4052919a7f8ce.zip |
Checks if something is drawn out of the screen in drawSurfaceMasked (fixes crashes with --force-1x-overlay)
svn-id: r21794
-rw-r--r-- | gui/ThemeNew.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp index f7410a6429..ed7ab970ee 100644 --- a/gui/ThemeNew.cpp +++ b/gui/ThemeNew.cpp @@ -1187,6 +1187,8 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface const OverlayColor transparency = _colors[kColorTransparency]; int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; + if (r.left + drawWidth > _screen.w) + drawWidth = _screen.w - r.left; int srcAdd = 0; if (upDown) { @@ -1197,14 +1199,22 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface srcAdd = surf->w; } + int h = r.height(); + if (r.top + h > _screen.h) + h = _screen.h - r.top; + while (dst < _screen.pixels) { dst += _screen.w; src += srcAdd; + --h; } + if (h <= 0) + return; + if (alpha >= 256) { if (leftRight) { - for (int i = 0; i < r.height(); ++i) { + for (int i = 0; i < h; ++i) { OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); for (int x = 0; x < drawWidth; ++x) { if (src[drawWidth-x-1] != transparency) @@ -1214,7 +1224,7 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface src += srcAdd; } } else { - for (int i = 0; i < r.height(); ++i) { + for (int i = 0; i < h; ++i) { OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); for (int x = 0; x < drawWidth; ++x) { if (src[x] != transparency) @@ -1226,7 +1236,7 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface } } else { if (leftRight) { - for (int i = 0; i < r.height(); ++i) { + for (int i = 0; i < h; ++i) { OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); for (int x = 0; x < drawWidth; ++x) { if (src[drawWidth-x-1] != transparency) @@ -1236,7 +1246,7 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface src += srcAdd; } } else { - for (int i = 0; i < r.height(); ++i) { + for (int i = 0; i < h; ++i) { OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); for (int x = 0; x < drawWidth; ++x) { if (src[x] != transparency) |