aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-12 17:35:48 -0400
committerPaul Gilbert2016-07-17 13:09:27 -0400
commit6b250453f90a399b76d373ae9205b1bb985f8e46 (patch)
tree2c5c8f8cc898b25469c9b74b42ccf4141a17735a /engines
parent513723c82d5db078236421577924bd9cde29b99b (diff)
downloadscummvm-rg350-6b250453f90a399b76d373ae9205b1bb985f8e46.tar.gz
scummvm-rg350-6b250453f90a399b76d373ae9205b1bb985f8e46.tar.bz2
scummvm-rg350-6b250453f90a399b76d373ae9205b1bb985f8e46.zip
TITANIC: Further implementation of movie frame decoding
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/support/avi_surface.cpp40
-rw-r--r--engines/titanic/support/avi_surface.h7
-rw-r--r--engines/titanic/support/mouse_cursor.cpp2
-rw-r--r--engines/titanic/support/mouse_cursor.h3
-rw-r--r--engines/titanic/support/movie.cpp2
-rw-r--r--engines/titanic/support/movie.h4
-rw-r--r--engines/titanic/support/video_surface.cpp2
-rw-r--r--engines/titanic/support/video_surface.h20
8 files changed, 56 insertions, 24 deletions
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 85590f1d1e..ca6a09ade2 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -23,6 +23,8 @@
#include "titanic/support/avi_surface.h"
#include "titanic/support/screen_manager.h"
#include "titanic/support/video_surface.h"
+#include "common/system.h"
+#include "graphics/pixelformat.h"
#include "video/avi_decoder.h"
namespace Titanic {
@@ -220,7 +222,8 @@ void AVISurface::setupDecompressor() {
AVIDecoder &decoder = *_decoders[idx];
// Setup frame surface
- _movieFrameSurface[idx] = CScreenManager::_screenManagerPtr->createSurface(decoder.getWidth(), decoder.getHeight());
+ _movieFrameSurface[idx] = new Graphics::ManagedSurface(decoder.getWidth(), decoder.getHeight(),
+ g_system->getScreenFormat());
// TODO: See whether this simplified form of original works
if (idx == 2)
@@ -259,15 +262,29 @@ bool AVISurface::renderFrame() {
if (!_decoders[0]->needsUpdate() || (_decoders[1] && !_decoders[1]->needsUpdate()))
return false;
- // Get the frame to render, and draw it on the surface
- // TODO: Handle transparency
+ // Decode each decoder's video stream into the appropriate surface
for (int idx = 0; idx < 2; ++idx) {
if (_decoders[idx]) {
const Graphics::Surface *frame = _decoders[idx]->decodeNextFrame();
- _videoSurface->blitFrom(Point(0, 0), frame);
+
+ if (_movieFrameSurface[idx]->format == frame->format) {
+ _movieFrameSurface[idx]->blitFrom(*frame);
+ } else {
+ // Format mis-match, so we need to convert the frame
+ Graphics::Surface *s = frame->convertTo(_movieFrameSurface[idx]->format,
+ _decoders[idx]->getPalette());
+ _movieFrameSurface[idx]->blitFrom(*s);
+ s->free();
+ delete s;
+ }
}
}
+ // Blit the primary video frame onto the main overall surface
+ _videoSurface->lock();
+ _videoSurface->getRawSurface()->blitFrom(*_movieFrameSurface[0]);
+ _videoSurface->unlock();
+
return false;
}
@@ -298,14 +315,19 @@ void AVISurface::setFrameRate(double rate) {
}
}
-CVideoSurface *AVISurface::getSecondarySurface() {
+Graphics::ManagedSurface *AVISurface::getSecondarySurface() {
return _streamCount <= 1 ? nullptr : _movieFrameSurface[1];
}
-CVideoSurface *AVISurface::duplicateSecondaryFrame() const {
- // TODO: Make this cleaner
- OSVideoSurface *src = dynamic_cast<OSVideoSurface *>(_movieFrameSurface[1]);
- return new OSVideoSurface(*src);
+Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const {
+ if (_streamCount <= 1) {
+ return nullptr;
+ } else {
+ Graphics::ManagedSurface *dest = new Graphics::ManagedSurface(_movieFrameSurface[1]->w,
+ _movieFrameSurface[1]->h, _movieFrameSurface[1]->format);
+ dest->blitFrom(*_movieFrameSurface[1]);
+ return dest;
+ }
}
} // End of namespace Titanic
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index 62fc5172c9..f74f6a808e 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -24,6 +24,7 @@
#define TITANIC_AVI_SURFACE_H
#include "video/avi_decoder.h"
+#include "graphics/managed_surface.h"
#include "titanic/core/resource_key.h"
#include "titanic/support/movie_range_info.h"
@@ -55,7 +56,7 @@ private:
int _priorFrame;
CMovieRangeInfoList _movieRangeInfo;
int _streamCount;
- CVideoSurface *_movieFrameSurface[2];
+ Graphics::ManagedSurface *_movieFrameSurface[2];
private:
/**
* Render a frame to the video surface
@@ -148,7 +149,7 @@ public:
/**
* Returns the surface for the secondary video track frame, if present
*/
- CVideoSurface *getSecondarySurface();
+ Graphics::ManagedSurface *getSecondarySurface();
/**
* Get a reference to the movie range info list
@@ -160,7 +161,7 @@ public:
/**
* Duplicates the secondary frame, if the movie has a second video track
*/
- CVideoSurface *duplicateSecondaryFrame() const;
+ Graphics::ManagedSurface *duplicateSecondaryFrame() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index 628211c7f1..5694d83dc6 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -85,7 +85,7 @@ void CMouseCursor::loadCursorImages() {
OSMovie movie(key, surface);
movie.setFrame(idx);
- CVideoSurface *frameSurface = movie.duplicateFrame();
+ Graphics::ManagedSurface *frameSurface = movie.duplicateFrame();
_cursors[idx]._frameSurface = frameSurface;
surface->setMovieFrameSurface(frameSurface);
}
diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h
index f6ab92dca7..7a81ad43fa 100644
--- a/engines/titanic/support/mouse_cursor.h
+++ b/engines/titanic/support/mouse_cursor.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
+#include "graphics/managed_surface.h"
namespace Titanic {
@@ -54,7 +55,7 @@ class CVideoSurface;
class CMouseCursor {
struct CursorEntry {
CVideoSurface *_videoSurface;
- CVideoSurface *_frameSurface;
+ Graphics::ManagedSurface *_frameSurface;
Common::Point _centroid;
CursorEntry() : _videoSurface(nullptr), _frameSurface(nullptr) {}
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 495cf7c2a7..b98a5b57a1 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -217,7 +217,7 @@ void OSMovie::setFrameRate(double rate) {
_aviSurface.setFrameRate(rate);
}
-CVideoSurface *OSMovie::duplicateFrame() const {
+Graphics::ManagedSurface *OSMovie::duplicateFrame() const {
return _aviSurface.duplicateSecondaryFrame();
}
diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h
index f9e368606c..b6c2a09667 100644
--- a/engines/titanic/support/movie.h
+++ b/engines/titanic/support/movie.h
@@ -135,7 +135,7 @@ public:
/**
* Creates a duplicate of the movie's frame
*/
- virtual CVideoSurface *duplicateFrame() const = 0;
+ virtual Graphics::ManagedSurface *duplicateFrame() const = 0;
/**
* Removes the movie from the list of currently playing movies
@@ -233,7 +233,7 @@ public:
/**
* Creates a duplicate of the frame info
*/
- virtual CVideoSurface *duplicateFrame() const;
+ virtual Graphics::ManagedSurface *duplicateFrame() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 3e6e93abf1..0429ed4257 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -541,7 +541,7 @@ void OSVideoSurface::transPixelate() {
unlock();
}
-CVideoSurface *OSVideoSurface::dupMovieFrame() const {
+Graphics::ManagedSurface *OSVideoSurface::dupMovieFrame() const {
return _movie ? _movie->duplicateFrame() : nullptr;
}
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index 254745805e..a0e74b5b3d 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/array.h"
+#include "graphics/managed_surface.h"
#include "titanic/support/font.h"
#include "titanic/support/direct_draw.h"
#include "titanic/support/movie.h"
@@ -62,7 +63,7 @@ protected:
CScreenManager *_screenManager;
Graphics::ManagedSurface *_rawSurface;
bool _pendingLoad;
- CVideoSurface *_movieFrameSurface;
+ Graphics::ManagedSurface *_movieFrameSurface;
int _field48;
int _videoSurfaceNum;
int _field50;
@@ -260,7 +261,7 @@ public:
/**
* Duplicates movie frame surface
*/
- virtual CVideoSurface *dupMovieFrame() const = 0;
+ virtual Graphics::ManagedSurface *dupMovieFrame() const = 0;
/**
* Frees the underlying surface
@@ -283,13 +284,14 @@ public:
void blitFrom(const Point &destPos, const Graphics::Surface *src);
/**
- *
+ * Sets the movie frame surface containing frame data from an active movie
*/
- void setMovieFrameSurface(CVideoSurface *frameSurface) { _movieFrameSurface = frameSurface; }
+ void setMovieFrameSurface(Graphics::ManagedSurface *frameSurface) { _movieFrameSurface = frameSurface; }
/**
+ * Get the previously set movie frame surface
*/
- CVideoSurface *getMovieFrameSurface() const { return _movieFrameSurface; }
+ Graphics::ManagedSurface *getMovieFrameSurface() const { return _movieFrameSurface; }
/**
* Get the pixels associated with the surface. Only valid when the
@@ -298,6 +300,12 @@ public:
uint16 *getPixels() { return (uint16 *)_rawSurface->getPixels(); }
/**
+ * Get a reference to the underlying surface. Only valid when the surface
+ * has been locked for access
+ */
+ Graphics::ManagedSurface *getRawSurface() { return _rawSurface; }
+
+ /**
* Returns the transparent color
*/
uint getTransparencyColor();
@@ -499,7 +507,7 @@ public:
/**
* Duplicates movie frame surface
*/
- virtual CVideoSurface *dupMovieFrame() const;
+ virtual Graphics::ManagedSurface *dupMovieFrame() const;
/**