[Scummvm-cvs-logs] SF.net SVN: scummvm:[45900] scummvm/trunk/backends/platform

aquadran at users.sourceforge.net aquadran at users.sourceforge.net
Sat Nov 14 16:46:38 CET 2009


Revision: 45900
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45900&view=rev
Author:   aquadran
Date:     2009-11-14 15:46:38 +0000 (Sat, 14 Nov 2009)

Log Message:
-----------
samsungtv: continue reduction of code duplication

Modified Paths:
--------------
    scummvm/trunk/backends/platform/samsungtv/graphics.cpp
    scummvm/trunk/backends/platform/samsungtv/samsungtv.cpp
    scummvm/trunk/backends/platform/samsungtv/samsungtv.h
    scummvm/trunk/backends/platform/sdl/graphics.cpp

Modified: scummvm/trunk/backends/platform/samsungtv/graphics.cpp
===================================================================
--- scummvm/trunk/backends/platform/samsungtv/graphics.cpp	2009-11-14 14:02:53 UTC (rev 45899)
+++ scummvm/trunk/backends/platform/samsungtv/graphics.cpp	2009-11-14 15:46:38 UTC (rev 45900)
@@ -34,220 +34,36 @@
 
 #if defined(SAMSUNGTV)
 
-Common::List<Graphics::PixelFormat> OSystem_SDL_SamsungTV::getSupportedFormats() {
-	static Common::List<Graphics::PixelFormat>list;
-	SDL_Surface *bak = _hwscreen;
-	_hwscreen = _prehwscreen;
-	list = OSystem_SDL::getSupportedFormats();
-	_hwscreen = bak;
-	return list;
-}
-
-static void fixupResolutionForAspectRatio(AspectRatio desiredAspectRatio, int &width, int &height) {
-	assert(&width != &height);
-
-	// FIXME: TV SDL return empty list. However TV accept any resolution
-	// Consider list fixed list or make calculation. For now it's disabled.
-//	if (desiredAspectRatio.isAuto())
-		return;
-	
-	int kw = desiredAspectRatio.kw();
-	int kh = desiredAspectRatio.kh();
-
-	const int w = width;
-	const int h = height;
-
-	SDL_Rect const* const*availableModes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_SWSURFACE); //TODO : Maybe specify a pixel format
-	assert(availableModes);
-
-	const SDL_Rect *bestMode = NULL;
-	uint bestMetric = (uint)-1; // Metric is wasted space
-	while (const SDL_Rect *mode = *availableModes++) {
-		if (mode->w < w)
-			continue;
-		if (mode->h < h)
-			continue;
-		if (mode->h * kw != mode->w * kh)
-			continue;
-		//printf("%d %d\n", mode->w, mode->h);
-
-		uint metric = mode->w * mode->h - w * h;
-		if (metric > bestMetric)
-			continue;
-
-		bestMetric = metric;
-		bestMode = mode;
-	}
-
-	if (!bestMode) {
-		warning("Unable to enforce the desired aspect ratio!");
-		return;
-	}
-	//printf("%d %d\n", bestMode->w, bestMode->h);
-	width = bestMode->w;
-	height = bestMode->h;
-}
-
 bool OSystem_SDL_SamsungTV::loadGFXMode() {
-	assert(_inited);
-	_forceFull = true;
+       OSystem_SDL::loadGFXMode();
+       _realhwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
+               _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE);
 
-	_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
-	_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
-
-	if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400)
-		_videoMode.aspectRatioCorrection = false;
-
-	if (_videoMode.aspectRatioCorrection)
-		_videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight);
-
-	_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
-	_videoMode.hardwareHeight = effectiveScreenHeight();
-
-	_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 
-						_screenFormat.bytesPerPixel << 3, 
-						((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift ,
-						((1 << _screenFormat.gBits()) - 1) << _screenFormat.gShift ,
-						((1 << _screenFormat.bBits()) - 1) << _screenFormat.bShift ,
-						((1 << _screenFormat.aBits()) - 1) << _screenFormat.aShift );
-	if (_screen == NULL)
-		error("allocating _screen failed");
-
-	//
-	// Create the surface that contains the scaled graphics in 16 bit mode
-	//
-
-	if (_videoMode.fullscreen) {
-		fixupResolutionForAspectRatio(_videoMode.desiredAspectRatio, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
-	}
-
-	_prehwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.hardwareWidth, _videoMode.hardwareHeight,
-						16, 0, 0, 0, 0);
-	if (_prehwscreen == NULL)
-		error("allocating _prehwscreen failed");
-
-	_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
-		_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
-	);
-
-	if (_hwscreen == NULL) {
-		// DON'T use error(), as this tries to bring up the debug
-		// console, which WON'T WORK now that _hwscreen is hosed.
-
-		if (!_oldVideoMode.setup) {
-			warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
-			quit();
-		} else {
-			return false;
-		}
-	}
-
-	//
-	// Create the surface used for the graphics in 16 bit before scaling, and also the overlay
-	//
-
-	// Need some extra bytes around when using 2xSaI
-	_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3,
-						16,
-						_prehwscreen->format->Rmask,
-						_prehwscreen->format->Gmask,
-						_prehwscreen->format->Bmask,
-						_prehwscreen->format->Amask);
-
-	if (_tmpscreen == NULL)
-		error("allocating _tmpscreen failed");
-
-	_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight,
-						16,
-						_prehwscreen->format->Rmask,
-						_prehwscreen->format->Gmask,
-						_prehwscreen->format->Bmask,
-						_prehwscreen->format->Amask);
-
-	if (_overlayscreen == NULL)
-		error("allocating _overlayscreen failed");
-
-	_overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel;
-
-	_overlayFormat.rLoss = _overlayscreen->format->Rloss;
-	_overlayFormat.gLoss = _overlayscreen->format->Gloss;
-	_overlayFormat.bLoss = _overlayscreen->format->Bloss;
-	_overlayFormat.aLoss = _overlayscreen->format->Aloss;
-
-	_overlayFormat.rShift = _overlayscreen->format->Rshift;
-	_overlayFormat.gShift = _overlayscreen->format->Gshift;
-	_overlayFormat.bShift = _overlayscreen->format->Bshift;
-	_overlayFormat.aShift = _overlayscreen->format->Ashift;
-
-	_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
-						16,
-						_prehwscreen->format->Rmask,
-						_prehwscreen->format->Gmask,
-						_prehwscreen->format->Bmask,
-						_prehwscreen->format->Amask);
-
-	if (_tmpscreen2 == NULL)
-		error("allocating _tmpscreen2 failed");
-
-#ifdef USE_OSD
-	_osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
-						_hwscreen->w,
-						_hwscreen->h,
-						32,
-						_hwscreen->format->Rmask,
-						_hwscreen->format->Gmask,
-						_hwscreen->format->Bmask,
-						_hwscreen->format->Amask);
-	if (_osdSurface == NULL)
-		error("allocating _osdSurface failed");
-	SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);
-#endif
-
-	// keyboard cursor control, some other better place for it?
-	_km.x_max = _videoMode.screenWidth * _videoMode.scaleFactor - 1;
-	_km.y_max = effectiveScreenHeight() - 1;
-	_km.delay_time = 25;
-	_km.last_time = 0;
-
-	// Distinguish 555 and 565 mode
-	if (_screen->format->Rmask == 0x7C00)
-		InitScalers(555);
-	else
-		InitScalers(565);
-
-	return true;
+       return true;
 }
 
 void OSystem_SDL_SamsungTV::unloadGFXMode() {
-	if (_prehwscreen) {
-		SDL_FreeSurface(_prehwscreen);
-		_prehwscreen = NULL;
-	}
+       if (_realhwscreen) {
+               SDL_FreeSurface(_realhwscreen);
+               _realhwscreen = NULL;
+       }
 
-	OSystem_SDL::unloadGFXMode();
+       OSystem_SDL::unloadGFXMode();
 }
 
 bool OSystem_SDL_SamsungTV::hotswapGFXMode() {
 	if (!_screen)
 		return false;
 
-	SDL_FreeSurface(_prehwscreen); _prehwscreen = NULL;
+	SDL_FreeSurface(_realhwscreen); _realhwscreen = NULL;
 
 	return OSystem_SDL::hotswapGFXMode();
 }
 
 void OSystem_SDL_SamsungTV::internUpdateScreen() {
-	// HACK: Use _prehwscreen instead of _hwscreen for this one.
-	// On the long run, it would be cleaner to use _prehwscreen as _hwscreen,
-	// and keep what is now called _hwscreen in a new variable _realhwscreen.
-	// This way we wouldn't have to overload drawMouse(), too.
-	SDL_Surface *bak = _hwscreen;
-	_hwscreen = _prehwscreen;
 	OSystem_SDL::internUpdateScreen();
-	_hwscreen = bak;
-
-	SDL_BlitSurface(_prehwscreen, 0, _hwscreen, 0);
-	SDL_UpdateRect(_hwscreen, 0, 0, 0, 0);
+	SDL_BlitSurface(_hwscreen, 0, _realhwscreen, 0);
+	SDL_UpdateRect(_realhwscreen, 0, 0, 0, 0);
 }
 
 void OSystem_SDL_SamsungTV::warpMouse(int x, int y) {
@@ -266,25 +82,4 @@
 	}
 }
 
-void OSystem_SDL_SamsungTV::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
-	SDL_Surface *bak = _hwscreen;
-	_hwscreen = _prehwscreen;
-	OSystem_SDL::setMouseCursor(buf, w, h, hotspot_x, hotspot_y, keycolor, cursorTargetScale, format);
-	_hwscreen = bak;
-}
-
-void OSystem_SDL_SamsungTV::blitCursor() {
-	SDL_Surface *bak = _hwscreen;
-	_hwscreen = _prehwscreen;
-	OSystem_SDL::blitCursor();
-	_hwscreen = bak;
-}
-
-void OSystem_SDL_SamsungTV::drawMouse() {
-	SDL_Surface *bak = _hwscreen;
-	_hwscreen = _prehwscreen;
-	OSystem_SDL::drawMouse();
-	_hwscreen = bak;
-}
-
 #endif

Modified: scummvm/trunk/backends/platform/samsungtv/samsungtv.cpp
===================================================================
--- scummvm/trunk/backends/platform/samsungtv/samsungtv.cpp	2009-11-14 14:02:53 UTC (rev 45899)
+++ scummvm/trunk/backends/platform/samsungtv/samsungtv.cpp	2009-11-14 15:46:38 UTC (rev 45900)
@@ -28,7 +28,7 @@
 #if defined(SAMSUNGTV)
 
 OSystem_SDL_SamsungTV::OSystem_SDL_SamsungTV() : OSystem_SDL(),
-	_prehwscreen(0) {
+	_realhwscreen(0) {
 }
 
 bool OSystem_SDL_SamsungTV::hasFeature(Feature f) {

Modified: scummvm/trunk/backends/platform/samsungtv/samsungtv.h
===================================================================
--- scummvm/trunk/backends/platform/samsungtv/samsungtv.h	2009-11-14 14:02:53 UTC (rev 45899)
+++ scummvm/trunk/backends/platform/samsungtv/samsungtv.h	2009-11-14 15:46:38 UTC (rev 45900)
@@ -41,19 +41,8 @@
 public:
 	OSystem_SDL_SamsungTV();
 
-	// Highest supported
-	virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
-
-	// Warp the mouse cursor. Where set_mouse_pos() only informs the
-	// backend of the mouse cursor's current position, this function
-	// actually moves the cursor to the specified position.
 	virtual void warpMouse(int x, int y);
 
-	// Set the bitmap that's used when drawing the cursor.
-	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
-
-	// Get the next event.
-	// Returns true if an event was retrieved.
 	virtual bool pollEvent(Common::Event &event);
 
 	virtual bool hasFeature(Feature f);
@@ -62,17 +51,14 @@
 
 protected:
 
-	SDL_Surface *_prehwscreen;
+	SDL_Surface *_realhwscreen;
 
-	virtual void drawMouse(); // overloaded by CE backend
-	virtual void blitCursor(); // overloaded by CE backend (FIXME)
+	virtual void internUpdateScreen();
 
-	virtual void internUpdateScreen(); // overloaded by CE backend
+	virtual bool loadGFXMode();
+	virtual void unloadGFXMode();
+	virtual bool hotswapGFXMode();
 
-	virtual bool loadGFXMode(); // overloaded by CE backend
-	virtual void unloadGFXMode(); // overloaded by CE backend
-	virtual bool hotswapGFXMode(); // overloaded by CE backend
-
 	void handleKbdMouse();
 	void generateMouseMoveEvent(int x, int y);
 

Modified: scummvm/trunk/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/graphics.cpp	2009-11-14 14:02:53 UTC (rev 45899)
+++ scummvm/trunk/backends/platform/sdl/graphics.cpp	2009-11-14 15:46:38 UTC (rev 45900)
@@ -568,6 +568,11 @@
 		fixupResolutionForAspectRatio(_videoMode.desiredAspectRatio, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
 	}
 
+#if defined(SAMSUNGTV)
+	_hwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, 0, 0, 0, 0);
+	if (_hwscreen == NULL)
+		error("allocating _hwscreen failed");
+#else
 	_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16,
 		_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
 	);
@@ -582,6 +587,7 @@
 			return false;
 		}
 	}
+#endif
 
 	//
 	// Create the surface used for the graphics in 16 bit before scaling, and also the overlay


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list