diff src/video/SDL_surface.c @ 2257:340942cfda48

Moved the colorkey and per-surface alpha into the blit info, in preparation for support for general color channel modulation. Removed and consolidated some data in the blit info.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 00:54:53 +0000
parents 6d99edd791bf
children 202ddfd1cfb1
line wrap: on
line diff
--- a/src/video/SDL_surface.c	Thu Aug 16 22:56:18 2007 +0000
+++ b/src/video/SDL_surface.c	Fri Aug 17 00:54:53 2007 +0000
@@ -231,7 +231,7 @@
 
     /* Optimize away operations that don't change anything */
     if ((flag == (surface->flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK))) &&
-        (key == surface->format->colorkey)) {
+        (key == surface->map->ckey)) {
         return (0);
     }
 
@@ -242,7 +242,7 @@
 
     if (flag) {
         surface->flags |= SDL_SRCCOLORKEY;
-        surface->format->colorkey = key;
+        surface->map->ckey = key;
         if (flag & SDL_RLEACCELOK) {
             surface->flags |= SDL_RLEACCELOK;
         } else {
@@ -250,7 +250,7 @@
         }
     } else {
         surface->flags &= ~(SDL_SRCCOLORKEY | SDL_RLEACCELOK);
-        surface->format->colorkey = 0;
+        surface->map->ckey = 0;
     }
     SDL_InvalidateMap(surface->map);
     return (0);
@@ -261,7 +261,7 @@
 SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
 {
     Uint32 oldflags = surface->flags;
-    Uint32 oldalpha = surface->format->alpha;
+    Uint32 oldalpha = (surface->map->cmod >> 24);
 
     /* Sanity check the flag as it gets passed in */
     if (flag & SDL_SRCALPHA) {
@@ -285,7 +285,8 @@
 
     if (flag) {
         surface->flags |= SDL_SRCALPHA;
-        surface->format->alpha = value;
+        surface->map->cmod &= 0x00FFFFFF;
+        surface->map->cmod |= ((Uint32)value << 24);
         if (flag & SDL_RLEACCELOK) {
             surface->flags |= SDL_RLEACCELOK;
         } else {
@@ -293,7 +294,7 @@
         }
     } else {
         surface->flags &= ~SDL_SRCALPHA;
-        surface->format->alpha = SDL_ALPHA_OPAQUE;
+        surface->map->cmod |= 0xFF000000;
     }
     /*
      * The representation for software surfaces is independent of
@@ -412,7 +413,7 @@
             return (-1);
         }
     }
-    return (src->map->sw_blit(src, srcrect, dst, dstrect));
+    return (src->map->blit(src, srcrect, dst, dstrect));
 }
 
 
@@ -601,7 +602,7 @@
         if ((flags & SDL_SRCCOLORKEY) != SDL_SRCCOLORKEY && format->Amask) {
             surface_flags &= ~SDL_SRCCOLORKEY;
         } else {
-            colorkey = surface->format->colorkey;
+            colorkey = surface->map->ckey;
             SDL_SetColorKey(surface, 0, 0);
         }
     }
@@ -610,7 +611,7 @@
         if (format->Amask) {
             surface->flags &= ~SDL_SRCALPHA;
         } else {
-            alpha = surface->format->alpha;
+            alpha = (Uint8)(surface->map->cmod >> 24);
             SDL_SetAlpha(surface, 0, 0);
         }
     }