Replaced the model of treating a window's shape as a render target with treating a window's shape as a surface passed into an SDL_SetWindowShape() function. I'll send this off to Andreas and Sam and start coding.
authorEli Gottlieb <eligottlieb@gmail.com>
Sat, 19 Jun 2010 23:10:57 -0400
changeset 47804f915a47b995
parent 4779 bb179250fcb3
child 4781 fc4c775b468a
Replaced the model of treating a window's shape as a render target with treating a window's shape as a surface passed into an SDL_SetWindowShape() function. I'll send this off to Andreas and Sam and start coding.
include/SDL_shape.h
src/video/SDL_shape.c
     1.1 --- a/include/SDL_shape.h	Thu Jun 10 17:50:38 2010 -0400
     1.2 +++ b/include/SDL_shape.h	Sat Jun 19 23:10:57 2010 -0400
     1.3 @@ -74,26 +74,6 @@
     1.4   */
     1.5  extern DECLSPEC SDL_bool SDLCALL SDL_WindowIsShaped(const SDL_Window *window);
     1.6  
     1.7 -/**
     1.8 - * \brief Select the shape of a given window as a rendering target.
     1.9 - *
    1.10 - * \param window The window whose shape should become the current rendering target.
    1.11 - *
    1.12 - * \return 0 on success, -1 if something other than a valid shaped window is passed into \c window.
    1.13 - *
    1.14 - * The shape of the window given in \c window is selected as the new render target, and in the default mode (see
    1.15 - * SDL_WindowShapeParams) the alpha channel of that render target determines which pixels of the window are part of its
    1.16 - * visible shape and which are not according to a cutoff value.  All normal SDL rendering functions can be used on it,
    1.17 - * and its own specific parameters can be examined and set with SDL_GetShapeParameters() and SDL_SetShapeParameters().
    1.18 - * The final shape will be computed and the actual appearance of the window changed only upon a call to
    1.19 - * SDL_RenderPresent().
    1.20 - *
    1.21 - * \sa SDL_GetShapeParameters
    1.22 - * \sa SDL_SetShapeParameters
    1.23 - * \sa SDL_RenderPresent
    1.24 - */
    1.25 -extern DECLSPEC int SDLCALL SDL_SelectShapeRenderer(const SDL_Window *window);
    1.26 -
    1.27  /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
    1.28  typedef enum {ShapeModeDefault, ShapeModeBinarizeAlpha} WindowShapeMode;
    1.29  /** \brief A union containing parameters for shaped windows. */
    1.30 @@ -111,18 +91,19 @@
    1.31  } SDL_WindowShapeMode;
    1.32  
    1.33  /**
    1.34 - * \brief Set the shape parameters of a shaped window.
    1.35 + * \brief Set the shape and parameters of a shaped window.
    1.36   *
    1.37   * \param window The shaped window whose parameters should be set.
    1.38 - * \param shapeMode The parameters to set for the shaped window.
    1.39 + * \param shape A surface encoding the desired shape for the window as a bitmap mask.
    1.40 + * \param parameters The parameters to set for the shaped window.
    1.41   *
    1.42 - * \return 0 on success, -1 on invalid parameters in the shapeMode argument, or -2 if the SDL_Window given is not a
    1.43 - *         shaped window.
    1.44 + * \return 0 on success, -1 on invalid an invalid shape argument, or -2 if the SDL_Window* given does not reference
    1.45 + *         a valid shaped window.
    1.46   *
    1.47   * \sa SDL_WindowShapeMode
    1.48 - * \sa SDL_GetShapeParameters
    1.49 + * \sa SDL_GetShapeParameters.
    1.50   */
    1.51 -extern DECLSPEC int SDLCALL SDL_SetShapeParameters(SDL_Window *window,SDL_WindowShapeMode shapeMode);
    1.52 +extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode parameters);
    1.53  
    1.54  /**
    1.55   * \brief Set the shape parameters of a shaped window.
     2.1 --- a/src/video/SDL_shape.c	Thu Jun 10 17:50:38 2010 -0400
     2.2 +++ b/src/video/SDL_shape.c	Sat Jun 19 23:10:57 2010 -0400
     2.3 @@ -34,13 +34,11 @@
     2.4  	return SDL_FALSE;
     2.5  }
     2.6  
     2.7 -int SDL_SelectShapeRenderer(const SDL_Window *window) {
     2.8 -	return -1;
     2.9 -}
    2.10 -
    2.11 -int SDL_SetShapeParameters(SDL_Window *window,SDL_WindowShapeMode shapeMode) {
    2.12 +int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode parameters) {
    2.13  	if(window == NULL || !SDL_WindowIsShaped(window))
    2.14  		return -2;
    2.15 +	if(shape == NULL)
    2.16 +		return -1;
    2.17  	return -3;
    2.18  }
    2.19