Fixed a bug in X11 shaping that refused to use color-key mode.
authorEli Gottlieb <eligottlieb@gmail.com>
Tue, 10 Aug 2010 16:10:26 -0400
changeset 48464f1573996a65
parent 4845 61cb2d20a46f
child 4847 4201864f77e7
child 4848 40b46225e3cf
Fixed a bug in X11 shaping that refused to use color-key mode.
include/SDL_shape.h
src/video/SDL_shape.c
src/video/x11/SDL_x11shape.c
     1.1 --- a/include/SDL_shape.h	Tue Aug 10 15:45:59 2010 -0400
     1.2 +++ b/include/SDL_shape.h	Tue Aug 10 16:10:26 2010 -0400
     1.3 @@ -89,6 +89,9 @@
     1.4  	/** \brief A color key is applied. */
     1.5  	ShapeModeColorKey
     1.6  } WindowShapeMode;
     1.7 +
     1.8 +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
     1.9 +
    1.10  /** \brief A union containing parameters for shaped windows. */
    1.11  typedef union {
    1.12  	/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
     2.1 --- a/src/video/SDL_shape.c	Tue Aug 10 15:45:59 2010 -0400
     2.2 +++ b/src/video/SDL_shape.c	Tue Aug 10 16:10:26 2010 -0400
     2.3 @@ -104,7 +104,7 @@
     2.4                      break;
     2.5                  case(ShapeModeColorKey):
     2.6                      key = mode.parameters.colorKey;
     2.7 -                    mask_value = ((key.r != r && key.g != g && key.b != b) ? 1 : 0);
     2.8 +                    mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0);
     2.9                      break;
    2.10              }
    2.11              bitmap[bitmap_pixel / ppb] |= mask_value << (7 - ((ppb - 1) - (bitmap_pixel % ppb)));
    2.12 @@ -237,7 +237,6 @@
    2.13      
    2.14      if(shapeMode != NULL)
    2.15          window->shaper->mode = *shapeMode;
    2.16 -    //TODO: Platform-specific implementations of SetWindowShape.  X11 is finished.  Win32 is finished.  Debugging is in progress on both.
    2.17      result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode);
    2.18      window->shaper->hasshape = SDL_TRUE;
    2.19      if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) {
     3.1 --- a/src/video/x11/SDL_x11shape.c	Tue Aug 10 15:45:59 2010 -0400
     3.2 +++ b/src/video/x11/SDL_x11shape.c	Tue Aug 10 16:10:26 2010 -0400
     3.3 @@ -81,12 +81,12 @@
     3.4  }
     3.5      
     3.6  int
     3.7 -X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
     3.8 +X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
     3.9      if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
    3.10          return -1;
    3.11  
    3.12  #if SDL_VIDEO_DRIVER_X11_XSHAPE
    3.13 -    if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)))
    3.14 +    if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode))
    3.15          return -2;
    3.16      if(shape->w != shaper->window->w || shape->h != shaper->window->h)
    3.17          return -3;