aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2011-08-08 23:46:05 +0200
committerJohannes Schickel2011-08-09 00:03:11 +0200
commit0630a88a04e9688d664751b6a68edf622d76b348 (patch)
tree87d7867c298c60272eff69777b16bff5c15c8bfe /backends/graphics
parentdedc74abfa44f7dac344da1868588193f91dd4f1 (diff)
downloadscummvm-rg350-0630a88a04e9688d664751b6a68edf622d76b348.tar.gz
scummvm-rg350-0630a88a04e9688d664751b6a68edf622d76b348.tar.bz2
scummvm-rg350-0630a88a04e9688d664751b6a68edf622d76b348.zip
SDL: Let SDL based graphics managers inherit from SdlGraphicsManager.
This also adapts port I can not test (not even the compilation). So if this breaks anything I am sorry about it.
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp23
-rw-r--r--backends/graphics/dinguxsdl/dinguxsdl-graphics.h1
-rw-r--r--backends/graphics/gph/gph-graphics.cpp23
-rw-r--r--backends/graphics/gph/gph-graphics.h1
-rw-r--r--backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp23
-rw-r--r--backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h1
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp49
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h13
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp20
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h8
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.cpp24
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.h2
12 files changed, 145 insertions, 43 deletions
diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
index 8075d0d45b..5aa39aa9a5 100644
--- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
+++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
@@ -514,17 +514,22 @@ 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);
+ transformMouseCoordinates(newEvent.mouse);
+ g_system->getEventManager()->pushEvent(newEvent);
+ }
+}
+
+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..468a19a3ee 100644
--- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h
+++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h
@@ -58,6 +58,7 @@ public:
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..12643fbff8 100644
--- a/backends/graphics/gph/gph-graphics.cpp
+++ b/backends/graphics/gph/gph-graphics.cpp
@@ -583,17 +583,22 @@ 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);
+ transformMouseCoordinates(newEvent.mouse);
+ g_system->getEventManager()->pushEvent(newEvent);
+ }
+}
+
+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..f7d0ce43fd 100644
--- a/backends/graphics/gph/gph-graphics.h
+++ b/backends/graphics/gph/gph-graphics.h
@@ -57,6 +57,7 @@ public:
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/linuxmotosdl/linuxmotosdl-graphics.cpp b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
index 732074b7e2..bf21bec3fb 100644
--- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
+++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
@@ -482,17 +482,22 @@ 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);
+ transformMouseCoordinates(newEvent.mouse);
+ g_system->getEventManager()->pushEvent(newEvent);
+ }
+}
+
+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..f615018733 100644
--- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
+++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
@@ -42,6 +42,7 @@ public:
virtual void hideOverlay();
virtual void warpMouse(int x, int y);
+ virtual void transformMouseCoordinates(Common::Point &point);
protected:
virtual void adjustMouseEvent(const Common::Event &event);
};
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index bd7dd32e3b..8828cb5f49 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),
@@ -655,4 +656,50 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
return OpenGLGraphicsManager::notifyEvent(event);
}
+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;
+
+ if (_videoMode.mode != OpenGL::GFX_ORIGINAL) {
+ _screenResized = true;
+ calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight);
+ }
+
+ int scale = MIN(_videoMode.hardwareWidth / _videoMode.screenWidth,
+ _videoMode.hardwareHeight / _videoMode.screenHeight);
+
+ if (getScale() != scale) {
+ scaleChanged = true;
+ setScale(MAX(MIN(scale, 3), 1));
+ }
+
+ if (_videoMode.mode == OpenGL::GFX_ORIGINAL) {
+ calculateDisplaySize(_videoMode.hardwareWidth, _videoMode.hardwareHeight);
+ }
+
+ _transactionDetails.sizeChanged = true;
+ endGFXTransaction();
+#ifdef USE_OSD
+ if (scaleChanged)
+ displayScaleChangedMsg();
+#endif
+ }
+}
+
+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..6cd255bbb8 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -23,19 +23,20 @@
#ifndef BACKENDS_GRAPHICS_OPENGLSDL_H
#define BACKENDS_GRAPHICS_OPENGLSDL_H
-#include "backends/platform/sdl/sdl-sys.h"
#if defined(ARRAYSIZE) && !defined(_WINDOWS_)
#undef ARRAYSIZE
#endif
+#include "backends/platform/sdl/sdl-sys.h"
+#include "backends/graphics/sdl/sdl-graphics.h"
#include "backends/graphics/opengl/opengl-graphics.h"
/**
* SDL OpenGL graphics manager
*/
-class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager {
+class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager, public SdlGraphicsManager {
public:
- OpenGLSdlGraphicsManager();
+ OpenGLSdlGraphicsManager(SdlEventSource *eventSource);
virtual ~OpenGLSdlGraphicsManager();
virtual bool hasFeature(OSystem::Feature f);
@@ -49,6 +50,12 @@ public:
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/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 2d41ecead4..293fd9b188 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), _sdlEventSource(sdlEventSource),
#ifdef USE_OSD
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
#endif
@@ -2324,4 +2324,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..3de59c79be 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,6 +141,11 @@ public:
// Override from Common::EventObserver
bool notifyEvent(const Common::Event &event);
+ // SdlGraphicsManager interface
+ virtual void notifyVideoExpose();
+ virtual void transformMouseCoordinates(Common::Point &point);
+ virtual void notifyMousePos(Common::Point mouse);
+
protected:
SdlEventSource *_sdlEventSource;
diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp
index b1b4d4cbe7..023000d6c1 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.cpp
+++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp
@@ -1162,20 +1162,24 @@ 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);
- }
- */
+ transformMouseCoordinates(newEvent.mouse);
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) {
if (x != _mouseCurState.x || y != _mouseCurState.y) {
undrawMouse();
diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h
index c9fc145194..f80a72b553 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.h
+++ b/backends/graphics/wincesdl/wincesdl-graphics.h
@@ -158,6 +158,8 @@ public:
static zoneDesc _zones[TOTAL_ZONES];
+ virtual void transformMouseCoordinates(Common::Point &point);
+
protected:
virtual void adjustMouseEvent(const Common::Event &event);