changeset 2900:3a9636c83849

Make it possible to switch algorithms in the future
author Sam Lantinga <slouken@libsdl.org>
date Sun, 21 Dec 2008 08:59:56 +0000
parents a0c837a16e4c
children 133601e3b255
files src/video/SDL_blendline.c src/video/SDL_blendrect.c src/video/SDL_draw.h src/video/SDL_drawline.c
diffstat 4 files changed, 61 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_blendline.c	Sun Dec 21 08:55:06 2008 +0000
+++ b/src/video/SDL_blendline.c	Sun Dec 21 08:59:56 2008 +0000
@@ -31,16 +31,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB555);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB555);
         break;
     case SDL_BLENDMODE_ADD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB555);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB555);
         break;
     case SDL_BLENDMODE_MOD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB555);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB555);
         break;
     default:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB555);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB555);
         break;
     }
     return 0;
@@ -54,16 +54,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB565);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB565);
         break;
     case SDL_BLENDMODE_ADD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB565);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB565);
         break;
     case SDL_BLENDMODE_MOD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB565);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB565);
         break;
     default:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB565);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB565);
         break;
     }
     return 0;
@@ -77,16 +77,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB888);
         break;
     case SDL_BLENDMODE_ADD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB888);
         break;
     case SDL_BLENDMODE_MOD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB888);
         break;
     default:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB888);
         break;
     }
     return 0;
@@ -100,16 +100,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
         break;
     case SDL_BLENDMODE_ADD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
         break;
     case SDL_BLENDMODE_MOD:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
         break;
     default:
-        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
+        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
         break;
     }
     return 0;
@@ -126,32 +126,32 @@
     case 2:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_BLEND_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_BLEND_RGB);
             break;
         case SDL_BLENDMODE_ADD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_ADD_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_MOD_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_MOD_RGB);
             break;
         default:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_RGB);
             break;
         }
         return 0;
     case 4:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGB);
             break;
         case SDL_BLENDMODE_ADD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGB);
             break;
         default:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGB);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGB);
             break;
         }
         return 0;
@@ -172,16 +172,16 @@
     case 4:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGBA);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGBA);
             break;
         case SDL_BLENDMODE_ADD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGBA);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGBA);
             break;
         case SDL_BLENDMODE_MOD:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGBA);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGBA);
             break;
         default:
-            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGBA);
+            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGBA);
             break;
         }
         return 0;
--- a/src/video/SDL_blendrect.c	Sun Dec 21 08:55:06 2008 +0000
+++ b/src/video/SDL_blendrect.c	Sun Dec 21 08:59:56 2008 +0000
@@ -32,16 +32,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
         break;
     case SDL_BLENDMODE_ADD:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
+        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
         break;
     case SDL_BLENDMODE_MOD:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
+        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
         break;
     default:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_RGB555);
+        FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
         break;
     }
     return 0;
@@ -55,16 +55,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
         break;
     case SDL_BLENDMODE_ADD:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
+        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
         break;
     case SDL_BLENDMODE_MOD:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
+        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
         break;
     default:
-        BLENDRECT(Uint16, DRAW_SETPIXEL_RGB565);
+        FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
         break;
     }
     return 0;
@@ -78,16 +78,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
         break;
     case SDL_BLENDMODE_ADD:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
         break;
     case SDL_BLENDMODE_MOD:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
         break;
     default:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_RGB888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
         break;
     }
     return 0;
@@ -101,16 +101,16 @@
 
     switch (blendMode) {
     case SDL_BLENDMODE_BLEND:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
         break;
     case SDL_BLENDMODE_ADD:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
         break;
     case SDL_BLENDMODE_MOD:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
         break;
     default:
-        BLENDRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
+        FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
         break;
     }
     return 0;
@@ -127,32 +127,32 @@
     case 2:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
+            FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
             break;
         case SDL_BLENDMODE_ADD:
-            BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
+            FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
-            BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
+            FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
             break;
         default:
-            BLENDRECT(Uint16, DRAW_SETPIXEL_RGB);
+            FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
             break;
         }
         return 0;
     case 4:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
             break;
         case SDL_BLENDMODE_ADD:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
+            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
+            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
             break;
         default:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_RGB);
+            FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
             break;
         }
         return 0;
@@ -173,16 +173,16 @@
     case 4:
         switch (blendMode) {
         case SDL_BLENDMODE_BLEND:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
             break;
         case SDL_BLENDMODE_ADD:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
+            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
             break;
         case SDL_BLENDMODE_MOD:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
+            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
             break;
         default:
-            BLENDRECT(Uint32, DRAW_SETPIXEL_RGBA);
+            FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
             break;
         }
         return 0;
--- a/src/video/SDL_draw.h	Sun Dec 21 08:55:06 2008 +0000
+++ b/src/video/SDL_draw.h	Sun Dec 21 08:59:56 2008 +0000
@@ -322,12 +322,13 @@
         } \
     } \
 }
+#define DRAWLINE(x0, y0, x1, y1, op)	BRESENHAM(x0, y0, x1, y1, op)
 
 /*
  * Define blend fill macro
  */
 
-#define BLENDRECT(type, op) \
+#define FILLRECT(type, op) \
 do { \
     int w; \
     int width = dstrect->w; \
--- a/src/video/SDL_drawline.c	Sun Dec 21 08:55:06 2008 +0000
+++ b/src/video/SDL_drawline.c	Sun Dec 21 08:59:56 2008 +0000
@@ -47,16 +47,16 @@
 
     switch (dst->format->BytesPerPixel) {
     case 1:
-        BRESENHAM(x1, y1, x2, y2, SETPIXEL1);
+        DRAWLINE(x1, y1, x2, y2, SETPIXEL1);
         break;
     case 2:
-        BRESENHAM(x1, y1, x2, y2, SETPIXEL2);
+        DRAWLINE(x1, y1, x2, y2, SETPIXEL2);
         break;
     case 3:
         SDL_Unsupported();
         return -1;
     case 4:
-        BRESENHAM(x1, y1, x2, y2, SETPIXEL4);
+        DRAWLINE(x1, y1, x2, y2, SETPIXEL4);
         break;
     }
     return 0;