From 4fe0b4e1ad9d44f65cc6c144f1998cbc17913797 Mon Sep 17 00:00:00 2001 From: Alejandro Marzini Date: Tue, 8 Jun 2010 23:44:05 +0000 Subject: Renamed and moved DefaultGraphicsManager to NullGraphicsManager. Added pure virtual class GraphicsManager. svn-id: r49528 --- backends/graphics/abstract-graphics.h | 70 +++++++++++++++++++++++ backends/graphics/default/default-graphics.cpp | 40 ------------- backends/graphics/default/default-graphics.h | 78 -------------------------- backends/graphics/null/null-graphics.h | 77 +++++++++++++++++++++++++ backends/graphics/sdl/sdl-graphics.cpp | 9 ++- backends/graphics/sdl/sdl-graphics.h | 5 +- backends/module.mk | 1 - 7 files changed, 157 insertions(+), 123 deletions(-) create mode 100644 backends/graphics/abstract-graphics.h delete mode 100644 backends/graphics/default/default-graphics.cpp delete mode 100644 backends/graphics/default/default-graphics.h create mode 100644 backends/graphics/null/null-graphics.h (limited to 'backends') diff --git a/backends/graphics/abstract-graphics.h b/backends/graphics/abstract-graphics.h new file mode 100644 index 0000000000..c38f66c9ed --- /dev/null +++ b/backends/graphics/abstract-graphics.h @@ -0,0 +1,70 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef BACKENDS_GRAPHICS_ABSTRACT_H +#define BACKENDS_GRAPHICS_ABSTRACT_H + +#include "common/system.h" +#include "common/noncopyable.h" + +class GraphicsManager : Common::NonCopyable { +public: + virtual ~GraphicsManager() {} + + virtual bool hasFeature(OSystem::Feature f) = 0; + virtual void setFeatureState(OSystem::Feature f, bool enable) = 0; + virtual bool getFeatureState(OSystem::Feature f) = 0; + + virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const = 0; + virtual int getDefaultGraphicsMode() const = 0; + virtual bool setGraphicsMode(int mode) = 0; + virtual int getGraphicsMode() const = 0; + virtual Graphics::PixelFormat getScreenFormat() const = 0; + virtual Common::List getSupportedFormats() = 0; + virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0; + virtual int16 getHeight() = 0; + virtual int16 getWidth() = 0; + virtual void setPalette(const byte *colors, uint start, uint num) = 0; + virtual void grabPalette(byte *colors, uint start, uint num) = 0; + virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0; + virtual Graphics::Surface *lockScreen() = 0; + virtual void unlockScreen() = 0; + virtual void fillScreen(uint32 col) = 0; + virtual void updateScreen() = 0; + virtual void setShakePos(int shakeOffset) = 0; + virtual void showOverlay() = 0; + virtual void hideOverlay() = 0; + virtual Graphics::PixelFormat getOverlayFormat() const = 0; + virtual void clearOverlay() = 0; + virtual void grabOverlay(OverlayColor *buf, int pitch) = 0; + virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h)= 0; + virtual int16 getOverlayHeight() = 0; + virtual int16 getOverlayWidth() = 0; + virtual bool showMouse(bool visible) = 0; + virtual void warpMouse(int x, int y) = 0; + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; +}; + +#endif diff --git a/backends/graphics/default/default-graphics.cpp b/backends/graphics/default/default-graphics.cpp deleted file mode 100644 index 9683eff9ac..0000000000 --- a/backends/graphics/default/default-graphics.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* 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. - * - * $URL$ - * $Id$ - * - */ - -#include "backends/graphics/default/default-graphics.h" - -bool DefaultGraphicsManager::hasGraphicsFeature(OSystem::Feature f) { - return false; -} - -bool DefaultGraphicsManager::getGraphicsFeatureState(OSystem::Feature f) { - return false; -} - -static const OSystem::GraphicsMode s_noGraphicsModes[] = { {0, 0, 0} }; - -const OSystem::GraphicsMode *DefaultGraphicsManager::getSupportedGraphicsModes() { - return s_noGraphicsModes; -} diff --git a/backends/graphics/default/default-graphics.h b/backends/graphics/default/default-graphics.h deleted file mode 100644 index 9e1593f0eb..0000000000 --- a/backends/graphics/default/default-graphics.h +++ /dev/null @@ -1,78 +0,0 @@ -/* 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. - * - * $URL$ - * $Id$ - * - */ - -#ifndef BACKENDS_GRAPHICS_DEFAULT_H -#define BACKENDS_GRAPHICS_DEFAULT_H - -#include "common/system.h" -#include "common/noncopyable.h" - -class DefaultGraphicsManager : Common::NonCopyable { -public: - DefaultGraphicsManager() {} - ~DefaultGraphicsManager() {} - - bool hasGraphicsFeature(OSystem::Feature f); - void setGraphicsFeatureState(OSystem::Feature f, bool enable) {} - bool getGraphicsFeatureState(OSystem::Feature f); - - const OSystem::GraphicsMode *getSupportedGraphicsModes(); - int getDefaultGraphicsMode() { return 0; } - bool setGraphicsMode(int mode) { return true; } - int getGraphicsMode() { return 0; } - inline Graphics::PixelFormat getScreenFormat() const { - return Graphics::PixelFormat::createFormatCLUT8(); - }; - inline Common::List getSupportedFormats() const { - Common::List list; - list.push_back(Graphics::PixelFormat::createFormatCLUT8()); - return list; - }; - void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) {} - int16 getHeight() { return 0; } - int16 getWidth() { return 0; } - void setPalette(const byte *colors, uint start, uint num) {} - void grabPalette(byte *colors, uint start, uint num) {} - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {} - Graphics::Surface *lockScreen() { return NULL; } - void unlockScreen() {} - void fillScreen(uint32 col) {} - void updateScreen() {} - void setShakePos(int shakeOffset) {} - void showOverlay() {} - void hideOverlay() {} - Graphics::PixelFormat getOverlayFormat() { return Graphics::PixelFormat(); } - void clearOverlay() {} - void grabOverlay(OverlayColor *buf, int pitch) {} - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {} - int16 getOverlayHeight() { return 0; } - int16 getOverlayWidth() { return 0; } - bool showMouse(bool visible) {} - void warpMouse(int x, int y) {} - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {} -}; - - -#endif diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h new file mode 100644 index 0000000000..8423f4f5da --- /dev/null +++ b/backends/graphics/null/null-graphics.h @@ -0,0 +1,77 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef BACKENDS_GRAPHICS_NULL_H +#define BACKENDS_GRAPHICS_NULL_H + +#include "backends/graphics/abstract-graphics.h" + +static const OSystem::GraphicsMode s_noGraphicsModes[] = { {0, 0, 0} }; + +class NullGraphicsManager : GraphicsManager { +public: + ~NullGraphicsManager() {} + + bool hasFeature(OSystem::Feature f) { return false; } + void setFeatureState(OSystem::Feature f, bool enable) {} + bool getFeatureState(OSystem::Feature f) { return false; } + + const OSystem::GraphicsMode *getSupportedGraphicsModes() { return s_noGraphicsModes; } + int getDefaultGraphicsMode() { return 0; } + bool setGraphicsMode(int mode) { return true; } + int getGraphicsMode() { return 0; } + inline Graphics::PixelFormat getScreenFormat() const { + return Graphics::PixelFormat::createFormatCLUT8(); + }; + inline Common::List getSupportedFormats() const { + Common::List list; + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + return list; + }; + void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) {} + int16 getHeight() { return 0; } + int16 getWidth() { return 0; } + void setPalette(const byte *colors, uint start, uint num) {} + void grabPalette(byte *colors, uint start, uint num) {} + void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {} + Graphics::Surface *lockScreen() { return NULL; } + void unlockScreen() {} + void fillScreen(uint32 col) {} + void updateScreen() {} + void setShakePos(int shakeOffset) {} + void showOverlay() {} + void hideOverlay() {} + Graphics::PixelFormat getOverlayFormat() { return Graphics::PixelFormat(); } + void clearOverlay() {} + void grabOverlay(OverlayColor *buf, int pitch) {} + void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {} + int16 getOverlayHeight() { return 0; } + int16 getOverlayWidth() { return 0; } + bool showMouse(bool visible) { return !visible; } + void warpMouse(int x, int y) {} + void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {} +}; + +#endif diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 5276cbbf30..8fc2ef6f08 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -1193,6 +1193,13 @@ void SdlGraphicsManager::unlockScreen() { g_system->unlockMutex(_graphicsMutex); } +void SdlGraphicsManager::fillScreen(uint32 col) { + Graphics::Surface *screen = lockScreen(); + if (screen && screen->pixels) + memset(screen->pixels, col, screen->h * screen->pitch); + unlockScreen(); +} + void SdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) { if (_forceFull) return; @@ -1966,7 +1973,7 @@ bool SdlGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) { // Ctrl-Alt-a toggles aspect ratio correction if (key.keysym.sym == 'a') { beginGFXTransaction(); - setGraphicsFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection); + setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection); endGFXTransaction(); #ifdef USE_OSD char buffer[128]; diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 13ce5af5dc..650b01794b 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -26,7 +26,7 @@ #ifndef BACKENDS_GRAPHICS_SDL_H #define BACKENDS_GRAPHICS_SDL_H -#include "backends/graphics/default/default-graphics.h" +#include "backends/graphics/abstract-graphics.h" #include "common/system.h" #include "graphics/scaler.h" @@ -68,7 +68,7 @@ public: int kh() const { return _kh; } }; -class SdlGraphicsManager : public DefaultGraphicsManager { +class SdlGraphicsManager : public GraphicsManager { public: SdlGraphicsManager(); ~SdlGraphicsManager(); @@ -306,5 +306,4 @@ protected: int effectiveScreenHeight() const; }; - #endif diff --git a/backends/module.mk b/backends/module.mk index a76dca2702..4b725bb16a 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -17,7 +17,6 @@ MODULE_OBJS := \ fs/wii/wii-fs-factory.o \ fs/n64/n64-fs-factory.o \ fs/n64/romfsstream.o \ - graphics/default/default-graphics.o \ graphics/sdl/sdl-graphics.o \ keymapper/action.o \ keymapper/keymap.o \ -- cgit v1.2.3