diff options
-rw-r--r-- | backends/sdl/sdl-common.cpp | 109 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 11 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 121 | ||||
-rw-r--r-- | backends/sdl/sdl_gl.cpp | 110 |
4 files changed, 120 insertions, 231 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index fbaf3870a1..c7440b9c43 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -989,3 +989,112 @@ void OSystem_SDL_Common::unlock_mutex(void *mutex) { void OSystem_SDL_Common::delete_mutex(void *mutex) { SDL_DestroyMutex((SDL_mutex *) mutex); } + +void OSystem_SDL_Common::show_overlay() +{ + // hide the mouse + undraw_mouse(); + + _overlayVisible = true; + clear_overlay(); +} + +void OSystem_SDL_Common::hide_overlay() +{ + // hide the mouse + undraw_mouse(); + + _overlayVisible = false; + _forceFull = true; +} + +void OSystem_SDL_Common::clear_overlay() +{ + if (!_overlayVisible) + return; + + // hide the mouse + undraw_mouse(); + + // Clear the overlay by making the game screen "look through" everywhere. + SDL_Rect src, dst; + src.x = src.y = 0; + dst.x = dst.y = 1; + src.w = dst.w = _screenWidth; + src.h = dst.h = _screenHeight; + if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) + error("SDL_BlitSurface failed: %s", SDL_GetError()); + + _forceFull = true; +} + +void OSystem_SDL_Common::grab_overlay(int16 *buf, int pitch) +{ + if (!_overlayVisible) + return; + + if (_tmpscreen == NULL) + return; + + // hide the mouse + undraw_mouse(); + + if (SDL_LockSurface(_tmpscreen) == -1) + error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + + int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1; + int h = _screenHeight; + do { + memcpy(buf, src, _screenWidth*2); + src += _tmpScreenWidth; + buf += pitch; + } while (--h); + + SDL_UnlockSurface(_tmpscreen); +} + +void OSystem_SDL_Common::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) +{ + if (!_overlayVisible) + return; + + if (_tmpscreen == NULL) + return; + + // Clip the coordinates + if (x < 0) { w+=x; buf-=x; x = 0; } + if (y < 0) { h+=y; buf-=y*pitch; y = 0; } + if (w > _screenWidth-x) { w = _screenWidth - x; } + if (h > _screenHeight-y) { h = _screenHeight - y; } + if (w <= 0 || h <= 0) + return; + + // Mark the modified region as dirty + cksum_valid = false; + add_dirty_rect(x, y, w, h); + + /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ + undraw_mouse(); + + if (SDL_LockSurface(_tmpscreen) == -1) + error("SDL_LockSurface failed: %s.\n", SDL_GetError()); + + int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); + do { + memcpy(dst, buf, w*2); + dst += _tmpScreenWidth; + buf += pitch; + } while (--h); + + SDL_UnlockSurface(_tmpscreen); +} + +int16 OSystem_SDL_Common::RBGToColor(uint8 r, uint8 g, uint8 b) +{ + return SDL_MapRGB(_tmpscreen->format, r, g, b); +} + +void OSystem_SDL_Common::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) +{ + SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b); +} diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index a20628e25d..ff0bd96135 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -103,6 +103,17 @@ public: void unlock_mutex(void *mutex); void delete_mutex(void *mutex); + // Overlay + virtual void show_overlay(); + virtual void hide_overlay(); + virtual void clear_overlay(); + virtual void grab_overlay(int16 *buf, int pitch); + virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h); + + // Methods that convert RBG to/from colors suitable for the overlay. + virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b); + virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b); + static OSystem *create(int gfx_mode, bool full_screen); protected: diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index 1979872459..01bb80a827 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -38,17 +38,6 @@ public: // Set a parameter uint32 property(int param, Property *value); - // Overlay - virtual void show_overlay(); - virtual void hide_overlay(); - virtual void clear_overlay(); - virtual void grab_overlay(int16 *buf, int pitch); - virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h); - - // Methods that convert RBG to/from colors suitable for the overlay. - virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b); - protected: SDL_Surface *_hwscreen; // hardware screen @@ -355,113 +344,3 @@ uint32 OSystem_SDL::property(int param, Property *value) { return OSystem_SDL_Common::property(param, value); } -int16 OSystem_SDL::RBGToColor(uint8 r, uint8 g, uint8 b) -{ - return SDL_MapRGB(_tmpscreen->format, r, g, b); -} - -void OSystem_SDL::colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b) -{ - SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b); -} - -void OSystem_SDL::show_overlay() -{ - // hide the mouse - undraw_mouse(); - - _overlayVisible = true; - clear_overlay(); -} - -void OSystem_SDL::hide_overlay() -{ - // hide the mouse - undraw_mouse(); - - _overlayVisible = false; - _forceFull = true; -} - -void OSystem_SDL::clear_overlay() -{ - if (!_overlayVisible) - return; - - // hide the mouse - undraw_mouse(); - - // Clear the overlay by making the game screen "look through" everywhere. - SDL_Rect src, dst; - src.x = src.y = 0; - dst.x = dst.y = 1; - src.w = dst.w = _screenWidth; - src.h = dst.h = _screenHeight; - if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) - error("SDL_BlitSurface failed: %s", SDL_GetError()); - - _forceFull = true; -} - -void OSystem_SDL::grab_overlay(int16 *buf, int pitch) -{ - if (!_overlayVisible) - return; - - if (_tmpscreen == NULL) - return; - - // hide the mouse - undraw_mouse(); - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1; - int h = _screenHeight; - do { - memcpy(buf, src, _screenWidth*2); - src += _tmpScreenWidth; - buf += pitch; - } while (--h); - - SDL_UnlockSurface(_tmpscreen); -} - -void OSystem_SDL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) -{ - if (!_overlayVisible) - return; - - if (_tmpscreen == NULL) - return; - - // Clip the coordinates - if (x < 0) { w+=x; buf-=x; x = 0; } - if (y < 0) { h+=y; buf-=y*pitch; y = 0; } - if (w > _screenWidth-x) { w = _screenWidth - x; } - if (h > _screenHeight-y) { h = _screenHeight - y; } - if (w <= 0 || h <= 0) - return; - - // Mark the modified region as dirty - cksum_valid = false; - add_dirty_rect(x, y, w, h); - - /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ - undraw_mouse(); - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); - do { - memcpy(dst, buf, w*2); - dst += _tmpScreenWidth; - buf += pitch; - } while (--h); - - SDL_UnlockSurface(_tmpscreen); -} - - diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 6675f11d01..f3a2fa7f63 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -45,13 +45,6 @@ public: // Set a parameter uint32 property(int param, Property *value); - // Overlay - virtual void show_overlay(); - virtual void hide_overlay(); - virtual void clear_overlay(); - virtual void grab_overlay(int16 *buf, int pitch); - virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h); - protected: FB2GL fb2gl; int gl_flags; @@ -338,106 +331,3 @@ uint32 OSystem_SDL_OpenGL::property(int param, Property *value) { return OSystem_SDL_Common::property(param, value); } - - -void OSystem_SDL_OpenGL::show_overlay() -{ - // hide the mouse - undraw_mouse(); - - _overlayVisible = true; - clear_overlay(); -} - -void OSystem_SDL_OpenGL::hide_overlay() -{ - // hide the mouse - undraw_mouse(); - - _overlayVisible = false; - _forceFull = true; -} - -void OSystem_SDL_OpenGL::clear_overlay() -{ - if (!_overlayVisible) - return; - - // hide the mouse - undraw_mouse(); - - // Clear the overlay by making the game screen "look through" everywhere. - SDL_Rect src, dst; - src.x = src.y = 0; -// dst.x = dst.y = 1; - dst.x = dst.y = 0; - src.w = dst.w = _screenWidth; - src.h = dst.h = _screenHeight; - if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) - error("SDL_BlitSurface failed: %s", SDL_GetError()); - - _forceFull = true; -} - -void OSystem_SDL_OpenGL::grab_overlay(int16 *buf, int pitch) -{ - if (!_overlayVisible) - return; - - if (_tmpscreen == NULL) - return; - - // hide the mouse - undraw_mouse(); - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - int16 *src = (int16 *)_tmpscreen->pixels + _tmpScreenWidth + 1; - int h = _screenHeight; - do { - memcpy(buf, src, _screenWidth*2); - src += _tmpScreenWidth; - buf += pitch; - } while (--h); - - SDL_UnlockSurface(_tmpscreen); -} - -void OSystem_SDL_OpenGL::copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) -{ - if (!_overlayVisible) - return; - - if (_tmpscreen == NULL) - return; - - // Clip the coordinates - if (x < 0) { w+=x; buf-=x; x = 0; } - if (y < 0) { h+=y; buf-=y*pitch; y = 0; } - if (w > _screenWidth-x) { w = _screenWidth - x; } - if (h > _screenHeight-y) { h = _screenHeight - y; } - if (w <= 0 || h <= 0) - return; - - // Mark the modified region as dirty - cksum_valid = false; - add_dirty_rect(x, y, w, h); - - /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ - undraw_mouse(); - - if (SDL_LockSurface(_tmpscreen) == -1) - error("SDL_LockSurface failed: %s.\n", SDL_GetError()); - - int16 *dst = (int16 *)_tmpscreen->pixels + (y+1) * _tmpScreenWidth + (x+1); - do { - memcpy(dst, buf, w*2); - dst += _tmpScreenWidth; - buf += pitch; - } while (--h); - - SDL_UnlockSurface(_tmpscreen); -} - - |