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 |