[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.h,1.79,1.80 graphics.cpp,1.45,1.46
Max Horn
fingolfin at users.sourceforge.net
Sun May 8 14:40:32 CEST 2005
Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25939/backends/sdl
Modified Files:
sdl-common.h graphics.cpp
Log Message:
Added two new methods to OSystem: grabPalette and grabRawScreen
Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- sdl-common.h 19 Apr 2005 20:22:49 -0000 1.79
+++ sdl-common.h 8 May 2005 21:39:05 -0000 1.80
@@ -80,11 +80,17 @@
// Set colors of the palette
void setPalette(const byte *colors, uint start, uint num);
+
+ // Get colors of the palette
+ void grabPalette(byte *colors, uint start, uint num);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h);
+ // Copies the screen to a buffer
+ bool grabRawScreen(Graphics::Surface *surf);
+
// Clear the screen
void clearScreen();
Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- graphics.cpp 6 May 2005 10:07:33 -0000 1.45
+++ graphics.cpp 8 May 2005 21:39:05 -0000 1.46
@@ -25,6 +25,7 @@
#include "common/util.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
+#include "graphics/surface.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", "Normal (no scaling)", GFX_NORMAL},
@@ -821,6 +822,25 @@
SDL_UnlockSurface(_screen);
}
+bool OSystem_SDL::grabRawScreen(Graphics::Surface *surf) {
+ assert(_screen);
+ assert(surf);
+
+ Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+
+ surf->create(_screenWidth, _screenHeight, _screen->format->BytesPerPixel);
+
+ // 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);
+
+ // Unlock the screen surface
+ SDL_UnlockSurface(_screen);
+
+ return true;
+}
void OSystem_SDL::addDirtyRect(int x, int y, int w, int h, bool mouseRect) {
if (_forceFull)
@@ -1007,6 +1027,18 @@
blitCursor();
}
+void OSystem_SDL::grabPalette(byte *colors, uint start, uint num) {
+ assert(colors);
+ const SDL_Color *base = _currentPalette + start;
+
+ for (uint i = 0; i < num; ++i) {
+ colors[i * 4] = base[i].r;
+ colors[i * 4 + 1] = base[i].g;
+ colors[i * 4 + 2] = base[i].b;
+ colors[i * 4 + 3] = 0xFF;
+ }
+}
+
void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) {
assert(colors);
const byte *b = colors;
More information about the Scummvm-git-logs
mailing list