aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/surfacesdl
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-03 19:18:01 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit2a15b8b280af4d4beddb142e468f511a65552e2d (patch)
tree1c04f72866b277ee1410ca952be5296db9e06d6f /backends/graphics/surfacesdl
parent9d186929e16ce023222028143a280aca03605fe9 (diff)
downloadscummvm-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.
Diffstat (limited to 'backends/graphics/surfacesdl')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp32
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h1
2 files changed, 33 insertions, 0 deletions
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