SDL: Make activateManager/deactivateManager SdlGraphicsManager specific.
We can do this now that we can use virtual inheritance and dynamic_cast because we enabled RTTI.
This commit is contained in:
parent
281672e171
commit
ea6d38d5f3
5 changed files with 22 additions and 30 deletions
|
@ -37,27 +37,6 @@ class GraphicsManager : public PaletteManager {
|
|||
public:
|
||||
virtual ~GraphicsManager() {}
|
||||
|
||||
/**
|
||||
* Makes this graphics manager active. That means it should be ready to
|
||||
* process inputs now. However, even without being active it should be
|
||||
* able to query the supported modes and other bits.
|
||||
*
|
||||
* HACK: Actually this is specific to SdlGraphicsManager subclasses.
|
||||
* But sadly we cannot cast from GraphicsManager to SdlGraphicsManager
|
||||
* because there is no relation between these two.
|
||||
*/
|
||||
virtual void activateManager() {}
|
||||
|
||||
/**
|
||||
* Makes this graphics manager inactive. This should allow another
|
||||
* graphics manager to become active again.
|
||||
*
|
||||
* HACK: Actually this is specific to SdlGraphicsManager subclasses.
|
||||
* But sadly we cannot cast from GraphicsManager to SdlGraphicsManager
|
||||
* because there is no relation between these two.
|
||||
*/
|
||||
virtual void deactivateManager() {}
|
||||
|
||||
virtual bool hasFeature(OSystem::Feature f) = 0;
|
||||
virtual void setFeatureState(OSystem::Feature f, bool enable) = 0;
|
||||
virtual bool getFeatureState(OSystem::Feature f) = 0;
|
||||
|
|
|
@ -73,7 +73,7 @@ OpenGLSdlGraphicsManager::~OpenGLSdlGraphicsManager() {
|
|||
}
|
||||
|
||||
void OpenGLSdlGraphicsManager::activateManager() {
|
||||
OpenGLGraphicsManager::activateManager();
|
||||
SdlGraphicsManager::activateManager();
|
||||
initEventSource();
|
||||
|
||||
// Register the graphics manager as a event observer
|
||||
|
@ -87,7 +87,7 @@ void OpenGLSdlGraphicsManager::deactivateManager() {
|
|||
}
|
||||
|
||||
deinitEventSource();
|
||||
OpenGLGraphicsManager::deactivateManager();
|
||||
SdlGraphicsManager::deactivateManager();
|
||||
}
|
||||
|
||||
bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) {
|
||||
|
|
|
@ -39,6 +39,19 @@ public:
|
|||
SdlGraphicsManager(SdlEventSource *source);
|
||||
virtual ~SdlGraphicsManager();
|
||||
|
||||
/**
|
||||
* Makes this graphics manager active. That means it should be ready to
|
||||
* process inputs now. However, even without being active it should be
|
||||
* able to query the supported modes and other bits.
|
||||
*/
|
||||
virtual void activateManager() {}
|
||||
|
||||
/**
|
||||
* Makes this graphics manager inactive. This should allow another
|
||||
* graphics manager to become active again.
|
||||
*/
|
||||
virtual void deactivateManager() {}
|
||||
|
||||
/**
|
||||
* Notify the graphics manager that the graphics needs to be redrawn, since
|
||||
* the application window was modified.
|
||||
|
|
|
@ -198,7 +198,7 @@ SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() {
|
|||
}
|
||||
|
||||
void SurfaceSdlGraphicsManager::activateManager() {
|
||||
GraphicsManager::activateManager();
|
||||
SdlGraphicsManager::activateManager();
|
||||
initEventSource();
|
||||
|
||||
// Register the graphics manager as a event observer
|
||||
|
@ -212,7 +212,7 @@ void SurfaceSdlGraphicsManager::deactivateManager() {
|
|||
}
|
||||
|
||||
deinitEventSource();
|
||||
GraphicsManager::deactivateManager();
|
||||
SdlGraphicsManager::deactivateManager();
|
||||
}
|
||||
|
||||
bool SurfaceSdlGraphicsManager::hasFeature(OSystem::Feature f) {
|
||||
|
|
|
@ -91,7 +91,7 @@ OSystem_SDL::~OSystem_SDL() {
|
|||
delete _savefileManager;
|
||||
_savefileManager = 0;
|
||||
if (_graphicsManager) {
|
||||
_graphicsManager->deactivateManager();
|
||||
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->deactivateManager();
|
||||
}
|
||||
delete _graphicsManager;
|
||||
_graphicsManager = 0;
|
||||
|
@ -240,7 +240,7 @@ void OSystem_SDL::initBackend() {
|
|||
// so the virtual keyboard can be initialized, but we have to add the
|
||||
// graphics manager as an event observer after initializing the event
|
||||
// manager.
|
||||
_graphicsManager->activateManager();
|
||||
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
|
||||
}
|
||||
|
||||
#if defined(USE_TASKBAR)
|
||||
|
@ -585,14 +585,14 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
|
|||
// manager, delete and create the new mode graphics manager
|
||||
if (_graphicsMode >= _firstGLMode && mode < _firstGLMode) {
|
||||
debug(1, "switching to plain SDL graphics");
|
||||
_graphicsManager->deactivateManager();
|
||||
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->deactivateManager();
|
||||
delete _graphicsManager;
|
||||
_graphicsManager = new SurfaceSdlGraphicsManager(_eventSource);
|
||||
|
||||
switchedManager = true;
|
||||
} else if (_graphicsMode < _firstGLMode && mode >= _firstGLMode) {
|
||||
debug(1, "switching to OpenGL graphics");
|
||||
_graphicsManager->deactivateManager();
|
||||
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->deactivateManager();
|
||||
delete _graphicsManager;
|
||||
_graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource);
|
||||
|
||||
|
@ -602,7 +602,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
|
|||
_graphicsMode = mode;
|
||||
|
||||
if (switchedManager) {
|
||||
_graphicsManager->activateManager();
|
||||
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
|
||||
|
||||
_graphicsManager->beginGFXTransaction();
|
||||
#ifdef USE_RGB_COLOR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue