From f80799cd5be7489fb4ab3fbb7fc55ecac25d1a6d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 15 Jun 2007 21:21:42 +0000 Subject: Fix for bug #1690813: BASS: Crash when changing scalers during intro svn-id: r27435 --- backends/platform/sdl/graphics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends/platform/sdl/graphics.cpp') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 212eb43585..e0b7de28ab 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1597,6 +1597,8 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) { assert (_transactionMode == kTransactionNone); assert(msg); + Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends + uint i; // Lock the OSD surface for drawing -- cgit v1.2.3 From b51f2f3212ae8a5abbdce4d947ec2d1cad1a0b6f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 19 Jun 2007 22:39:59 +0000 Subject: Implemented the OSystem framebuffer API, as discussed on scummvm-devel. All changes are just fine, and won't cause any compile problems or regressions, despite the fact that I can't test most of the non-SDL backend changes, at an improbability level of two to the power of two hundred and seventy-six thousand to one against - possibly much higher. Anything you still can't cope with is therefore your own problem. Please relax. svn-id: r27548 --- backends/platform/sdl/graphics.cpp | 50 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'backends/platform/sdl/graphics.cpp') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index e0b7de28ab..f93c806aa8 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -761,22 +761,6 @@ void OSystem_SDL::setAspectRatioCorrection(bool enable) { } } -void OSystem_SDL::clearScreen() { - assert (_transactionMode == kTransactionNone); - - // Try to lock the screen surface - if (SDL_LockSurface(_screen) == -1) - error("SDL_LockSurface failed: %s", SDL_GetError()); - - byte *dst = (byte *)_screen->pixels; - - // Clear the screen - memset(dst, 0, _screenWidth * _screenHeight); - - // Unlock the screen surface - SDL_UnlockSurface(_screen); -} - void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { assert (_transactionMode == kTransactionNone); assert(src); @@ -848,24 +832,44 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int SDL_UnlockSurface(_screen); } -bool OSystem_SDL::grabRawScreen(Graphics::Surface *surf) { - assert(_screen); - assert(surf); +Graphics::Surface *OSystem_SDL::lockScreen() { + assert (_transactionMode == kTransactionNone); - Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends + // Lock the graphics mutex + lockMutex(_graphicsMutex); - surf->create(_screenWidth, _screenHeight, _screen->format->BytesPerPixel); + // paranoia check + assert(!_screenIsLocked); + _screenIsLocked = true; // Try to lock the screen surface if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s", SDL_GetError()); - memcpy(surf->pixels, _screen->pixels, _screenWidth * _screenHeight * _screen->format->BytesPerPixel); + _framebuffer.pixels = _screen->pixels; + _framebuffer.w = _screen->w; + _framebuffer.h = _screen->h; + _framebuffer.pitch = _screen->pitch; + _framebuffer.bytesPerPixel = 1; + + return &_framebuffer; +} + +void OSystem_SDL::unlockScreen() { + assert (_transactionMode == kTransactionNone); + + // paranoia check + assert(_screenIsLocked); + _screenIsLocked = false; // Unlock the screen surface SDL_UnlockSurface(_screen); - return true; + // Trigger a full screen update + _forceFull = true; + + // Finally unlock the graphics mutex + unlockMutex(_graphicsMutex); } void OSystem_SDL::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) { -- cgit v1.2.3