stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/video cursor.c


From: Nehal Mistry
Subject: [Stratagus-CVS] stratagus/src/video cursor.c
Date: Wed, 03 Dec 2003 12:34:06 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Nehal Mistry <address@hidden>   03/12/03 12:34:05

Modified files:
        src/video      : cursor.c 

Log message:
        implement save/load cursor rectangle

Patches:
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.84 stratagus/src/video/cursor.c:1.85
--- stratagus/src/video/cursor.c:1.84   Mon Dec  1 23:00:15 2003
+++ stratagus/src/video/cursor.c        Wed Dec  3 12:34:05 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: cursor.c,v 1.84 2003/12/02 04:00:15 nehalmistry Exp $
+//     $Id: cursor.c,v 1.85 2003/12/03 17:34:05 nehalmistry Exp $
 
 //@{
 
@@ -163,7 +163,7 @@
 local int OldCursorRectangleW;         /// saved cursor width in pixel
 local int OldCursorRectangleH;         /// saved cursor height in pixel
 #ifdef USE_SDL_SURFACE
-local SDL_Surface* OldCursorRectangle;         /// background saved behind 
rectangle
+local void* OldCursorRectangle;                /// background saved behind 
rectangle
 #else
 local void* OldCursorRectangle;                /// background saved behind 
rectangle
 #endif
@@ -298,34 +298,59 @@
 #ifdef USE_SDL_SURFACE
 global void LoadCursorRectangle(void* buffer, int x, int y, int w, int h)
 {
-    // FIXME: todo
     int i;
     int bpp;
-
-    return;
+    void *sp;
 
     bpp = TheScreen->format->BytesPerPixel;
-    SDL_LockSurface(TheScreen);
-    for (i = 0; i < h; ++i) {
-       memcpy(&((char*)TheScreen->pixels)[x * bpp + (y + i) * 
TheScreen->pitch], buffer, w * bpp);
+
+    VideoLockScreen();
+
+    sp = buffer;
+    memcpy(&((unsigned char*)TheScreen->pixels)
+       [x * bpp + y * TheScreen->pitch], sp, w * bpp);
+    sp = sp + w * bpp;
+    memcpy(&((unsigned char*)TheScreen->pixels)
+       [x * bpp + (y + h) * TheScreen->pitch], sp, w * bpp);
+    sp = sp + w * bpp;
+    for (i = 1; i < h; ++i) {
+       memcpy(&((unsigned char*)TheScreen->pixels)
+           [x * bpp + (y + i) * TheScreen->pitch], sp, bpp);
+       memcpy(&((unsigned char*)TheScreen->pixels)
+           [(x + w - 1) * bpp + (y + i) * TheScreen->pitch], 
+               sp + bpp, bpp);
+       sp += bpp * 2;
     }
-    SDL_UnlockSurface(TheScreen);
+
+    VideoUnlockScreen();
 }
 
 global void SaveCursorRectangle(void* buffer, int x, int y, int w, int h)
 {
     int i;
     int bpp;
-
-    return;
+    void *dp;
 
     bpp = TheScreen->format->BytesPerPixel;
-    SDL_LockSurface(TheScreen);
-    for (i = 0; i < h; ++i) {
-       memcpy(buffer, &((char*)TheScreen->pixels)[x * bpp + (y + i) * 
TheScreen->pitch], w * bpp);
+    
+    VideoLockScreen();
+
+    dp = buffer;
+    memcpy(dp, &((unsigned char*)TheScreen->pixels)
+       [x * bpp + y * TheScreen->pitch], w * bpp);
+    dp = dp + w * bpp;
+    memcpy(dp, &((unsigned char*)TheScreen->pixels)
+       [x * bpp + (y + h) * TheScreen->pitch], w * bpp);
+    dp = dp + w * bpp;
+    for (i = 1; i < h; ++i) {
+       memcpy(dp, &((unsigned char*)TheScreen->pixels)
+           [x * bpp + (y + i) * TheScreen->pitch], bpp);
+       memcpy(dp + bpp, &((unsigned char*)TheScreen->pixels)
+           [(x + w - 1) * bpp + (y + i) * TheScreen->pitch], bpp);
+       dp += bpp * 2;
     }
-    SDL_UnlockSurface(TheScreen);
-    // FIXME: todo
+
+    VideoUnlockScreen();
 }
 #else
 /**
@@ -1202,10 +1227,9 @@
        free(OldCursorRectangle);
        OldCursorRectangle = 0;
     }
-
 #ifdef USE_SDL_SURFACE
-//    OldCursorImage = SDL_CreateRGBSurface(SDL_SWSURFACE, 40, 40, 8, 0, 0, 0, 
0);
-//    OldCursorRectangle = SDL_CreateRGBSurface(SDL_SWSURFACE, 40, 40, 8, 0, 
0, 0, 0);
+    OldCursorRectangle = malloc((2 * VideoWidth + 2 * 
+       (VideoHeight - 2)) * TheScreen->format->BytesPerPixel);
 #else
     switch (VideoBpp) {
        case 8:
@@ -1257,7 +1281,7 @@
     int i;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.84 2003/12/02 
04:00:15 nehalmistry Exp $\n\n");
+    CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.85 2003/12/03 
17:34:05 nehalmistry Exp $\n\n");
 
     for (i = 0; Cursors[i].OType; ++i) {
        CLprintf(file, "(define-cursor '%s '%s\n",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]