Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Use the enumerated type for blend and scale mode instead of int
Renamed SDL_TextureScaleMode to SDL_ScaleMode
  • Loading branch information
slouken committed Dec 12, 2010
1 parent 2dab4e6 commit de6d1b5
Show file tree
Hide file tree
Showing 28 changed files with 355 additions and 282 deletions.
47 changes: 46 additions & 1 deletion Makefile.in
Expand Up @@ -44,7 +44,52 @@ EMBEDSPU = @EMBEDSPU@

DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-Win32.zip WhatsNew Xcode Xcode-iPhoneOS

HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_clipboard.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_gesture.h SDL_haptic.h SDL_input.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_touch.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
HDRS = \
SDL.h \
SDL_assert.h \
SDL_atomic.h \
SDL_audio.h \
SDL_blendmode.h \
SDL_clipboard.h \
SDL_compat.h \
SDL_cpuinfo.h \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
SDL_gesture.h \
SDL_haptic.h \
SDL_input.h \
SDL_joystick.h \
SDL_keyboard.h \
SDL_keysym.h \
SDL_loadso.h \
SDL_main.h \
SDL_mouse.h \
SDL_mutex.h \
SDL_name.h \
SDL_opengl.h \
SDL_opengles.h \
SDL_pixels.h \
SDL_platform.h \
SDL_power.h \
SDL_quit.h \
SDL_rect.h \
SDL_revision.h \
SDL_rwops.h \
SDL_scalemode.h \
SDL_scancode.h \
SDL_shape.h \
SDL_stdinc.h \
SDL_surface.h \
SDL_syswm.h \
SDL_thread.h \
SDL_timer.h \
SDL_touch.h \
SDL_types.h \
SDL_version.h \
SDL_video.h \
begin_code.h \
close_code.h

LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
Expand Down
64 changes: 64 additions & 0 deletions include/SDL_blendmode.h
@@ -0,0 +1,64 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/

/**
* \file SDL_blendmode.h
*
* Header file declaring the SDL_BlendMode enumeration
*/

#ifndef _SDL_blendmode_h
#define _SDL_blendmode_h

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif

/**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
*/
typedef enum
{
SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
SDL_BLENDMODE_MASK = 0x00000001, /**< dst = A ? src : dst
(alpha is mask) */

SDL_BLENDMODE_BLEND = 0x00000002, /**< dst = (src * A) + (dst * (1-A)) */
SDL_BLENDMODE_ADD = 0x00000004, /**< dst = (src * A) + dst */
SDL_BLENDMODE_MOD = 0x00000008 /**< dst = src * dst */
} SDL_BlendMode;

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"

#endif /* _SDL_video_h */

/* vi: set ts=4 sw=4 expandtab: */
8 changes: 8 additions & 0 deletions include/SDL_compat.h
Expand Up @@ -202,6 +202,14 @@ typedef enum
SDL_GRAB_ON = 1
} SDL_GrabMode;

typedef enum
{
SDL_TEXTURESCALEMODE_NONE = SDL_SCALEMODE_NONE,
SDL_TEXTURESCALEMODE_FAST = SDL_SCALEMODE_FAST,
SDL_TEXTURESCALEMODE_SLOW = SDL_SCALEMODE_SLOW,
SDL_TEXTURESCALEMODE_BEST = SDL_SCALEMODE_BEST
} SDL_TextureScaleMode;

struct SDL_SysWMinfo;

/**
Expand Down
69 changes: 69 additions & 0 deletions include/SDL_scalemode.h
@@ -0,0 +1,69 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/

/**
* \file SDL_scalemode.h
*
* Header file declaring the SDL_ScaleMode enumeration
*/

#ifndef _SDL_scalemode_h
#define _SDL_scalemode_h

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif

/**
* \brief The texture scale mode used in SDL_RenderCopy().
*/
typedef enum
{
SDL_SCALEMODE_NONE = 0x00000000, /**< No scaling, rectangles must
match dimensions */

SDL_SCALEMODE_FAST = 0x00000001, /**< Point sampling or
equivalent algorithm */

SDL_SCALEMODE_SLOW = 0x00000002, /**< Linear filtering or
equivalent algorithm */

SDL_SCALEMODE_BEST = 0x00000004 /**< Bicubic filtering or
equivalent algorithm */
} SDL_ScaleMode;


/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"

#endif /* _SDL_video_h */

/* vi: set ts=4 sw=4 expandtab: */
112 changes: 16 additions & 96 deletions include/SDL_surface.h
Expand Up @@ -32,6 +32,8 @@
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_scalemode.h"
#include "SDL_rwops.h"

#include "begin_code.h"
Expand Down Expand Up @@ -88,7 +90,7 @@ typedef struct SDL_Surface
struct SDL_BlitMap *map; /**< Private */

/** format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /**< Private */
int format_version; /**< Private */

/** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */
Expand Down Expand Up @@ -300,7 +302,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
* \sa SDL_GetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
int blendMode);
SDL_BlendMode blendMode);

/**
* \brief Get the blend mode used for blit operations.
Expand All @@ -313,13 +315,13 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
* \sa SDL_SetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
int *blendMode);
SDL_BlendMode *blendMode);

/**
* \brief Set the scale mode used for blit operations.
*
* \param surface The surface to update.
* \param scaleMode ::SDL_TextureScaleMode to use for blit scaling.
* \param scaleMode ::SDL_ScaleMode to use for blit scaling.
*
* \return 0 on success, or -1 if the surface is not valid or the scale mode is
* not supported.
Expand All @@ -331,7 +333,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
* \sa SDL_GetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
int scaleMode);
SDL_ScaleMode scaleMode);

/**
* \brief Get the scale mode used for blit operations.
Expand All @@ -344,7 +346,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
* \sa SDL_SetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
int *scaleMode);
SDL_ScaleMode *scaleMode);

/**
* Sets the clipping rectangle for the destination surface in a blit.
Expand Down Expand Up @@ -413,10 +415,10 @@ extern DECLSPEC int SDLCALL SDL_DrawPoints
*/
extern DECLSPEC int SDLCALL SDL_BlendPoint
(SDL_Surface * dst, int x, int y,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendPoints
(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Draws a line with \c color.
Expand All @@ -438,10 +440,10 @@ extern DECLSPEC int SDLCALL SDL_DrawLines
*/
extern DECLSPEC int SDLCALL SDL_BlendLine
(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendLines
(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Draws the given rectangle with \c color.
Expand All @@ -467,10 +469,10 @@ extern DECLSPEC int SDLCALL SDL_DrawRects
*/
extern DECLSPEC int SDLCALL SDL_BlendRect
(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Performs a fast fill of the given rectangle with \c color.
Expand All @@ -496,92 +498,10 @@ extern DECLSPEC int SDLCALL SDL_FillRects
*/
extern DECLSPEC int SDLCALL SDL_BlendFillRect
(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendFillRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

#if 0
/**
* Draws the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);

/**
* Blends an RGBA value into the outline of the given circle.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Fills the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);

/**
* Blends an RGBA value into the given circle.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Draws the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);

/**
* Blends an RGBA value into the outline of the given ellipse.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Fills the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);

/**
* Blends an RGBA value into the given ellipse.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
#endif // 0
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Performs a fast blit from the source surface to the destination surface.
Expand Down

0 comments on commit de6d1b5

Please sign in to comment.