Return an error with color fills on less than 8 bpp surfaces.
authorSam Lantinga <slouken@libsdl.org>
Tue, 15 Oct 2002 05:22:50 +0000
changeset 532058d47b7a3b4
parent 531 8450e66651ea
child 533 263e4884f70d
Return an error with color fills on less than 8 bpp surfaces.
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_surface.c	Tue Oct 15 04:26:20 2002 +0000
     1.2 +++ b/src/video/SDL_surface.c	Tue Oct 15 05:22:50 2002 +0000
     1.3 @@ -524,6 +524,20 @@
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +static int SDL_FillRect1(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
     1.8 +{
     1.9 +	/* FIXME: We have to worry about packing order.. *sigh* */
    1.10 +	SDL_SetError("1-bpp rect fill not yet implemented");
    1.11 +	return -1;
    1.12 +}
    1.13 +
    1.14 +static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
    1.15 +{
    1.16 +	/* FIXME: We have to worry about packing order.. *sigh* */
    1.17 +	SDL_SetError("4-bpp rect fill not yet implemented");
    1.18 +	return -1;
    1.19 +}
    1.20 +
    1.21  /* 
    1.22   * This function performs a fast fill of the given rectangle with 'color'
    1.23   */
    1.24 @@ -534,6 +548,22 @@
    1.25  	int x, y;
    1.26  	Uint8 *row;
    1.27  
    1.28 +	/* This function doesn't work on surfaces < 8 bpp */
    1.29 +	if ( dst->format->BitsPerPixel < 8 ) {
    1.30 +		switch(dst->format->BitsPerPixel) {
    1.31 +		    case 1:
    1.32 +			return SDL_FillRect1(dst, dstrect, color);
    1.33 +			break;
    1.34 +		    case 4:
    1.35 +			return SDL_FillRect4(dst, dstrect, color);
    1.36 +			break;
    1.37 +		    default:
    1.38 +			SDL_SetError("Fill rect on unsupported surface format");
    1.39 +			return(-1);
    1.40 +			break;
    1.41 +		}
    1.42 +	}
    1.43 +
    1.44  	/* If 'dstrect' == NULL, then fill the whole surface */
    1.45  	if ( dstrect ) {
    1.46  		/* Perform clipping */