[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.64,1.65 sdl-common.h,1.28,1.29 sdl.cpp,1.38,1.39 sdl_gl.cpp,1.43,1.44

Max Horn fingolfin at users.sourceforge.net
Wed Jul 2 08:09:12 CEST 2003


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv5978

Modified Files:
	sdl-common.cpp sdl-common.h sdl.cpp sdl_gl.cpp 
Log Message:
cleanup; made mutex protection of graphics code a little bit tighter by protecting all of method property(); moved set_palette to OSystem_SDL_Common (it was identical in both normal and GL backend)

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- sdl-common.cpp	22 Jun 2003 14:59:21 -0000	1.64
+++ sdl-common.cpp	2 Jul 2003 15:08:46 -0000	1.65
@@ -63,7 +63,7 @@
 		error("Could not initialize SDL: %s.\n", SDL_GetError());
 	}
 
-	_mutex = SDL_CreateMutex();
+	_graphicsMutex = SDL_CreateMutex();
 
 	SDL_ShowCursor(SDL_DISABLE);
 	
@@ -94,7 +94,7 @@
 	_mouseHotspotX(0), _mouseHotspotY(0),
 	_currentShakePos(0), _newShakePos(0),
 	_paletteDirtyStart(0), _paletteDirtyEnd(0),
-	_mutex(0) {
+	_graphicsMutex(0) {
 
 	// allocate palette storage
 	_currentPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256);
@@ -113,7 +113,7 @@
 		free(_dirty_checksums);
 	free(_currentPalette);
 	free(_mouseBackup);
-	SDL_DestroyMutex(_mutex);
+	SDL_DestroyMutex(_graphicsMutex);
 
 	SDL_ShowCursor(SDL_ENABLE);
 #ifdef MACOSX
@@ -147,7 +147,7 @@
 	if (_screen == NULL)
 		return;
 
-	StackLock lock(_mutex);	// Lock the mutex until this function ends
+	StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
 	
 	if (((uint32)buf & 3) == 0 && pitch == _screenWidth && x==0 && y==0 &&
 			w==_screenWidth && h==_screenHeight && _mode_flags&DF_WANT_RECT_OPTIM) {
@@ -1228,7 +1228,7 @@
 	if (!_overlayVisible)
 		return;
 	
-	StackLock lock(_mutex);	// Lock the mutex until this function ends
+	StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
 	
 	// hide the mouse
 	undraw_mouse();
@@ -1325,6 +1325,24 @@
 	} while (--h);
 
 	SDL_UnlockSurface(_tmpscreen);
+}
+
+void OSystem_SDL_Common::set_palette(const byte *colors, uint start, uint num) {
+	const byte *b = colors;
+	uint i;
+	SDL_Color *base = _currentPalette + start;
+	for (i = 0; i < num; i++) {
+		base[i].r = b[0];
+		base[i].g = b[1];
+		base[i].b = b[2];
+		b += 4;
+	}
+
+	if (start < _paletteDirtyStart)
+		_paletteDirtyStart = start;
+
+	if (start + num > _paletteDirtyEnd)
+		_paletteDirtyEnd = start + num;
 }
 
 int16 OSystem_SDL_Common::RGBToColor(uint8 r, uint8 g, uint8 b) {

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- sdl-common.h	22 Jun 2003 11:55:40 -0000	1.28
+++ sdl-common.h	2 Jul 2003 15:08:46 -0000	1.29
@@ -31,13 +31,13 @@
 
 class OSystem_SDL_Common : public OSystem {
 public:
-	// Set colors of the palette
-	void set_palette(const byte *colors, uint start, uint num) = 0;
-
 	// Set the size of the video bitmap.
 	// Typically, 320x200
 	void init_size(uint w, uint h);
 
+	// Set colors of the palette
+	void set_palette(const byte *colors, uint start, uint num);
+
 	// Draw a bitmap to screen.
 	// The screen will not be updated to reflect the new bitmap
 	void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h);
@@ -208,7 +208,7 @@
 	
 	// Mutex that prevents multiple threads interferring with each other
 	// when accessing the screen.
-	SDL_mutex *_mutex;
+	SDL_mutex *_graphicsMutex;
 
 
 	void add_dirty_rgn_auto(const byte *buf);

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- sdl.cpp	30 Jun 2003 14:31:09 -0000	1.38
+++ sdl.cpp	2 Jul 2003 15:08:46 -0000	1.39
@@ -29,9 +29,6 @@
 public:
 	OSystem_SDL();
 
-	// Set colors of the palette
-	void set_palette(const byte *colors, uint start, uint num);
-
 	// Update the dirty areas of the screen
 	void update_screen();
 
@@ -57,24 +54,6 @@
 {
 }
 
-void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) {
-	const byte *b = colors;
-	uint i;
-	SDL_Color *base = _currentPalette + start;
-	for (i = 0; i < num; i++) {
-		base[i].r = b[0];
-		base[i].g = b[1];
-		base[i].b = b[2];
-		b += 4;
-	}
-
-	if (start < _paletteDirtyStart)
-		_paletteDirtyStart = start;
-
-	if (start + num > _paletteDirtyEnd)
-		_paletteDirtyEnd = start + num;
-}
-
 void OSystem_SDL::load_gfx_mode() {
 	_forceFull = true;
 	_mode_flags = DF_UPDATE_EXPAND_1_PIXEL;
@@ -201,8 +180,6 @@
 	if (!_screen)
 		return;
 
-	StackLock lock(_mutex);	// Lock the mutex until this function ends
-
 	// Keep around the old _screen & _tmpscreen so we can restore the screen data
 	// after the mode switch.
 	SDL_Surface *old_screen = _screen;
@@ -233,7 +210,7 @@
 void OSystem_SDL::update_screen() {
 	assert(_hwscreen != NULL);
 
-	StackLock lock(_mutex);	// Lock the mutex until this function ends
+	StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
 
 	// If the shake position changed, fill the dirty area with blackness
 	if (_currentShakePos != _newShakePos) {
@@ -357,6 +334,9 @@
 }
 
 uint32 OSystem_SDL::property(int param, Property *value) {
+
+	StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
+
 	if (param == PROP_TOGGLE_FULLSCREEN) {
 		assert(_hwscreen != 0);
 		_full_screen ^= true;

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- sdl_gl.cpp	30 Jun 2003 14:31:09 -0000	1.43
+++ sdl_gl.cpp	2 Jul 2003 15:08:46 -0000	1.44
@@ -36,9 +36,6 @@
 public:
 	OSystem_SDL_OpenGL();
 
-	// Set colors of the palette
-	void set_palette(const byte *colors, uint start, uint num);
-
 	// Update the dirty areas of the screen
 	void update_screen();
 
@@ -87,24 +84,6 @@
   _glWindow.h = 480;
 }
 
-void OSystem_SDL_OpenGL::set_palette(const byte *colors, uint start, uint num) {
-	const byte *b = colors;
-	uint i;
-	SDL_Color *base = _currentPalette + start;
-	for (i = 0; i < num; i++) {
-		base[i].r = b[0];
-		base[i].g = b[1];
-		base[i].b = b[2];
-		b += 4;
-	}
-
-	if (start < _paletteDirtyStart)
-		_paletteDirtyStart = start;
-
-	if (start + num > _paletteDirtyEnd)
-		_paletteDirtyEnd = start + num;
-}
-
 void OSystem_SDL_OpenGL::load_gfx_mode() {
 	uint32 Rmask, Gmask, Bmask, Amask;
 	// I have to force 16 bit color depth with 565 ordering
@@ -304,8 +283,6 @@
 	if (!_screen)
 		return;
 
-	StackLock lock(_mutex); // Lock the mutex until this function ends
-
 	// Keep around the old _screen & _tmpscreen so we can restore the screen data
 	// after the mode switch.
 	SDL_Surface *old_screen = _screen;
@@ -342,7 +319,7 @@
 
 void OSystem_SDL_OpenGL::update_screen() {
 
-	StackLock lock(_mutex);	// Lock the mutex until this function ends
+	StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
 
 	// If the shake position changed, fill the dirty area with blackness
 	if (_currentShakePos != _newShakePos) {
@@ -540,6 +517,8 @@
 */
 
 uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
+
+	StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
 
 	if (param == PROP_TOGGLE_FULLSCREEN) {
 		if (!_usingOpenGL)





More information about the Scummvm-git-logs mailing list