diff options
author | Vicent Marti | 2008-05-28 14:27:22 +0000 |
---|---|---|
committer | Vicent Marti | 2008-05-28 14:27:22 +0000 |
commit | 119b7126b9162eb0adefaff7a2f002f23472824b (patch) | |
tree | 2ef9b696e862d338613d44faf5ce6682f0282e8c | |
parent | 4e1aa5328a115150696dfb323a6d6481c2c82c68 (diff) | |
download | scummvm-rg350-119b7126b9162eb0adefaff7a2f002f23472824b.tar.gz scummvm-rg350-119b7126b9162eb0adefaff7a2f002f23472824b.tar.bz2 scummvm-rg350-119b7126b9162eb0adefaff7a2f002f23472824b.zip |
InterfaceManager core implemented.
svn-id: r32339
-rw-r--r-- | base/main.cpp | 13 | ||||
-rw-r--r-- | graphics/VectorRenderer.cpp | 98 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 19 | ||||
-rw-r--r-- | gui/InterfaceManager.cpp | 97 | ||||
-rw-r--r-- | gui/InterfaceManager.h | 38 |
5 files changed, 166 insertions, 99 deletions
diff --git a/base/main.cpp b/base/main.cpp index a666110b83..51b3451837 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -42,12 +42,9 @@ #include "common/system.h" #include "gui/newgui.h" #include "gui/message.h" +#include "gui/InterfaceManager.h" -#define _VECTOR_RENDERER_DBG 1 - -#if defined(_VECTOR_RENDERER_DBG) -#include "graphics/VectorRenderer.h" -#elif defined(_WIN32_WCE) +#if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" #elif defined(__DC__) #include "backends/platform/dc/DCLauncherDialog.h" @@ -71,9 +68,11 @@ static bool launcherDialog(OSystem &system) { // Clear the main screen system.clearScreen(); -#if defined(_VECTOR_RENDERER_DBG) +#if 1 + + GUI::InterfaceManager iManager(&system, GUI::InterfaceManager::GFX_Standard_16bit); - Graphics::vector_renderer_test( &system ); + iManager.runGUI(); return true; #else diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index c34b73d4bd..dfb555c20b 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -24,102 +24,28 @@ */ #include "common/util.h" -#include "graphics/surface.h" -#include "graphics/colormasks.h" #include "common/system.h" #include "common/events.h" +#include "graphics/surface.h" +#include "graphics/colormasks.h" + +#include "gui/InterfaceManager.h" #include "graphics/VectorRenderer.h" namespace Graphics { -/******************************************************************** - * DEBUG FUNCTIONS - ********************************************************************/ -VectorRenderer *createRenderer() { - return new VectorRendererSpec<uint16, ColorMasks<565> >; -} +VectorRenderer *createRenderer(int mode) { + switch (mode) { + case GUI::InterfaceManager::GFX_Standard_16bit: + return new VectorRendererSpec<uint16, ColorMasks<565> >; + case GUI::InterfaceManager::GFX_Antialias_16bit: + return new VectorRendererAA<uint16, ColorMasks<565> >; -void vector_renderer_test(OSystem *_system) { - Common::EventManager *eventMan = _system->getEventManager(); - - VectorRenderer *vr = createRenderer(); - - Surface _screen; - _screen.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); - - if (!_screen.pixels) - return; - - _system->clearOverlay(); - _system->grabOverlay((OverlayColor*)_screen.pixels, _screen.w); - - vr->setSurface(&_screen); - vr->clearSurface(); - - _system->showOverlay(); - - DrawStep *steps = new DrawStep[5]; - - steps[0].color1.r = 214; - steps[0].color1.g = 113; - steps[0].color1.b = 8; - steps[0].color2.r = 240; - steps[0].color2.g = 200; - steps[0].color2.b = 25; - steps[0].fill_mode = kFillMode_Gradient; - steps[0].drawing_call = &VectorRenderer::drawCallback_FILLSURFACE; - steps[0].flags = kDrawStep_SetGradient | kDrawStep_SetFillMode; - - steps[1].color1.r = 206; - steps[1].color1.g = 121; - steps[1].color1.b = 99; - steps[1].color2.r = 173; - steps[1].color2.g = 40; - steps[1].color2.b = 8; - steps[1].x = 500; - steps[1].y = 95; - steps[1].r = 8; - steps[1].w = 120; - steps[1].h = 30; - steps[1].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ; - steps[1].flags = kDrawStep_SetGradient; - - steps[2].x = 500; - steps[2].y = 135; - steps[2].r = 8; - steps[2].w = 120; - steps[2].h = 30; - steps[2].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ; - steps[2].flags = kDrawStep_CallbackOnly; - - steps[3].x = 500; - steps[3].y = 175; - steps[3].r = 8; - steps[3].w = 120; - steps[3].h = 30; - steps[3].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ; - steps[3].flags = kDrawStep_CallbackOnly; - - bool running = true; - while (running) { // draw!! - - for (int i = 0; i < 4; ++i) - vr->drawStep(&steps[i]); - - _system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(0, 0), _screen.w, 0, 0, _screen.w, _screen.w); - _system->updateScreen(); - - Common::Event event; - _system->delayMillis(100); - while (eventMan->pollEvent(event)) { - if (event.type == Common::EVENT_QUIT) - running = false; - } + default: + return NULL; } - - _system->hideOverlay(); } /******************************************************************** diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 1b315f46b4..65d0cce417 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -32,10 +32,10 @@ #include "common/system.h" namespace Graphics { - -void vector_renderer_test(OSystem *_system); class VectorRenderer; +VectorRenderer *createRenderer(int mode); + /** Specifies the way in which a shape is filled */ enum FillMode { kFillMode_Disabled = 0, @@ -297,6 +297,8 @@ public: virtual void drawStep(DrawStep *step); + virtual void copyFrame(OSystem *sys) = 0; + protected: Surface *_activeSurface; /** Pointer to the surface currently being drawn */ @@ -403,6 +405,17 @@ public: } } + virtual void copyFrame(OSystem *sys) { +#ifdef OVERLAY_MULTIPLE_DEPTHS + sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(0, 0), + _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->w); +#else + sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(0, 0), + _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->w); +#endif + sys->updateScreen(); + } + protected: /** @@ -598,7 +611,7 @@ protected: * * @see VectorRenderer::drawLineAlg() */ - void drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color); + virtual void drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color); /** * "Wu's Circle Antialiasing Algorithm" as published by Xiaolin Wu, July 1991 diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index f886423e4c..8469654657 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -34,6 +34,103 @@ namespace GUI { +template<typename PixelType> +void InterfaceManager::screenInit() { + freeScreen(); + + _screen = new Graphics::Surface; + _screen->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType)); + _system->clearOverlay(); +} + +void InterfaceManager::setGraphicsMode(Graphics_Mode mode) { + if (mode == _graphicsMode) + return; + + _graphicsMode = mode; + + switch (mode) { + case GFX_Standard_16bit: + _bytesPerPixel = sizeof(uint16); + screenInit<uint16>(); + break; + + case GFX_Antialias_16bit: + _bytesPerPixel = sizeof(uint16); + screenInit<uint16>(); + break; + } + + _vectorRenderer = Graphics::createRenderer(mode); + _vectorRenderer->setSurface(_screen); +} + +int InterfaceManager::runGUI() { + Common::EventManager *eventMan = _system->getEventManager(); + _system->showOverlay(); + + Graphics::DrawStep *steps = new Graphics::DrawStep[5]; + + steps[0].color1.r = 214; + steps[0].color1.g = 113; + steps[0].color1.b = 8; + steps[0].color2.r = 240; + steps[0].color2.g = 200; + steps[0].color2.b = 25; + steps[0].fill_mode = Graphics::kFillMode_Gradient; + steps[0].drawing_call = &Graphics::VectorRenderer::drawCallback_FILLSURFACE; + steps[0].flags = Graphics::kDrawStep_SetGradient | Graphics::kDrawStep_SetFillMode; + + steps[1].color1.r = 206; + steps[1].color1.g = 121; + steps[1].color1.b = 99; + steps[1].color2.r = 173; + steps[1].color2.g = 40; + steps[1].color2.b = 8; + steps[1].x = 500; + steps[1].y = 95; + steps[1].r = 8; + steps[1].w = 120; + steps[1].h = 30; + steps[1].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ; + steps[1].flags = Graphics::kDrawStep_SetGradient; + + steps[2].x = 500; + steps[2].y = 135; + steps[2].r = 8; + steps[2].w = 120; + steps[2].h = 30; + steps[2].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ; + steps[2].flags = Graphics::kDrawStep_CallbackOnly; + + steps[3].x = 500; + steps[3].y = 175; + steps[3].r = 8; + steps[3].w = 120; + steps[3].h = 30; + steps[3].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ; + steps[3].flags = Graphics::kDrawStep_CallbackOnly; + + bool running = true; + while (running) { // draw!! + + for (int i = 0; i < 4; ++i) + _vectorRenderer->drawStep(&steps[i]); + + _vectorRenderer->copyFrame(_system); + + Common::Event event; + _system->delayMillis(100); + while (eventMan->pollEvent(event)) { + if (event.type == Common::EVENT_QUIT) + running = false; + } + } + + _system->hideOverlay(); + return 1; +} + } // end of namespace GUI. diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h index 92f5c570a4..5a5eccff41 100644 --- a/gui/InterfaceManager.h +++ b/gui/InterfaceManager.h @@ -37,14 +37,26 @@ namespace GUI { class InterfaceManager { public: - InterfaceManager() : _vectorRenderer(NULL) { - _vectorRenderer = createRenderer(); + enum Graphics_Mode { + GFX_Disabled = 0, + GFX_Standard_16bit, + GFX_Antialias_16bit + }; + + InterfaceManager(OSystem *system, Graphics_Mode mode) : _vectorRenderer(NULL), + _system(system), _graphicsMode(GFX_Disabled), _screen(NULL), _bytesPerPixel(0) { + + setGraphicsMode(mode); } ~InterfaceManager() { - delete _vectorRenderer; + freeRenderer(); + freeScreen(); } + void setGraphicsMode(Graphics_Mode mode); + int runGUI(); + protected: Graphics::VectorRenderer *createRenderer() { // TODO: Find out what pixel format we are using, @@ -52,7 +64,27 @@ protected: return new Graphics::VectorRendererSpec<uint16, ColorMasks<565> >; } + template<typename PixelType> + void screenInit(); + + void freeRenderer() { + if (_vectorRenderer != NULL) + delete _vectorRenderer; + } + + void freeScreen() { + if (_screen != NULL) { + _screen->free(); + delete _screen; + } + } + + OSystem *_system; Graphics::VectorRenderer *_vectorRenderer; + Graphics::Surface *_screen; + + int _bytesPerPixel; + Graphics_Mode _graphicsMode; }; } // end of namespace GUI. |