summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2013-07-23 08:06:49 -0700
committerSam Lantinga <slouken@libsdl.org>2013-07-23 08:06:49 -0700
commit4862c1fc30a737198e7d5390dc52c3f3de5c9611 (patch)
tree18c2f872662696a3664be385643078d5d213b4d5 /include
parent03cc44af0339672f1e52d692571711cdf705aabd (diff)
Updated blend semantics so blending uses the following formula:
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstA = srcA + (dstA * (1-srcA)) This allows proper compositing semantics without requiring premultiplied alpha. Needs full unit test coverage and bug fixes!
Diffstat (limited to 'include')
-rw-r--r--include/SDL_blendmode.h15
-rw-r--r--include/SDL_surface.h30
2 files changed, 25 insertions, 20 deletions
diff --git a/include/SDL_blendmode.h b/include/SDL_blendmode.h
index 37c475aefd..85aa474595 100644
--- a/include/SDL_blendmode.h
+++ b/include/SDL_blendmode.h
@@ -39,10 +39,17 @@ extern "C" {
*/
typedef enum
{
- SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
- SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */
- SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */
- SDL_BLENDMODE_MOD = 0x00000004 /**< dst = src * dst */
+ SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
+ dstRGBA = srcRGBA */
+ SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
+ dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
+ dstA = srcA + (dstA * (1-srcA)) */
+ SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
+ dstRGB = (srcRGB * srcA) + dstRGB
+ dstA = dstA */
+ SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate
+ dstRGB = srcRGB * dstRGB
+ dstA = dstA */
} SDL_BlendMode;
/* Ends C function definitions when using C++ */
diff --git a/include/SDL_surface.h b/include/SDL_surface.h
index 76fcfde32c..fece797437 100644
--- a/include/SDL_surface.h
+++ b/include/SDL_surface.h
@@ -399,44 +399,42 @@ extern DECLSPEC int SDLCALL SDL_FillRects
*
* The blit function should not be called on a locked surface.
*
- * The blit semantics for surfaces with and without alpha and colorkey
+ * The blit semantics for surfaces with and without blending and colorkey
* are defined as follows:
* \verbatim
RGBA->RGB:
- SDL_SRCALPHA set:
- alpha-blend (using alpha-channel).
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
- SDL_SRCALPHA not set:
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB.
if SDL_SRCCOLORKEY set, only copy the pixels matching the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGBA:
- SDL_SRCALPHA set:
- alpha-blend (using the source per-surface alpha value);
- set destination alpha to opaque.
- SDL_SRCALPHA not set:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source per-surface alpha)
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB, set destination alpha to source per-surface alpha value.
both:
if SDL_SRCCOLORKEY set, only copy the pixels matching the
source color key.
RGBA->RGBA:
- SDL_SRCALPHA set:
- alpha-blend (using the source alpha channel) the RGB values;
- leave destination alpha untouched. [Note: is this correct?]
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
- SDL_SRCALPHA not set:
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
copy all of RGBA to the destination.
if SDL_SRCCOLORKEY set, only copy the pixels matching the
RGB values of the source color key, ignoring alpha in the
- comparison.
+ comparison.
RGB->RGB:
- SDL_SRCALPHA set:
- alpha-blend (using the source per-surface alpha value).
- SDL_SRCALPHA not set:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source per-surface alpha)
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB.
both:
if SDL_SRCCOLORKEY set, only copy the pixels matching the