aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-03 17:44:26 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit7ff1f918084b8d41826ad869d8c9865e1d53e082 (patch)
treef9c876b13ae01a9c523ba059bed66c036ab343b9 /backends
parent1c823b6c1d465bd894f7f37a963165ee009f35ea (diff)
downloadscummvm-rg350-7ff1f918084b8d41826ad869d8c9865e1d53e082.tar.gz
scummvm-rg350-7ff1f918084b8d41826ad869d8c9865e1d53e082.tar.bz2
scummvm-rg350-7ff1f918084b8d41826ad869d8c9865e1d53e082.zip
GUI: Add copyRectToOSD()
I was lazy to implement that in OpenGLGraphicsManager and I'm not sure it's implemented correctly in SurfaceSdlGraphicsManager, but it works for me.
Diffstat (limited to 'backends')
-rw-r--r--backends/base-backend.cpp4
-rw-r--r--backends/base-backend.h1
-rw-r--r--backends/graphics/graphics.h1
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp6
-rw-r--r--backends/graphics/opengl/opengl-graphics.h1
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp48
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h1
-rw-r--r--backends/modular-backend.cpp4
-rw-r--r--backends/modular-backend.h1
9 files changed, 67 insertions, 0 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index 3e95c3e26a..cf6fdfc877 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -39,6 +39,10 @@ void BaseBackend::displayMessageOnOSD(const char *msg) {
dialog.runModal();
}
+void BaseBackend::copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {
+ warning("BaseBackend::copyRectToOSD not implemented"); //TODO
+}
+
void BaseBackend::initBackend() {
// Init Event manager
#ifndef DISABLE_DEFAULT_EVENT_MANAGER
diff --git a/backends/base-backend.h b/backends/base-backend.h
index 598f682b32..7000d3b14a 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -33,6 +33,7 @@ public:
virtual void initBackend();
virtual void displayMessageOnOSD(const char *msg);
+ virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h);
virtual void fillScreen(uint32 col);
};
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 3671b9f0b9..8b0ac19d9e 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -84,6 +84,7 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
virtual void displayMessageOnOSD(const char *msg) {}
+ virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {}
// 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 4d6a00a3b3..e9f26bc7bc 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -751,6 +751,12 @@ void OpenGLGraphicsManager::displayMessageOnOSD(const char *msg) {
#endif
}
+void OpenGLGraphicsManager::copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {
+#ifdef USE_OSD
+ warning("implement copyRectToOSD"); //TODO
+#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 35435c156e..e0d1664e76 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -115,6 +115,7 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual void displayMessageOnOSD(const char *msg);
+ virtual void copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h);
// 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 5b591e77ff..88fdc09f0a 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2197,6 +2197,54 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const char *msg) {
// Ensure a full redraw takes place next time the screen is updated
_forceFull = true;
}
+
+void SurfaceSdlGraphicsManager::copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {
+ assert(_transactionMode == kTransactionNone);
+ assert(buf);
+
+ 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());
+
+#ifdef USE_RGB_COLOR
+ byte *dst = (byte *)_osdSurface->pixels + y * _osdSurface->pitch + x * _osdSurface->format->BytesPerPixel;
+ if (_videoMode.screenWidth == w && pitch == _osdSurface->pitch) {
+ memcpy(dst, buf, h*pitch);
+ } else {
+ const byte *src = (const byte *)buf;
+ do {
+ memcpy(dst, src, w * _osdSurface->format->BytesPerPixel);
+ src += pitch;
+ dst += _osdSurface->pitch;
+ } while (--h);
+ }
+#else
+ byte *dst = (byte *)_osdSurface->pixels + y * _osdSurface->pitch + x;
+ if (_osdSurface->pitch == pitch && pitch == w) {
+ memcpy(dst, buf, h*w);
+ } else {
+ const byte *src = (const byte *)buf;
+ do {
+ memcpy(dst, src, w);
+ src += pitch;
+ dst += _osdSurface->pitch;
+ } while (--h);
+ }
+#endif
+
+ // 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 25d6ff041c..a8bafd0a84 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -145,6 +145,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);
#endif
// Override from Common::EventObserver
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index d8be9ca7ed..08565dcbdd 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -241,6 +241,10 @@ void ModularBackend::displayMessageOnOSD(const char *msg) {
_graphicsManager->displayMessageOnOSD(msg);
}
+void ModularBackend::copyRectToOSD(const void *buf, int pitch, int x, int y, int w, int h) {
+ _graphicsManager->copyRectToOSD(buf, pitch, x, y, w, h);
+}
+
void ModularBackend::quit() {
exit(0);
}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 20e8b7357d..cf3babfc47 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -127,6 +127,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);
//@}