Mercurial > sdl-ios-xcode
comparison src/video/SDL_surface.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 |
---|---|
75 } else { | 75 } else { |
76 flags &= ~SDL_HWSURFACE; | 76 flags &= ~SDL_HWSURFACE; |
77 } | 77 } |
78 | 78 |
79 /* Allocate the surface */ | 79 /* Allocate the surface */ |
80 surface = (SDL_Surface *)malloc(sizeof(*surface)); | 80 surface = (SDL_Surface *)SDL_malloc(sizeof(*surface)); |
81 if ( surface == NULL ) { | 81 if ( surface == NULL ) { |
82 SDL_OutOfMemory(); | 82 SDL_OutOfMemory(); |
83 return(NULL); | 83 return(NULL); |
84 } | 84 } |
85 surface->flags = SDL_SWSURFACE; | 85 surface->flags = SDL_SWSURFACE; |
101 Amask = screen->format->Amask; | 101 Amask = screen->format->Amask; |
102 } | 102 } |
103 } | 103 } |
104 surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); | 104 surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); |
105 if ( surface->format == NULL ) { | 105 if ( surface->format == NULL ) { |
106 free(surface); | 106 SDL_free(surface); |
107 return(NULL); | 107 return(NULL); |
108 } | 108 } |
109 if ( Amask ) { | 109 if ( Amask ) { |
110 surface->flags |= SDL_SRCALPHA; | 110 surface->flags |= SDL_SRCALPHA; |
111 } | 111 } |
123 | 123 |
124 /* Get the pixels */ | 124 /* Get the pixels */ |
125 if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) || | 125 if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) || |
126 (video->AllocHWSurface(this, surface) < 0) ) { | 126 (video->AllocHWSurface(this, surface) < 0) ) { |
127 if ( surface->w && surface->h ) { | 127 if ( surface->w && surface->h ) { |
128 surface->pixels = malloc(surface->h*surface->pitch); | 128 surface->pixels = SDL_malloc(surface->h*surface->pitch); |
129 if ( surface->pixels == NULL ) { | 129 if ( surface->pixels == NULL ) { |
130 SDL_FreeSurface(surface); | 130 SDL_FreeSurface(surface); |
131 SDL_OutOfMemory(); | 131 SDL_OutOfMemory(); |
132 return(NULL); | 132 return(NULL); |
133 } | 133 } |
134 /* This is important for bitmaps */ | 134 /* This is important for bitmaps */ |
135 memset(surface->pixels, 0, surface->h*surface->pitch); | 135 SDL_memset(surface->pixels, 0, surface->h*surface->pitch); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 /* Allocate an empty mapping */ | 139 /* Allocate an empty mapping */ |
140 surface->map = SDL_AllocBlitMap(); | 140 surface->map = SDL_AllocBlitMap(); |
613 row += dst->pitch; | 613 row += dst->pitch; |
614 } | 614 } |
615 } else { | 615 } else { |
616 #ifdef __powerpc__ | 616 #ifdef __powerpc__ |
617 /* | 617 /* |
618 * memset() on PPC (both glibc and codewarrior) uses | 618 * SDL_memset() on PPC (both glibc and codewarrior) uses |
619 * the dcbz (Data Cache Block Zero) instruction, which | 619 * the dcbz (Data Cache Block Zero) instruction, which |
620 * causes an alignment exception if the destination is | 620 * causes an alignment exception if the destination is |
621 * uncachable, so only use it on software surfaces | 621 * uncachable, so only use it on software surfaces |
622 */ | 622 */ |
623 if((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { | 623 if((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { |
625 /* | 625 /* |
626 * 64-bit stores are probably most | 626 * 64-bit stores are probably most |
627 * efficient to uncached video memory | 627 * efficient to uncached video memory |
628 */ | 628 */ |
629 double fill; | 629 double fill; |
630 memset(&fill, color, (sizeof fill)); | 630 SDL_memset(&fill, color, (sizeof fill)); |
631 for(y = dstrect->h; y; y--) { | 631 for(y = dstrect->h; y; y--) { |
632 Uint8 *d = row; | 632 Uint8 *d = row; |
633 unsigned n = x; | 633 unsigned n = x; |
634 unsigned nn; | 634 unsigned nn; |
635 Uint8 c = color; | 635 Uint8 c = color; |
677 } | 677 } |
678 } else | 678 } else |
679 #endif /* __powerpc__ */ | 679 #endif /* __powerpc__ */ |
680 { | 680 { |
681 for(y = dstrect->h; y; y--) { | 681 for(y = dstrect->h; y; y--) { |
682 memset(row, color, x); | 682 SDL_memset(row, color, x); |
683 row += dst->pitch; | 683 row += dst->pitch; |
684 } | 684 } |
685 } | 685 } |
686 } | 686 } |
687 } else { | 687 } else { |
709 color <<= 8; | 709 color <<= 8; |
710 #endif | 710 #endif |
711 for ( y=dstrect->h; y; --y ) { | 711 for ( y=dstrect->h; y; --y ) { |
712 Uint8 *pixels = row; | 712 Uint8 *pixels = row; |
713 for ( x=dstrect->w; x; --x ) { | 713 for ( x=dstrect->w; x; --x ) { |
714 memcpy(pixels, &color, 3); | 714 SDL_memcpy(pixels, &color, 3); |
715 pixels += 3; | 715 pixels += 3; |
716 } | 716 } |
717 row += dst->pitch; | 717 row += dst->pitch; |
718 } | 718 } |
719 break; | 719 break; |
830 return(NULL); | 830 return(NULL); |
831 } | 831 } |
832 | 832 |
833 /* Copy the palette if any */ | 833 /* Copy the palette if any */ |
834 if ( format->palette && convert->format->palette ) { | 834 if ( format->palette && convert->format->palette ) { |
835 memcpy(convert->format->palette->colors, | 835 SDL_memcpy(convert->format->palette->colors, |
836 format->palette->colors, | 836 format->palette->colors, |
837 format->palette->ncolors*sizeof(SDL_Color)); | 837 format->palette->ncolors*sizeof(SDL_Color)); |
838 convert->format->palette->ncolors = format->palette->ncolors; | 838 convert->format->palette->ncolors = format->palette->ncolors; |
839 } | 839 } |
840 | 840 |
932 SDL_VideoDevice *this = current_video; | 932 SDL_VideoDevice *this = current_video; |
933 video->FreeHWSurface(this, surface); | 933 video->FreeHWSurface(this, surface); |
934 } | 934 } |
935 if ( surface->pixels && | 935 if ( surface->pixels && |
936 ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) { | 936 ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) { |
937 free(surface->pixels); | 937 SDL_free(surface->pixels); |
938 } | 938 } |
939 free(surface); | 939 SDL_free(surface); |
940 #ifdef CHECK_LEAKS | 940 #ifdef CHECK_LEAKS |
941 --surfaces_allocated; | 941 --surfaces_allocated; |
942 #endif | 942 #endif |
943 } | 943 } |