[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.42,1.43
Max Horn
fingolfin at users.sourceforge.net
Wed Apr 30 11:35:05 CEST 2003
Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv17451
Modified Files:
sdl-common.cpp
Log Message:
free movement may not be necessary for now, but doing it is trivial, so why not. Still this code is horribly inefficient :-/.
Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- sdl-common.cpp 29 Mar 2003 09:56:51 -0000 1.42
+++ sdl-common.cpp 30 Apr 2003 18:34:29 -0000 1.43
@@ -194,38 +194,43 @@
void OSystem_SDL_Common::move_screen(int dx, int dy, int height) {
- if ((dx == 0) && (dy == 0))
+
+ // Short circuit check - do we have to do anything anyway?
+ if ((dx == 0 && dy == 0) || height <= 0)
return;
+
+ int x, y;
+
+ // We'll have to do a full screen redraw anyway, so set the flag.
+ _forceFull = true;
+
+ // Hide the mouse
+ if (_mouseDrawn)
+ undraw_mouse();
- if (dx == 0) {
- // vertical movement
- if (dy > 0) {
- // move down
- // copy from bottom to top
- for (int y = height - 1; y >= dy; y--)
- copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
- } else {
- // move up
- // copy from top to bottom
- for (int y = 0; y < height + dx; y++)
- copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
- }
- } else if (dy == 0) {
- // horizontal movement
- if (dx > 0) {
- // move right
- // copy from right to left
- for (int x = _screenWidth - 1; x >= dx; x--)
- copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height);
- } else {
- // move left
- // copy from left to right
- for (int x = 0; x < _screenWidth; x++)
- copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height);
- }
- } else {
- // free movement
- // not neccessary for now
+ // FIXME - calling copy rect repeatedly is horribly inefficient, as it (un)locks the surface repeatedly
+ // and it performs unneeded clipping checks etc.
+
+ // vertical movement
+ if (dy > 0) {
+ // move down - copy from bottom to top
+ for (y = height - 1; y >= dy; y--)
+ copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
+ } else if (dy < 0) {
+ // move up - copy from top to bottom
+ for (y = 0; y < height + dx; y++)
+ copy_rect((byte *)_screen->pixels + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
+ }
+
+ // horizontal movement
+ if (dx > 0) {
+ // move right - copy from right to left
+ for (x = _screenWidth - 1; x >= dx; x--)
+ copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height);
+ } else if (dx < 0) {
+ // move left - copy from left to right
+ for (x = 0; x < _screenWidth; x++)
+ copy_rect((byte *)_screen->pixels + x - dx, _screenWidth, x, 0, 1, height);
}
}
More information about the Scummvm-git-logs
mailing list