diff options
| author | Max Horn | 2003-07-02 15:08:46 +0000 | 
|---|---|---|
| committer | Max Horn | 2003-07-02 15:08:46 +0000 | 
| commit | e1ca5552ddccf427cf1a0ca84e335b74b183d638 (patch) | |
| tree | 0c825fdf214968d7769bfc38d026c4f7d476e867 | |
| parent | 5b71113dcb4b87287417d0605c48fbc2a9eab451 (diff) | |
| download | scummvm-rg350-e1ca5552ddccf427cf1a0ca84e335b74b183d638.tar.gz scummvm-rg350-e1ca5552ddccf427cf1a0ca84e335b74b183d638.tar.bz2 scummvm-rg350-e1ca5552ddccf427cf1a0ca84e335b74b183d638.zip | |
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)
svn-id: r8717
| -rw-r--r-- | backends/sdl/sdl-common.cpp | 28 | ||||
| -rw-r--r-- | backends/sdl/sdl-common.h | 8 | ||||
| -rw-r--r-- | backends/sdl/sdl.cpp | 28 | ||||
| -rw-r--r-- | backends/sdl/sdl_gl.cpp | 27 | 
4 files changed, 34 insertions, 57 deletions
| diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index 63e949fede..f1ff07099a 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -63,7 +63,7 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect  		error("Could not initialize SDL: %s.\n", SDL_GetError());  	} -	_mutex = SDL_CreateMutex(); +	_graphicsMutex = SDL_CreateMutex();  	SDL_ShowCursor(SDL_DISABLE); @@ -94,7 +94,7 @@ OSystem_SDL_Common::OSystem_SDL_Common()  	_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 @@ OSystem_SDL_Common::~OSystem_SDL_Common() {  		free(_dirty_checksums);  	free(_currentPalette);  	free(_mouseBackup); -	SDL_DestroyMutex(_mutex); +	SDL_DestroyMutex(_graphicsMutex);  	SDL_ShowCursor(SDL_ENABLE);  #ifdef MACOSX @@ -147,7 +147,7 @@ void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int  	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 @@ void OSystem_SDL_Common::clear_overlay() {  	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(); @@ -1327,6 +1327,24 @@ void OSystem_SDL_Common::copy_rect_overlay(const int16 *buf, int pitch, int x, i  	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) {  	return SDL_MapRGB(_tmpscreen->format, r, g, b);  } diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 9c4bf91ab7..da878153d4 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -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 @@ protected:  	// 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); diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 27616d09f8..4e9cb69bf9 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -29,9 +29,6 @@ class OSystem_SDL : public OSystem_SDL_Common {  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 @@ OSystem_SDL::OSystem_SDL()  {  } -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 @@ void OSystem_SDL::hotswap_gfx_mode() {  	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::hotswap_gfx_mode() {  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 @@ void OSystem_SDL::update_screen() {  }  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; diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index ec23965a76..6fab0577fb 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -36,9 +36,6 @@ class OSystem_SDL_OpenGL : public OSystem_SDL_Common {  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 @@ OSystem_SDL_OpenGL::OSystem_SDL_OpenGL()    _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 @@ void OSystem_SDL_OpenGL::hotswap_gfx_mode() {  	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::hotswap_gfx_mode() {  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) { @@ -541,6 +518,8 @@ bool OSystem_SDL_OpenGL::poll_event(Event *event) {  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)  			assert(_hwscreen != 0); | 
