diff options
author | Johannes Schickel | 2014-01-23 15:23:12 -0800 |
---|---|---|
committer | Johannes Schickel | 2014-01-23 15:23:12 -0800 |
commit | 2fe303ce3fff008a58e9750c66e707ec4e7c93d8 (patch) | |
tree | f4ba16f62f0a054c596d65dd8796ef7323a6b535 /backends/graphics | |
parent | 29eeb91d4e0f7862815cd3129441ba3dfeee85c1 (diff) | |
parent | a7f94591b03984978b77bad069a2456417b55df9 (diff) | |
download | scummvm-rg350-2fe303ce3fff008a58e9750c66e707ec4e7c93d8.tar.gz scummvm-rg350-2fe303ce3fff008a58e9750c66e707ec4e7c93d8.tar.bz2 scummvm-rg350-2fe303ce3fff008a58e9750c66e707ec4e7c93d8.zip |
Merge pull request #409 from lordhoto/rtti
Enable RTTI and clean up the code by exploiting the availability of dynamic_cast.
Diffstat (limited to 'backends/graphics')
-rw-r--r-- | backends/graphics/graphics.h | 21 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 2 | ||||
-rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.cpp | 6 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 4 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.h | 23 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 6 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 2 |
7 files changed, 24 insertions, 40 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 74258b8910..24397228e6 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -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; diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index d2d0358407..93c0c5bc83 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -47,7 +47,7 @@ enum { GFX_NEAREST = 1 }; -class OpenGLGraphicsManager : public GraphicsManager { +class OpenGLGraphicsManager : virtual public GraphicsManager { public: OpenGLGraphicsManager(); virtual ~OpenGLGraphicsManager(); diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index e39cd35870..3f9fc1fbd5 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -73,8 +73,7 @@ OpenGLSdlGraphicsManager::~OpenGLSdlGraphicsManager() { } void OpenGLSdlGraphicsManager::activateManager() { - OpenGLGraphicsManager::activateManager(); - initEventSource(); + SdlGraphicsManager::activateManager(); // Register the graphics manager as a event observer g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false); @@ -86,8 +85,7 @@ void OpenGLSdlGraphicsManager::deactivateManager() { g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this); } - deinitEventSource(); - OpenGLGraphicsManager::deactivateManager(); + SdlGraphicsManager::deactivateManager(); } bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) { diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 417f4faf54..40b97b267b 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -31,10 +31,10 @@ SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *source) SdlGraphicsManager::~SdlGraphicsManager() { } -void SdlGraphicsManager::initEventSource() { +void SdlGraphicsManager::activateManager() { _eventSource->setGraphicsManager(this); } -void SdlGraphicsManager::deinitEventSource() { +void SdlGraphicsManager::deactivateManager() { _eventSource->setGraphicsManager(0); } diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 4d4338af16..3791961cfa 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -23,6 +23,8 @@ #ifndef BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H #define BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H +#include "backends/graphics/graphics.h" + #include "common/rect.h" class SdlEventSource; @@ -31,16 +33,26 @@ 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 { +class SdlGraphicsManager : virtual public GraphicsManager { 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. * @@ -80,9 +92,6 @@ public: virtual void notifyMousePos(Common::Point mouse) = 0; protected: - void initEventSource(); - void deinitEventSource(); - SdlEventSource *_eventSource; }; diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 89802ac8ab..b3af08e2e8 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -198,8 +198,7 @@ SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() { } void SurfaceSdlGraphicsManager::activateManager() { - GraphicsManager::activateManager(); - initEventSource(); + SdlGraphicsManager::activateManager(); // Register the graphics manager as a event observer g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false); @@ -211,8 +210,7 @@ void SurfaceSdlGraphicsManager::deactivateManager() { g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this); } - deinitEventSource(); - GraphicsManager::deactivateManager(); + SdlGraphicsManager::deactivateManager(); } bool SurfaceSdlGraphicsManager::hasFeature(OSystem::Feature f) { diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 00c05ff2bf..22b7780675 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -75,7 +75,7 @@ public: /** * SDL graphics manager */ -class SurfaceSdlGraphicsManager : public GraphicsManager, public SdlGraphicsManager, public Common::EventObserver { +class SurfaceSdlGraphicsManager : public SdlGraphicsManager, public Common::EventObserver { public: SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource); virtual ~SurfaceSdlGraphicsManager(); |