diff options
author | Alexander Tkachev | 2016-06-03 19:18:01 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 2a15b8b280af4d4beddb142e468f511a65552e2d (patch) | |
tree | 1c04f72866b277ee1410ca952be5296db9e06d6f | |
parent | 9d186929e16ce023222028143a280aca03605fe9 (diff) | |
download | scummvm-rg350-2a15b8b280af4d4beddb142e468f511a65552e2d.tar.gz scummvm-rg350-2a15b8b280af4d4beddb142e468f511a65552e2d.tar.bz2 scummvm-rg350-2a15b8b280af4d4beddb142e468f511a65552e2d.zip |
GUI: Add clearOSD() method
So one can erase everything from OSD and then blit something on it.
-rw-r--r-- | backends/base-backend.cpp | 5 | ||||
-rw-r--r-- | backends/base-backend.h | 1 | ||||
-rw-r--r-- | backends/graphics/graphics.h | 1 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 17 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 1 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 32 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 1 | ||||
-rw-r--r-- | backends/modular-backend.cpp | 4 | ||||
-rw-r--r-- | backends/modular-backend.h | 1 | ||||
-rw-r--r-- | common/system.h | 6 |
10 files changed, 69 insertions, 0 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp index cf6fdfc877..59d674461c 100644 --- a/backends/base-backend.cpp +++ b/backends/base-backend.cpp @@ -43,6 +43,11 @@ void BaseBackend::copyRectToOSD(const void *buf, int pitch, int x, int y, int w, warning("BaseBackend::copyRectToOSD not implemented"); //TODO } +void BaseBackend::clearOSD() { + warning("BaseBackend::clearOSD not implemented"); //TODO + //what should I do? Remove all TimedMessageDialogs? +} + void BaseBackend::initBackend() { // Init Event manager #ifndef DISABLE_DEFAULT_EVENT_MANAGER diff --git a/backends/base-backend.h b/backends/base-backend.h index 7000d3b14a..edee427ca7 100644 --- a/backends/base-backend.h +++ b/backends/base-backend.h @@ -34,6 +34,7 @@ public: virtual void displayMessageOnOSD(const char *msg); virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h); + virtual void clearOSD(); virtual void fillScreen(uint32 col); }; diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 8b0ac19d9e..1063a10a9c 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -85,6 +85,7 @@ public: virtual void displayMessageOnOSD(const char *msg) {} virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {} + virtual void clearOSD() {} // Graphics::PaletteManager interface //virtual void setPalette(const byte *colors, uint start, uint num) = 0; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index e9f26bc7bc..97788be3ad 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -757,6 +757,23 @@ void OpenGLGraphicsManager::copyRectToOSD(const void *buf, int pitch, int x, int #endif } +void OpenGLGraphicsManager::clearOSD() { +#ifdef USE_OSD + // HACK: Actually no client code should use graphics functions from + // another thread. But the MT-32 emulator still does, thus we need to + // make sure this doesn't happen while a updateScreen call is done. + Common::StackLock lock(_osdMutex); + + Graphics::Surface *dst = _osd->getSurface(); + _osd->fill(0); + _osd->flagDirty(); + + // Init the OSD display parameters. + _osdAlpha = kOSDInitialAlpha; + _osdFadeStartTime = g_system->getMillis() + kOSDFadeOutDelay; +#endif +} + void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) { assert(_gameScreen->hasPalette()); diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index e0d1664e76..f36d5d17f2 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -116,6 +116,7 @@ public: virtual void displayMessageOnOSD(const char *msg); virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h); + virtual void clearOSD(); // PaletteManager interface virtual void setPalette(const byte *colors, uint start, uint num); diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 88fdc09f0a..4a33890f42 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -2245,6 +2245,38 @@ void SurfaceSdlGraphicsManager::copyRectToOSD(const void *buf, int pitch, int x, // Ensure a full redraw takes place next time the screen is updated _forceFull = true; } + +void SurfaceSdlGraphicsManager::clearOSD() { + assert(_transactionMode == kTransactionNone); + + Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends + + // Lock the OSD surface for drawing + if (SDL_LockSurface(_osdSurface)) + error("displayMessageOnOSD: SDL_LockSurface failed: %s", SDL_GetError()); + + Graphics::Surface dst; + dst.init(_osdSurface->w, _osdSurface->h, _osdSurface->pitch, _osdSurface->pixels, + Graphics::PixelFormat(_osdSurface->format->BytesPerPixel, + 8 - _osdSurface->format->Rloss, 8 - _osdSurface->format->Gloss, + 8 - _osdSurface->format->Bloss, 8 - _osdSurface->format->Aloss, + _osdSurface->format->Rshift, _osdSurface->format->Gshift, + _osdSurface->format->Bshift, _osdSurface->format->Ashift)); + + // Clear everything with the "transparent" color, i.e. the colorkey + SDL_FillRect(_osdSurface, 0, kOSDColorKey); + + // Finished drawing, so unlock the OSD surface again + SDL_UnlockSurface(_osdSurface); + + // Init the OSD display parameters, and the fade out + _osdAlpha = SDL_ALPHA_TRANSPARENT + kOSDInitialAlpha * (SDL_ALPHA_OPAQUE - SDL_ALPHA_TRANSPARENT) / 100; + _osdFadeStartTime = SDL_GetTicks() + kOSDFadeOutDelay; + SDL_SetAlpha(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _osdAlpha); + + // Ensure a full redraw takes place next time the screen is updated + _forceFull = true; +} #endif bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index a8bafd0a84..01974cf6ab 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -146,6 +146,7 @@ public: #ifdef USE_OSD virtual void displayMessageOnOSD(const char *msg); virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h); + virtual void clearOSD(); #endif // Override from Common::EventObserver diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 08565dcbdd..6ad80ecbb3 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -245,6 +245,10 @@ void ModularBackend::copyRectToOSD(const void *buf, int pitch, int x, int y, int _graphicsManager->copyRectToOSD(buf, pitch, x, y, w, h); } +void ModularBackend::clearOSD() { + _graphicsManager->clearOSD(); +} + void ModularBackend::quit() { exit(0); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index cf3babfc47..06c69b55ad 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -128,6 +128,7 @@ public: virtual void quit(); virtual void displayMessageOnOSD(const char *msg); virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h); + virtual void clearOSD(); //@} diff --git a/common/system.h b/common/system.h index 64e4b927b3..6071e4582b 100644 --- a/common/system.h +++ b/common/system.h @@ -1113,6 +1113,12 @@ public: virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) = 0; /** + * Clears 'on screen display' from everything drawn on it. + */ + + virtual void clearOSD() = 0; + + /** * Return the SaveFileManager, used to store and load savestates * and other modifiable persistent game data. For more information, * refer to the SaveFileManager documentation. |