aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp39
-rw-r--r--backends/graphics/dinguxsdl/dinguxsdl-graphics.h2
-rw-r--r--backends/graphics/gph/gph-graphics.cpp25
-rw-r--r--backends/graphics/gph/gph-graphics.h2
-rw-r--r--backends/graphics/graphics.h4
-rw-r--r--backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp25
-rw-r--r--backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h3
-rw-r--r--backends/graphics/opengl/gltexture.h20
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp53
-rw-r--r--backends/graphics/opengl/opengl-graphics.h21
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp102
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h15
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp35
-rw-r--r--backends/graphics/sdl/sdl-graphics.h86
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp61
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h11
-rw-r--r--backends/graphics/symbiansdl/symbiansdl-graphics.cpp1
-rw-r--r--backends/graphics/symbiansdl/symbiansdl-graphics.h1
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.cpp28
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.h4
20 files changed, 323 insertions, 215 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..96b0619a6a 100644
--- a/backends/graphics/gph/gph-graphics.cpp
+++ b/backends/graphics/gph/gph-graphics.cpp
@@ -141,7 +141,7 @@ void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f
if (w > 320 || h > 240){
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
- _sdlEventSource->toggleMouseGrab();
+ _eventSource->toggleMouseGrab();
}
_videoMode.overlayWidth = 320;
@@ -579,21 +579,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..0118fc7ecd 100644
--- a/backends/graphics/gph/gph-graphics.h
+++ b/backends/graphics/gph/gph-graphics.h
@@ -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..84515732fe 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;
@@ -609,50 +621,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() {
+}
- _transactionDetails.sizeChanged = true;
- endGFXTransaction();
+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);
+
+ 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/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 2d41ecead4..146200148a 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:
@@ -846,7 +849,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);
@@ -2235,20 +2238,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);
@@ -2297,26 +2286,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;
}
@@ -2324,4 +2297,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 2ca78cedde..58b735ef8b 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.cpp
+++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp
@@ -934,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;
}
@@ -1158,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) {
@@ -1657,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 92894e0dcd..2e8c3313b3 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.h
+++ b/backends/graphics/wincesdl/wincesdl-graphics.h
@@ -158,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();
@@ -206,4 +205,3 @@ private:
};
#endif /* BACKENDS_GRAPHICS_WINCE_SDL_H */
-