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

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


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

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

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- sdl-common.cpp	13 Dec 2002 17:21:11 -0000	1.17
+++ sdl-common.cpp	13 Dec 2002 17:27:15 -0000	1.18
@@ -989,3 +989,112 @@
 void OSystem_SDL_Common::delete_mutex(void *mutex) {
 	SDL_DestroyMutex((SDL_mutex *) mutex);
 }
+
+void OSystem_SDL_Common::show_overlay()
+{
+	// hide the mouse
+	undraw_mouse();
+
+	_overlayVisible = true;
+	clear_overlay();
+}
+
+void OSystem_SDL_Common::hide_overlay()
+{
+	// hide the mouse
+	undraw_mouse();
+
+	_overlayVisible = false;
+	_forceFull = true;
+}
+
+void OSystem_SDL_Common::clear_overlay()
+{
+	if (!_overlayVisible)
+		return;
+	
+	// hide the mouse
+	undraw_mouse();
+
+	// Clear the overlay by making the game screen "look through" everywhere.
+	SDL_Rect src, dst;
+	src.x = src.y = 0;
+	dst.x = dst.y = 1;
+	src.w = dst.w = _screenWidth;
+	src.h = dst.h = _screenHeight;
+	if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0)
+		error("SDL_BlitSurface failed: %s", SDL_GetError());
+
+	_forceFull = true;
+}
+
+void OSystem_SDL_Common::grab_overlay(int16 *buf, int pitch)
+{
+	if (!_overlayVisible)
+		return;
+
+	if (_tmpscreen == NULL)
+		return;
+
+	// hide the mouse
+	undraw_mouse();
+
+	if (SDL_LockSurface(_tmpscreen) == -1)
+		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
+
+	int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1;
+	int h = _screenHeight;
+	do {
+		memcpy(buf, src, _screenWidth*2);
+		src += _tmpScreenWidth;
+		buf += pitch;
+	} while (--h);
+
+	SDL_UnlockSurface(_tmpscreen);
+}
+
+void OSystem_SDL_Common::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
+{
+	if (!_overlayVisible)
+		return;
+
+	if (_tmpscreen == NULL)
+		return;
+
+	// Clip the coordinates
+	if (x < 0) { w+=x; buf-=x; x = 0; }
+	if (y < 0) { h+=y; buf-=y*pitch; y = 0; }
+	if (w > _screenWidth-x) { w = _screenWidth - x; }
+	if (h > _screenHeight-y) { h = _screenHeight - y; }
+	if (w <= 0 || h <= 0)
+		return;
+	
+	// Mark the modified region as dirty
+	cksum_valid = false;
+	add_dirty_rect(x, y, w, h);
+
+	/* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */
+	undraw_mouse();
+
+	if (SDL_LockSurface(_tmpscreen) == -1)
+		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
+
+	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
+	do {
+		memcpy(dst, buf, w*2);
+		dst += _tmpScreenWidth;
+		buf += pitch;
+	} while (--h);
+
+	SDL_UnlockSurface(_tmpscreen);
+}
+
+int16 OSystem_SDL_Common::RBGToColor(uint8 r, uint8 g, uint8 b)
+{
+	return SDL_MapRGB(_tmpscreen->format, r, g, b);
+}
+
+void OSystem_SDL_Common::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
+{
+	SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b);
+}

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sdl-common.h	13 Dec 2002 17:21:16 -0000	1.8
+++ sdl-common.h	13 Dec 2002 17:27:19 -0000	1.9
@@ -103,6 +103,17 @@
 	void unlock_mutex(void *mutex);
 	void delete_mutex(void *mutex);
 
+	// Overlay
+	virtual void show_overlay();
+	virtual void hide_overlay();
+	virtual void clear_overlay();
+	virtual void grab_overlay(int16 *buf, int pitch);
+	virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
+
+	// Methods that convert RBG to/from colors suitable for the overlay.
+	virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b);
+	virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b);
+
 	static OSystem *create(int gfx_mode, bool full_screen);
 
 protected:

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sdl.cpp	13 Dec 2002 17:21:20 -0000	1.16
+++ sdl.cpp	13 Dec 2002 17:27:22 -0000	1.17
@@ -38,17 +38,6 @@
 	// Set a parameter
 	uint32 property(int param, Property *value);
 
-	// Overlay
-	virtual void show_overlay();
-	virtual void hide_overlay();
-	virtual void clear_overlay();
-	virtual void grab_overlay(int16 *buf, int pitch);
-	virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
-
-	// Methods that convert RBG to/from colors suitable for the overlay.
-	virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b);
-	virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b);
-
 protected:
 	SDL_Surface *_hwscreen;    // hardware screen
 
@@ -354,114 +343,4 @@
 	
 	return OSystem_SDL_Common::property(param, value);
 }
-
-int16 OSystem_SDL::RBGToColor(uint8 r, uint8 g, uint8 b)
-{
-	return SDL_MapRGB(_tmpscreen->format, r, g, b);
-}
-
-void OSystem_SDL::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
-{
-	SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b);
-}
-
-void OSystem_SDL::show_overlay()
-{
-	// hide the mouse
-	undraw_mouse();
-
-	_overlayVisible = true;
-	clear_overlay();
-}
-
-void OSystem_SDL::hide_overlay()
-{
-	// hide the mouse
-	undraw_mouse();
-
-	_overlayVisible = false;
-	_forceFull = true;
-}
-
-void OSystem_SDL::clear_overlay()
-{
-	if (!_overlayVisible)
-		return;
-	
-	// hide the mouse
-	undraw_mouse();
-
-	// Clear the overlay by making the game screen "look through" everywhere.
-	SDL_Rect src, dst;
-	src.x = src.y = 0;
-	dst.x = dst.y = 1;
-	src.w = dst.w = _screenWidth;
-	src.h = dst.h = _screenHeight;
-	if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0)
-		error("SDL_BlitSurface failed: %s", SDL_GetError());
-
-	_forceFull = true;
-}
-
-void OSystem_SDL::grab_overlay(int16 *buf, int pitch)
-{
-	if (!_overlayVisible)
-		return;
-
-	if (_tmpscreen == NULL)
-		return;
-
-	// hide the mouse
-	undraw_mouse();
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1;
-	int h = _screenHeight;
-	do {
-		memcpy(buf, src, _screenWidth*2);
-		src += _tmpScreenWidth;
-		buf += pitch;
-	} while (--h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
-void OSystem_SDL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
-{
-	if (!_overlayVisible)
-		return;
-
-	if (_tmpscreen == NULL)
-		return;
-
-	// Clip the coordinates
-	if (x < 0) { w+=x; buf-=x; x = 0; }
-	if (y < 0) { h+=y; buf-=y*pitch; y = 0; }
-	if (w > _screenWidth-x) { w = _screenWidth - x; }
-	if (h > _screenHeight-y) { h = _screenHeight - y; }
-	if (w <= 0 || h <= 0)
-		return;
-	
-	// Mark the modified region as dirty
-	cksum_valid = false;
-	add_dirty_rect(x, y, w, h);
-
-	/* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */
-	undraw_mouse();
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
-	do {
-		memcpy(dst, buf, w*2);
-		dst += _tmpScreenWidth;
-		buf += pitch;
-	} while (--h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
 

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- sdl_gl.cpp	13 Dec 2002 17:21:23 -0000	1.17
+++ sdl_gl.cpp	13 Dec 2002 17:27:28 -0000	1.18
@@ -45,13 +45,6 @@
 	// Set a parameter
 	uint32 property(int param, Property *value);
 
-	// Overlay
-	virtual void show_overlay();
-	virtual void hide_overlay();
-	virtual void clear_overlay();
-	virtual void grab_overlay(int16 *buf, int pitch);
-	virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
-
 protected:
 	FB2GL fb2gl;
 	int gl_flags;
@@ -338,106 +331,3 @@
 	
 	return OSystem_SDL_Common::property(param, value);
 }
-
-
-void OSystem_SDL_OpenGL::show_overlay()
-{
-	// hide the mouse
-	undraw_mouse();
-
-	_overlayVisible = true;
-	clear_overlay();
-}
-
-void OSystem_SDL_OpenGL::hide_overlay()
-{
-	// hide the mouse
-	undraw_mouse();
-
-	_overlayVisible = false;
-	_forceFull = true;
-}
-
-void OSystem_SDL_OpenGL::clear_overlay()
-{
-	if (!_overlayVisible)
-		return;
-	
-	// hide the mouse
-	undraw_mouse();
-
-	// Clear the overlay by making the game screen "look through" everywhere.
-	SDL_Rect src, dst;
-	src.x = src.y = 0;
-//	dst.x = dst.y = 1;
-	dst.x = dst.y = 0;
-	src.w = dst.w = _screenWidth;
-	src.h = dst.h = _screenHeight;
-	if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0)
-		error("SDL_BlitSurface failed: %s", SDL_GetError());
-
-	_forceFull = true;
-}
-
-void OSystem_SDL_OpenGL::grab_overlay(int16 *buf, int pitch)
-{
-	if (!_overlayVisible)
-		return;
-
-	if (_tmpscreen == NULL)
-		return;
-
-	// hide the mouse
-	undraw_mouse();
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1;
-	int h = _screenHeight;
-	do {
-		memcpy(buf, src, _screenWidth*2);
-		src += _tmpScreenWidth;
-		buf += pitch;
-	} while (--h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
-void OSystem_SDL_OpenGL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h)
-{
-	if (!_overlayVisible)
-		return;
-
-	if (_tmpscreen == NULL)
-		return;
-
-	// Clip the coordinates
-	if (x < 0) { w+=x; buf-=x; x = 0; }
-	if (y < 0) { h+=y; buf-=y*pitch; y = 0; }
-	if (w > _screenWidth-x) { w = _screenWidth - x; }
-	if (h > _screenHeight-y) { h = _screenHeight - y; }
-	if (w <= 0 || h <= 0)
-		return;
-	
-	// Mark the modified region as dirty
-	cksum_valid = false;
-	add_dirty_rect(x, y, w, h);
-
-	/* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */
-	undraw_mouse();
-
-	if (SDL_LockSurface(_tmpscreen) == -1)
-		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
-
-	int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1);
-	do {
-		memcpy(dst, buf, w*2);
-		dst += _tmpScreenWidth;
-		buf += pitch;
-	} while (--h);
-
-	SDL_UnlockSurface(_tmpscreen);
-}
-
-





More information about the Scummvm-git-logs mailing list