comparison src/video/SDL_cursor.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents 450721ad5436
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
123 SDL_SetError("Cursor hot spot doesn't lie within cursor"); 123 SDL_SetError("Cursor hot spot doesn't lie within cursor");
124 return(NULL); 124 return(NULL);
125 } 125 }
126 126
127 /* Allocate memory for the cursor */ 127 /* Allocate memory for the cursor */
128 cursor = (SDL_Cursor *)malloc(sizeof *cursor); 128 cursor = (SDL_Cursor *)SDL_malloc(sizeof *cursor);
129 if ( cursor == NULL ) { 129 if ( cursor == NULL ) {
130 SDL_OutOfMemory(); 130 SDL_OutOfMemory();
131 return(NULL); 131 return(NULL);
132 } 132 }
133 savelen = (w*4)*h; 133 savelen = (w*4)*h;
135 cursor->area.y = 0; 135 cursor->area.y = 0;
136 cursor->area.w = w; 136 cursor->area.w = w;
137 cursor->area.h = h; 137 cursor->area.h = h;
138 cursor->hot_x = hot_x; 138 cursor->hot_x = hot_x;
139 cursor->hot_y = hot_y; 139 cursor->hot_y = hot_y;
140 cursor->data = (Uint8 *)malloc((w/8)*h*2); 140 cursor->data = (Uint8 *)SDL_malloc((w/8)*h*2);
141 cursor->mask = cursor->data+((w/8)*h); 141 cursor->mask = cursor->data+((w/8)*h);
142 cursor->save[0] = (Uint8 *)malloc(savelen*2); 142 cursor->save[0] = (Uint8 *)SDL_malloc(savelen*2);
143 cursor->save[1] = cursor->save[0] + savelen; 143 cursor->save[1] = cursor->save[0] + savelen;
144 cursor->wm_cursor = NULL; 144 cursor->wm_cursor = NULL;
145 if ( ! cursor->data || ! cursor->save[0] ) { 145 if ( ! cursor->data || ! cursor->save[0] ) {
146 SDL_FreeCursor(cursor); 146 SDL_FreeCursor(cursor);
147 SDL_OutOfMemory(); 147 SDL_OutOfMemory();
149 } 149 }
150 for ( i=((w/8)*h)-1; i>=0; --i ) { 150 for ( i=((w/8)*h)-1; i>=0; --i ) {
151 cursor->data[i] = data[i]; 151 cursor->data[i] = data[i];
152 cursor->mask[i] = mask[i] | data[i]; 152 cursor->mask[i] = mask[i] | data[i];
153 } 153 }
154 memset(cursor->save[0], 0, savelen*2); 154 SDL_memset(cursor->save[0], 0, savelen*2);
155 155
156 /* If the window manager gives us a good cursor, we're done! */ 156 /* If the window manager gives us a good cursor, we're done! */
157 if ( video->CreateWMCursor ) { 157 if ( video->CreateWMCursor ) {
158 cursor->wm_cursor = video->CreateWMCursor(video, data, mask, 158 cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
159 w, h, hot_x, hot_y); 159 w, h, hot_x, hot_y);
242 if ( cursor != SDL_defcursor ) { 242 if ( cursor != SDL_defcursor ) {
243 SDL_VideoDevice *video = current_video; 243 SDL_VideoDevice *video = current_video;
244 SDL_VideoDevice *this = current_video; 244 SDL_VideoDevice *this = current_video;
245 245
246 if ( cursor->data ) { 246 if ( cursor->data ) {
247 free(cursor->data); 247 SDL_free(cursor->data);
248 } 248 }
249 if ( cursor->save[0] ) { 249 if ( cursor->save[0] ) {
250 free(cursor->save[0]); 250 SDL_free(cursor->save[0]);
251 } 251 }
252 if ( video && cursor->wm_cursor ) { 252 if ( video && cursor->wm_cursor ) {
253 video->FreeWMCursor(this, cursor->wm_cursor); 253 video->FreeWMCursor(this, cursor->wm_cursor);
254 } 254 }
255 free(cursor); 255 SDL_free(cursor);
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 int SDL_ShowCursor (int toggle) 260 int SDL_ShowCursor (int toggle)
446 for ( w=area->w/8; w; w-- ) { 446 for ( w=area->w/8; w; w-- ) {
447 maskb = *mask++; 447 maskb = *mask++;
448 datab = *data++; 448 datab = *data++;
449 for ( i=0; i<8; ++i ) { 449 for ( i=0; i<8; ++i ) {
450 if ( maskb & 0x80 ) { 450 if ( maskb & 0x80 ) {
451 memset(dst,pixels[datab>>7],3); 451 SDL_memset(dst,pixels[datab>>7],3);
452 } 452 }
453 maskb <<= 1; 453 maskb <<= 1;
454 datab <<= 1; 454 datab <<= 1;
455 dst += 3; 455 dst += 3;
456 } 456 }
521 maskb = *mask++; 521 maskb = *mask++;
522 datab = *data++; 522 datab = *data++;
523 } 523 }
524 if ( (x >= minx) && (x < maxx) ) { 524 if ( (x >= minx) && (x < maxx) ) {
525 if ( maskb & 0x80 ) { 525 if ( maskb & 0x80 ) {
526 memset(dst, pixels8[datab>>7], dstbpp); 526 SDL_memset(dst, pixels8[datab>>7], dstbpp);
527 } 527 }
528 } 528 }
529 maskb <<= 1; 529 maskb <<= 1;
530 datab <<= 1; 530 datab <<= 1;
531 dst += dstbpp; 531 dst += dstbpp;
539 maskb = *mask++; 539 maskb = *mask++;
540 datab = *data++; 540 datab = *data++;
541 } 541 }
542 if ( (x >= minx) && (x < maxx) ) { 542 if ( (x >= minx) && (x < maxx) ) {
543 if ( maskb & 0x80 ) { 543 if ( maskb & 0x80 ) {
544 memset(dst, pixels[datab>>7], dstbpp); 544 SDL_memset(dst, pixels[datab>>7], dstbpp);
545 } 545 }
546 } 546 }
547 maskb <<= 1; 547 maskb <<= 1;
548 datab <<= 1; 548 datab <<= 1;
549 dst += dstbpp; 549 dst += dstbpp;
614 614
615 /* Perform the copy */ 615 /* Perform the copy */
616 w = area.w*screenbpp; 616 w = area.w*screenbpp;
617 h = area.h; 617 h = area.h;
618 while ( h-- ) { 618 while ( h-- ) {
619 memcpy(dst, src, w); 619 SDL_memcpy(dst, src, w);
620 dst += w; 620 dst += w;
621 src += screen->pitch; 621 src += screen->pitch;
622 } 622 }
623 } 623 }
624 624
692 692
693 /* Perform the copy */ 693 /* Perform the copy */
694 w = area.w*screenbpp; 694 w = area.w*screenbpp;
695 h = area.h; 695 h = area.h;
696 while ( h-- ) { 696 while ( h-- ) {
697 memcpy(dst, src, w); 697 SDL_memcpy(dst, src, w);
698 src += w; 698 src += w;
699 dst += screen->pitch; 699 dst += screen->pitch;
700 } 700 }
701 701
702 /* Perform pixel conversion on cursor background */ 702 /* Perform pixel conversion on cursor background */
746 746
747 if ( SDL_cursor ) { 747 if ( SDL_cursor ) {
748 savelen = SDL_cursor->area.w*4*SDL_cursor->area.h; 748 savelen = SDL_cursor->area.w*4*SDL_cursor->area.h;
749 SDL_cursor->area.x = 0; 749 SDL_cursor->area.x = 0;
750 SDL_cursor->area.y = 0; 750 SDL_cursor->area.y = 0;
751 memset(SDL_cursor->save[0], 0, savelen); 751 SDL_memset(SDL_cursor->save[0], 0, savelen);
752 } 752 }
753 } 753 }