diff options
Diffstat (limited to 'backends/graphics')
21 files changed, 400 insertions, 301 deletions
diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index 8075d0d45b..17a95688f3 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -122,7 +122,7 @@ void DINGUXSdlGraphicsManager::initSize(uint w, uint h) {  	if (w > 320 || h > 240) {  		setGraphicsMode(GFX_HALF);  		setGraphicsModeIntern(); -		_sdlEventSource->toggleMouseGrab(); +		_eventSource->toggleMouseGrab();  	}  	_transactionDetails.sizeChanged = true; @@ -427,6 +427,7 @@ void DINGUXSdlGraphicsManager::hideOverlay() {  }  bool DINGUXSdlGraphicsManager::loadGFXMode() { +	debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight);  	// Forcefully disable aspect ratio correction for games  	// which starts with a native 240px height resolution. @@ -435,7 +436,6 @@ bool DINGUXSdlGraphicsManager::loadGFXMode() {  		_videoMode.aspectRatioCorrection = false;  	} -	debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight);  	if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) {  		_videoMode.aspectRatioCorrection = false;  		setGraphicsMode(GFX_HALF); @@ -473,9 +473,13 @@ bool DINGUXSdlGraphicsManager::hasFeature(OSystem::Feature f) {  void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {  	switch (f) { -		case OSystem::kFeatureAspectRatioCorrection: +	case OSystem::kFeatureAspectRatioCorrection:  		setAspectRatioCorrection(enable);  		break; +	case OSystem::kFeatureCursorPalette: +		_cursorPaletteDisabled = !enable; +		blitCursor(); +		break;	  	default:  		break;  	} @@ -485,8 +489,10 @@ bool DINGUXSdlGraphicsManager::getFeatureState(OSystem::Feature f) {  	assert(_transactionMode == kTransactionNone);  	switch (f) { -		case OSystem::kFeatureAspectRatioCorrection: -		return _videoMode.aspectRatioCorrection; +	case OSystem::kFeatureAspectRatioCorrection: +			return _videoMode.aspectRatioCorrection; +	case OSystem::kFeatureCursorPalette: +		return !_cursorPaletteDisabled;  	default:  		return false;  	} @@ -510,21 +516,16 @@ void DINGUXSdlGraphicsManager::warpMouse(int x, int y) {  	SurfaceSdlGraphicsManager::warpMouse(x, y);  } -void DINGUXSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { -	if (!event.synthetic) { -		Common::Event newEvent(event); -		newEvent.synthetic = true; -		if (!_overlayVisible) { -			if (_videoMode.mode == GFX_HALF) { -				newEvent.mouse.x *= 2; -				newEvent.mouse.y *= 2; -			} -			newEvent.mouse.x /= _videoMode.scaleFactor; -			newEvent.mouse.y /= _videoMode.scaleFactor; -			if (_videoMode.aspectRatioCorrection) -				newEvent.mouse.y = aspect2Real(newEvent.mouse.y); +void DINGUXSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	if (!_overlayVisible) { +		if (_videoMode.mode == GFX_HALF) { +			point.x *= 2; +			point.y *= 2;  		} -		g_system->getEventManager()->pushEvent(newEvent); +		point.x /= _videoMode.scaleFactor; +		point.y /= _videoMode.scaleFactor; +		if (_videoMode.aspectRatioCorrection) +			point.y = aspect2Real(point.y);  	}  } diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h index 84a784b771..ecdd01d166 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h @@ -57,7 +57,7 @@ public:  	SurfaceSdlGraphicsManager::MousePos *getMouseCurState();  	SurfaceSdlGraphicsManager::VideoState *getVideoMode(); -	virtual void adjustMouseEvent(const Common::Event &event); +	virtual void transformMouseCoordinates(Common::Point &point);  };  #endif /* BACKENDS_GRAPHICS_SDL_DINGUX_H */ diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index 82a32203fb..a0c1d9ad2b 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -36,7 +36,7 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {  };  GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *sdlEventSource) - : SurfaceSdlGraphicsManager(sdlEventSource) { +	: SurfaceSdlGraphicsManager(sdlEventSource) {  }  const OSystem::GraphicsMode *GPHGraphicsManager::getSupportedGraphicsModes() const { @@ -138,10 +138,10 @@ void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f  	_videoMode.screenWidth = w;  	_videoMode.screenHeight = h; -	if (w > 320 || h > 240){ +	if (w > 320 || h > 240) {  		setGraphicsMode(GFX_HALF);  		setGraphicsModeIntern(); -		_sdlEventSource->toggleMouseGrab(); +		_eventSource->toggleMouseGrab();  	}  	_videoMode.overlayWidth = 320; @@ -161,9 +161,9 @@ void GPHGraphicsManager::drawMouse() {  	int width, height;  	int hotX, hotY; -	if (_videoMode.mode == GFX_HALF && !_overlayVisible){ -		dst.x = _mouseCurState.x/2; -		dst.y = _mouseCurState.y/2; +	if (_videoMode.mode == GFX_HALF && !_overlayVisible) { +		dst.x = _mouseCurState.x / 2; +		dst.y = _mouseCurState.y / 2;  	} else {  		dst.x = _mouseCurState.x;  		dst.y = _mouseCurState.y; @@ -230,9 +230,9 @@ void GPHGraphicsManager::undrawMouse() {  	if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight))  		return; -	if (_mouseBackup.w != 0 && _mouseBackup.h != 0){ -		if (_videoMode.mode == GFX_HALF && !_overlayVisible){ -			addDirtyRect(x*2, y*2, _mouseBackup.w*2, _mouseBackup.h*2); +	if (_mouseBackup.w != 0 && _mouseBackup.h != 0) { +		if (_videoMode.mode == GFX_HALF && !_overlayVisible) { +			addDirtyRect(x * 2, y * 2, _mouseBackup.w * 2, _mouseBackup.h * 2);  		} else {  			addDirtyRect(x, y, _mouseBackup.w, _mouseBackup.h);  		} @@ -252,8 +252,8 @@ void GPHGraphicsManager::internUpdateScreen() {  	// If the shake position changed, fill the dirty area with blackness  	if (_currentShakePos != _newShakePos || -		(_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { -		SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; +	        (_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { +		SDL_Rect blackrect = {0, 0, _videoMode.screenWidth *_videoMode.scaleFactor, _newShakePos *_videoMode.scaleFactor};  		if (_videoMode.aspectRatioCorrection && !_overlayVisible)  			blackrect.h = real2Aspect(blackrect.h - 1) + 1; @@ -269,8 +269,8 @@ void GPHGraphicsManager::internUpdateScreen() {  	// screen surface accordingly.  	if (_screen && _paletteDirtyEnd != 0) {  		SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, -			_paletteDirtyStart, -			_paletteDirtyEnd - _paletteDirtyStart); +		              _paletteDirtyStart, +		              _paletteDirtyEnd - _paletteDirtyStart);  		_paletteDirtyEnd = 0; @@ -326,6 +326,9 @@ void GPHGraphicsManager::internUpdateScreen() {  		_dirtyRectList[0].y = 0;  		_dirtyRectList[0].w = width;  		_dirtyRectList[0].h = height; + +		// HACK: Make sure the full hardware screen is wiped clean. +		SDL_FillRect(_hwscreen, NULL, 0);  	}  	// Only draw anything if necessary @@ -337,8 +340,8 @@ void GPHGraphicsManager::internUpdateScreen() {  		for (r = _dirtyRectList; r != lastRect; ++r) {  			dst = *r; -			dst.x++;	// Shift rect by one since 2xSai needs to access the data around -			dst.y++;	// any pixel to scale it, and we want to avoid mem access crashes. +			dst.x++;    // Shift rect by one since 2xSai needs to access the data around +			dst.y++;    // any pixel to scale it, and we want to avoid mem access crashes.  			if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0)  				error("SDL_BlitSurface failed: %s", SDL_GetError()); @@ -374,11 +377,11 @@ void GPHGraphicsManager::internUpdateScreen() {  				assert(scalerProc != NULL);  				if ((_videoMode.mode == GFX_HALF) && (scalerProc == DownscaleAllByHalf)) { -					if (dst_x%2==1){ +					if (dst_x % 2 == 1) {  						dst_x--;  						dst_w++;  					} -					if (dst_y%2==1){ +					if (dst_y % 2 == 1) {  						dst_y--;  						dst_h++;  					} @@ -388,14 +391,14 @@ void GPHGraphicsManager::internUpdateScreen() {  					dst_y = dst_y / 2;  					scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, -						   (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); +					           (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h);  				} else {  					scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,  					           (byte *)_hwscreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h);  				}  			} -			if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf){ +			if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf) {  				r->w = r->w / 2;  				r->h = dst_h / 2;  			} else { @@ -419,7 +422,7 @@ void GPHGraphicsManager::internUpdateScreen() {  		// This is necessary if shaking is active.  		if (_forceFull) {  			_dirtyRectList[0].y = 0; -			_dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight()/2 : effectiveScreenHeight(); +			_dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight() / 2 : effectiveScreenHeight();  		}  		drawMouse(); @@ -439,7 +442,7 @@ void GPHGraphicsManager::internUpdateScreen() {  }  void GPHGraphicsManager::showOverlay() { -	if (_videoMode.mode == GFX_HALF){ +	if (_videoMode.mode == GFX_HALF) {  		_mouseCurState.x = _mouseCurState.x / 2;  		_mouseCurState.y = _mouseCurState.y / 2;  	} @@ -447,89 +450,41 @@ void GPHGraphicsManager::showOverlay() {  }  void GPHGraphicsManager::hideOverlay() { -	if (_videoMode.mode == GFX_HALF){ +	if (_videoMode.mode == GFX_HALF) {  		_mouseCurState.x = _mouseCurState.x * 2;  		_mouseCurState.y = _mouseCurState.y * 2;  	}  	SurfaceSdlGraphicsManager::hideOverlay();  } +bool GPHGraphicsManager::loadGFXMode() { -//bool GPHGraphicsManager::loadGFXMode() { - - -//	_videoMode.overlayWidth = 320; -//	_videoMode.overlayHeight = 240; -//	_videoMode.fullscreen = true; -// -//	/* Forcefully disable aspect ratio correction for games -//	   that start with a native 240px height resolution -//	   This corrects games with non-standard resolutions -//	   such as MM Nes (256x240). -//	*/ -//	if(_videoMode.screenHeight == 240) { -//		_videoMode.aspectRatioCorrection = false; -//	} - -//	debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight); -//	if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { -//		_videoMode.aspectRatioCorrection = false; -//		setGraphicsMode(GFX_HALF); -//		debug("GraphicsMode set to HALF"); -//	} else { -//		setGraphicsMode(GFX_NORMAL); -//		debug("GraphicsMode set to NORMAL"); -//	} - - -//	if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { -//		//_videoMode.overlayWidth = _videoMode.screenWidth / 2; -//		//_videoMode.overlayHeight = _videoMode.screenHeight / 2; -//		_videoMode.overlayWidth = 320; -//		_videoMode.overlayHeight = 240; -//		_videoMode.fullscreen = true; -//	} else { -// -//		_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; -//		_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; -// -//		if (_videoMode.aspectRatioCorrection) -//			_videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); -// -//		//_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; -//		//_videoMode.hardwareHeight = effectiveScreenHeight(); -//		_videoMode.hardwareWidth = 320; -//		_videoMode.hardwareHeight = 240; -// -//	} - -//	return SurfaceSdlGraphicsManager::loadGFXMode(); -//} +	// We don't offer anything other than fullscreen on GPH devices so let’s not even pretend. +	_videoMode.fullscreen = true; + +	// Set the hardware stats to match the LCD. +	_videoMode.hardwareWidth = 320; +	_videoMode.hardwareHeight = 240; + +	if (_videoMode.screenHeight != 200) +		_videoMode.aspectRatioCorrection = false; -bool GPHGraphicsManager::loadGFXMode() {  	if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) {  		_videoMode.aspectRatioCorrection = false;  		setGraphicsMode(GFX_HALF); -//		printf("GFX_HALF\n");  	} else {  		setGraphicsMode(GFX_NORMAL); -//		printf("GFX_NORMAL\n");  	}  	if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) {  		_videoMode.overlayWidth = _videoMode.screenWidth / 2;  		_videoMode.overlayHeight = _videoMode.screenHeight / 2; -		_videoMode.fullscreen = true;  	} else { -  		_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;  		_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;  		if (_videoMode.aspectRatioCorrection)  			_videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); - -		_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; -		_videoMode.hardwareHeight = effectiveScreenHeight();  	}  	return SurfaceSdlGraphicsManager::loadGFXMode();  } @@ -542,9 +497,13 @@ bool GPHGraphicsManager::hasFeature(OSystem::Feature f) {  void GPHGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {  	switch (f) { -		case OSystem::kFeatureAspectRatioCorrection: +	case OSystem::kFeatureAspectRatioCorrection:  		setAspectRatioCorrection(enable);  		break; +	case OSystem::kFeatureCursorPalette: +		_cursorPaletteDisabled = !enable; +		blitCursor(); +		break;  	default:  		break;  	} @@ -554,8 +513,10 @@ bool GPHGraphicsManager::getFeatureState(OSystem::Feature f) {  	assert(_transactionMode == kTransactionNone);  	switch (f) { -		case OSystem::kFeatureAspectRatioCorrection: +	case OSystem::kFeatureAspectRatioCorrection:  		return _videoMode.aspectRatioCorrection; +	case OSystem::kFeatureCursorPalette: +		return !_cursorPaletteDisabled;  	default:  		return false;  	} @@ -571,7 +532,7 @@ SurfaceSdlGraphicsManager::VideoState *GPHGraphicsManager::getVideoMode() {  void GPHGraphicsManager::warpMouse(int x, int y) {  	if (_mouseCurState.x != x || _mouseCurState.y != y) { -		if (_videoMode.mode == GFX_HALF && !_overlayVisible){ +		if (_videoMode.mode == GFX_HALF && !_overlayVisible) {  			x = x / 2;  			y = y / 2;  		} @@ -579,21 +540,16 @@ void GPHGraphicsManager::warpMouse(int x, int y) {  	SurfaceSdlGraphicsManager::warpMouse(x, y);  } -void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) { -	if (!event.synthetic) { -		Common::Event newEvent(event); -		newEvent.synthetic = true; -		if (!_overlayVisible) { -			if (_videoMode.mode == GFX_HALF) { -				newEvent.mouse.x *= 2; -				newEvent.mouse.y *= 2; -			} -			newEvent.mouse.x /= _videoMode.scaleFactor; -			newEvent.mouse.y /= _videoMode.scaleFactor; -			if (_videoMode.aspectRatioCorrection) -				newEvent.mouse.y = aspect2Real(newEvent.mouse.y); +void GPHGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	if (!_overlayVisible) { +		if (_videoMode.mode == GFX_HALF) { +			point.x *= 2; +			point.y *= 2;  		} -		g_system->getEventManager()->pushEvent(newEvent); +		point.x /= _videoMode.scaleFactor; +		point.y /= _videoMode.scaleFactor; +		if (_videoMode.aspectRatioCorrection) +			point.y = aspect2Real(point.y);  	}  } diff --git a/backends/graphics/gph/gph-graphics.h b/backends/graphics/gph/gph-graphics.h index 45b8618569..f1f3d18b41 100644 --- a/backends/graphics/gph/gph-graphics.h +++ b/backends/graphics/gph/gph-graphics.h @@ -24,7 +24,7 @@  #define BACKENDS_GRAPHICS_GPH_H  #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#include "graphics/scaler/aspect.h"	// for aspect2Real +#include "graphics/scaler/aspect.h" // for aspect2Real  #include "graphics/scaler/downscaler.h"  enum { @@ -56,7 +56,7 @@ public:  	SurfaceSdlGraphicsManager::MousePos *getMouseCurState();  	SurfaceSdlGraphicsManager::VideoState *getVideoMode(); -	virtual void adjustMouseEvent(const Common::Event &event); +	virtual void transformMouseCoordinates(Common::Point &point);  };  #endif /* BACKENDS_GRAPHICS_GPH_H */ diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 20924ed581..3f282df587 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -84,6 +84,10 @@ public:  	virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;  	virtual void displayMessageOnOSD(const char *msg) {} + +	// Graphics::PaletteManager interface +	//virtual void setPalette(const byte *colors, uint start, uint num) = 0; +	//virtual void grabPalette(byte *colors, uint start, uint num) = 0;  };  #endif diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp index 732074b7e2..de9838a0d7 100644 --- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp +++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp @@ -134,7 +134,7 @@ void LinuxmotoSdlGraphicsManager::initSize(uint w, uint h) {  	if	(w > 320 || h > 240) {  		setGraphicsMode(GFX_HALF);  		setGraphicsModeIntern(); -		_sdlEventSource->toggleMouseGrab(); +		_eventSource->toggleMouseGrab();  	}  	_transactionDetails.sizeChanged = true; @@ -478,21 +478,16 @@ void LinuxmotoSdlGraphicsManager::warpMouse(int x, int y) {  	SurfaceSdlGraphicsManager::warpMouse(x, y);  } -void LinuxmotoSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { -	if (!event.synthetic) { -		Common::Event newEvent(event); -		newEvent.synthetic = true; -		if (!_overlayVisible) { -			if (_videoMode.mode == GFX_HALF) { -				newEvent.mouse.x *= 2; -				newEvent.mouse.y *= 2; -			} -			newEvent.mouse.x /= _videoMode.scaleFactor; -			newEvent.mouse.y /= _videoMode.scaleFactor; -			if (_videoMode.aspectRatioCorrection) -				newEvent.mouse.y = aspect2Real(newEvent.mouse.y); +void LinuxmotoSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	if (!_overlayVisible) { +		if (_videoMode.mode == GFX_HALF) { +			point.x *= 2; +			point.y *= 2;  		} -		g_system->getEventManager()->pushEvent(newEvent); +		point.x /= _videoMode.scaleFactor; +		point.y /= _videoMode.scaleFactor; +		if (_videoMode.aspectRatioCorrection) +			point.y = aspect2Real(point.y);  	}  } diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h index 938512f323..ee2a566d71 100644 --- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h +++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h @@ -42,8 +42,7 @@ public:  	virtual void hideOverlay();  	virtual void warpMouse(int x, int y); -protected: -	virtual void adjustMouseEvent(const Common::Event &event); +	virtual void transformMouseCoordinates(Common::Point &point);  };  #endif diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h index f0cd7aed56..71f1eeb78f 100644 --- a/backends/graphics/opengl/gltexture.h +++ b/backends/graphics/opengl/gltexture.h @@ -20,6 +20,9 @@   *   */ +#ifndef BACKENDS_GRAPHICS_OPENGL_GLTEXTURE_H +#define BACKENDS_GRAPHICS_OPENGL_GLTEXTURE_H +  #include "common/scummsys.h"  #ifdef WIN32 @@ -31,7 +34,20 @@  #undef ARRAYSIZE  #endif -#if defined(USE_GLES) +// HACK: At this point in Windows platforms, common/util.h has been included +// via common/rect.h (from backends/graphics/sdl/sdl-graphics.h), via +// backends/graphics/openglsdl/openglsdl-graphics.h. Thus, we end up with +// COMMON_UTIL_H defined, and ARRAYSIZE undefined (bad!). Therefore, +// ARRAYSIZE is undefined in openglsdl-graphics.cpp. This is a temporary +// hackish solution fo fix compilation under Windows. +#if !defined(ARRAYSIZE) && defined(COMMON_UTIL_H) +#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) +#endif + +#if defined(BADA) +#include <FGraphicsOpengl.h> +using namespace Osp::Graphics::Opengl; +#elif defined(USE_GLES)  #include <GLES/gl.h>  #elif defined(SDL_BACKEND)  #include <SDL_opengl.h> @@ -106,3 +122,5 @@ protected:  	GLint _filter;  	bool _refresh;  }; + +#endif diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 046be4c669..8e01e76f16 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -67,10 +67,6 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()  }  OpenGLGraphicsManager::~OpenGLGraphicsManager() { -	// Unregister the event observer -	if (g_system->getEventManager()->getEventDispatcher() != NULL) -		g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this); -  	free(_gamePalette);  	free(_cursorPalette); @@ -79,11 +75,6 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() {  	delete _cursorTexture;  } -void OpenGLGraphicsManager::initEventObserver() { -	// Register the graphics manager as a event observer -	g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false); -} -  //  // Feature  // @@ -1254,12 +1245,16 @@ void OpenGLGraphicsManager::toggleAntialiasing() {  	_transactionDetails.filterChanged = true;  } -uint OpenGLGraphicsManager::getAspectRatio() { +uint OpenGLGraphicsManager::getAspectRatio() const {  	// In case we enable aspect ratio correction we force a 4/3 ratio. +	// But just for 320x200 and 640x400 games, since other games do not need +	// this.  	// TODO: This makes OpenGL Normal behave like OpenGL Conserve, when aspect  	// ratio correction is enabled, but it's better than the previous 4/3 mode  	// mess at least... -	if (_videoMode.aspectRatioCorrection) +	if (_videoMode.aspectRatioCorrection +	    && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) +	    || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400)))  		return 13333;  	else if (_videoMode.mode == OpenGL::GFX_NORMAL)  		return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight; @@ -1282,36 +1277,6 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {  	}  } -bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) { -	switch (event.type) { -	case Common::EVENT_MOUSEMOVE: -		if (!event.synthetic) { -			_cursorState.x = event.mouse.x; -			_cursorState.y = event.mouse.y; -		} -	case Common::EVENT_LBUTTONDOWN: -	case Common::EVENT_RBUTTONDOWN: -	case Common::EVENT_WHEELUP: -	case Common::EVENT_WHEELDOWN: -	case Common::EVENT_MBUTTONDOWN: -	case Common::EVENT_LBUTTONUP: -	case Common::EVENT_RBUTTONUP: -	case Common::EVENT_MBUTTONUP: -		if (!event.synthetic) { -			Common::Event newEvent(event); -			newEvent.synthetic = true; -			adjustMousePosition(newEvent.mouse.x, newEvent.mouse.y); -			g_system->getEventManager()->pushEvent(newEvent); -		} -		return !event.synthetic; - -	default: -		break; -	} - -	return false; -} -  bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {  	int width = _videoMode.hardwareWidth;  	int height = _videoMode.hardwareHeight; @@ -1383,9 +1348,13 @@ const char *OpenGLGraphicsManager::getCurrentModeName() {  }  #ifdef USE_OSD +const Graphics::Font *OpenGLGraphicsManager::getFontOSD() { +  return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); +} +  void OpenGLGraphicsManager::updateOSD() {  	// The font we are going to use: -	const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); +	const Graphics::Font *font = getFontOSD();  	if (_osdSurface.w != _osdTexture->getWidth() || _osdSurface.h != _osdTexture->getHeight())  		_osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), _overlayFormat); diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 56f7d92a12..6ded680eae 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -26,7 +26,8 @@  #include "backends/graphics/opengl/gltexture.h"  #include "backends/graphics/graphics.h"  #include "common/array.h" -#include "common/events.h" +#include "common/rect.h" +#include "graphics/font.h"  #include "graphics/pixelformat.h"  // Uncomment this to enable the 'on screen display' code. @@ -50,13 +51,11 @@ enum {   * the buffers swap, and implement loadGFXMode for handling the window/context if   * needed. If USE_RGB_COLOR is enabled, getSupportedFormats must be implemented.   */ -class OpenGLGraphicsManager : public GraphicsManager, public Common::EventObserver { +class OpenGLGraphicsManager : public GraphicsManager {  public:  	OpenGLGraphicsManager();  	virtual ~OpenGLGraphicsManager(); -	virtual void initEventObserver(); -  	virtual bool hasFeature(OSystem::Feature f);  	virtual void setFeatureState(OSystem::Feature f, bool enable);  	virtual bool getFeatureState(OSystem::Feature f); @@ -109,10 +108,6 @@ public:  	virtual void setCursorPalette(const byte *colors, uint start, uint num);  	virtual void displayMessageOnOSD(const char *msg); - -	// Override from Common::EventObserver -	bool notifyEvent(const Common::Event &event); -  protected:  	/**  	 * Setup OpenGL settings @@ -220,10 +215,7 @@ protected:  	virtual void calculateDisplaySize(int &width, int &height);  	virtual void refreshDisplaySize(); -	/** -	 * Returns the current target aspect ratio x 10000 -	 */ -	virtual uint getAspectRatio(); +	uint getAspectRatio() const;  	bool _formatBGR; @@ -324,6 +316,11 @@ protected:  	 */  	Common::Array<Common::String> _osdLines; +  /** +   * Returns the font used for on screen display +   */ +  virtual const Graphics::Font *getFontOSD(); +  	/**  	 * Update the OSD texture / surface.  	 */ diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index bd7dd32e3b..cfc78cfcac 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -30,8 +30,9 @@  #include "common/textconsole.h"  #include "common/translation.h" -OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager() +OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource)  	: +	SdlGraphicsManager(eventSource),  	_hwscreen(0),  	_screenResized(false),  	_activeFullscreenMode(-2), @@ -71,6 +72,14 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()  }  OpenGLSdlGraphicsManager::~OpenGLSdlGraphicsManager() { +	// Unregister the event observer +	if (g_system->getEventManager()->getEventDispatcher() != NULL) +		g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this); +} + +void OpenGLSdlGraphicsManager::initEventObserver() { +	// Register the graphics manager as a event observer +	g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false);  }  bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) { @@ -304,14 +313,17 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {  		_videoMode.overlayWidth = _videoMode.hardwareWidth = _videoMode.screenWidth * scaleFactor;  		_videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor; -		int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight; -		int desiredAspectRatio = getAspectRatio(); - -		// Do not downscale dimensions, only enlarge them if needed -		if (screenAspectRatio > desiredAspectRatio) -			_videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000  + 5000) / desiredAspectRatio; -		else if (screenAspectRatio < desiredAspectRatio) -			_videoMode.hardwareWidth = (_videoMode.overlayHeight * desiredAspectRatio + 5000) / 10000; +		// The only modes where we need to adapt the aspect ratio are 320x200 +		// and 640x400. That is since our aspect ratio correction in fact is +		// only used to ensure that the original pixel size aspect for these +		// modes is used. +		// (Non-square pixels on old monitors vs square pixel on new ones). +		if (_videoMode.aspectRatioCorrection +		    && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) +		    || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) +			_videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; +		else +			_videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor;  	}  	_screenResized = false; @@ -448,6 +460,10 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) {  			_activeFullscreenMode = -2;  			setFullscreenMode(!isFullscreen);  		} + +		// HACK: We need to force a refresh here, since we change the +		// fullscreen mode. +		_transactionDetails.needRefresh = true;  	endGFXTransaction();  	// Ignore resize events for the next 10 frames @@ -609,50 +625,54 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {  			}  		}  		break; +  	case Common::EVENT_KEYUP:  		return isHotkey(event); -	// HACK: Handle special SDL event -	// The new screen size is saved on the mouse event as part of HACK, -	// there is no common resize event. -	case OSystem_SDL::kSdlEventResize: -		// Do not resize if ignoring resize events. -		if (!_ignoreResizeFrames && !getFullscreenMode()) { -			bool scaleChanged = false; -			beginGFXTransaction(); -				_videoMode.hardwareWidth = event.mouse.x; -				_videoMode.hardwareHeight = event.mouse.y; - -				if (_videoMode.mode != OpenGL::GFX_ORIGINAL) { -					_screenResized = true; -					calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight); -				} -				int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth, -				                _videoMode.hardwareHeight / _videoMode.screenHeight); +	default: +		break; +	} -				if (getScale() != scale) { -					scaleChanged = true; -					setScale(MAX(MIN(scale, 3), 1)); -				} +	return false; +} -				if (_videoMode.mode == OpenGL::GFX_ORIGINAL) { -					calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight); -				} +void OpenGLSdlGraphicsManager::notifyVideoExpose() { +} + +void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) { +	// Do not resize if ignoring resize events. +	if (!_ignoreResizeFrames && !getFullscreenMode()) { +		bool scaleChanged = false; +		beginGFXTransaction(); +			_videoMode.hardwareWidth = width; +			_videoMode.hardwareHeight = height; + +			_screenResized = true; + +			int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth, +			                _videoMode.hardwareHeight / _videoMode.screenHeight); -				_transactionDetails.sizeChanged = true; -			endGFXTransaction(); +			if (getScale() != scale) { +				scaleChanged = true; +				setScale(MAX(MIN(scale, 3), 1)); +			} + +			_transactionDetails.sizeChanged = true; +		endGFXTransaction();  #ifdef USE_OSD -			if (scaleChanged) -				displayScaleChangedMsg(); +		if (scaleChanged) +			displayScaleChangedMsg();  #endif -		} -		return true; - -	default: -		break;  	} +} -	return OpenGLGraphicsManager::notifyEvent(event); +void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	adjustMousePosition(point.x, point.y); +} +  +void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { +	_cursorState.x = mouse.x; +	_cursorState.y = mouse.y;  }  #endif diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h index ba9f94db2d..1587183328 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.h +++ b/backends/graphics/openglsdl/openglsdl-graphics.h @@ -27,15 +27,17 @@  #if defined(ARRAYSIZE) && !defined(_WINDOWS_)  #undef ARRAYSIZE  #endif - +#include "backends/graphics/sdl/sdl-graphics.h"  #include "backends/graphics/opengl/opengl-graphics.h" +#include "common/events.h" +  /**   * SDL OpenGL graphics manager   */ -class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager { +class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager, public SdlGraphicsManager, public Common::EventObserver {  public: -	OpenGLSdlGraphicsManager(); +	OpenGLSdlGraphicsManager(SdlEventSource *eventSource);  	virtual ~OpenGLSdlGraphicsManager();  	virtual bool hasFeature(OSystem::Feature f); @@ -45,10 +47,17 @@ public:  	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;  #endif +	virtual void initEventObserver();  	virtual bool notifyEvent(const Common::Event &event);  	virtual void updateScreen(); +	// SdlGraphicsManager interface +	virtual void notifyVideoExpose(); +	virtual void notifyResize(const uint width, const uint height); +	virtual void transformMouseCoordinates(Common::Point &point); +	virtual void notifyMousePos(Common::Point mouse); +  protected:  	virtual void internUpdateScreen(); diff --git a/backends/graphics/openpandora/op-graphics.h b/backends/graphics/openpandora/op-graphics.h index ed26df7475..0b3eeae8ec 100644 --- a/backends/graphics/openpandora/op-graphics.h +++ b/backends/graphics/openpandora/op-graphics.h @@ -24,7 +24,7 @@  #define BACKENDS_GRAPHICS_OP_H  #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#include "graphics/scaler/aspect.h"	// for aspect2Real +#include "graphics/scaler/aspect.h" // for aspect2Real  #include "graphics/scaler/downscaler.h"  enum { diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp new file mode 100644 index 0000000000..2eca4b8aab --- /dev/null +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "backends/graphics/sdl/sdl-graphics.h" + +#include "backends/events/sdl/sdl-events.h" + +SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *source) +	: _eventSource(source) { +	_eventSource->setGraphicsManager(this); +} + +SdlGraphicsManager::~SdlGraphicsManager() { +	_eventSource->setGraphicsManager(0); +} + diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h new file mode 100644 index 0000000000..ea9149fccb --- /dev/null +++ b/backends/graphics/sdl/sdl-graphics.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H +#define BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H + +#include "common/rect.h" + +class SdlEventSource; + +/** + * Base class for a SDL based graphics manager. + * + * It features a few extra a few extra features required by SdlEventSource. + * FIXME/HACK: + * Note it does not inherit from GraphicsManager to avoid a diamond inheritance + * in the current OpenGLSdlGraphicsManager. + */ +class SdlGraphicsManager { +public: +	SdlGraphicsManager(SdlEventSource *source); +	virtual ~SdlGraphicsManager(); + +	/** +	 * Notify the graphics manager that the graphics needs to be redrawn, since +	 * the application window was modified. +	 * +	 * This is basically called when SDL_VIDEOEXPOSE was received. +	 */ +	virtual void notifyVideoExpose() = 0; + +	/** +	 * Notify the graphics manager about an resize event. +	 * +	 * It is noteworthy that the requested width/height should actually be set +	 * up as is and not changed by the graphics manager, since else it might +	 * lead to odd behavior for certain window managers. +	 * +	 * It is only required to overwrite this method in case you want a +	 * resizable window. The default implementation just does nothing. +	 * +	 * @param width Requested window width. +	 * @param height Requested window height. +	 */ +	virtual void notifyResize(const uint width, const uint height) {} + +	/** +	 * Transforms real screen coordinates into the current active screen +	 * coordinates (may be either game screen or overlay). +	 * +	 * @param point Mouse coordinates to transform. +	 */ +	virtual void transformMouseCoordinates(Common::Point &point) = 0; + +	/** +	 * Notifies the graphics manager about a position change according to the +	 * real screen coordinates. +	 * +	 * @param mouse Mouse position. +	 */ +	virtual void notifyMousePos(Common::Point mouse) = 0; + +protected: +	SdlEventSource *_eventSource; +}; + +#endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 66207b6808..f3a1cad040 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -122,7 +122,7 @@ static AspectRatio getDesiredAspectRatio() {  SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource)  	: -	_sdlEventSource(sdlEventSource), +	SdlGraphicsManager(sdlEventSource),  #ifdef USE_OSD  	_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),  #endif @@ -249,7 +249,10 @@ void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)  }  bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) { -	assert(_transactionMode == kTransactionNone); +	// We need to allow this to be called from within a transaction, since we +	// currently use it to retreive the graphics state, when switching from +	// SDL->OpenGL mode for example. +	//assert(_transactionMode == kTransactionNone);  	switch (f) {  	case OSystem::kFeatureFullscreenMode: @@ -728,7 +731,8 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {  	_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;  	_videoMode.hardwareHeight = effectiveScreenHeight(); -#else +// On GPH devices ALL the _videoMode.hardware... are setup in GPHGraphicsManager::loadGFXMode() +#elif !defined(GPH_DEVICE)  	_videoMode.hardwareWidth = _videoMode.overlayWidth;  	_videoMode.hardwareHeight = _videoMode.overlayHeight;  #endif @@ -752,6 +756,12 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {  		error("allocating _screen failed");  #endif +	// SDL 1.2 palettes default to all black, +	// SDL 1.3 palettes default to all white, +	// Thus set our own default palette to all black. +	// SDL_SetColors does nothing for non indexed surfaces. +	SDL_SetColors(_screen, _currentPalette, 0, 256); +  	//  	// Create the surface that contains the scaled graphics in 16 bit mode  	// @@ -840,7 +850,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {  	SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);  #endif -	_sdlEventSource->resetKeyboadEmulation( +	_eventSource->resetKeyboadEmulation(  		_videoMode.screenWidth * _videoMode.scaleFactor - 1,  		effectiveScreenHeight() - 1); @@ -2229,20 +2239,6 @@ bool SurfaceSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {  	return false;  } -void SurfaceSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { -	if (!event.synthetic) { -		Common::Event newEvent(event); -		newEvent.synthetic = true; -		if (!_overlayVisible) { -			newEvent.mouse.x /= _videoMode.scaleFactor; -			newEvent.mouse.y /= _videoMode.scaleFactor; -			if (_videoMode.aspectRatioCorrection) -				newEvent.mouse.y = aspect2Real(newEvent.mouse.y); -		} -		g_system->getEventManager()->pushEvent(newEvent); -	} -} -  void SurfaceSdlGraphicsManager::toggleFullScreen() {  	beginGFXTransaction();  		setFullscreenMode(!_videoMode.fullscreen); @@ -2291,26 +2287,10 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {  			if (handleScalerHotkeys(event.kbd.keycode))  				return true;  		} +  	case Common::EVENT_KEYUP:  		return isScalerHotkey(event); -	case Common::EVENT_MOUSEMOVE: -		if (event.synthetic) -			setMousePos(event.mouse.x, event.mouse.y); -	case Common::EVENT_LBUTTONDOWN: -	case Common::EVENT_RBUTTONDOWN: -	case Common::EVENT_WHEELUP: -	case Common::EVENT_WHEELDOWN: -	case Common::EVENT_MBUTTONDOWN: -	case Common::EVENT_LBUTTONUP: -	case Common::EVENT_RBUTTONUP: -	case Common::EVENT_MBUTTONUP: -		adjustMouseEvent(event); -		return !event.synthetic; - -	// HACK: Handle special SDL event -	case OSystem_SDL::kSdlEventExpose: -		_forceFull = true; -		return false; +  	default:  		break;  	} @@ -2318,4 +2298,22 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {  	return false;  } +void SurfaceSdlGraphicsManager::notifyVideoExpose() { +	_forceFull = true; +} + +void SurfaceSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	if (!_overlayVisible) { +		point.x /= _videoMode.scaleFactor; +		point.y /= _videoMode.scaleFactor; +		if (_videoMode.aspectRatioCorrection) +			point.y = aspect2Real(point.y); +	} +} + +void SurfaceSdlGraphicsManager::notifyMousePos(Common::Point mouse) { +	transformMouseCoordinates(mouse); +	setMousePos(mouse.x, mouse.y); +} +  #endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index cd8710d443..f71096d43e 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -24,6 +24,7 @@  #define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H  #include "backends/graphics/graphics.h" +#include "backends/graphics/sdl/sdl-graphics.h"  #include "graphics/pixelformat.h"  #include "graphics/scaler.h"  #include "common/events.h" @@ -74,7 +75,7 @@ public:  /**   * SDL graphics manager   */ -class SurfaceSdlGraphicsManager : public GraphicsManager, public Common::EventObserver { +class SurfaceSdlGraphicsManager : public GraphicsManager, public SdlGraphicsManager, public Common::EventObserver {  public:  	SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource);  	virtual ~SurfaceSdlGraphicsManager(); @@ -140,9 +141,12 @@ public:  	// Override from Common::EventObserver  	bool notifyEvent(const Common::Event &event); -protected: -	SdlEventSource *_sdlEventSource; +	// SdlGraphicsManager interface +	virtual void notifyVideoExpose(); +	virtual void transformMouseCoordinates(Common::Point &point); +	virtual void notifyMousePos(Common::Point mouse); +protected:  #ifdef USE_OSD  	/** Surface containing the OSD message */  	SDL_Surface *_osdSurface; @@ -329,7 +333,6 @@ protected:  	virtual bool handleScalerHotkeys(Common::KeyCode key);  	virtual bool isScalerHotkey(const Common::Event &event); -	virtual void adjustMouseEvent(const Common::Event &event);  	virtual void setMousePos(int x, int y);  	virtual void toggleFullScreen();  	virtual bool saveScreenshot(const char *filename); diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp index 4a9a219641..5fe8b19887 100644 --- a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp +++ b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp @@ -77,4 +77,3 @@ void SymbianSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)  }  #endif - diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.h b/backends/graphics/symbiansdl/symbiansdl-graphics.h index 404ca87a0a..73e810a629 100644 --- a/backends/graphics/symbiansdl/symbiansdl-graphics.h +++ b/backends/graphics/symbiansdl/symbiansdl-graphics.h @@ -39,4 +39,3 @@ public:  };  #endif - diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp index f9f963dc70..58b735ef8b 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.cpp +++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp @@ -44,7 +44,7 @@  WINCESdlGraphicsManager::WINCESdlGraphicsManager(SdlEventSource *sdlEventSource)  	: SurfaceSdlGraphicsManager(sdlEventSource), -	  _panelInitialized(false), _noDoubleTapRMB(false), +	  _panelInitialized(false), _noDoubleTapRMB(false), _noDoubleTapPT(false),  	  _toolbarHighDrawn(false), _newOrientation(0), _orientationLandscape(0),  	  _panelVisible(true), _saveActiveToolbar(NAME_MAIN_PANEL), _panelStateForced(false),  	  _canBeAspectScaled(false), _scalersChanged(false), _saveToolbarState(false), @@ -478,6 +478,9 @@ void WINCESdlGraphicsManager::update_game_settings() {  	if (ConfMan.hasKey("no_doubletap_rightclick"))  		_noDoubleTapRMB = ConfMan.getBool("no_doubletap_rightclick"); + +	if (ConfMan.hasKey("no_doubletap_paneltoggle")) +		_noDoubleTapPT = ConfMan.getBool("no_doubletap_paneltoggle");  }  void WINCESdlGraphicsManager::internUpdateScreen() { @@ -931,7 +934,7 @@ bool WINCESdlGraphicsManager::loadGFXMode() {  		_toolbarHigh = NULL;  	// keyboard cursor control, some other better place for it? -	_sdlEventSource->resetKeyboadEmulation(_videoMode.screenWidth * _scaleFactorXm / _scaleFactorXd - 1, _videoMode.screenHeight * _scaleFactorXm / _scaleFactorXd - 1); +	_eventSource->resetKeyboadEmulation(_videoMode.screenWidth * _scaleFactorXm / _scaleFactorXd - 1, _videoMode.screenHeight * _scaleFactorXm / _scaleFactorXd - 1);  	return true;  } @@ -1155,22 +1158,17 @@ void WINCESdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, in  	}  } -void WINCESdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { -	if (!event.synthetic) { -		Common::Event newEvent(event); -		newEvent.synthetic = true; -		/* -		if (!_overlayVisible) { -			newEvent.mouse.x = newEvent.mouse.x * _scaleFactorXd / _scaleFactorXm; -			newEvent.mouse.y = newEvent.mouse.y * _scaleFactorYd / _scaleFactorYm; -			newEvent.mouse.x /= _videoMode.scaleFactor; -			newEvent.mouse.y /= _videoMode.scaleFactor; -			if (_videoMode.aspectRatioCorrection) -				newEvent.mouse.y = aspect2Real(newEvent.mouse.y); -		} -		*/ -		g_system->getEventManager()->pushEvent(newEvent); +void WINCESdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { +	/* +	if (!_overlayVisible) { +		point.x = point.x * _scaleFactorXd / _scaleFactorXm; +		point.y = point.y * _scaleFactorYd / _scaleFactorYm; +		point.x /= _videoMode.scaleFactor; +		point.y /= _videoMode.scaleFactor; +		if (_videoMode.aspectRatioCorrection) +			point.y = aspect2Real(point.y);  	} +	*/  }  void WINCESdlGraphicsManager::setMousePos(int x, int y) { @@ -1599,6 +1597,19 @@ void WINCESdlGraphicsManager::swap_mouse_visibility() {  		undrawMouse();  } +void WINCESdlGraphicsManager::init_panel() { +	_panelVisible = true; +	if (_panelInitialized) { +		_toolbarHandler.setVisible(true); +		_toolbarHandler.setActive(NAME_MAIN_PANEL); +	} +} + +void WINCESdlGraphicsManager::reset_panel() { +	_panelVisible = false; +	_toolbarHandler.setVisible(false); +} +  // Smartphone actions  void WINCESdlGraphicsManager::initZones() {  	int i; @@ -1641,4 +1652,3 @@ WINCESdlGraphicsManager::zoneDesc WINCESdlGraphicsManager::_zones[TOTAL_ZONES] =  };  #endif /* _WIN32_WCE */ - diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h index c620082b0c..2e8c3313b3 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.h +++ b/backends/graphics/wincesdl/wincesdl-graphics.h @@ -90,6 +90,8 @@ public:  	void swap_zoom_up();  	void swap_zoom_down();  	void swap_mouse_visibility(); +	void init_panel(); +	void reset_panel();  	void swap_freeLook();  	bool getFreeLookState(); @@ -115,6 +117,7 @@ public:  	bool _panelInitialized; // only initialize the toolbar once  	bool _noDoubleTapRMB;   // disable double tap -> rmb click +	bool _noDoubleTapPT;    // disable double tap for toolbar toggling  	CEGUI::ToolbarHandler _toolbarHandler; @@ -155,8 +158,7 @@ public:  	static zoneDesc _zones[TOTAL_ZONES]; -protected: -	virtual void adjustMouseEvent(const Common::Event &event); +	virtual void transformMouseCoordinates(Common::Point &point);  private:  	bool update_scalers(); @@ -203,4 +205,3 @@ private:  };  #endif /* BACKENDS_GRAPHICS_WINCE_SDL_H */ -  | 
