[Scummvm-cvs-logs] CVS: scummvm/backends/sdl graphics.cpp,1.16,1.17 sdl-common.h,1.66,1.67 sdl.cpp,1.74,1.75
Eugene Sandulenko
sev at users.sourceforge.net
Tue Nov 23 13:32:02 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.316,2.317 script_v100he.cpp,2.27,2.28 script_v72he.cpp,2.185,2.186 script_v7he.cpp,2.118,2.119 script_v80he.cpp,2.63,2.64 script_v90he.cpp,2.111,2.112
- Next message: [Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.209,1.210 logic.h,1.120,1.121 queen.cpp,1.96,1.97
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31908
Modified Files:
graphics.cpp sdl-common.h sdl.cpp
Log Message:
Next step in transaction implementation. Now it postpones all calls.
NOTE: This breaks most ports, and they will not pass assertions. If you will
fix it (by moving violating OSystem calls to go() method), I'll be grateful.
If you don't bother to fix it, there is a workaround. Just comment out
beginGFXTransaction() and endGFXTransaction() in backends/sdl/graphics.cpp.
This will tunr it off and will use default transaction-less implementation.
Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- graphics.cpp 13 Nov 2004 04:33:27 -0000 1.16
+++ graphics.cpp 23 Nov 2004 21:30:34 -0000 1.17
@@ -49,12 +49,55 @@
return GFX_DOUBLESIZE;
}
+void OSystem_SDL::beginGFXTransaction(void) {
+ assert (_transactionMode == kTransactionNone);
+
+ _transactionMode = kTransactionActive;
+
+ _transactionDetails.modeChanged = false;
+ _transactionDetails.wChanged = false;
+ _transactionDetails.hChanged = false;
+ _transactionDetails.arChanged = false;
+ _transactionDetails.fsChanged = false;
+}
+
+void OSystem_SDL::endGFXTransaction(void) {
+ assert (_transactionMode == kTransactionActive);
+
+ _transactionMode = kTransactionCommit;
+ if (_transactionDetails.modeChanged) {
+ setGraphicsMode(_transactionDetails.mode);
+ }
+ if (_transactionDetails.wChanged || _transactionDetails.hChanged) {
+ initSize(_transactionDetails.w, _transactionDetails.h);
+ }
+ if (_transactionDetails.arChanged) {
+ setAspectRatioCorrection(_transactionDetails.ar);
+ }
+ if (_transactionDetails.fsChanged) {
+ setFullscreenMode(_transactionDetails.fs);
+ }
+ _transactionMode = kTransactionNone;
+}
+
bool OSystem_SDL::setGraphicsMode(int mode) {
Common::StackLock lock(_graphicsMutex);
int newScaleFactor = 1;
ScalerProc *newScalerProc;
+ switch (_transactionMode) {
+ case kTransactionActive:
+ _transactionDetails.mode = mode;
+ _transactionDetails.modeChanged = true;
+ return true;
+ break;
+ case kTransactionCommit:
+ break;
+ default:
+ break;
+ }
+
switch(mode) {
case GFX_NORMAL:
newScaleFactor = 1;
@@ -143,10 +186,25 @@
}
int OSystem_SDL::getGraphicsMode() const {
+ assert (_transactionMode == kTransactionNone);
return _mode;
}
void OSystem_SDL::initSize(uint w, uint h) {
+ switch (_transactionMode) {
+ case kTransactionActive:
+ _transactionDetails.w = w;
+ _transactionDetails.wChanged = true;
+ _transactionDetails.h = h;
+ _transactionDetails.hChanged = true;
+ return;
+ break;
+ case kTransactionCommit:
+ break;
+ default:
+ break;
+ }
+
// Avoid redundant res changes
if ((int)w == _screenWidth && (int)h == _screenHeight)
return;
@@ -316,6 +374,8 @@
}
void OSystem_SDL::updateScreen() {
+ assert (_transactionMode == kTransactionNone);
+
Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
internUpdateScreen();
@@ -485,6 +545,18 @@
}
void OSystem_SDL::setFullscreenMode(bool enable) {
+ switch (_transactionMode) {
+ case kTransactionActive:
+ _transactionDetails.fs = enable;
+ _transactionDetails.fsChanged = true;
+ return;
+ break;
+ case kTransactionCommit:
+ break;
+ default:
+ break;
+ }
+
Common::StackLock lock(_graphicsMutex);
if (_full_screen != enable) {
@@ -514,7 +586,37 @@
}
}
+void OSystem_SDL::setAspectRatioCorrection(bool enable) {
+ switch (_transactionMode) {
+ case kTransactionActive:
+ _transactionDetails.ar = enable;
+ _transactionDetails.arChanged = true;
+ return;
+ break;
+ case kTransactionCommit:
+ break;
+ default:
+ break;
+ }
+
+ if (_screenHeight == 200 && _adjustAspectRatio != enable) {
+ Common::StackLock lock(_graphicsMutex);
+
+ //assert(_hwscreen != 0);
+ _adjustAspectRatio ^= true;
+ hotswap_gfx_mode();
+
+ // Blit everything to the screen
+ internUpdateScreen();
+
+ // Make sure that an EVENT_SCREEN_CHANGED gets sent later
+ _modeChanged = true;
+ }
+}
+
void OSystem_SDL::clearScreen() {
+ assert (_transactionMode == kTransactionNone);
+
// Try to lock the screen surface
if (SDL_LockSurface(_screen) == -1)
error("SDL_LockSurface failed: %s", SDL_GetError());
@@ -529,6 +631,8 @@
}
void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) {
+ assert (_transactionMode == kTransactionNone);
+
if (_screen == NULL)
return;
@@ -746,6 +850,8 @@
}
void OSystem_SDL::setShakePos(int shake_pos) {
+ assert (_transactionMode == kTransactionNone);
+
_newShakePos = shake_pos;
}
@@ -755,6 +861,8 @@
#pragma mark -
void OSystem_SDL::showOverlay() {
+ assert (_transactionMode == kTransactionNone);
+
// hide the mouse
undraw_mouse();
@@ -763,6 +871,8 @@
}
void OSystem_SDL::hideOverlay() {
+ assert (_transactionMode == kTransactionNone);
+
// hide the mouse
undraw_mouse();
@@ -771,6 +881,8 @@
}
void OSystem_SDL::clearOverlay() {
+ assert (_transactionMode == kTransactionNone);
+
if (!_overlayVisible)
return;
@@ -792,6 +904,8 @@
}
void OSystem_SDL::grabOverlay(OverlayColor *buf, int pitch) {
+ assert (_transactionMode == kTransactionNone);
+
if (!_overlayVisible)
return;
@@ -816,6 +930,8 @@
}
void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+ assert (_transactionMode == kTransactionNone);
+
if (!_overlayVisible)
return;
@@ -946,6 +1062,8 @@
}
void OSystem_SDL::draw_mouse() {
+ assert (_transactionMode == kTransactionNone);
+
if (_mouseDrawn || !_mouseVisible)
return;
@@ -1034,6 +1152,8 @@
}
void OSystem_SDL::undraw_mouse() {
+ assert (_transactionMode == kTransactionNone);
+
if (!_mouseDrawn)
return;
_mouseDrawn = false;
@@ -1103,7 +1223,8 @@
#ifdef USE_OSD
void OSystem_SDL::displayMessageOnOSD(const char *msg) {
-
+ assert (_transactionMode == kTransactionNone);
+
uint i;
// Lock the OSD surface for drawing
Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- sdl-common.h 13 Nov 2004 04:33:27 -0000 1.66
+++ sdl-common.h 23 Nov 2004 21:30:37 -0000 1.67
@@ -53,6 +53,9 @@
OSystem_SDL();
virtual ~OSystem_SDL();
+ void beginGFXTransaction(void);
+ void endGFXTransaction(void);
+
// Set the size of the video bitmap.
// Typically, 320x200
void initSize(uint w, uint h);
@@ -195,11 +198,31 @@
DF_UPDATE_EXPAND_1_PIXEL = 1 << 1
};
+ enum {
+ kTransactionNone = 0,
+ kTransactionCommit = 1,
+ kTransactionActive = 2
+ };
+
+ struct transactionDetails {
+ int mode;
+ bool modeChanged;
+ int w;
+ bool wChanged;
+ int h;
+ bool hChanged;
+ bool fs;
+ bool fsChanged;
+ bool ar;
+ bool arChanged;
+ } _transactionDetails;
+
bool _forceFull; // Force full redraw on next updateScreen
ScalerProc *_scalerProc;
int _scalerType;
int _scaleFactor;
int _mode;
+ int _transactionMode;
bool _full_screen;
uint32 _mode_flags;
bool _modeChanged;
@@ -281,6 +304,7 @@
virtual void hotswap_gfx_mode();
void setFullscreenMode(bool enable);
+ void setAspectRatioCorrection(bool enable);
bool save_screenshot(const char *filename);
Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- sdl.cpp 15 Oct 2004 22:28:12 -0000 1.74
+++ sdl.cpp 23 Nov 2004 21:30:38 -0000 1.75
@@ -104,7 +104,7 @@
_mouseHotspotX(0), _mouseHotspotY(0),
_currentShakePos(0), _newShakePos(0),
_paletteDirtyStart(0), _paletteDirtyEnd(0),
- _graphicsMutex(0) {
+ _graphicsMutex(0), _transactionMode(kTransactionNone) {
// allocate palette storage
_currentPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256);
@@ -160,19 +160,7 @@
setFullscreenMode(enable);
break;
case kFeatureAspectRatioCorrection:
- if (_screenHeight == 200 && _adjustAspectRatio != enable) {
- Common::StackLock lock(_graphicsMutex);
-
- //assert(_hwscreen != 0);
- _adjustAspectRatio ^= true;
- hotswap_gfx_mode();
-
- // Blit everything to the screen
- internUpdateScreen();
-
- // Make sure that an EVENT_SCREEN_CHANGED gets sent later
- _modeChanged = true;
- }
+ setAspectRatioCorrection(enable);
break;
case kFeatureAutoComputeDirtyRects:
if (enable)
@@ -186,6 +174,8 @@
}
bool OSystem_SDL::getFeatureState(Feature f) {
+ assert (_transactionMode != kTransactionNone);
+
switch (f) {
case kFeatureFullscreenMode:
return _full_screen;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.316,2.317 script_v100he.cpp,2.27,2.28 script_v72he.cpp,2.185,2.186 script_v7he.cpp,2.118,2.119 script_v80he.cpp,2.63,2.64 script_v90he.cpp,2.111,2.112
- Next message: [Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.209,1.210 logic.h,1.120,1.121 queen.cpp,1.96,1.97
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list