diff 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
line wrap: on
line diff
--- a/src/video/SDL_surface.c	Tue Dec 02 17:10:05 2008 +0000
+++ b/src/video/SDL_surface.c	Tue Dec 02 17:14:04 2008 +0000
@@ -336,6 +336,7 @@
     SDL_UnlockSurface(surface);
 
     SDL_SetColorKey(surface, 0, 0);
+    SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
 }
 
 int
@@ -808,7 +809,16 @@
     SDL_LowerBlit(surface, &bounds, convert, &bounds);
 
     /* Clean up the original surface, and update converted surface */
-    SDL_SetClipRect(convert, &surface->clip_rect);
+    convert->map->info.r = surface->map->info.r;
+    convert->map->info.g = surface->map->info.g;
+    convert->map->info.b = surface->map->info.b;
+    convert->map->info.a = surface->map->info.a;
+    convert->map->info.flags =
+        (copy_flags &
+         ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND
+           | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY |
+           SDL_COPY_RLE_ALPHAKEY));
+    surface->map->info.flags = copy_flags;
     if (copy_flags & SDL_COPY_COLORKEY) {
         Uint8 keyR, keyG, keyB, keyA;
 
@@ -816,21 +826,20 @@
                     &keyG, &keyB, &keyA);
         SDL_SetColorKey(convert, 1,
                         SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
+        /* This is needed when converting for 3D texture upload */
         SDL_ConvertColorkeyToAlpha(convert);
     }
-    convert->map->info.r = surface->map->info.r;
-    convert->map->info.g = surface->map->info.g;
-    convert->map->info.b = surface->map->info.b;
-    convert->map->info.a = surface->map->info.a;
-    convert->map->info.flags = copy_flags;
-    surface->map->info.flags = copy_flags;
+    SDL_SetClipRect(convert, &surface->clip_rect);
 
     /* Enable alpha blending by default if the new surface has an
      * alpha channel or alpha modulation */
-    if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
+    if ((surface->format->Amask && format->Amask) ||
+        (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
         SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
     }
-    SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL));
+    if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
+        SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
+    }
 
     /* We're ready to go! */
     return (convert);