Commit 8209e2a9 authored by Sam Lantinga's avatar Sam Lantinga

Restored SDL_BLENDMODE_MOD for MAME

parent 31f1dceb
...@@ -45,6 +45,7 @@ typedef enum ...@@ -45,6 +45,7 @@ typedef enum
SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */ SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */ SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */
SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */ SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */
SDL_BLENDMODE_MOD = 0x00000004 /**< dst = src * dst */
} SDL_BlendMode; } SDL_BlendMode;
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
......
...@@ -625,6 +625,14 @@ D3D_SetBlendMode(D3D_RenderData * data, int blendMode) ...@@ -625,6 +625,14 @@ D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
D3DBLEND_ONE); D3DBLEND_ONE);
break; break;
case SDL_BLENDMODE_MOD:
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
TRUE);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
D3DBLEND_ZERO);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
D3DBLEND_SRCCOLOR);
break;
} }
} }
......
...@@ -529,6 +529,11 @@ GL_SetBlendMode(GL_RenderData * data, int blendMode) ...@@ -529,6 +529,11 @@ GL_SetBlendMode(GL_RenderData * data, int blendMode)
data->glEnable(GL_BLEND); data->glEnable(GL_BLEND);
data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break; break;
case SDL_BLENDMODE_MOD:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
break;
} }
data->blendMode = blendMode; data->blendMode = blendMode;
} }
......
...@@ -495,6 +495,11 @@ GLES_SetBlendMode(GLES_RenderData * data, int blendMode) ...@@ -495,6 +495,11 @@ GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
data->glEnable(GL_BLEND); data->glEnable(GL_BLEND);
data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break; break;
case SDL_BLENDMODE_MOD:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
break;
} }
data->blendMode = blendMode; data->blendMode = blendMode;
} }
......
...@@ -38,6 +38,9 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -38,6 +38,9 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555); FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
break;
default: default:
FILLRECT(Uint16, DRAW_SETPIXEL_RGB555); FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
break; break;
...@@ -58,6 +61,9 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -58,6 +61,9 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565); FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
break;
default: default:
FILLRECT(Uint16, DRAW_SETPIXEL_RGB565); FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
break; break;
...@@ -78,6 +84,9 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -78,6 +84,9 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888); FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
break;
default: default:
FILLRECT(Uint32, DRAW_SETPIXEL_RGB888); FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
break; break;
...@@ -98,6 +107,9 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -98,6 +107,9 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888); FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
break;
default: default:
FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888); FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
break; break;
...@@ -121,6 +133,9 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -121,6 +133,9 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB); FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
break;
default: default:
FILLRECT(Uint16, DRAW_SETPIXEL_RGB); FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
break; break;
...@@ -134,6 +149,9 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -134,6 +149,9 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB); FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
break;
default: default:
FILLRECT(Uint32, DRAW_SETPIXEL_RGB); FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
break; break;
...@@ -161,6 +179,9 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, ...@@ -161,6 +179,9 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA); FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
break; break;
case SDL_BLENDMODE_MOD:
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
break;
default: default:
FILLRECT(Uint32, DRAW_SETPIXEL_RGBA); FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
break; break;
......
This diff is collapsed.
...@@ -38,6 +38,9 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, ...@@ -38,6 +38,9 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY_ADD_RGB555(x, y); DRAW_SETPIXELXY_ADD_RGB555(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY_MOD_RGB555(x, y);
break;
default: default:
DRAW_SETPIXELXY_RGB555(x, y); DRAW_SETPIXELXY_RGB555(x, y);
break; break;
...@@ -58,6 +61,9 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, ...@@ -58,6 +61,9 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY_ADD_RGB565(x, y); DRAW_SETPIXELXY_ADD_RGB565(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY_MOD_RGB565(x, y);
break;
default: default:
DRAW_SETPIXELXY_RGB565(x, y); DRAW_SETPIXELXY_RGB565(x, y);
break; break;
...@@ -78,6 +84,9 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, ...@@ -78,6 +84,9 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY_ADD_RGB888(x, y); DRAW_SETPIXELXY_ADD_RGB888(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY_MOD_RGB888(x, y);
break;
default: default:
DRAW_SETPIXELXY_RGB888(x, y); DRAW_SETPIXELXY_RGB888(x, y);
break; break;
...@@ -98,6 +107,9 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode ...@@ -98,6 +107,9 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY_ADD_ARGB8888(x, y); DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
break;
default: default:
DRAW_SETPIXELXY_ARGB8888(x, y); DRAW_SETPIXELXY_ARGB8888(x, y);
break; break;
...@@ -121,6 +133,9 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin ...@@ -121,6 +133,9 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY2_ADD_RGB(x, y); DRAW_SETPIXELXY2_ADD_RGB(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY2_MOD_RGB(x, y);
break;
default: default:
DRAW_SETPIXELXY2_RGB(x, y); DRAW_SETPIXELXY2_RGB(x, y);
break; break;
...@@ -134,6 +149,9 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin ...@@ -134,6 +149,9 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY4_ADD_RGB(x, y); DRAW_SETPIXELXY4_ADD_RGB(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY4_MOD_RGB(x, y);
break;
default: default:
DRAW_SETPIXELXY4_RGB(x, y); DRAW_SETPIXELXY4_RGB(x, y);
break; break;
...@@ -161,6 +179,9 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui ...@@ -161,6 +179,9 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
DRAW_SETPIXELXY4_ADD_RGBA(x, y); DRAW_SETPIXELXY4_ADD_RGBA(x, y);
break; break;
case SDL_BLENDMODE_MOD:
DRAW_SETPIXELXY4_MOD_RGBA(x, y);
break;
default: default:
DRAW_SETPIXELXY4_RGBA(x, y); DRAW_SETPIXELXY4_RGBA(x, y);
break; break;
......
...@@ -70,6 +70,16 @@ do { \ ...@@ -70,6 +70,16 @@ do { \
setpixel; \ setpixel; \
} while (0) } while (0)
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
do { \
unsigned sr, sg, sb, sa; sa; \
getpixel; \
sr = DRAW_MUL(sr, r); \
sg = DRAW_MUL(sg, g); \
sb = DRAW_MUL(sb, b); \
setpixel; \
} while (0)
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \ #define DRAW_SETPIXELXY(x, y, type, bpp, op) \
do { \ do { \
type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
...@@ -92,6 +102,10 @@ do { \ ...@@ -92,6 +102,10 @@ do { \
DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
RGB555_FROM_RGB(*pixel, sr, sg, sb)) RGB555_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXEL_MOD_RGB555 \
DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
RGB555_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXELXY_RGB555(x, y) \ #define DRAW_SETPIXELXY_RGB555(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555) DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
...@@ -101,6 +115,9 @@ do { \ ...@@ -101,6 +115,9 @@ do { \
#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \ #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555) DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
/* /*
* Define draw operators for RGB565 * Define draw operators for RGB565
*/ */
...@@ -116,6 +133,10 @@ do { \ ...@@ -116,6 +133,10 @@ do { \
DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
RGB565_FROM_RGB(*pixel, sr, sg, sb)) RGB565_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXEL_MOD_RGB565 \
DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
RGB565_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXELXY_RGB565(x, y) \ #define DRAW_SETPIXELXY_RGB565(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565) DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
...@@ -125,6 +146,9 @@ do { \ ...@@ -125,6 +146,9 @@ do { \
#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \ #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565) DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
/* /*
* Define draw operators for RGB888 * Define draw operators for RGB888
*/ */
...@@ -140,6 +164,10 @@ do { \ ...@@ -140,6 +164,10 @@ do { \
DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
RGB888_FROM_RGB(*pixel, sr, sg, sb)) RGB888_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXEL_MOD_RGB888 \
DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
RGB888_FROM_RGB(*pixel, sr, sg, sb))
#define DRAW_SETPIXELXY_RGB888(x, y) \ #define DRAW_SETPIXELXY_RGB888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
...@@ -149,6 +177,9 @@ do { \ ...@@ -149,6 +177,9 @@ do { \
#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \ #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
/* /*
* Define draw operators for ARGB8888 * Define draw operators for ARGB8888
*/ */
...@@ -164,6 +195,10 @@ do { \ ...@@ -164,6 +195,10 @@ do { \
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
#define DRAW_SETPIXEL_MOD_ARGB8888 \
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
#define DRAW_SETPIXELXY_ARGB8888(x, y) \ #define DRAW_SETPIXELXY_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
...@@ -173,6 +208,9 @@ do { \ ...@@ -173,6 +208,9 @@ do { \
#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \ #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
/* /*
* Define draw operators for general RGB * Define draw operators for general RGB
*/ */
...@@ -188,6 +226,10 @@ do { \ ...@@ -188,6 +226,10 @@ do { \
DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
#define DRAW_SETPIXEL_MOD_RGB \
DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
#define DRAW_SETPIXELXY2_RGB(x, y) \ #define DRAW_SETPIXELXY2_RGB(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB) DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
...@@ -206,6 +248,12 @@ do { \ ...@@ -206,6 +248,12 @@ do { \
#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \ #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
/* /*
* Define draw operators for general RGBA * Define draw operators for general RGBA
...@@ -222,6 +270,10 @@ do { \ ...@@ -222,6 +270,10 @@ do { \
DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
#define DRAW_SETPIXEL_MOD_RGBA \
DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
#define DRAW_SETPIXELXY4_RGBA(x, y) \ #define DRAW_SETPIXELXY4_RGBA(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
...@@ -231,6 +283,9 @@ do { \ ...@@ -231,6 +283,9 @@ do { \
#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \ #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA) DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
/* /*
* Define line drawing macro * Define line drawing macro
*/ */
......
...@@ -1423,7 +1423,7 @@ SDL_RLESurface(SDL_Surface * surface) ...@@ -1423,7 +1423,7 @@ SDL_RLESurface(SDL_Surface * surface)
/* Pass on combinations not supported */ /* Pass on combinations not supported */
if ((flags & SDL_COPY_MODULATE_COLOR) || if ((flags & SDL_COPY_MODULATE_COLOR) ||
((flags & SDL_COPY_MODULATE_ALPHA) && surface->format->Amask) || ((flags & SDL_COPY_MODULATE_ALPHA) && surface->format->Amask) ||
(flags & SDL_COPY_ADD) || (flags & (SDL_COPY_ADD | SDL_COPY_MOD)) ||
(flags & SDL_COPY_NEAREST)) { (flags & SDL_COPY_NEAREST)) {
return -1; return -1;
} }
......
...@@ -181,7 +181,9 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, ...@@ -181,7 +181,9 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
} }
/* Check blend flags */ /* Check blend flags */
flagcheck = (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)); flagcheck =
(flags &
(SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
if ((flagcheck & entries[i].flags) != flagcheck) { if ((flagcheck & entries[i].flags) != flagcheck) {
continue; continue;
} }
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define SDL_COPY_MODULATE_ALPHA 0x00000002 #define SDL_COPY_MODULATE_ALPHA 0x00000002
#define SDL_COPY_BLEND 0x00000010 #define SDL_COPY_BLEND 0x00000010
#define SDL_COPY_ADD 0x00000020 #define SDL_COPY_ADD 0x00000020
#define SDL_COPY_MOD 0x00000040
#define SDL_COPY_COLORKEY 0x00000100 #define SDL_COPY_COLORKEY 0x00000100
#define SDL_COPY_NEAREST 0x00000200 #define SDL_COPY_NEAREST 0x00000200
#define SDL_COPY_RLE_DESIRED 0x00001000 #define SDL_COPY_RLE_DESIRED 0x00001000
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -117,7 +117,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info) ...@@ -117,7 +117,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
srcB = (srcB * srcA) / 255; srcB = (srcB * srcA) / 255;
} }
} }
switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) { switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
case 0: case 0:
dstR = srcR; dstR = srcR;
dstG = srcG; dstG = srcG;
...@@ -140,6 +140,11 @@ SDL_Blit_Slow(SDL_BlitInfo * info) ...@@ -140,6 +140,11 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
if (dstB > 255) if (dstB > 255)
dstB = 255; dstB = 255;
break; break;
case SDL_COPY_MOD:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
} }
if (dst_fmt->Amask) { if (dst_fmt->Amask) {
ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA); ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
......
...@@ -448,7 +448,8 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode) ...@@ -448,7 +448,8 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
status = 0; status = 0;
flags = surface->map->info.flags; flags = surface->map->info.flags;
surface->map->info.flags &= ~(SDL_COPY_BLEND | SDL_COPY_ADD); surface->map->info.flags &=
~(SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
switch (blendMode) { switch (blendMode) {
case SDL_BLENDMODE_NONE: case SDL_BLENDMODE_NONE:
break; break;
...@@ -458,6 +459,9 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode) ...@@ -458,6 +459,9 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_ADD:
surface->map->info.flags |= SDL_COPY_ADD; surface->map->info.flags |= SDL_COPY_ADD;
break; break;
case SDL_BLENDMODE_MOD:
surface->map->info.flags |= SDL_COPY_MOD;
break;
default: default:
SDL_Unsupported(); SDL_Unsupported();
status = -1; status = -1;
...@@ -489,13 +493,17 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) ...@@ -489,13 +493,17 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode)
return 0; return 0;
} }
switch (surface->map->info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) { switch (surface->map->
info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
case SDL_COPY_BLEND: case SDL_COPY_BLEND:
*blendMode = SDL_BLENDMODE_BLEND; *blendMode = SDL_BLENDMODE_BLEND;
break; break;
case SDL_COPY_ADD: case SDL_COPY_ADD:
*blendMode = SDL_BLENDMODE_ADD; *blendMode = SDL_BLENDMODE_ADD;
break; break;
case SDL_COPY_MOD:
*blendMode = SDL_BLENDMODE_MOD;
break;
default: default:
*blendMode = SDL_BLENDMODE_NONE; *blendMode = SDL_BLENDMODE_NONE;
break; break;
......
...@@ -237,7 +237,7 @@ __EOF__ ...@@ -237,7 +237,7 @@ __EOF__
${s}B = (${s}B * ${s}A) / 255; ${s}B = (${s}B * ${s}A) / 255;
} }
} }
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND: case SDL_COPY_BLEND:
${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255; ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255; ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
...@@ -248,6 +248,11 @@ __EOF__ ...@@ -248,6 +248,11 @@ __EOF__
${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255; ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255;
${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255; ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255;
break; break;
case SDL_COPY_MOD:
${d}R = (${s}R * ${d}R) / 255;
${d}G = (${s}G * ${d}G) / 255;
${d}B = (${s}B * ${d}B) / 255;
break;
} }
__EOF__ __EOF__
} }
...@@ -397,7 +402,7 @@ __EOF__ ...@@ -397,7 +402,7 @@ __EOF__
} }
} }
if ( $blend ) { if ( $blend ) {
$flag = "SDL_COPY_BLEND | SDL_COPY_ADD"; $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD";
if ( $flags eq "" ) { if ( $flags eq "" ) {
$flags = $flag; $flags = $flag;
} else { } else {
......
This diff is collapsed.
...@@ -188,6 +188,15 @@ static int render_hasBlendModes (void) ...@@ -188,6 +188,15 @@ static int render_hasBlendModes (void)
if (!render_isSupported(ret)) if (!render_isSupported(ret))
fail = 1; fail = 1;
ret = (mode != SDL_BLENDMODE_ADD); ret = (mode != SDL_BLENDMODE_ADD);
if (!render_isSupported(ret))
fail = 1;
ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
if (!render_isSupported(ret))
fail = 1;
ret = SDL_GetRenderDrawBlendMode( &mode );
if (!render_isSupported(ret))
fail = 1;
ret = (mode != SDL_BLENDMODE_MOD);
if (!render_isSupported(ret)) if (!render_isSupported(ret))
fail = 1; fail = 1;
ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE );
...@@ -829,6 +838,13 @@ static int render_testBlitBlend (void) ...@@ -829,6 +838,13 @@ static int render_testBlitBlend (void)
&img_blendAdd, ALLOWABLE_ERROR_BLENDED )) &img_blendAdd, ALLOWABLE_ERROR_BLENDED ))
return -1; return -1;
/* Test Mod. */
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
return -1;
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
&img_blendMod, ALLOWABLE_ERROR_BLENDED ))
return -1;
/* Clear surface. */ /* Clear surface. */
if (render_clearScreen()) if (render_clearScreen())
return -1; return -1;
...@@ -852,7 +868,7 @@ static int render_testBlitBlend (void) ...@@ -852,7 +868,7 @@ static int render_testBlitBlend (void)
if (mode==0) mode = SDL_BLENDMODE_NONE; if (mode==0) mode = SDL_BLENDMODE_NONE;
else if (mode==1) mode = SDL_BLENDMODE_BLEND; else if (mode==1) mode = SDL_BLENDMODE_BLEND;
else if (mode==2) mode = SDL_BLENDMODE_ADD; else if (mode==2) mode = SDL_BLENDMODE_ADD;
else if (mode==3) mode = SDL_BLENDMODE_NONE; else if (mode==3) mode = SDL_BLENDMODE_MOD;
ret = SDL_SetTextureBlendMode( tface, mode ); ret = SDL_SetTextureBlendMode( tface, mode );
if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0)) if (SDL_ATassert( "SDL_SetTextureBlendMode", ret == 0))
return -1; return -1;
......
...@@ -324,6 +324,13 @@ static void surface_testBlitBlend( SDL_Surface *testsur ) ...@@ -324,6 +324,13 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
surface_compare( testsur, &img_blendAdd, 0 )==0 )) surface_compare( testsur, &img_blendAdd, 0 )==0 ))
return; return;
/* Test Mod. */
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MOD).",
surface_compare( testsur, &img_blendMod, 0 )==0 ))
return;
/* Clear surface. */ /* Clear surface. */
ret = SDL_FillRect( testsur, NULL, ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) ); SDL_MapRGB( testsur->format, 0, 0, 0 ) );
...@@ -349,7 +356,7 @@ static void surface_testBlitBlend( SDL_Surface *testsur ) ...@@ -349,7 +356,7 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
if (mode==0) mode = SDL_BLENDMODE_NONE; if (mode==0) mode = SDL_BLENDMODE_NONE;
else if (mode==1) mode = SDL_BLENDMODE_BLEND; else if (mode==1) mode = SDL_BLENDMODE_BLEND;
else if (mode==2) mode = SDL_BLENDMODE_ADD; else if (mode==2) mode = SDL_BLENDMODE_ADD;
else if (mode==3) mode = SDL_BLENDMODE_NONE; else if (mode==3) mode = SDL_BLENDMODE_MOD;
ret = SDL_SetSurfaceBlendMode( face, mode ); ret = SDL_SetSurfaceBlendMode( face, mode );
if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
return; return;
......
...@@ -190,6 +190,9 @@ main(int argc, char *argv[]) ...@@ -190,6 +190,9 @@ main(int argc, char *argv[])
} else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
blendMode = SDL_BLENDMODE_ADD; blendMode = SDL_BLENDMODE_ADD;
consumed = 2; consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
blendMode = SDL_BLENDMODE_MOD;
consumed = 2;
} }
} }
} else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
...@@ -205,7 +208,7 @@ main(int argc, char *argv[]) ...@@ -205,7 +208,7 @@ main(int argc, char *argv[])
} }
if (consumed < 0) { if (consumed < 0) {
fprintf(stderr, fprintf(stderr,
"Usage: %s %s [--blend none|blend|add] [--cyclecolor] [--cyclealpha]\n", "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
argv[0], CommonUsage(state)); argv[0], CommonUsage(state));
return 1; return 1;
} }
......
...@@ -223,6 +223,9 @@ main(int argc, char *argv[]) ...@@ -223,6 +223,9 @@ main(int argc, char *argv[])
} else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
blendMode = SDL_BLENDMODE_ADD; blendMode = SDL_BLENDMODE_ADD;
consumed = 2; consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
blendMode = SDL_BLENDMODE_MOD;
consumed = 2;
} }
} }
} else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
...@@ -238,7 +241,7 @@ main(int argc, char *argv[]) ...@@ -238,7 +241,7 @@ main(int argc, char *argv[])
} }
if (consumed < 0) { if (consumed < 0) {
fprintf(stderr, fprintf(stderr,
"Usage: %s %s [--blend none|blend|add] [--cyclecolor] [--cyclealpha]\n", "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
argv[0], CommonUsage(state)); argv[0], CommonUsage(state));
return 1; return 1;
} }
......
...@@ -237,6 +237,9 @@ main(int argc, char *argv[]) ...@@ -237,6 +237,9 @@ main(int argc, char *argv[])
} else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
blendMode = SDL_BLENDMODE_ADD; blendMode = SDL_BLENDMODE_ADD;
consumed = 2; consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
blendMode = SDL_BLENDMODE_MOD;
consumed = 2;
} }
} }
} else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
...@@ -252,7 +255,7 @@ main(int argc, char *argv[]) ...@@ -252,7 +255,7 @@ main(int argc, char *argv[])
} }
if (consumed < 0) { if (consumed < 0) {
fprintf(stderr, fprintf(stderr,
"Usage: %s %s [--blend none|blend|add] [--cyclecolor] [--cyclealpha]\n", "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
argv[0], CommonUsage(state)); argv[0], CommonUsage(state));
quit(1); quit(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment