comparison src/video/SDL_surface.c @ 532:058d47b7a3b4

Return an error with color fills on less than 8 bpp surfaces.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 15 Oct 2002 05:22:50 +0000
parents 4314a501d7be
children b8d311d90021
comparison
equal deleted inserted replaced
531:8450e66651ea 532:058d47b7a3b4
522 } 522 }
523 dstrect->w = dstrect->h = 0; 523 dstrect->w = dstrect->h = 0;
524 return 0; 524 return 0;
525 } 525 }
526 526
527 static int SDL_FillRect1(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
528 {
529 /* FIXME: We have to worry about packing order.. *sigh* */
530 SDL_SetError("1-bpp rect fill not yet implemented");
531 return -1;
532 }
533
534 static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
535 {
536 /* FIXME: We have to worry about packing order.. *sigh* */
537 SDL_SetError("4-bpp rect fill not yet implemented");
538 return -1;
539 }
540
527 /* 541 /*
528 * This function performs a fast fill of the given rectangle with 'color' 542 * This function performs a fast fill of the given rectangle with 'color'
529 */ 543 */
530 int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) 544 int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
531 { 545 {
532 SDL_VideoDevice *video = current_video; 546 SDL_VideoDevice *video = current_video;
533 SDL_VideoDevice *this = current_video; 547 SDL_VideoDevice *this = current_video;
534 int x, y; 548 int x, y;
535 Uint8 *row; 549 Uint8 *row;
550
551 /* This function doesn't work on surfaces < 8 bpp */
552 if ( dst->format->BitsPerPixel < 8 ) {
553 switch(dst->format->BitsPerPixel) {
554 case 1:
555 return SDL_FillRect1(dst, dstrect, color);
556 break;
557 case 4:
558 return SDL_FillRect4(dst, dstrect, color);
559 break;
560 default:
561 SDL_SetError("Fill rect on unsupported surface format");
562 return(-1);
563 break;
564 }
565 }
536 566
537 /* If 'dstrect' == NULL, then fill the whole surface */ 567 /* If 'dstrect' == NULL, then fill the whole surface */
538 if ( dstrect ) { 568 if ( dstrect ) {
539 /* Perform clipping */ 569 /* Perform clipping */
540 if ( !SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) ) { 570 if ( !SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) ) {