[Scummvm-cvs-logs] SF.net SVN: scummvm:[51885] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Aug 8 02:51:10 CEST 2010


Revision: 51885
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51885&view=rev
Author:   drmccoy
Date:     2010-08-08 00:51:09 +0000 (Sun, 08 Aug 2010)

Log Message:
-----------
GOB: Make the demoplayer use the new VideoPlayer interface

Modified Paths:
--------------
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/demos/demoplayer.h
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.h

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:50:35 UTC (rev 51884)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:51:09 UTC (rev 51885)
@@ -152,12 +152,13 @@
 
 	debugC(1, kDebugDemo, "Playing video \"%s\"", file);
 
-	int16 x = _rebase0 ? 0 : -1;
-	int16 y = _rebase0 ? 0 : -1;
-	if (_vm->_vidPlayer->primaryOpen(file, x, y)) {
-		bool videoSupportsDouble = false;
-			//((_vm->_vidPlayer->getFeatures() & Graphics::CoktelDecoder::kFeaturesSupportsDouble) != 0);
+	VideoPlayer::Properties props;
 
+	props.x = _rebase0 ? 0 : -1;
+	props.y = _rebase0 ? 0 : -1;
+
+	int slot;
+	if ((slot = _vm->_vidPlayer->openVideo(true, file, props)) >= 0) {
 		if (_autoDouble) {
 			int16 defX = _rebase0 ? 0 : _vm->_vidPlayer->getDefaultX();
 			int16 defY = _rebase0 ? 0 : _vm->_vidPlayer->getDefaultY();
@@ -167,16 +168,12 @@
 			_doubleMode = ((right < 320) && (bottom < 200));
 		}
 
-		if (_doubleMode) {
-			if (videoSupportsDouble) {
-				_vm->_vidPlayer->slotSetDoubleMode(-1, true);
-				playVideoNormal();
-			} else
-				playVideoDoubled();
-		} else
-			playVideoNormal();
+		if (_doubleMode)
+			playVideoDoubled(slot);
+		else
+			playVideoNormal(slot);
 
-		_vm->_vidPlayer->primaryClose();
+		_vm->_vidPlayer->closeVideo(slot);
 
 		if (waitTime > 0)
 			_vm->_util->longDelay(waitTime);
@@ -210,53 +207,67 @@
 	playADL(fileName, waitEsc, repeat);
 }
 
-void DemoPlayer::playVideoNormal() {
-	_vm->_vidPlayer->primaryPlay();
+void DemoPlayer::playVideoNormal(int slot) {
+	VideoPlayer::Properties props;
+
+	_vm->_vidPlayer->play(slot, props);
 }
 
-void DemoPlayer::playVideoDoubled() {
-	Common::String fileNameOpened = _vm->_vidPlayer->getFileName();
-	_vm->_vidPlayer->primaryClose();
+void DemoPlayer::playVideoDoubled(int slot) {
+	Common::String fileNameOpened = _vm->_vidPlayer->getFileName(slot);
+	_vm->_vidPlayer->closeVideo(slot);
 
-	int16 x = _rebase0 ? 0 : -1;
-	int16 y = _rebase0 ? 0 : -1;
-	if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), x, y,
-				VideoPlayer::kFlagScreenSurface)) {
+	VideoPlayer::Properties props;
 
-		for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) {
-			// _vm->_vidPlayer->playFrame(i);
+	props.x            = _rebase0 ? 0 : -1;
+	props.y            = _rebase0 ? 0 : -1;
+	props.flags        = VideoPlayer::kFlagScreenSurface;
+	props.waitEndFrame = false;
 
-			/*
-			Graphics::CoktelDecoder::State state;// = _vm->_vidPlayer->getState();
+	_vm->_vidPlayer->evaluateFlags(props);
 
-			int16 w = state.right - state.left + 1;
-			int16 h = state.bottom - state.top + 1;
-			int16 wD = (state.left * 2) + (w * 2);
-			int16 hD = (state.top * 2) + (h * 2);
+	slot = _vm->_vidPlayer->openVideo(true, fileNameOpened, props);
+	if (slot < 0)
+		return;
 
+	for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(slot); i++) {
+		props.startFrame = _vm->_vidPlayer->getCurrentFrame(slot) + 1;
+		props.lastFrame  = _vm->_vidPlayer->getCurrentFrame(slot) + 1;
+
+		_vm->_vidPlayer->play(slot, props);
+
+		const Common::List<Common::Rect> *rects = _vm->_vidPlayer->getDirtyRects(slot);
+		if (rects) {
+			for (Common::List<Common::Rect>::const_iterator rect = rects->begin(); rect != rects->end(); ++rect) {
+				int16 w  = rect->right  - rect->left;
+				int16 h  = rect->bottom - rect->top;
+				int16 wD = (rect->left * 2) + (w * 2);
+				int16 hD = (rect->top  * 2) + (h * 2);
+
 			_vm->_video->drawSpriteDouble(*_vm->_draw->_spritesArray[0], *_vm->_draw->_frontSurface,
-					state.left, state.top, state.right, state.bottom, state.left, state.top, 0);
+					rect->left, rect->top, rect->right - 1, rect->bottom - 1, rect->left, rect->top, 0);
 			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
-					state.left * 2, state.top * 2, wD, hD);
-			*/
-			_vm->_video->retrace();
+					rect->left * 2, rect->top * 2, wD, hD);
+			}
+		}
 
-			_vm->_util->processInput();
-			if (_vm->shouldQuit())
-				break;
+		_vm->_video->retrace();
 
-			int16 key;
-			bool end = false;
-			while (_vm->_util->checkKey(key))
-				if (key == kKeyEscape)
-					end = true;
-			if (end)
-				break;
+		_vm->_util->processInput();
+		if (_vm->shouldQuit())
+			break;
 
-			_vm->_vidPlayer->slotWaitEndFrame();
+		int16 key;
+		bool end = false;
+		while (_vm->_util->checkKey(key))
+			if (key == kKeyEscape)
+				end = true;
+		if (end)
+			break;
 
-		}
+		_vm->_vidPlayer->waitEndFrame(slot);
 	}
+
 }
 
 void DemoPlayer::playADL(const Common::String &fileName, bool waitEsc, int32 repeat) {

Modified: scummvm/trunk/engines/gob/demos/demoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.h	2010-08-08 00:50:35 UTC (rev 51884)
+++ scummvm/trunk/engines/gob/demos/demoplayer.h	2010-08-08 00:51:09 UTC (rev 51885)
@@ -59,8 +59,8 @@
 	void playVideo(const char *fileName);
 	void playADL(const char *params);
 
-	void playVideoNormal();
-	void playVideoDoubled();
+	void playVideoNormal(int slot);
+	void playVideoDoubled(int slot);
 	void playADL(const Common::String &fileName, bool waitEsc = true, int32 repeat = -1);
 
 private:

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:50:35 UTC (rev 51884)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:51:09 UTC (rev 51885)
@@ -40,7 +40,8 @@
 VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(Draw::kFrontSurface),
 	x(-1), y(-1), width(-1), height(-1), flags(kFlagFrontSurface),
 	startFrame(-1), lastFrame(-1), endFrame(-1), breakKey(kShortKeyEscape),
-	palCmd(8), palStart(0), palEnd(255), palFrame(-1), fade(false), canceled(false) {
+	palCmd(8), palStart(0), palEnd(255), palFrame(-1),
+	fade(false), waitEndFrame(true), canceled(false) {
 
 }
 
@@ -241,8 +242,8 @@
 			properties.fade = false;
 		}
 
-		if (!_noCursorSwitch)
-			_vm->_util->delay(video->decoder->getTimeToNextFrame());
+		if (!_noCursorSwitch && properties.waitEndFrame)
+			waitEndFrame(slot);
 	}
 
 	evalBgShading(*video);
@@ -250,6 +251,14 @@
 	return true;
 }
 
+void VideoPlayer::waitEndFrame(int slot) {
+	Video *video = getVideoBySlot(slot);
+	if (!video)
+		return;
+
+	_vm->_util->delay(video->decoder->getTimeToNextFrame());
+}
+
 bool VideoPlayer::playFrame(int slot, Properties &properties) {
 	Video *video = getVideoBySlot(slot);
 	if (!video)
@@ -353,7 +362,7 @@
 			_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
 	}
 
-	if (primary)
+	if (primary && properties.waitEndFrame)
 		checkAbort(*video, properties);
 
 	return true;
@@ -445,6 +454,14 @@
 	return video->decoder->getDefaultY();
 }
 
+const Common::List<Common::Rect> *VideoPlayer::getDirtyRects(int slot) const {
+	const Video *video = getVideoBySlot(slot);
+	if (!video)
+		return 0;
+
+	return &video->decoder->getDirtyRects();
+}
+
 bool VideoPlayer::hasEmbeddedFile(const Common::String &fileName, int slot) const {
 	const Video *video = getVideoBySlot(slot);
 	if (!video)

Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 00:50:35 UTC (rev 51884)
+++ scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 00:51:09 UTC (rev 51885)
@@ -27,6 +27,8 @@
 #define GOB_VIDEOPLAYER_H
 
 #include "common/array.h"
+#include "common/list.h"
+#include "common/rect.h"
 #include "common/str.h"
 
 #include "graphics/surface.h"
@@ -85,6 +87,8 @@
 
 		bool fade; ///< Fade in?
 
+		bool waitEndFrame; ///< Wait for the frame's time to run out?
+
 		bool canceled; ///< Was the video canceled?
 
 		Properties();
@@ -99,6 +103,7 @@
 	bool closeVideo(int slot = 0);
 
 	bool play(int slot, Properties &properties);
+	void waitEndFrame(int slot);
 
 	bool slotIsOpen(int slot = 0) const;
 
@@ -111,6 +116,8 @@
 	uint16 getDefaultX    (int slot = 0) const;
 	uint16 getDefaultY    (int slot = 0) const;
 
+	const Common::List<Common::Rect> *getDirtyRects(int slot = 0) const;
+
 	bool                      hasEmbeddedFile(const Common::String &fileName, int slot = 0) const;
 	Common::MemoryReadStream *getEmbeddedFile(const Common::String &fileName, int slot = 0);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list