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.
This commit is contained in:
parent
dedc74abfa
commit
0630a88a04
13 changed files with 150 additions and 48 deletions
|
@ -514,18 +514,23 @@ void DINGUXSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
if (!event.synthetic) {
|
if (!event.synthetic) {
|
||||||
Common::Event newEvent(event);
|
Common::Event newEvent(event);
|
||||||
newEvent.synthetic = true;
|
newEvent.synthetic = true;
|
||||||
if (!_overlayVisible) {
|
transformMouseCoordinates(newEvent.mouse);
|
||||||
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);
|
|
||||||
}
|
|
||||||
g_system->getEventManager()->pushEvent(newEvent);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
|
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
|
||||||
|
|
||||||
virtual void adjustMouseEvent(const Common::Event &event);
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
|
virtual void transformMouseCoordinates(Common::Point &point);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BACKENDS_GRAPHICS_SDL_DINGUX_H */
|
#endif /* BACKENDS_GRAPHICS_SDL_DINGUX_H */
|
||||||
|
|
|
@ -583,18 +583,23 @@ void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
if (!event.synthetic) {
|
if (!event.synthetic) {
|
||||||
Common::Event newEvent(event);
|
Common::Event newEvent(event);
|
||||||
newEvent.synthetic = true;
|
newEvent.synthetic = true;
|
||||||
if (!_overlayVisible) {
|
transformMouseCoordinates(newEvent.mouse);
|
||||||
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);
|
|
||||||
}
|
|
||||||
g_system->getEventManager()->pushEvent(newEvent);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
|
SurfaceSdlGraphicsManager::VideoState *getVideoMode();
|
||||||
|
|
||||||
virtual void adjustMouseEvent(const Common::Event &event);
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
|
virtual void transformMouseCoordinates(Common::Point &point);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BACKENDS_GRAPHICS_GPH_H */
|
#endif /* BACKENDS_GRAPHICS_GPH_H */
|
||||||
|
|
|
@ -482,18 +482,23 @@ void LinuxmotoSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
if (!event.synthetic) {
|
if (!event.synthetic) {
|
||||||
Common::Event newEvent(event);
|
Common::Event newEvent(event);
|
||||||
newEvent.synthetic = true;
|
newEvent.synthetic = true;
|
||||||
if (!_overlayVisible) {
|
transformMouseCoordinates(newEvent.mouse);
|
||||||
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);
|
|
||||||
}
|
|
||||||
g_system->getEventManager()->pushEvent(newEvent);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual void hideOverlay();
|
virtual void hideOverlay();
|
||||||
virtual void warpMouse(int x, int y);
|
virtual void warpMouse(int x, int y);
|
||||||
|
|
||||||
|
virtual void transformMouseCoordinates(Common::Point &point);
|
||||||
protected:
|
protected:
|
||||||
virtual void adjustMouseEvent(const Common::Event &event);
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
|
|
||||||
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()
|
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource)
|
||||||
:
|
:
|
||||||
|
SdlGraphicsManager(eventSource),
|
||||||
_hwscreen(0),
|
_hwscreen(0),
|
||||||
_screenResized(false),
|
_screenResized(false),
|
||||||
_activeFullscreenMode(-2),
|
_activeFullscreenMode(-2),
|
||||||
|
@ -655,4 +656,50 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
return OpenGLGraphicsManager::notifyEvent(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
|
#endif
|
||||||
|
|
|
@ -23,19 +23,20 @@
|
||||||
#ifndef BACKENDS_GRAPHICS_OPENGLSDL_H
|
#ifndef BACKENDS_GRAPHICS_OPENGLSDL_H
|
||||||
#define BACKENDS_GRAPHICS_OPENGLSDL_H
|
#define BACKENDS_GRAPHICS_OPENGLSDL_H
|
||||||
|
|
||||||
#include "backends/platform/sdl/sdl-sys.h"
|
|
||||||
#if defined(ARRAYSIZE) && !defined(_WINDOWS_)
|
#if defined(ARRAYSIZE) && !defined(_WINDOWS_)
|
||||||
#undef ARRAYSIZE
|
#undef ARRAYSIZE
|
||||||
#endif
|
#endif
|
||||||
|
#include "backends/platform/sdl/sdl-sys.h"
|
||||||
|
#include "backends/graphics/sdl/sdl-graphics.h"
|
||||||
|
|
||||||
#include "backends/graphics/opengl/opengl-graphics.h"
|
#include "backends/graphics/opengl/opengl-graphics.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SDL OpenGL graphics manager
|
* SDL OpenGL graphics manager
|
||||||
*/
|
*/
|
||||||
class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager {
|
class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager, public SdlGraphicsManager {
|
||||||
public:
|
public:
|
||||||
OpenGLSdlGraphicsManager();
|
OpenGLSdlGraphicsManager(SdlEventSource *eventSource);
|
||||||
virtual ~OpenGLSdlGraphicsManager();
|
virtual ~OpenGLSdlGraphicsManager();
|
||||||
|
|
||||||
virtual bool hasFeature(OSystem::Feature f);
|
virtual bool hasFeature(OSystem::Feature f);
|
||||||
|
@ -49,6 +50,12 @@ public:
|
||||||
|
|
||||||
virtual void updateScreen();
|
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:
|
protected:
|
||||||
virtual void internUpdateScreen();
|
virtual void internUpdateScreen();
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ static AspectRatio getDesiredAspectRatio() {
|
||||||
|
|
||||||
SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource)
|
SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource)
|
||||||
:
|
:
|
||||||
_sdlEventSource(sdlEventSource),
|
SdlGraphicsManager(sdlEventSource), _sdlEventSource(sdlEventSource),
|
||||||
#ifdef USE_OSD
|
#ifdef USE_OSD
|
||||||
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
|
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
|
||||||
#endif
|
#endif
|
||||||
|
@ -2324,4 +2324,22 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
return false;
|
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
|
#endif
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H
|
#define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H
|
||||||
|
|
||||||
#include "backends/graphics/graphics.h"
|
#include "backends/graphics/graphics.h"
|
||||||
|
#include "backends/graphics/sdl/sdl-graphics.h"
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
#include "graphics/scaler.h"
|
#include "graphics/scaler.h"
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
|
@ -74,7 +75,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* SDL graphics manager
|
* SDL graphics manager
|
||||||
*/
|
*/
|
||||||
class SurfaceSdlGraphicsManager : public GraphicsManager, public Common::EventObserver {
|
class SurfaceSdlGraphicsManager : public GraphicsManager, public SdlGraphicsManager, public Common::EventObserver {
|
||||||
public:
|
public:
|
||||||
SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource);
|
SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource);
|
||||||
virtual ~SurfaceSdlGraphicsManager();
|
virtual ~SurfaceSdlGraphicsManager();
|
||||||
|
@ -140,6 +141,11 @@ public:
|
||||||
// Override from Common::EventObserver
|
// Override from Common::EventObserver
|
||||||
bool notifyEvent(const Common::Event &event);
|
bool notifyEvent(const Common::Event &event);
|
||||||
|
|
||||||
|
// SdlGraphicsManager interface
|
||||||
|
virtual void notifyVideoExpose();
|
||||||
|
virtual void transformMouseCoordinates(Common::Point &point);
|
||||||
|
virtual void notifyMousePos(Common::Point mouse);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SdlEventSource *_sdlEventSource;
|
SdlEventSource *_sdlEventSource;
|
||||||
|
|
||||||
|
|
|
@ -1162,20 +1162,24 @@ void WINCESdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
if (!event.synthetic) {
|
if (!event.synthetic) {
|
||||||
Common::Event newEvent(event);
|
Common::Event newEvent(event);
|
||||||
newEvent.synthetic = true;
|
newEvent.synthetic = true;
|
||||||
/*
|
transformMouseCoordinates(newEvent.mouse);
|
||||||
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);
|
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) {
|
void WINCESdlGraphicsManager::setMousePos(int x, int y) {
|
||||||
if (x != _mouseCurState.x || y != _mouseCurState.y) {
|
if (x != _mouseCurState.x || y != _mouseCurState.y) {
|
||||||
undrawMouse();
|
undrawMouse();
|
||||||
|
|
|
@ -158,6 +158,8 @@ public:
|
||||||
|
|
||||||
static zoneDesc _zones[TOTAL_ZONES];
|
static zoneDesc _zones[TOTAL_ZONES];
|
||||||
|
|
||||||
|
virtual void transformMouseCoordinates(Common::Point &point);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void adjustMouseEvent(const Common::Event &event);
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ void OSystem_SDL::initBackend() {
|
||||||
|
|
||||||
// If the gfx_mode is from OpenGL, create the OpenGL graphics manager
|
// If the gfx_mode is from OpenGL, create the OpenGL graphics manager
|
||||||
if (use_opengl) {
|
if (use_opengl) {
|
||||||
_graphicsManager = new OpenGLSdlGraphicsManager();
|
_graphicsManager = new OpenGLSdlGraphicsManager(_eventSource);
|
||||||
graphicsManagerType = 1;
|
graphicsManagerType = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
|
||||||
} else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) {
|
} else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) {
|
||||||
debug(1, "switching to OpenGL graphics");
|
debug(1, "switching to OpenGL graphics");
|
||||||
delete _graphicsManager;
|
delete _graphicsManager;
|
||||||
_graphicsManager = new OpenGLSdlGraphicsManager();
|
_graphicsManager = new OpenGLSdlGraphicsManager(_eventSource);
|
||||||
((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver();
|
((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver();
|
||||||
_graphicsManager->beginGFXTransaction();
|
_graphicsManager->beginGFXTransaction();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue