aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorTony Puccinelli2010-06-05 01:05:19 +0000
committerTony Puccinelli2010-06-05 01:05:19 +0000
commit95e56f2052956e80a6319b2916a8f899340effaf (patch)
treef9525eb32e05f1a4746233fe3daf254d07cb83ab /backends/platform/sdl
parent28e28a2fea9f6adf4967463024c609e6a01ac5b0 (diff)
parent3a5fe4ca002a85f7c4549c8d36203553553c53f9 (diff)
downloadscummvm-rg350-95e56f2052956e80a6319b2916a8f899340effaf.tar.gz
scummvm-rg350-95e56f2052956e80a6319b2916a8f899340effaf.tar.bz2
scummvm-rg350-95e56f2052956e80a6319b2916a8f899340effaf.zip
merged trunk into branch and corrected __PS2__ to __PLAYSTATION2__ in a couple files
svn-id: r49435
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/graphics.cpp100
-rw-r--r--backends/platform/sdl/sdl.cpp25
-rw-r--r--backends/platform/sdl/sdl.h15
3 files changed, 7 insertions, 133 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index b3ef101e9e..9d0d872c3d 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -469,12 +469,7 @@ void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format)
_videoMode.screenWidth = w;
_videoMode.screenHeight = h;
- _cksumNum = (w * h / (8 * 8));
-
_transactionDetails.sizeChanged = true;
-
- free(_dirtyChecksums);
- _dirtyChecksums = (uint32 *)calloc(_cksumNum * 2, sizeof(uint32));
}
int OSystem_SDL::effectiveScreenHeight() const {
@@ -976,16 +971,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int
assert(h > 0 && y + h <= _videoMode.screenHeight);
assert(w > 0 && x + w <= _videoMode.screenWidth);
- if (IS_ALIGNED(src, 4) && pitch == _videoMode.screenWidth && x == 0 && y == 0 &&
- w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {
- /* Special, optimized case for full screen updates.
- * It tries to determine what areas were actually changed,
- * and just updates those, on the actual display. */
- addDirtyRgnAuto(src);
- } else {
- _cksumValid = false;
- addDirtyRect(x, y, w, h);
- }
+ addDirtyRect(x, y, w, h);
// Try to lock the screen surface
if (SDL_LockSurface(_screen) == -1)
@@ -1131,89 +1117,6 @@ void OSystem_SDL::addDirtyRect(int x, int y, int w, int h, bool realCoordinates)
}
}
-
-void OSystem_SDL::makeChecksums(const byte *buf) {
- assert(buf);
- uint32 *sums = _dirtyChecksums;
- uint x,y;
- const uint last_x = (uint)_videoMode.screenWidth / 8;
- const uint last_y = (uint)_videoMode.screenHeight / 8;
-
- const uint BASE = 65521; /* largest prime smaller than 65536 */
-
- /* the 8x8 blocks in buf are enumerated starting in the top left corner and
- * reading each line at a time from left to right */
- for (y = 0; y != last_y; y++, buf += _videoMode.screenWidth * (8 - 1))
- for (x = 0; x != last_x; x++, buf += 8) {
- // Adler32 checksum algorithm (from RFC1950, used by gzip and zlib).
- // This computes the Adler32 checksum of a 8x8 pixel block. Note
- // that we can do the modulo operation (which is the slowest part)
- // of the algorithm) at the end, instead of doing each iteration,
- // since we only have 64 iterations in total - and thus s1 and
- // s2 can't overflow anyway.
- uint32 s1 = 1;
- uint32 s2 = 0;
- const byte *ptr = buf;
- for (int subY = 0; subY < 8; subY++) {
- for (int subX = 0; subX < 8; subX++) {
- s1 += ptr[subX];
- s2 += s1;
- }
- ptr += _videoMode.screenWidth;
- }
-
- s1 %= BASE;
- s2 %= BASE;
-
- /* output the checksum for this block */
- *sums++ = (s2 << 16) + s1;
- }
-}
-
-void OSystem_SDL::addDirtyRgnAuto(const byte *buf) {
- assert(buf);
- assert(IS_ALIGNED(buf, 4));
-
- /* generate a table of the checksums */
- makeChecksums(buf);
-
- if (!_cksumValid) {
- _forceFull = true;
- _cksumValid = true;
- }
-
- /* go through the checksum list, compare it with the previous checksums,
- and add all dirty rectangles to a list. try to combine small rectangles
- into bigger ones in a simple way */
- if (!_forceFull) {
- int x, y, w;
- uint32 *ck = _dirtyChecksums;
-
- for (y = 0; y != _videoMode.screenHeight / 8; y++) {
- for (x = 0; x != _videoMode.screenWidth / 8; x++, ck++) {
- if (ck[0] != ck[_cksumNum]) {
- /* found a dirty 8x8 block, now go as far to the right as possible,
- and at the same time, unmark the dirty status by setting old to new. */
- w=0;
- do {
- ck[w + _cksumNum] = ck[w];
- w++;
- } while (x + w != _videoMode.screenWidth / 8 && ck[w] != ck[w + _cksumNum]);
-
- addDirtyRect(x * 8, y * 8, w * 8, 8);
-
- if (_forceFull)
- goto get_out;
- }
- }
- }
- } else {
- get_out:;
- /* Copy old checksums to new */
- memcpy(_dirtyChecksums + _cksumNum, _dirtyChecksums, _cksumNum * sizeof(uint32));
- }
-}
-
int16 OSystem_SDL::getHeight() {
return _videoMode.screenHeight;
}
@@ -1432,7 +1335,6 @@ void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i
return;
// Mark the modified region as dirty
- _cksumValid = false;
addDirtyRect(x, y, w, h);
if (SDL_LockSurface(_overlayscreen) == -1)
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 6b23acfb8b..e54d70e8b2 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -149,7 +149,6 @@ void OSystem_SDL::initBackend() {
memset(&_videoMode, 0, sizeof(_videoMode));
memset(&_transactionDetails, 0, sizeof(_transactionDetails));
- _cksumValid = false;
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && defined(USE_SCALERS)
_videoMode.mode = GFX_DOUBLESIZE;
_videoMode.scaleFactor = 2;
@@ -163,7 +162,6 @@ void OSystem_SDL::initBackend() {
_scalerProc = Normal1x;
#endif
_scalerType = 0;
- _modeFlags = 0;
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
_videoMode.fullscreen = ConfMan.getBool("fullscreen");
@@ -233,7 +231,7 @@ OSystem_SDL::OSystem_SDL()
#endif
_overlayVisible(false),
_overlayscreen(0), _tmpscreen2(0),
- _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0),
+ _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0),
_scrollLock(false),
_mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0),
_mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true),
@@ -251,9 +249,9 @@ OSystem_SDL::OSystem_SDL()
_screenIsLocked(false),
_graphicsMutex(0), _transactionMode(kTransactionNone) {
- // allocate palette storage
- _currentPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256);
- _cursorPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256);
+ // clear palette storage
+ memset(_currentPalette, 0, sizeof(_currentPalette));
+ memset(_cursorPalette, 0, sizeof(_cursorPalette));
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
@@ -281,9 +279,6 @@ OSystem_SDL::~OSystem_SDL() {
SDL_RemoveTimer(_timerID);
closeMixer();
- free(_dirtyChecksums);
- free(_currentPalette);
- free(_cursorPalette);
free(_mouseData);
delete _savefile;
@@ -453,7 +448,6 @@ bool OSystem_SDL::hasFeature(Feature f) {
return
(f == kFeatureFullscreenMode) ||
(f == kFeatureAspectRatioCorrection) ||
- (f == kFeatureAutoComputeDirtyRects) ||
(f == kFeatureCursorHasPalette) ||
(f == kFeatureIconifyWindow);
}
@@ -466,12 +460,6 @@ void OSystem_SDL::setFeatureState(Feature f, bool enable) {
case kFeatureAspectRatioCorrection:
setAspectRatioCorrection(enable);
break;
- case kFeatureAutoComputeDirtyRects:
- if (enable)
- _modeFlags |= DF_WANT_RECT_OPTIM;
- else
- _modeFlags &= ~DF_WANT_RECT_OPTIM;
- break;
case kFeatureIconifyWindow:
if (enable)
SDL_WM_IconifyWindow();
@@ -489,8 +477,6 @@ bool OSystem_SDL::getFeatureState(Feature f) {
return _videoMode.fullscreen;
case kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
- case kFeatureAutoComputeDirtyRects:
- return _modeFlags & DF_WANT_RECT_OPTIM;
default:
return false;
}
@@ -512,9 +498,6 @@ void OSystem_SDL::quit() {
SDL_RemoveTimer(_timerID);
closeMixer();
- free(_dirtyChecksums);
- free(_currentPalette);
- free(_cursorPalette);
free(_mouseData);
delete _timer;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index b178d58994..b6baa52391 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -289,10 +289,6 @@ protected:
uint32 _cdEndTime, _cdStopTime;
enum {
- DF_WANT_RECT_OPTIM = 1 << 0
- };
-
- enum {
kTransactionNone = 0,
kTransactionActive = 1,
kTransactionRollback = 2
@@ -340,7 +336,6 @@ protected:
Graphics::Surface _framebuffer;
/** Current video mode flags (see DF_* constants) */
- uint32 _modeFlags;
bool _modeChanged;
int _screenChangeCount;
@@ -352,9 +347,6 @@ protected:
// Dirty rect management
SDL_Rect _dirtyRectList[NUM_DIRTY_RECT];
int _numDirtyRects;
- uint32 *_dirtyChecksums;
- bool _cksumValid;
- int _cksumNum;
// Keyboard mouse emulation. Disabled by fingolfin 2004-12-18.
// I am keeping the rest of the code in for now, since the joystick
@@ -420,11 +412,11 @@ protected:
int _newShakePos;
// Palette data
- SDL_Color *_currentPalette;
+ SDL_Color _currentPalette[256];
uint _paletteDirtyStart, _paletteDirtyEnd;
// Cursor palette data
- SDL_Color *_cursorPalette;
+ SDL_Color _cursorPalette[256];
/**
* Mutex which prevents multiple threads from interfering with each other
@@ -457,9 +449,6 @@ protected:
Common::TimerManager *_timer;
protected:
- void addDirtyRgnAuto(const byte *buf);
- void makeChecksums(const byte *buf);
-
virtual void addDirtyRect(int x, int y, int w, int h, bool realCoordinates = false); // overloaded by CE backend
virtual void drawMouse(); // overloaded by CE backend