aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorMax Horn2010-06-02 00:52:57 +0000
committerMax Horn2010-06-02 00:52:57 +0000
commit767edc91faebdc1a60e5c8b3764b169dc9807ea5 (patch)
tree838b131043f177882fe03a7832124e0f8f53b350 /backends/platform/sdl
parentc4c63223cc45ce192f8b03f27fff56fcdf56a502 (diff)
downloadscummvm-rg350-767edc91faebdc1a60e5c8b3764b169dc9807ea5.tar.gz
scummvm-rg350-767edc91faebdc1a60e5c8b3764b169dc9807ea5.tar.bz2
scummvm-rg350-767edc91faebdc1a60e5c8b3764b169dc9807ea5.zip
OSYSTEM: Get rid of kFeatureAutoComputeDirtyRects
svn-id: r49388
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/graphics.cpp100
-rw-r--r--backends/platform/sdl/sdl.cpp15
-rw-r--r--backends/platform/sdl/sdl.h11
3 files changed, 2 insertions, 124 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index e0bf7565fb..82670cfcb7 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 c947e32cd8..f8ae824acf 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),
@@ -281,7 +279,6 @@ OSystem_SDL::~OSystem_SDL() {
SDL_RemoveTimer(_timerID);
closeMixer();
- free(_dirtyChecksums);
free(_mouseData);
delete _savefile;
@@ -451,7 +448,6 @@ bool OSystem_SDL::hasFeature(Feature f) {
return
(f == kFeatureFullscreenMode) ||
(f == kFeatureAspectRatioCorrection) ||
- (f == kFeatureAutoComputeDirtyRects) ||
(f == kFeatureCursorHasPalette) ||
(f == kFeatureIconifyWindow);
}
@@ -464,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();
@@ -487,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;
}
@@ -510,7 +498,6 @@ void OSystem_SDL::deinit() {
SDL_RemoveTimer(_timerID);
closeMixer();
- free(_dirtyChecksums);
free(_mouseData);
delete _timer;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index bfaabab80a..341a59c8cf 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -291,10 +291,6 @@ protected:
uint32 _cdEndTime, _cdStopTime;
enum {
- DF_WANT_RECT_OPTIM = 1 << 0
- };
-
- enum {
kTransactionNone = 0,
kTransactionActive = 1,
kTransactionRollback = 2
@@ -342,7 +338,6 @@ protected:
Graphics::Surface _framebuffer;
/** Current video mode flags (see DF_* constants) */
- uint32 _modeFlags;
bool _modeChanged;
int _screenChangeCount;
@@ -354,9 +349,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
@@ -459,9 +451,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