Skip to content

Commit

Permalink
TITANIC: Clarify movie secondary video tracks as a transparency mask
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 29, 2016
1 parent 0da273f commit aba58e6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
9 changes: 5 additions & 4 deletions engines/titanic/support/avi_surface.cpp
Expand Up @@ -39,15 +39,16 @@ Video::AVIDecoder::AVIVideoTrack &AVIDecoder::getVideoTrack() {
}

/**
* Track filter for AVIDecoder that filters out any secondary video track
* Track filter for AVIDecoder that filters out any secondary
* video track some videos have to hold transparency masks
*/
static bool primaryTrackSelect(bool isVideo, int trackCounter) {
return !isVideo || trackCounter == 0;
}

/**
* Track filter for AVIDecoder that only accepts the secondary video track
* for a video, if present
* Track filter for AVIDecoder that only accepts the secondary
* transparency msak video track for a video, if present
*/
static bool secondaryTrackSelect(bool isVideo, int trackCounter) {
return isVideo && trackCounter > 0;
Expand Down Expand Up @@ -348,7 +349,7 @@ Graphics::ManagedSurface *AVISurface::getSecondarySurface() {
return _streamCount <= 1 ? nullptr : _movieFrameSurface[1];
}

Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const {
Graphics::ManagedSurface *AVISurface::duplicateTransparency() const {
if (_streamCount <= 1) {
return nullptr;
} else {
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/support/avi_surface.h
Expand Up @@ -168,9 +168,9 @@ class AVISurface {
}

/**
* Duplicates the secondary frame, if the movie has a second video track
* Duplicates the transparency mask for the frame, if the movie includes it
*/
Graphics::ManagedSurface *duplicateSecondaryFrame() const;
Graphics::ManagedSurface *duplicateTransparency() const;

/**
* Returns true if it's time for the next
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/support/mouse_cursor.cpp
Expand Up @@ -84,7 +84,7 @@ void CMouseCursor::loadCursorImages() {

Graphics::ManagedSurface *frameSurface = movie.duplicateFrame();
_cursors[idx]._frameSurface = frameSurface;
surface->setMovieFrameSurface(frameSurface);
surface->setTransparencySurface(frameSurface);
}
}

Expand Down
6 changes: 3 additions & 3 deletions engines/titanic/support/movie.cpp
Expand Up @@ -157,7 +157,7 @@ void OSMovie::addEvent(int frameNumber, CGameObject *obj) {

void OSMovie::setFrame(uint frameNumber) {
_aviSurface.setFrame(frameNumber);
_videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface());
_videoSurface->setTransparencySurface(_aviSurface.getSecondarySurface());
}

bool OSMovie::handleEvents(CMovieEventList &events) {
Expand All @@ -169,7 +169,7 @@ bool OSMovie::handleEvents(CMovieEventList &events) {
// Handle updating the frame
while (_aviSurface.isPlaying() && _aviSurface.isNextFrame()) {
_aviSurface.handleEvents(events);
_videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface());
_videoSurface->setTransparencySurface(_aviSurface.getSecondarySurface());
}

// Flag there's a video frame
Expand Down Expand Up @@ -204,7 +204,7 @@ void OSMovie::setFrameRate(double rate) {
}

Graphics::ManagedSurface *OSMovie::duplicateFrame() const {
return _aviSurface.duplicateSecondaryFrame();
return _aviSurface.duplicateTransparency();
}

} // End of namespace Titanic
18 changes: 9 additions & 9 deletions engines/titanic/support/video_surface.cpp
Expand Up @@ -32,8 +32,8 @@ int CVideoSurface::_videoSurfaceCounter = 0;
CVideoSurface::CVideoSurface(CScreenManager *screenManager) :
_screenManager(screenManager), _rawSurface(nullptr), _movie(nullptr),
_pendingLoad(false), _transBlitFlag(false), _fastBlitFlag(false),
_movieFrameSurface(nullptr), _transparencyMode(TRANS_DEFAULT),
_freeMovieSurface(DisposeAfterUse::NO), _hasFrame(true), _lockCount(0) {
_transparencySurface(nullptr), _transparencyMode(TRANS_DEFAULT),
_freeTransparencySurface(DisposeAfterUse::NO), _hasFrame(true), _lockCount(0) {
_videoSurfaceNum = _videoSurfaceCounter++;
}

Expand All @@ -42,8 +42,8 @@ CVideoSurface::~CVideoSurface() {
_videoSurfaceCounter -= freeSurface();
--_videoSurfaceCounter;

if (_freeMovieSurface == DisposeAfterUse::YES)
delete _movieFrameSurface;
if (_freeTransparencySurface == DisposeAfterUse::YES)
delete _transparencySurface;
}

void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) {
Expand Down Expand Up @@ -138,8 +138,8 @@ void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoS

if (src->_fastBlitFlag) {
_rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top));
} else if (getMovieFrameSurface()) {
movieBlitRect(srcRect, destRect, src);
} else if (getTransparencySurface()) {
transBlitRect(srcRect, destRect, src);
} else {
_rawSurface->transBlitFrom(*src->_rawSurface, srcRect, destRect, src->getTransparencyColor());
}
Expand All @@ -149,8 +149,8 @@ void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoS
}

void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) {
if (getMovieFrameSurface()) {
movieBlitRect(srcRect, destRect, src);
if (getTransparencySurface()) {
transBlitRect(srcRect, destRect, src);
} else {
src->lock();
lock();
Expand All @@ -162,7 +162,7 @@ void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoS
}
}

void CVideoSurface::movieBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) {
void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) {
if (lock()) {
if (src->lock()) {
Graphics::ManagedSurface *srcSurface = src->_rawSurface;
Expand Down
14 changes: 7 additions & 7 deletions engines/titanic/support/video_surface.h
Expand Up @@ -57,15 +57,15 @@ class CVideoSurface : public ListItem {

void blitRect1(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
void blitRect2(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
void movieBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
void transBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
protected:
static int _videoSurfaceCounter;
protected:
CScreenManager *_screenManager;
Graphics::ManagedSurface *_rawSurface;
bool _pendingLoad;
Graphics::ManagedSurface *_movieFrameSurface;
DisposeAfterUse::Flag _freeMovieSurface;
Graphics::ManagedSurface *_transparencySurface;
DisposeAfterUse::Flag _freeTransparencySurface;
int _videoSurfaceNum;
bool _hasFrame;
int _lockCount;
Expand Down Expand Up @@ -295,14 +295,14 @@ class CVideoSurface : public ListItem {
void blitFrom(const Point &destPos, const Graphics::Surface *src);

/**
* Sets the movie frame surface containing frame data from an active movie
* Sets a raw surface to use as a transparency mask for the surface
*/
void setMovieFrameSurface(Graphics::ManagedSurface *frameSurface) { _movieFrameSurface = frameSurface; }
void setTransparencySurface(Graphics::ManagedSurface *surface) { _transparencySurface = surface; }

/**
* Get the previously set movie frame surface
* Get the previously set transparency mask surface
*/
Graphics::ManagedSurface *getMovieFrameSurface() const { return _movieFrameSurface; }
Graphics::ManagedSurface *getTransparencySurface() const { return _transparencySurface; }

/**
* Get the pixels associated with the surface. Only valid when the
Expand Down

0 comments on commit aba58e6

Please sign in to comment.