comparison src/video/SDL_surface.c @ 2824:4dba7aa7ea77

Added slow but complete blit fallback Don't try to RLE encode surfaces that have alpha channel and alpha modulation Don't turn on blending when converting an RGB surface to RGBA format Do turn on blending when converting colorkey to alpha channel
author Sam Lantinga <slouken@libsdl.org>
date Tue, 02 Dec 2008 17:14:04 +0000
parents 365fe1a2aad5
children 6258fa7cd300
comparison
equal deleted inserted replaced
2823:15e1dd1fff78 2824:4dba7aa7ea77
334 } 334 }
335 335
336 SDL_UnlockSurface(surface); 336 SDL_UnlockSurface(surface);
337 337
338 SDL_SetColorKey(surface, 0, 0); 338 SDL_SetColorKey(surface, 0, 0);
339 SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
339 } 340 }
340 341
341 int 342 int
342 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) 343 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
343 { 344 {
806 bounds.w = surface->w; 807 bounds.w = surface->w;
807 bounds.h = surface->h; 808 bounds.h = surface->h;
808 SDL_LowerBlit(surface, &bounds, convert, &bounds); 809 SDL_LowerBlit(surface, &bounds, convert, &bounds);
809 810
810 /* Clean up the original surface, and update converted surface */ 811 /* Clean up the original surface, and update converted surface */
811 SDL_SetClipRect(convert, &surface->clip_rect); 812 convert->map->info.r = surface->map->info.r;
813 convert->map->info.g = surface->map->info.g;
814 convert->map->info.b = surface->map->info.b;
815 convert->map->info.a = surface->map->info.a;
816 convert->map->info.flags =
817 (copy_flags &
818 ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND
819 | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY |
820 SDL_COPY_RLE_ALPHAKEY));
821 surface->map->info.flags = copy_flags;
812 if (copy_flags & SDL_COPY_COLORKEY) { 822 if (copy_flags & SDL_COPY_COLORKEY) {
813 Uint8 keyR, keyG, keyB, keyA; 823 Uint8 keyR, keyG, keyB, keyA;
814 824
815 SDL_GetRGBA(surface->map->info.colorkey, surface->format, &keyR, 825 SDL_GetRGBA(surface->map->info.colorkey, surface->format, &keyR,
816 &keyG, &keyB, &keyA); 826 &keyG, &keyB, &keyA);
817 SDL_SetColorKey(convert, 1, 827 SDL_SetColorKey(convert, 1,
818 SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA)); 828 SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
829 /* This is needed when converting for 3D texture upload */
819 SDL_ConvertColorkeyToAlpha(convert); 830 SDL_ConvertColorkeyToAlpha(convert);
820 } 831 }
821 convert->map->info.r = surface->map->info.r; 832 SDL_SetClipRect(convert, &surface->clip_rect);
822 convert->map->info.g = surface->map->info.g;
823 convert->map->info.b = surface->map->info.b;
824 convert->map->info.a = surface->map->info.a;
825 convert->map->info.flags = copy_flags;
826 surface->map->info.flags = copy_flags;
827 833
828 /* Enable alpha blending by default if the new surface has an 834 /* Enable alpha blending by default if the new surface has an
829 * alpha channel or alpha modulation */ 835 * alpha channel or alpha modulation */
830 if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) { 836 if ((surface->format->Amask && format->Amask) ||
837 (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
831 SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND); 838 SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
832 } 839 }
833 SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL)); 840 if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
841 SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
842 }
834 843
835 /* We're ready to go! */ 844 /* We're ready to go! */
836 return (convert); 845 return (convert);
837 } 846 }
838 847