aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorJody Northup2009-06-30 07:30:57 +0000
committerJody Northup2009-06-30 07:30:57 +0000
commit9e1916bcad3cc33a870bdbff5bd01b39e523492d (patch)
tree557ec11652f89b3323c1bcc117df2eedebfca817 /backends/platform/sdl
parent6f644324863437dedecb254bf088b33c914c7241 (diff)
downloadscummvm-rg350-9e1916bcad3cc33a870bdbff5bd01b39e523492d.tar.gz
scummvm-rg350-9e1916bcad3cc33a870bdbff5bd01b39e523492d.tar.bz2
scummvm-rg350-9e1916bcad3cc33a870bdbff5bd01b39e523492d.zip
renamed kTransactionPixelFormatNotSupported to kTransactionFormatNotSupported, retyped all Graphics::PixelFormat * parameters to const Graphics::PixelFormat *, (hopefully) repaired all memory leaks on screen and cursor format changes, provided OSystem::getScreenFormat and OSystem::getSupportedFormats methods for when ENABLE_RGB_COLOR is not set, completely forgot the "commit early, commit often" mantra.
svn-id: r41972
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/graphics.cpp23
-rw-r--r--backends/platform/sdl/sdl.h4
2 files changed, 15 insertions, 12 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index a45f31108b..27f32ee8d2 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -125,7 +125,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
#ifdef ENABLE_RGB_COLOR
} else if (_videoMode.format != _oldVideoMode.format) {
- errors |= kTransactionPixelFormatNotSupported;
+ errors |= kTransactionFormatNotSupported;
_videoMode.format = _oldVideoMode.format;
_screenFormat = _videoMode.format;
@@ -354,21 +354,24 @@ int OSystem_SDL::getGraphicsMode() const {
return _videoMode.mode;
}
-void OSystem_SDL::initSize(uint w, uint h, Graphics::PixelFormat *format) {
+void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
assert(_transactionMode == kTransactionActive);
#ifdef ENABLE_RGB_COLOR
//avoid redundant format changes
+ Graphics::PixelFormat newFormat;
if (!format)
- format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0);
+ newFormat = Graphics::PixelFormat::createFormatCLUT8();
+ else
+ newFormat = *format;
- assert(format->bytesPerPixel > 0);
+ assert(newFormat.bytesPerPixel > 0);
- if (*format != _videoMode.format)
+ if (newFormat != _videoMode.format)
{
- _videoMode.format = *format;
+ _videoMode.format = newFormat;
_transactionDetails.formatChanged = true;
- _screenFormat = *format;
+ _screenFormat = newFormat;
}
#endif
@@ -1373,11 +1376,11 @@ void OSystem_SDL::warpMouse(int x, int y) {
}
}
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format) {
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
#ifdef ENABLE_RGB_COLOR
if (!format)
- format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0);
- if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
+ _cursorFormat = Graphics::PixelFormat(1,8,8,8,8,0,0,0,0);
+ else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
_cursorFormat = *format;
keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
#else
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index befb82cc89..68dfe64d53 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -123,7 +123,7 @@ public:
// Set the size and format of the video bitmap.
// Typically, 320x200 CLUT8
- virtual void initSize(uint w, uint h, Graphics::PixelFormat *format); // overloaded by CE backend
+ virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format); // overloaded by CE backend
virtual int getScreenChangeID() const { return _screenChangeCount; }
@@ -152,7 +152,7 @@ public:
virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
// Set the bitmap that's used when drawing the cursor.
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
// Set colors of cursor palette
void setCursorPalette(const byte *colors, uint start, uint num);