diff options
Diffstat (limited to 'backends/sdl')
| -rw-r--r-- | backends/sdl/graphics.cpp | 32 | ||||
| -rw-r--r-- | backends/sdl/sdl-common.h | 6 | 
2 files changed, 38 insertions, 0 deletions
| diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp index 658a1f3739..43e1a7cd4d 100644 --- a/backends/sdl/graphics.cpp +++ b/backends/sdl/graphics.cpp @@ -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 @@ 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); +	 +	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 @@ void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) {  		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; diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 2d3337e0d5..a4265c6f31 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -80,11 +80,17 @@ public:  	// 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(); | 
