src/video/SDL_surface.c
changeset 2824 4dba7aa7ea77
parent 2807 365fe1a2aad5
child 2853 6258fa7cd300
     1.1 --- a/src/video/SDL_surface.c	Tue Dec 02 17:10:05 2008 +0000
     1.2 +++ b/src/video/SDL_surface.c	Tue Dec 02 17:14:04 2008 +0000
     1.3 @@ -336,6 +336,7 @@
     1.4      SDL_UnlockSurface(surface);
     1.5  
     1.6      SDL_SetColorKey(surface, 0, 0);
     1.7 +    SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
     1.8  }
     1.9  
    1.10  int
    1.11 @@ -808,7 +809,16 @@
    1.12      SDL_LowerBlit(surface, &bounds, convert, &bounds);
    1.13  
    1.14      /* Clean up the original surface, and update converted surface */
    1.15 -    SDL_SetClipRect(convert, &surface->clip_rect);
    1.16 +    convert->map->info.r = surface->map->info.r;
    1.17 +    convert->map->info.g = surface->map->info.g;
    1.18 +    convert->map->info.b = surface->map->info.b;
    1.19 +    convert->map->info.a = surface->map->info.a;
    1.20 +    convert->map->info.flags =
    1.21 +        (copy_flags &
    1.22 +         ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND
    1.23 +           | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY |
    1.24 +           SDL_COPY_RLE_ALPHAKEY));
    1.25 +    surface->map->info.flags = copy_flags;
    1.26      if (copy_flags & SDL_COPY_COLORKEY) {
    1.27          Uint8 keyR, keyG, keyB, keyA;
    1.28  
    1.29 @@ -816,21 +826,20 @@
    1.30                      &keyG, &keyB, &keyA);
    1.31          SDL_SetColorKey(convert, 1,
    1.32                          SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
    1.33 +        /* This is needed when converting for 3D texture upload */
    1.34          SDL_ConvertColorkeyToAlpha(convert);
    1.35      }
    1.36 -    convert->map->info.r = surface->map->info.r;
    1.37 -    convert->map->info.g = surface->map->info.g;
    1.38 -    convert->map->info.b = surface->map->info.b;
    1.39 -    convert->map->info.a = surface->map->info.a;
    1.40 -    convert->map->info.flags = copy_flags;
    1.41 -    surface->map->info.flags = copy_flags;
    1.42 +    SDL_SetClipRect(convert, &surface->clip_rect);
    1.43  
    1.44      /* Enable alpha blending by default if the new surface has an
    1.45       * alpha channel or alpha modulation */
    1.46 -    if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
    1.47 +    if ((surface->format->Amask && format->Amask) ||
    1.48 +        (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
    1.49          SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
    1.50      }
    1.51 -    SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL));
    1.52 +    if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
    1.53 +        SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
    1.54 +    }
    1.55  
    1.56      /* We're ready to go! */
    1.57      return (convert);