aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
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
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')
-rw-r--r--backends/graphics/graphics.h1
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp17
-rw-r--r--backends/graphics/opengl/opengl-graphics.h1
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp32
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h1
5 files changed, 52 insertions, 0 deletions
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