[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.16,1.17 sdl-common.h,1.7,1.8 sdl.cpp,1.15,1.16 sdl_gl.cpp,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Fri Dec 13 09:22:07 CET 2002


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

Modified Files:
	sdl-common.cpp sdl-common.h sdl.cpp sdl_gl.cpp 
Log Message:
unified common code

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sdl-common.cpp	22 Nov 2002 18:46:18 -0000	1.16
+++ sdl-common.cpp	13 Dec 2002 17:21:11 -0000	1.17
@@ -70,8 +70,9 @@
 }
 
 OSystem_SDL_Common::OSystem_SDL_Common()
-	: _screen(0), _screenWidth(0), _screenHeight(0), _cdrom(0),
-	_dirty_checksums(0),
+	: _screen(0), _screenWidth(0), _screenHeight(0),
+	_tmpscreen(0), _tmpScreenWidth(0), _overlayVisible(false),
+	_cdrom(0), _dirty_checksums(0),
 	_mouseVisible(false), _mouseDrawn(false), _mouseData(0),
 	_mouseHotspotX(0), _mouseHotspotY(0),
 	_currentShakePos(0), _newShakePos(0)
@@ -729,8 +730,6 @@
 	int h = _mouseCurState.h;
 	byte color;
 	byte *src = _mouseData;		// Image representing the mouse
-	byte *bak = _mouseBackup;		// Surface used to backup the area obscured by the mouse
-	byte *dst;					// Surface we are drawing into
 
 	// clip the mouse rect, and addjust the src pointer accordingly
 	if (x < 0) {
@@ -743,6 +742,7 @@
 		src -= y * _mouseCurState.w;
 		y = 0;
 	}
+
 	if (w > _screenWidth - x)
 		w = _screenWidth - x;
 	if (h > _screenHeight - y)
@@ -760,32 +760,59 @@
 	_mouseOldState.h = h;
 
 	// Draw the mouse cursor; backup the covered area in "bak"
-
-	if (SDL_LockSurface(_screen) == -1)
+	
+	if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 	
 	// Mark as dirty
 	add_dirty_rect(x, y, w, h);
 
-	dst = (byte *)_screen->pixels + y * _screenWidth + x;
-	while (h > 0) {
-		int width = w;
-		while (width > 0) {
-			*bak++ = *dst;
-			color = *src++;
-			if (color != 0xFF)	// 0xFF = transparent, don't draw
-				*dst = color;
-			dst++;
-			width--;
+	if (!_overlayVisible) {
+		byte *bak = _mouseBackup;		// Surface used to backup the area obscured by the mouse
+		byte *dst;					// Surface we are drawing into
+	
+		dst = (byte *)_screen->pixels + y * _screenWidth + x;
+		while (h > 0) {
+			int width = w;
+			while (width > 0) {
+				*bak++ = *dst;
+				color = *src++;
+				if (color != 0xFF)	// 0xFF = transparent, don't draw
+					*dst = color;
+				dst++;
+				width--;
+			}
+			src += _mouseCurState.w - w;
+			bak += MAX_MOUSE_W - w;
+			dst += _screenWidth - w;
+			h--;
 		}
-		src += _mouseCurState.w - w;
-		bak += MAX_MOUSE_W - w;
-		dst += _screenWidth - w;
-		h--;
+	
+	} else {
+		uint16 *bak = (uint16*)_mouseBackup;	// Surface used to backup the area obscured by the mouse
+		uint16 *dst;					// Surface we are drawing into
+	
+		dst = (uint16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
+		while (h > 0) {
+			int width = w;
+			while (width > 0) {
+				*bak++ = *dst;
+				color = *src++;
+				if (color != 0xFF)	// 0xFF = transparent, don't draw
+					*dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b);
+				dst++;
+				width--;
+			}
+			src += _mouseCurState.w - w;
+			bak += MAX_MOUSE_W - w;
+			dst += _tmpScreenWidth - w;
+			h--;
+		}
+	
 	}
 
-	SDL_UnlockSurface(_screen);
-
+	SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen);
+	
 	// Finally, set the flag to indicate the mouse has been drawn
 	_mouseDrawn = true;
 }
@@ -795,28 +822,43 @@
 		return;
 	_mouseDrawn = false;
 
-	if (SDL_LockSurface(_screen) == -1)
+	if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
-	byte *dst, *bak = _mouseBackup;
 	const int old_mouse_x = _mouseOldState.x;
 	const int old_mouse_y = _mouseOldState.y;
 	const int old_mouse_w = _mouseOldState.w;
 	const int old_mouse_h = _mouseOldState.h;
 	int x, y;
 
-	// No need to do clipping here, since draw_mouse() did that already
+	if (!_overlayVisible) {
+	
+		byte *dst, *bak = _mouseBackup;
+	
+		// No need to do clipping here, since draw_mouse() did that already
+		dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x;
+		for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) {
+			for (x = 0; x < old_mouse_w; ++x) {
+				dst[x] = bak[x];
+			}
+		}
+	
+	} else {
 
-	dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x;
-	for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) {
-		for (x = 0; x < old_mouse_w; ++x) {
-			dst[x] = bak[x];
+		uint16 *dst, *bak = (uint16 *)_mouseBackup;
+	
+		// No need to do clipping here, since draw_mouse() did that already
+		dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * _tmpScreenWidth + (old_mouse_x+1);
+		for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _tmpScreenWidth) {
+			for (x = 0; x < old_mouse_w; ++x) {
+				dst[x] = bak[x];
+			}
 		}
 	}
 
 	add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);
 
-	SDL_UnlockSurface(_screen);
+	SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen);
 }
 
 void OSystem_SDL_Common::stop_cdrom() {	/* Stop CD Audio in 1/10th of a second */

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sdl-common.h	13 Nov 2002 14:38:49 -0000	1.7
+++ sdl-common.h	13 Dec 2002 17:21:16 -0000	1.8
@@ -106,6 +106,8 @@
 	static OSystem *create(int gfx_mode, bool full_screen);
 
 protected:
+	typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
+								uint8 *dstPtr, uint32 dstPitch, int width, int height);
 
 	OSystem_SDL_Common();
 	virtual ~OSystem_SDL_Common();
@@ -113,6 +115,11 @@
 	// unseen game screen
 	SDL_Surface *_screen;
 	int _screenWidth, _screenHeight;
+
+	// temporary screen (for scalers/overlay)
+	SDL_Surface *_tmpscreen;
+	int _tmpScreenWidth;
+	bool _overlayVisible;
 
 	// CD Audio
 	SDL_CD *_cdrom;

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- sdl.cpp	13 Dec 2002 16:15:40 -0000	1.15
+++ sdl.cpp	13 Dec 2002 17:21:20 -0000	1.16
@@ -25,9 +25,9 @@
 #include "common/util.h"
 #include "common/engine.h"	// Only #included for error() and warning()
 
-class OSystem_SDL_Normal : public OSystem_SDL_Common {
+class OSystem_SDL : public OSystem_SDL_Common {
 public:
-	OSystem_SDL_Normal();
+	OSystem_SDL();
 
 	// Set colors of the palette
 	void set_palette(const byte *colors, uint start, uint num);
@@ -50,36 +50,25 @@
 	virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b);
 
 protected:
-	typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
-								uint8 *dstPtr, uint32 dstPitch, int width, int height);
-
-	SDL_Surface *_tmpscreen;   // temporary screen (for scalers/overlay)
 	SDL_Surface *_hwscreen;    // hardware screen
-	bool _overlay_visible;
 
 	ScalerProc *_scaler_proc;
 
-	int TMP_SCREEN_WIDTH;
-
-	virtual void draw_mouse();
-	virtual void undraw_mouse();
-
 	virtual void load_gfx_mode();
 	virtual void unload_gfx_mode();
 	void hotswap_gfx_mode();
 };
 
 OSystem_SDL_Common *OSystem_SDL_Common::create() {
-	return new OSystem_SDL_Normal();
+	return new OSystem_SDL();
 }
 
-OSystem_SDL_Normal::OSystem_SDL_Normal()
-	 : _tmpscreen(0), _hwscreen(0), _overlay_visible(false),
-	   _scaler_proc(0), TMP_SCREEN_WIDTH(0)
+OSystem_SDL::OSystem_SDL()
+	 : _hwscreen(0), _scaler_proc(0)
 {
 }
 
-void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) {
+void OSystem_SDL::set_palette(const byte *colors, uint start, uint num) {
 	const byte *b = colors;
 	uint i;
 	SDL_Color *base = _currentPalette + start;
@@ -97,121 +86,12 @@
 		_paletteDirtyEnd = start + num;
 }
 
-void OSystem_SDL_Normal::draw_mouse() {
-	if (!_overlay_visible) {
-		OSystem_SDL_Common::draw_mouse();
-	}
-
-	if (_mouseDrawn || !_mouseVisible)
-		return;
-
-	int x = _mouseCurState.x - _mouseHotspotX;
-	int y = _mouseCurState.y - _mouseHotspotY;
-	int w = _mouseCurState.w;
-	int h = _mouseCurState.h;
-	byte color;
-	byte *src = _mouseData;		// Image representing the mouse
-	uint16 *bak = (uint16*)_mouseBackup;	// Surface used to backup the area obscured by the mouse
-	uint16 *dst;					// Surface we are drawing into
-
-	// clip the mouse rect, and addjust the src pointer accordingly
-	if (x < 0) {
-		w += x;
-		src -= x;
-		x = 0;
-	}
-	if (y < 0) {
-		h += y;
-		src -= y * _mouseCurState.w;
-		y = 0;
-	}
-
-	// Quick check to see if anything has to be drawn at all
-	if (w <= 0 || h <= 0)
-		return;
-
-	if (w > _screenWidth - x)
-		w = _screenWidth - x;
-	if (h > _screenHeight - y)
-		h = _screenHeight - y;
-
-	// Store the bounding box so that undraw mouse can restore the area the
-	// mouse currently covers to its original content.
-	_mouseOldState.x = x;
-	_mouseOldState.y = y;
-	_mouseOldState.w = w;
-	_mouseOldState.h = h;
-
-	// Draw the mouse cursor; backup the covered area in "bak"
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	// Mark as dirty
-	add_dirty_rect(x, y, w, h);
-
-	dst = (uint16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1);
-	while (h > 0) {
-		int width = w;
-		while (width > 0) {
-			*bak++ = *dst;
-			color = *src++;
-			if (color != 0xFF)	// 0xFF = transparent, don't draw
-				*dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b);
-			dst++;
-			width--;
-		}
-		src += _mouseCurState.w - w;
-		bak += MAX_MOUSE_W - w;
-		dst += TMP_SCREEN_WIDTH - w;
-		h--;
-	}
-
-	SDL_UnlockSurface(_tmpscreen);
-	
-	// Finally, set the flag to indicate the mouse has been drawn
-	_mouseDrawn = true;
-}
-
-void OSystem_SDL_Normal::undraw_mouse() {
-	if (!_overlay_visible) {
-		OSystem_SDL_Common::undraw_mouse();
-	}
-
-	if (!_mouseDrawn)
-		return;
-	_mouseDrawn = false;
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	uint16 *dst, *bak = (uint16 *)_mouseBackup;
-	const int old_mouse_x = _mouseOldState.x;
-	const int old_mouse_y = _mouseOldState.y;
-	const int old_mouse_w = _mouseOldState.w;
-	const int old_mouse_h = _mouseOldState.h;
-	int x, y;
-
-	// No need to do clipping here, since draw_mouse() did that already
-
-	dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * TMP_SCREEN_WIDTH + (old_mouse_x+1);
-	for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += TMP_SCREEN_WIDTH) {
-		for (x = 0; x < old_mouse_w; ++x) {
-			dst[x] = bak[x];
-		}
-	}
-
-	add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
-void OSystem_SDL_Normal::load_gfx_mode() {
+void OSystem_SDL::load_gfx_mode() {
 	_forceFull = true;
 	_mode_flags = DF_WANT_RECT_OPTIM | DF_UPDATE_EXPAND_1_PIXEL;
 
 	_tmpscreen = NULL;
-	TMP_SCREEN_WIDTH = (_screenWidth + 3);
+	_tmpScreenWidth = (_screenWidth + 3);
 	
 	switch(_mode) {
 	case GFX_2XSAI:
@@ -284,9 +164,9 @@
 		Init_2xSaI(565);
 	
 	// Need some extra bytes around when using 2xSaI
-	uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(_screenHeight+3), sizeof(uint16));
+	uint16 *tmp_screen = (uint16*)calloc(_tmpScreenWidth*(_screenHeight+3), sizeof(uint16));
 	_tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen,
-						TMP_SCREEN_WIDTH, _screenHeight + 3, 16, TMP_SCREEN_WIDTH*2,
+						_tmpScreenWidth, _screenHeight + 3, 16, _tmpScreenWidth*2,
 						_hwscreen->format->Rmask,
 						_hwscreen->format->Gmask,
 						_hwscreen->format->Bmask,
@@ -303,7 +183,7 @@
 
 }
 
-void OSystem_SDL_Normal::unload_gfx_mode() {
+void OSystem_SDL::unload_gfx_mode() {
 	if (_screen) {
 		SDL_FreeSurface(_screen);
 		_screen = NULL; 
@@ -321,7 +201,7 @@
 	}
 }
 
-void OSystem_SDL_Normal::hotswap_gfx_mode() {
+void OSystem_SDL::hotswap_gfx_mode() {
 
 
 	// Keep around the old _screen & _tmpscreen so we can restore the screen data
@@ -351,7 +231,7 @@
 	update_screen();
 }
 
-void OSystem_SDL_Normal::update_screen() {
+void OSystem_SDL::update_screen() {
 	
 	assert(_hwscreen != NULL);
 
@@ -398,7 +278,7 @@
 		SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects;
 	
 		// Convert appropriate parts of the 8bpp image into 16bpp
-		if (!_overlay_visible) {
+		if (!_overlayVisible) {
 			SDL_Rect dst;
 			for(r = _dirty_rect_list; r != last_rect; ++r) {
 				dst = *r;
@@ -453,7 +333,7 @@
 	_forceFull = false;
 }
 
-uint32 OSystem_SDL_Normal::property(int param, Property *value) {
+uint32 OSystem_SDL::property(int param, Property *value) {
 
 	if (param == PROP_TOGGLE_FULLSCREEN) {
 		assert(_hwscreen != 0);
@@ -475,37 +355,37 @@
 	return OSystem_SDL_Common::property(param, value);
 }
 
-int16 OSystem_SDL_Normal::RBGToColor(uint8 r, uint8 g, uint8 b)
+int16 OSystem_SDL::RBGToColor(uint8 r, uint8 g, uint8 b)
 {
 	return SDL_MapRGB(_tmpscreen->format, r, g, b);
 }
 
-void OSystem_SDL_Normal::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
+void OSystem_SDL::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
 {
 	SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b);
 }
 
-void OSystem_SDL_Normal::show_overlay()
+void OSystem_SDL::show_overlay()
 {
 	// hide the mouse
 	undraw_mouse();
 
-	_overlay_visible = true;
+	_overlayVisible = true;
 	clear_overlay();
 }
 
-void OSystem_SDL_Normal::hide_overlay()
+void OSystem_SDL::hide_overlay()
 {
 	// hide the mouse
 	undraw_mouse();
 
-	_overlay_visible = false;
+	_overlayVisible = false;
 	_forceFull = true;
 }
 
-void OSystem_SDL_Normal::clear_overlay()
+void OSystem_SDL::clear_overlay()
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 	
 	// hide the mouse
@@ -523,9 +403,9 @@
 	_forceFull = true;
 }
 
-void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch)
+void OSystem_SDL::grab_overlay(int16 *buf, int pitch)
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 
 	if (_tmpscreen == NULL)
@@ -537,20 +417,20 @@
 	if (SDL_LockSurface(_tmpscreen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
-	int16 *src = (int16 *)_tmpscreen->pixels + TMP_SCREEN_WIDTH + 1;
+	int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1;
 	int h = _screenHeight;
 	do {
 		memcpy(buf, src, _screenWidth*2);
-		src += TMP_SCREEN_WIDTH;
+		src += _tmpScreenWidth;
 		buf += pitch;
 	} while (--h);
 
 	SDL_UnlockSurface(_tmpscreen);
 }
 
-void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
+void OSystem_SDL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 
 	if (_tmpscreen == NULL)
@@ -574,10 +454,10 @@
 	if (SDL_LockSurface(_tmpscreen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
-	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1);
+	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
 	do {
 		memcpy(dst, buf, w*2);
-		dst += TMP_SCREEN_WIDTH;
+		dst += _tmpScreenWidth;
 		buf += pitch;
 	} while (--h);
 

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sdl_gl.cpp	13 Dec 2002 16:15:45 -0000	1.16
+++ sdl_gl.cpp	13 Dec 2002 17:21:23 -0000	1.17
@@ -32,9 +32,9 @@
 
 #include "fb2opengl.h"
 
-class OSystem_SDL_Normal : public OSystem_SDL_Common {
+class OSystem_SDL_OpenGL : public OSystem_SDL_Common {
 public:
-	OSystem_SDL_Normal() : _tmpscreen(0), _overlay_visible(false) { _glScreenStart = 0; _glBilinearFilter = true; }
+	OSystem_SDL_OpenGL() { _glScreenStart = 0; _glBilinearFilter = true; }
 
 	// Set colors of the palette
 	void set_palette(const byte *colors, uint start, uint num);
@@ -60,27 +60,16 @@
 	SDL_Surface *tmpSurface; // Used for black rectangles blitting 
 	SDL_Rect tmpBlackRect; // Black rectangle at end of the GL screen
 
-	typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
-								uint8 *dstPtr, uint32 dstPitch, int width, int height);
-
-	SDL_Surface *_tmpscreen;   // temporary screen (for scalers/overlay)
-	bool _overlay_visible;
-
-	virtual void draw_mouse();
-	virtual void undraw_mouse();
-
 	virtual void load_gfx_mode();
 	virtual void unload_gfx_mode();
 	void hotswap_gfx_mode();
-	
-	int TMP_SCREEN_WIDTH;
 };
 
 OSystem_SDL_Common *OSystem_SDL_Common::create() {
-	return new OSystem_SDL_Normal();
+	return new OSystem_SDL_OpenGL();
 }
 
-void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) {
+void OSystem_SDL_OpenGL::set_palette(const byte *colors, uint start, uint num) {
 	const byte *b = colors;
 	uint i;
 	SDL_Color *base = _currentPalette + start;
@@ -98,116 +87,7 @@
 		_paletteDirtyEnd = start + num;
 }
 
-void OSystem_SDL_Normal::draw_mouse() {
-	if (!_overlay_visible) {
-		OSystem_SDL_Common::draw_mouse();
-	}
-
-	if (_mouseDrawn || !_mouseVisible)
-		return;
-
-	int x = _mouseCurState.x - _mouseHotspotX;
-	int y = _mouseCurState.y - _mouseHotspotY;
-	int w = _mouseCurState.w;
-	int h = _mouseCurState.h;
-	byte color;
-	byte *src = _mouseData;		// Image representing the mouse
-	uint16 *bak = (uint16*)_mouseBackup;	// Surface used to backup the area obscured by the mouse
-	uint16 *dst;					// Surface we are drawing into
-
-	// clip the mouse rect, and addjust the src pointer accordingly
-	if (x < 0) {
-		w += x;
-		src -= x;
-		x = 0;
-	}
-	if (y < 0) {
-		h += y;
-		src -= y * _mouseCurState.w;
-		y = 0;
-	}
-
-	// Quick check to see if anything has to be drawn at all
-	if (w <= 0 || h <= 0)
-		return;
-
-	if (w > _screenWidth - x)
-		w = _screenWidth - x;
-	if (h > _screenHeight - y)
-		h = _screenHeight - y;
-
-	// Store the bounding box so that undraw mouse can restore the area the
-	// mouse currently covers to its original content.
-	_mouseOldState.x = x;
-	_mouseOldState.y = y;
-	_mouseOldState.w = w;
-	_mouseOldState.h = h;
-
-	// Draw the mouse cursor; backup the covered area in "bak"
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	// Mark as dirty
-	add_dirty_rect(x, y, w, h);
-
-	dst = (uint16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1);
-	while (h > 0) {
-		int width = w;
-		while (width > 0) {
-			*bak++ = *dst;
-			color = *src++;
-			if (color != 0xFF)	// 0xFF = transparent, don't draw
-				*dst = RBGToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b);
-			dst++;
-			width--;
-		}
-		src += _mouseCurState.w - w;
-		bak += MAX_MOUSE_W - w;
-		dst += TMP_SCREEN_WIDTH - w;
-		h--;
-	}
-
-	SDL_UnlockSurface(_tmpscreen);
-	
-	// Finally, set the flag to indicate the mouse has been drawn
-	_mouseDrawn = true;
-}
-
-void OSystem_SDL_Normal::undraw_mouse() {
-	if (!_overlay_visible) {
-		OSystem_SDL_Common::undraw_mouse();
-	}
-
-	if (!_mouseDrawn)
-		return;
-	_mouseDrawn = false;
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	uint16 *dst, *bak = (uint16 *)_mouseBackup;
-	const int old_mouse_x = _mouseOldState.x;
-	const int old_mouse_y = _mouseOldState.y;
-	const int old_mouse_w = _mouseOldState.w;
-	const int old_mouse_h = _mouseOldState.h;
-	int x, y;
-
-	// No need to do clipping here, since draw_mouse() did that already
-
-	dst = (uint16 *)_tmpscreen->pixels + (old_mouse_y+1) * TMP_SCREEN_WIDTH + (old_mouse_x+1);
-	for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += TMP_SCREEN_WIDTH) {
-		for (x = 0; x < old_mouse_w; ++x) {
-			dst[x] = bak[x];
-		}
-	}
-
-	add_dirty_rect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
-void OSystem_SDL_Normal::load_gfx_mode() {
+void OSystem_SDL_OpenGL::load_gfx_mode() {
 	uint32 Rmask, Gmask, Bmask, Amask;
 	// I have to force 16 bit color depth with 565 ordering
 	// SDL_SetVideoMode sometimes doesn't accept your color depth definition
@@ -221,7 +101,7 @@
 	_scaleFactor = 2;
 
 	_tmpscreen = NULL;
-	TMP_SCREEN_WIDTH = (_screenWidth + 3);
+	_tmpScreenWidth = (_screenWidth + 3);
 	
 	//
 	// Create the surface that contains the 8 bit game data
@@ -251,9 +131,9 @@
 	//
 
 	// Need some extra bytes around when using 2xSaI
-	uint16 *tmp_screen = (uint16*)calloc(TMP_SCREEN_WIDTH*(_screenHeight+3),sizeof(uint16));
+	uint16 *tmp_screen = (uint16*)calloc(_tmpScreenWidth*(_screenHeight+3),sizeof(uint16));
 	_tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen,
-						TMP_SCREEN_WIDTH, _screenHeight + 3, 16, TMP_SCREEN_WIDTH*2,
+						_tmpScreenWidth, _screenHeight + 3, 16, _tmpScreenWidth*2,
 						Rmask,
 						Gmask,
 						Bmask,
@@ -284,7 +164,7 @@
 
 }
 
-void OSystem_SDL_Normal::unload_gfx_mode() {
+void OSystem_SDL_OpenGL::unload_gfx_mode() {
 	if (_screen) {
 		SDL_FreeSurface(_screen);
 		_screen = NULL; 
@@ -297,7 +177,7 @@
 	}
 }
 
-void OSystem_SDL_Normal::update_screen() {
+void OSystem_SDL_OpenGL::update_screen() {
 	
 	// If the shake position changed, fill the dirty area with blackness
 	if (_currentShakePos != _newShakePos) {
@@ -343,7 +223,7 @@
 		SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects;
 	
 		// Convert appropriate parts of the 8bpp image into 16bpp
-		if (!_overlay_visible) {
+		if (!_overlayVisible) {
 			SDL_Rect dst;
 			for(r = _dirty_rect_list; r != last_rect; ++r) {
 				dst = *r;
@@ -370,7 +250,7 @@
 	_forceFull = false;
 }
 
-void OSystem_SDL_Normal::hotswap_gfx_mode() {
+void OSystem_SDL_OpenGL::hotswap_gfx_mode() {
 	/* We allocate a screen sized bitmap which contains a "backup"
 	 * of the screen data during the change. Then we draw that to
 	 * the new screen right after it's setup.
@@ -393,7 +273,7 @@
 	update_screen();
 }
 
-uint32 OSystem_SDL_Normal::property(int param, Property *value) {
+uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
 
 	if (param == PROP_TOGGLE_FULLSCREEN) {
 		_full_screen ^= true;
@@ -460,27 +340,27 @@
 }
 
 
-void OSystem_SDL_Normal::show_overlay()
+void OSystem_SDL_OpenGL::show_overlay()
 {
 	// hide the mouse
 	undraw_mouse();
 
-	_overlay_visible = true;
+	_overlayVisible = true;
 	clear_overlay();
 }
 
-void OSystem_SDL_Normal::hide_overlay()
+void OSystem_SDL_OpenGL::hide_overlay()
 {
 	// hide the mouse
 	undraw_mouse();
 
-	_overlay_visible = false;
+	_overlayVisible = false;
 	_forceFull = true;
 }
 
-void OSystem_SDL_Normal::clear_overlay()
+void OSystem_SDL_OpenGL::clear_overlay()
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 	
 	// hide the mouse
@@ -499,9 +379,9 @@
 	_forceFull = true;
 }
 
-void OSystem_SDL_Normal::grab_overlay(int16 *buf, int pitch)
+void OSystem_SDL_OpenGL::grab_overlay(int16 *buf, int pitch)
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 
 	if (_tmpscreen == NULL)
@@ -513,20 +393,20 @@
 	if (SDL_LockSurface(_tmpscreen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
-	int16 *src = (int16 *)_tmpscreen->pixels + TMP_SCREEN_WIDTH + 1;
+	int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1;
 	int h = _screenHeight;
 	do {
 		memcpy(buf, src, _screenWidth*2);
-		src += TMP_SCREEN_WIDTH;
+		src += _tmpScreenWidth;
 		buf += pitch;
 	} while (--h);
 
 	SDL_UnlockSurface(_tmpscreen);
 }
 
-void OSystem_SDL_Normal::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
+void OSystem_SDL_OpenGL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
 {
-	if (!_overlay_visible)
+	if (!_overlayVisible)
 		return;
 
 	if (_tmpscreen == NULL)
@@ -550,10 +430,10 @@
 	if (SDL_LockSurface(_tmpscreen) == -1)
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
-	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * TMP_SCREEN_WIDTH + (x+1);
+	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
 	do {
 		memcpy(dst, buf, w*2);
-		dst += TMP_SCREEN_WIDTH;
+		dst += _tmpScreenWidth;
 		buf += pitch;
 	} while (--h);
 





More information about the Scummvm-git-logs mailing list