Make it possible to switch algorithms in the future
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Dec 2008 08:59:56 +0000
changeset 29003a9636c83849
parent 2899 a0c837a16e4c
child 2901 133601e3b255
Make it possible to switch algorithms in the future
src/video/SDL_blendline.c
src/video/SDL_blendrect.c
src/video/SDL_draw.h
src/video/SDL_drawline.c
     1.1 --- a/src/video/SDL_blendline.c	Sun Dec 21 08:55:06 2008 +0000
     1.2 +++ b/src/video/SDL_blendline.c	Sun Dec 21 08:59:56 2008 +0000
     1.3 @@ -31,16 +31,16 @@
     1.4  
     1.5      switch (blendMode) {
     1.6      case SDL_BLENDMODE_BLEND:
     1.7 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB555);
     1.8 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB555);
     1.9          break;
    1.10      case SDL_BLENDMODE_ADD:
    1.11 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB555);
    1.12 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB555);
    1.13          break;
    1.14      case SDL_BLENDMODE_MOD:
    1.15 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB555);
    1.16 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB555);
    1.17          break;
    1.18      default:
    1.19 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB555);
    1.20 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB555);
    1.21          break;
    1.22      }
    1.23      return 0;
    1.24 @@ -54,16 +54,16 @@
    1.25  
    1.26      switch (blendMode) {
    1.27      case SDL_BLENDMODE_BLEND:
    1.28 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB565);
    1.29 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB565);
    1.30          break;
    1.31      case SDL_BLENDMODE_ADD:
    1.32 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB565);
    1.33 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB565);
    1.34          break;
    1.35      case SDL_BLENDMODE_MOD:
    1.36 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB565);
    1.37 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB565);
    1.38          break;
    1.39      default:
    1.40 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB565);
    1.41 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB565);
    1.42          break;
    1.43      }
    1.44      return 0;
    1.45 @@ -77,16 +77,16 @@
    1.46  
    1.47      switch (blendMode) {
    1.48      case SDL_BLENDMODE_BLEND:
    1.49 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB888);
    1.50 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB888);
    1.51          break;
    1.52      case SDL_BLENDMODE_ADD:
    1.53 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB888);
    1.54 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB888);
    1.55          break;
    1.56      case SDL_BLENDMODE_MOD:
    1.57 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB888);
    1.58 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB888);
    1.59          break;
    1.60      default:
    1.61 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB888);
    1.62 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB888);
    1.63          break;
    1.64      }
    1.65      return 0;
    1.66 @@ -100,16 +100,16 @@
    1.67  
    1.68      switch (blendMode) {
    1.69      case SDL_BLENDMODE_BLEND:
    1.70 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
    1.71 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
    1.72          break;
    1.73      case SDL_BLENDMODE_ADD:
    1.74 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
    1.75 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
    1.76          break;
    1.77      case SDL_BLENDMODE_MOD:
    1.78 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
    1.79 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
    1.80          break;
    1.81      default:
    1.82 -        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
    1.83 +        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
    1.84          break;
    1.85      }
    1.86      return 0;
    1.87 @@ -126,32 +126,32 @@
    1.88      case 2:
    1.89          switch (blendMode) {
    1.90          case SDL_BLENDMODE_BLEND:
    1.91 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_BLEND_RGB);
    1.92 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_BLEND_RGB);
    1.93              break;
    1.94          case SDL_BLENDMODE_ADD:
    1.95 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_ADD_RGB);
    1.96 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_ADD_RGB);
    1.97              break;
    1.98          case SDL_BLENDMODE_MOD:
    1.99 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_MOD_RGB);
   1.100 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_MOD_RGB);
   1.101              break;
   1.102          default:
   1.103 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY2_RGB);
   1.104 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_RGB);
   1.105              break;
   1.106          }
   1.107          return 0;
   1.108      case 4:
   1.109          switch (blendMode) {
   1.110          case SDL_BLENDMODE_BLEND:
   1.111 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGB);
   1.112 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGB);
   1.113              break;
   1.114          case SDL_BLENDMODE_ADD:
   1.115 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGB);
   1.116 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGB);
   1.117              break;
   1.118          case SDL_BLENDMODE_MOD:
   1.119 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGB);
   1.120 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGB);
   1.121              break;
   1.122          default:
   1.123 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGB);
   1.124 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGB);
   1.125              break;
   1.126          }
   1.127          return 0;
   1.128 @@ -172,16 +172,16 @@
   1.129      case 4:
   1.130          switch (blendMode) {
   1.131          case SDL_BLENDMODE_BLEND:
   1.132 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGBA);
   1.133 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGBA);
   1.134              break;
   1.135          case SDL_BLENDMODE_ADD:
   1.136 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGBA);
   1.137 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGBA);
   1.138              break;
   1.139          case SDL_BLENDMODE_MOD:
   1.140 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGBA);
   1.141 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGBA);
   1.142              break;
   1.143          default:
   1.144 -            BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGBA);
   1.145 +            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGBA);
   1.146              break;
   1.147          }
   1.148          return 0;
     2.1 --- a/src/video/SDL_blendrect.c	Sun Dec 21 08:55:06 2008 +0000
     2.2 +++ b/src/video/SDL_blendrect.c	Sun Dec 21 08:59:56 2008 +0000
     2.3 @@ -32,16 +32,16 @@
     2.4  
     2.5      switch (blendMode) {
     2.6      case SDL_BLENDMODE_BLEND:
     2.7 -        BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
     2.8 +        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
     2.9          break;
    2.10      case SDL_BLENDMODE_ADD:
    2.11 -        BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
    2.12 +        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
    2.13          break;
    2.14      case SDL_BLENDMODE_MOD:
    2.15 -        BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
    2.16 +        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
    2.17          break;
    2.18      default:
    2.19 -        BLENDRECT(Uint16, DRAW_SETPIXEL_RGB555);
    2.20 +        FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
    2.21          break;
    2.22      }
    2.23      return 0;
    2.24 @@ -55,16 +55,16 @@
    2.25  
    2.26      switch (blendMode) {
    2.27      case SDL_BLENDMODE_BLEND:
    2.28 -        BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
    2.29 +        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
    2.30          break;
    2.31      case SDL_BLENDMODE_ADD:
    2.32 -        BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
    2.33 +        FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
    2.34          break;
    2.35      case SDL_BLENDMODE_MOD:
    2.36 -        BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
    2.37 +        FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
    2.38          break;
    2.39      default:
    2.40 -        BLENDRECT(Uint16, DRAW_SETPIXEL_RGB565);
    2.41 +        FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
    2.42          break;
    2.43      }
    2.44      return 0;
    2.45 @@ -78,16 +78,16 @@
    2.46  
    2.47      switch (blendMode) {
    2.48      case SDL_BLENDMODE_BLEND:
    2.49 -        BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
    2.50 +        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
    2.51          break;
    2.52      case SDL_BLENDMODE_ADD:
    2.53 -        BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
    2.54 +        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
    2.55          break;
    2.56      case SDL_BLENDMODE_MOD:
    2.57 -        BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
    2.58 +        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
    2.59          break;
    2.60      default:
    2.61 -        BLENDRECT(Uint32, DRAW_SETPIXEL_RGB888);
    2.62 +        FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
    2.63          break;
    2.64      }
    2.65      return 0;
    2.66 @@ -101,16 +101,16 @@
    2.67  
    2.68      switch (blendMode) {
    2.69      case SDL_BLENDMODE_BLEND:
    2.70 -        BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
    2.71 +        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
    2.72          break;
    2.73      case SDL_BLENDMODE_ADD:
    2.74 -        BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
    2.75 +        FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
    2.76          break;
    2.77      case SDL_BLENDMODE_MOD:
    2.78 -        BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
    2.79 +        FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
    2.80          break;
    2.81      default:
    2.82 -        BLENDRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
    2.83 +        FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
    2.84          break;
    2.85      }
    2.86      return 0;
    2.87 @@ -127,32 +127,32 @@
    2.88      case 2:
    2.89          switch (blendMode) {
    2.90          case SDL_BLENDMODE_BLEND:
    2.91 -            BLENDRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
    2.92 +            FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
    2.93              break;
    2.94          case SDL_BLENDMODE_ADD:
    2.95 -            BLENDRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
    2.96 +            FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
    2.97              break;
    2.98          case SDL_BLENDMODE_MOD:
    2.99 -            BLENDRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
   2.100 +            FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
   2.101              break;
   2.102          default:
   2.103 -            BLENDRECT(Uint16, DRAW_SETPIXEL_RGB);
   2.104 +            FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
   2.105              break;
   2.106          }
   2.107          return 0;
   2.108      case 4:
   2.109          switch (blendMode) {
   2.110          case SDL_BLENDMODE_BLEND:
   2.111 -            BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
   2.112 +            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
   2.113              break;
   2.114          case SDL_BLENDMODE_ADD:
   2.115 -            BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
   2.116 +            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
   2.117              break;
   2.118          case SDL_BLENDMODE_MOD:
   2.119 -            BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
   2.120 +            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
   2.121              break;
   2.122          default:
   2.123 -            BLENDRECT(Uint32, DRAW_SETPIXEL_RGB);
   2.124 +            FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
   2.125              break;
   2.126          }
   2.127          return 0;
   2.128 @@ -173,16 +173,16 @@
   2.129      case 4:
   2.130          switch (blendMode) {
   2.131          case SDL_BLENDMODE_BLEND:
   2.132 -            BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
   2.133 +            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
   2.134              break;
   2.135          case SDL_BLENDMODE_ADD:
   2.136 -            BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
   2.137 +            FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
   2.138              break;
   2.139          case SDL_BLENDMODE_MOD:
   2.140 -            BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
   2.141 +            FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
   2.142              break;
   2.143          default:
   2.144 -            BLENDRECT(Uint32, DRAW_SETPIXEL_RGBA);
   2.145 +            FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
   2.146              break;
   2.147          }
   2.148          return 0;
     3.1 --- a/src/video/SDL_draw.h	Sun Dec 21 08:55:06 2008 +0000
     3.2 +++ b/src/video/SDL_draw.h	Sun Dec 21 08:59:56 2008 +0000
     3.3 @@ -322,12 +322,13 @@
     3.4          } \
     3.5      } \
     3.6  }
     3.7 +#define DRAWLINE(x0, y0, x1, y1, op)	BRESENHAM(x0, y0, x1, y1, op)
     3.8  
     3.9  /*
    3.10   * Define blend fill macro
    3.11   */
    3.12  
    3.13 -#define BLENDRECT(type, op) \
    3.14 +#define FILLRECT(type, op) \
    3.15  do { \
    3.16      int w; \
    3.17      int width = dstrect->w; \
     4.1 --- a/src/video/SDL_drawline.c	Sun Dec 21 08:55:06 2008 +0000
     4.2 +++ b/src/video/SDL_drawline.c	Sun Dec 21 08:59:56 2008 +0000
     4.3 @@ -47,16 +47,16 @@
     4.4  
     4.5      switch (dst->format->BytesPerPixel) {
     4.6      case 1:
     4.7 -        BRESENHAM(x1, y1, x2, y2, SETPIXEL1);
     4.8 +        DRAWLINE(x1, y1, x2, y2, SETPIXEL1);
     4.9          break;
    4.10      case 2:
    4.11 -        BRESENHAM(x1, y1, x2, y2, SETPIXEL2);
    4.12 +        DRAWLINE(x1, y1, x2, y2, SETPIXEL2);
    4.13          break;
    4.14      case 3:
    4.15          SDL_Unsupported();
    4.16          return -1;
    4.17      case 4:
    4.18 -        BRESENHAM(x1, y1, x2, y2, SETPIXEL4);
    4.19 +        DRAWLINE(x1, y1, x2, y2, SETPIXEL4);
    4.20          break;
    4.21      }
    4.22      return 0;