comparison src/video/gapi/SDL_gapivideo.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 c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
175 return(0); 175 return(0);
176 } 176 }
177 } 177 }
178 178
179 /* Set up the new video mode rectangle */ 179 /* Set up the new video mode rectangle */
180 mode = (SDL_Rect *)malloc(sizeof *mode); 180 mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
181 if ( mode == NULL ) { 181 if ( mode == NULL ) {
182 SDL_OutOfMemory(); 182 SDL_OutOfMemory();
183 return(-1); 183 return(-1);
184 } 184 }
185 mode->x = 0; 185 mode->x = 0;
188 mode->h = h; 188 mode->h = h;
189 189
190 /* Allocate the new list of modes, and fill in the new mode */ 190 /* Allocate the new list of modes, and fill in the new mode */
191 next_mode = gapi->SDL_nummodes[index]; 191 next_mode = gapi->SDL_nummodes[index];
192 gapi->SDL_modelist[index] = (SDL_Rect **) 192 gapi->SDL_modelist[index] = (SDL_Rect **)
193 realloc(gapi->SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); 193 SDL_realloc(gapi->SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
194 if ( gapi->SDL_modelist[index] == NULL ) { 194 if ( gapi->SDL_modelist[index] == NULL ) {
195 SDL_OutOfMemory(); 195 SDL_OutOfMemory();
196 gapi->SDL_nummodes[index] = 0; 196 gapi->SDL_nummodes[index] = 0;
197 free(mode); 197 SDL_free(mode);
198 return(-1); 198 return(-1);
199 } 199 }
200 gapi->SDL_modelist[index][next_mode] = mode; 200 gapi->SDL_modelist[index][next_mode] = mode;
201 gapi->SDL_modelist[index][next_mode+1] = NULL; 201 gapi->SDL_modelist[index][next_mode+1] = NULL;
202 gapi->SDL_nummodes[index]++; 202 gapi->SDL_nummodes[index]++;
209 if( g_hGapiLib ) 209 if( g_hGapiLib )
210 { 210 {
211 FreeLibrary(g_hGapiLib); 211 FreeLibrary(g_hGapiLib);
212 g_hGapiLib = 0; 212 g_hGapiLib = 0;
213 } 213 }
214 free(device->hidden); 214 SDL_free(device->hidden);
215 free(device); 215 SDL_free(device);
216 } 216 }
217 217
218 static SDL_VideoDevice *GAPI_CreateDevice(int devindex) 218 static SDL_VideoDevice *GAPI_CreateDevice(int devindex)
219 { 219 {
220 SDL_VideoDevice *device; 220 SDL_VideoDevice *device;
227 return 0; 227 return 0;
228 } 228 }
229 } 229 }
230 230
231 /* Initialize all variables that we clean on shutdown */ 231 /* Initialize all variables that we clean on shutdown */
232 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 232 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
233 if ( device ) { 233 if ( device ) {
234 memset(device, 0, (sizeof *device)); 234 SDL_memset(device, 0, (sizeof *device));
235 device->hidden = (struct SDL_PrivateVideoData *) 235 device->hidden = (struct SDL_PrivateVideoData *)
236 malloc((sizeof *device->hidden)); 236 SDL_malloc((sizeof *device->hidden));
237 } 237 }
238 if ( (device == NULL) || (device->hidden == NULL) ) { 238 if ( (device == NULL) || (device->hidden == NULL) ) {
239 SDL_OutOfMemory(); 239 SDL_OutOfMemory();
240 if ( device ) { 240 if ( device ) {
241 free(device); 241 SDL_free(device);
242 } 242 }
243 return(0); 243 return(0);
244 } 244 }
245 memset(device->hidden, 0, (sizeof *device->hidden)); 245 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
246 246
247 /* Set the function pointers */ 247 /* Set the function pointers */
248 device->VideoInit = GAPI_VideoInit; 248 device->VideoInit = GAPI_VideoInit;
249 device->ListModes = GAPI_ListModes; 249 device->ListModes = GAPI_ListModes;
250 device->SetVideoMode = GAPI_SetVideoMode; 250 device->SetVideoMode = GAPI_SetVideoMode;
659 SetWindowLong(SDL_Window, GWL_STYLE, style); 659 SetWindowLong(SDL_Window, GWL_STYLE, style);
660 660
661 /* Allocate bitmap */ 661 /* Allocate bitmap */
662 if(gapiBuffer) 662 if(gapiBuffer)
663 { 663 {
664 free(gapiBuffer); 664 SDL_free(gapiBuffer);
665 gapiBuffer = NULL; 665 gapiBuffer = NULL;
666 } 666 }
667 gapiBuffer = malloc(video->h * video->pitch); 667 gapiBuffer = SDL_malloc(video->h * video->pitch);
668 video->pixels = gapiBuffer; 668 video->pixels = gapiBuffer;
669 669
670 if ( ! this->hidden->buffer ) { 670 if ( ! this->hidden->buffer ) {
671 SDL_SetError("Couldn't allocate buffer for requested mode"); 671 SDL_SetError("Couldn't allocate buffer for requested mode");
672 return(NULL); 672 return(NULL);
673 } 673 }
674 674
675 memset(gapiBuffer, 255, video->h * video->pitch); 675 SDL_memset(gapiBuffer, 255, video->h * video->pitch);
676 MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE); 676 MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE);
677 ShowWindow(SDL_Window, SW_SHOW); 677 ShowWindow(SDL_Window, SW_SHOW);
678 SetForegroundWindow(SDL_Window); 678 SetForegroundWindow(SDL_Window);
679 679
680 #if REPORT_VIDEO_INFO 680 #if REPORT_VIDEO_INFO
736 736
737 static int updateLine8to8(_THIS, unsigned char *srcPointer, unsigned char *destPointer, int width, int height, int lines) 737 static int updateLine8to8(_THIS, unsigned char *srcPointer, unsigned char *destPointer, int width, int height, int lines)
738 { 738 {
739 if( gapi->dstPixelStep == 1) /* optimized blitting on most devices */ 739 if( gapi->dstPixelStep == 1) /* optimized blitting on most devices */
740 { 740 {
741 memcpy(destPointer, srcPointer, width); 741 SDL_memcpy(destPointer, srcPointer, width);
742 return 1; 742 return 1;
743 } else 743 } else
744 { 744 {
745 // TODO: read 4 pixels, write DWORD 745 // TODO: read 4 pixels, write DWORD
746 int step = gapi->dstPixelStep; 746 int step = gapi->dstPixelStep;
759 PIXEL *line1, *line2; 759 PIXEL *line1, *line2;
760 int step = gapi->dstPixelStep / 2; 760 int step = gapi->dstPixelStep / 2;
761 761
762 if( step == 1 ) /* optimized blitting on most devices */ 762 if( step == 1 ) /* optimized blitting on most devices */
763 { 763 {
764 memcpy(destPointer, srcPointer, width * sizeof(PIXEL)); 764 SDL_memcpy(destPointer, srcPointer, width * sizeof(PIXEL));
765 return 1; 765 return 1;
766 } 766 }
767 else 767 else
768 { 768 {
769 if( (gapi->gapiOrientation != SDL_ORIENTATION_UP) && 769 if( (gapi->gapiOrientation != SDL_ORIENTATION_UP) &&
1060 if ((g_hGapiLib != 0) && this && this->hidden && this->hidden->gxFunc.GXCloseDisplay && !this->hidden->useVga) 1060 if ((g_hGapiLib != 0) && this && this->hidden && this->hidden->gxFunc.GXCloseDisplay && !this->hidden->useVga)
1061 this->hidden->gxFunc.GXCloseDisplay(); 1061 this->hidden->gxFunc.GXCloseDisplay();
1062 1062
1063 if (this->screen->pixels != NULL) 1063 if (this->screen->pixels != NULL)
1064 { 1064 {
1065 free(this->screen->pixels); 1065 SDL_free(this->screen->pixels);
1066 this->screen->pixels = NULL; 1066 this->screen->pixels = NULL;
1067 } 1067 }
1068 if ( screen_icn ) { 1068 if ( screen_icn ) {
1069 DestroyIcon(screen_icn); 1069 DestroyIcon(screen_icn);
1070 screen_icn = NULL; 1070 screen_icn = NULL;
1087 1087
1088 /* Free video mode lists */ 1088 /* Free video mode lists */
1089 for ( i=0; i<NUM_MODELISTS; ++i ) { 1089 for ( i=0; i<NUM_MODELISTS; ++i ) {
1090 if ( gapi->SDL_modelist[i] != NULL ) { 1090 if ( gapi->SDL_modelist[i] != NULL ) {
1091 for ( j=0; gapi->SDL_modelist[i][j]; ++j ) 1091 for ( j=0; gapi->SDL_modelist[i][j]; ++j )
1092 free(gapi->SDL_modelist[i][j]); 1092 SDL_free(gapi->SDL_modelist[i][j]);
1093 free(gapi->SDL_modelist[i]); 1093 SDL_free(gapi->SDL_modelist[i]);
1094 gapi->SDL_modelist[i] = NULL; 1094 gapi->SDL_modelist[i] = NULL;
1095 } 1095 }
1096 } 1096 }
1097 1097
1098 } 1098 }