diff src/render/software/SDL_draw.h @ 5187:d976b67150c5

Restored SDL_BLENDMODE_MOD for MAME
author Sam Lantinga <slouken@libsdl.org>
date Fri, 04 Feb 2011 19:50:56 -0800
parents d72793305335
children b530ef003506
line wrap: on
line diff
--- a/src/render/software/SDL_draw.h	Fri Feb 04 19:18:08 2011 -0800
+++ b/src/render/software/SDL_draw.h	Fri Feb 04 19:50:56 2011 -0800
@@ -70,6 +70,16 @@
     setpixel; \
 } 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) \
 do { \
     type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
@@ -92,6 +102,10 @@
     DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*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) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
 
@@ -101,6 +115,9 @@
 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
     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
  */
@@ -116,6 +133,10 @@
     DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*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) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
 
@@ -125,6 +146,9 @@
 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
     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
  */
@@ -140,6 +164,10 @@
     DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*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) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
 
@@ -149,6 +177,9 @@
 #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
     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
  */
@@ -164,6 +195,10 @@
     DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*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) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
 
@@ -173,6 +208,9 @@
 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
     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
  */
@@ -188,6 +226,10 @@
     DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*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) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
 
@@ -206,6 +248,12 @@
 #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
     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
@@ -222,6 +270,10 @@
     DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*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) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
 
@@ -231,6 +283,9 @@
 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
     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
  */