[Scummvm-cvs-logs] SF.net SVN: scummvm: [22515] scummvm/trunk/graphics
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Thu May 18 06:19:08 CEST 2006
Revision: 22515
Author: eriktorbjorn
Date: 2006-05-18 06:18:02 -0700 (Thu, 18 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22515&view=rev
Log Message:
-----------
Allow changing scaler while playing MPEG cutscenes.
Modified Paths:
--------------
scummvm/trunk/engines/sword1/animation.cpp
scummvm/trunk/engines/sword1/animation.h
scummvm/trunk/engines/sword2/animation.cpp
scummvm/trunk/engines/sword2/animation.h
scummvm/trunk/graphics/animation.cpp
scummvm/trunk/graphics/animation.h
Modified: scummvm/trunk/engines/sword1/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword1/animation.cpp 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/engines/sword1/animation.cpp 2006-05-18 13:18:02 UTC (rev 22515)
@@ -58,19 +58,6 @@
#endif
}
-void AnimationState::updateScreen(void) {
-#ifndef BACKEND_8BIT
- int width = _movieScale * _frameWidth;
- int height = _movieScale * _frameHeight;
- int pitch = _movieScale * _movieWidth;
- int x = _movieScale * ((_movieWidth - _frameWidth) / 2);
- int y = _movieScale * ((_movieHeight - _frameHeight) / 2);
-
- _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y + _movieScale * 40, width, height);
-#endif
- _sys->updateScreen();
-}
-
OverlayColor *AnimationState::giveRgbBuffer(void) {
#ifdef BACKEND_8BIT
return NULL;
@@ -153,11 +140,9 @@
OSystem::Event event;
while (_sys->pollEvent(event)) {
switch (event.type) {
-#ifndef BACKEND_8BIT
case OSystem::EVENT_SCREEN_CHANGED:
- anim->buildLookup();
+ anim->screenChanged();
break;
-#endif
case OSystem::EVENT_KEYDOWN:
if (event.kbd.keycode == 27) {
delete anim;
Modified: scummvm/trunk/engines/sword1/animation.h
===================================================================
--- scummvm/trunk/engines/sword1/animation.h 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/engines/sword1/animation.h 2006-05-18 13:18:02 UTC (rev 22515)
@@ -61,13 +61,9 @@
private:
Screen *_scr;
- int _frameWidth;
- int _frameHeight;
-
public:
AnimationState(Screen *scr, Audio::Mixer *snd, OSystem *sys);
~AnimationState();
- void updateScreen();
OverlayColor *giveRgbBuffer(void);
bool soundFinished();
Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/engines/sword2/animation.cpp 2006-05-18 13:18:02 UTC (rev 22515)
@@ -114,29 +114,6 @@
#endif
}
-void AnimationState::updateScreen() {
- int x, y;
-
- x = (_movieWidth - _frameWidth) / 2;
- y = (_movieHeight - _frameHeight) / 2;
-
-#ifdef BACKEND_8BIT
- byte *buf = _vm->_screen->getScreen() + y * RENDERWIDE + x;
-
- _vm->_system->copyRectToScreen(buf, _movieWidth, (640 - _movieWidth) / 2, (480 - _movieHeight) / 2, _movieWidth, _movieHeight);
-#else
- int width = _movieScale * _frameWidth;
- int height = _movieScale * _frameHeight;
- int pitch = _movieScale * _movieWidth;
-
- x *= _movieScale;
- y *= _movieScale;
-
- _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y, width, height);
-#endif
- _vm->_system->updateScreen();
-}
-
void AnimationState::drawYUV(int width, int height, byte *const *dat) {
_frameWidth = width;
_frameHeight = height;
@@ -350,11 +327,9 @@
OSystem::Event event;
while (_sys->pollEvent(event)) {
switch (event.type) {
-#ifndef BACKEND_8BIT
case OSystem::EVENT_SCREEN_CHANGED:
- anim->buildLookup();
+ anim->screenChanged();
break;
-#endif
case OSystem::EVENT_KEYDOWN:
if (event.kbd.keycode == 27)
skipCutscene = true;
Modified: scummvm/trunk/engines/sword2/animation.h
===================================================================
--- scummvm/trunk/engines/sword2/animation.h 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/engines/sword2/animation.h 2006-05-18 13:18:02 UTC (rev 22515)
@@ -45,9 +45,6 @@
private:
Sword2Engine *_vm;
- int _frameWidth;
- int _frameHeight;
-
public:
AnimationState(Sword2Engine *vm);
~AnimationState();
@@ -57,7 +54,6 @@
#endif
void clearScreen();
- void updateScreen();
private:
void drawYUV(int width, int height, byte *const *dat);
Modified: scummvm/trunk/graphics/animation.cpp
===================================================================
--- scummvm/trunk/graphics/animation.cpp 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/graphics/animation.cpp 2006-05-18 13:18:02 UTC (rev 22515)
@@ -39,7 +39,7 @@
_movieScale = MIN(screenW / _movieWidth, screenH / _movieHeight);
- assert (_movieScale >= 1);
+ assert(_movieScale >= 1);
if (_movieScale > 3)
_movieScale = 3;
@@ -125,7 +125,7 @@
_lutCalcNum = (BITDEPTH + _palettes[_palNum].end + 2) / (_palettes[_palNum].end + 2);
#else
buildLookup();
- _overlay = (OverlayColor*)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor));
+ _overlay = (OverlayColor *)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor));
_sys->showOverlay();
#endif
@@ -255,6 +255,34 @@
return false;
}
+void BaseAnimationState::screenChanged() {
+#ifndef BACKEND_8BIT
+ const int screenW = _sys->getOverlayWidth();
+ const int screenH = _sys->getOverlayHeight();
+
+ int newScale = MIN(screenW / _movieWidth, screenH / _movieHeight);
+
+ assert(newScale >= 1);
+ if (newScale > 3)
+ newScale = 3;
+
+ if (newScale != _movieScale) {
+ // HACK: Since frames generally do not cover the entire screen,
+ // We need to undraw the old frame. This is a very hacky
+ // way of doing that.
+ OverlayColor *buf = (OverlayColor *)calloc(screenW * screenH, sizeof(OverlayColor));
+ _sys->copyRectToOverlay(buf, screenW, 0, 0, screenW, screenH);
+ free(buf);
+
+ free(_overlay);
+ _movieScale = newScale;
+ _overlay = (OverlayColor *)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor));
+ }
+
+ buildLookup();
+#endif
+}
+
#ifdef BACKEND_8BIT
/**
@@ -445,7 +473,7 @@
}
void BaseAnimationState::plotYUV1x(int width, int height, byte *const *dat) {
- OverlayColor *ptr = _overlay + _movieWidth * (_movieHeight - height) / 2 + (_movieWidth - width) / 2;
+ OverlayColor *ptr = _overlay;
byte *lum = dat[0];
byte *cr = dat[2];
@@ -498,7 +526,7 @@
}
void BaseAnimationState::plotYUV2x(int width, int height, byte *const *dat) {
- OverlayColor *ptr = _overlay + 2 * _movieWidth * (_movieHeight - height) + _movieWidth - width;
+ OverlayColor *ptr = _overlay;
byte *lum = dat[0];
byte *cr = dat[2];
@@ -563,7 +591,7 @@
}
void BaseAnimationState::plotYUV3x(int width, int height, byte *const *dat) {
- OverlayColor *ptr = _overlay + (3 * (_movieHeight - height) / 2) * 3 * _movieWidth + 3 * (_movieWidth - width ) / 2;
+ OverlayColor *ptr = _overlay;
byte *lum = dat[0];
byte *cr = dat[2];
@@ -633,6 +661,23 @@
}
}
+void BaseAnimationState::updateScreen() {
+#ifndef BACKEND_8BIT
+ int width = _movieScale * _frameWidth;
+ int height = _movieScale * _frameHeight;
+ int pitch = _movieScale * _movieWidth;
+
+ const int screenW = _sys->getOverlayWidth();
+ const int screenH = _sys->getOverlayHeight();
+
+ int x = (screenW - _movieScale * _frameWidth) / 2;
+ int y = (screenH - _movieScale * _frameHeight) / 2;
+
+ _sys->copyRectToOverlay(_overlay, pitch, x, y, width, height);
#endif
+ _sys->updateScreen();
+}
+#endif
+
} // End of namespace Graphics
Modified: scummvm/trunk/graphics/animation.h
===================================================================
--- scummvm/trunk/graphics/animation.h 2006-05-18 11:36:29 UTC (rev 22514)
+++ scummvm/trunk/graphics/animation.h 2006-05-18 13:18:02 UTC (rev 22515)
@@ -78,6 +78,9 @@
const int _movieWidth;
const int _movieHeight;
+ int _frameWidth;
+ int _frameHeight;
+
#ifndef BACKEND_8BIT
int _movieScale;
#endif
@@ -130,6 +133,8 @@
bool init(const char *name, void *audioArg = NULL);
bool decodeFrame();
+ void screenChanged();
+ void updateScreen();
#ifndef BACKEND_8BIT
void buildLookup();
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