aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-08-04 23:46:13 -0500
committerColin Snover2017-09-03 20:58:07 -0500
commit7545bb7133099400245ef5db5cecc015e57acd56 (patch)
treeb9d35674c329fd232c64d23b7bab05975137a5f3
parent43a07abb46cc55d09f7415090f9f53c068c856aa (diff)
downloadscummvm-rg350-7545bb7133099400245ef5db5cecc015e57acd56.tar.gz
scummvm-rg350-7545bb7133099400245ef5db5cecc015e57acd56.tar.bz2
scummvm-rg350-7545bb7133099400245ef5db5cecc015e57acd56.zip
SCI32: Clip videos to the screen
This is needed for 8.VMD in Lighthouse (room 380, the credits room), which is rendered partially off the bottom of the screen. OSystem does not accept rects that are offscreen. Technically this video probably should not have been doubled vertically by game scripts, but there is not enough space to fix the rendering with a regular script patch, and it is a very unimportant video.
-rw-r--r--engines/sci/graphics/video32.cpp23
-rw-r--r--engines/sci/graphics/video32.h5
2 files changed, 20 insertions, 8 deletions
diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index 2b1f7219fd..c9c48eb9fd 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -252,7 +252,7 @@ void VideoPlayer::renderFrame(const Graphics::Surface &nextFrame) const {
freeConvertedFrame = true;
}
- g_system->copyRectToScreen(convertedFrame->getPixels(), convertedFrame->pitch, _drawRect.left, _drawRect.top, convertedFrame->w, convertedFrame->h);
+ g_system->copyRectToScreen(convertedFrame->getPixels(), convertedFrame->pitch, _drawRect.left, _drawRect.top, _drawRect.width(), _drawRect.height());
g_sci->_gfxFrameout->updateScreen();
if (freeConvertedFrame) {
@@ -285,6 +285,14 @@ void VideoPlayer::renderLQToSurface(Graphics::Surface &out, const Graphics::Surf
}
}
+void VideoPlayer::setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height) {
+ _drawRect = Common::Rect(x, y, x + width, y + height);
+ if (_drawRect.right > g_system->getWidth() || _drawRect.bottom > g_system->getHeight()) {
+ warning("Draw rect (%d, %d, %d, %d) is out of bounds of the screen; clipping it", PRINT_RECT(_drawRect));
+ _drawRect.clip(g_system->getWidth(), g_system->getHeight());
+ }
+}
+
#pragma mark SEQPlayer
SEQPlayer::SEQPlayer(EventManager *eventMan) :
@@ -566,10 +574,9 @@ void VMDPlayer::init(int16 x, const int16 y, const PlayFlags flags, const int16
#endif
_stretchVertical = flags & kPlayFlagStretchVertical;
- _drawRect = Common::Rect(x,
- y,
- x + (_decoder->getWidth() << _doublePixels),
- y + (_decoder->getHeight() << (_doublePixels || _stretchVertical)));
+ setDrawRect(x, y,
+ (_decoder->getWidth() << _doublePixels),
+ (_decoder->getHeight() << (_doublePixels || _stretchVertical)));
}
VMDPlayer::IOStatus VMDPlayer::close() {
@@ -1010,9 +1017,9 @@ void DuckPlayer::open(const GuiResourceId resourceId, const int displayMode, con
// SSCI seems to incorrectly calculate the draw rect by scaling the origin
// in addition to the width/height for the BR point
- _drawRect = Common::Rect(x, y,
- x + (_decoder->getWidth() << _doublePixels),
- y + (_decoder->getHeight() << _doublePixels));
+ setDrawRect(x, y,
+ (_decoder->getWidth() << _doublePixels),
+ (_decoder->getHeight() << _doublePixels));
g_sci->_gfxCursor32->hide();
diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h
index 5c213484d3..cd4436f7e7 100644
--- a/engines/sci/graphics/video32.h
+++ b/engines/sci/graphics/video32.h
@@ -162,6 +162,11 @@ protected:
void renderLQToSurface(Graphics::Surface &out, const Graphics::Surface &nextFrame, const bool doublePixels, const bool blackLines) const;
/**
+ * Sets the draw rect, clipping it to the screen's dimensions if necessary.
+ */
+ void setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height);
+
+ /**
* The rectangle where the video will be drawn, in screen coordinates.
*/
Common::Rect _drawRect;