src/video/SDL_draw.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 09 Dec 2009 15:56:56 +0000
changeset 3536 0267b8b1595c
parent 3063 9f2482d6662c
child 3593 b931bcfd94a0
permissions -rw-r--r--
Added interfaces for batch drawing of points, lines and rects:
SDL_DrawPoints()
SDL_BlendPoints()
SDL_BlendLines()
SDL_DrawLines()
SDL_FillRects()
SDL_BlendRects()
SDL_RenderPoints()
SDL_RenderLines()
SDL_RenderRects()
Renamed SDL_RenderFill() to SDL_RenderRect()
slouken@2898
     1
/*
slouken@2898
     2
    SDL - Simple DirectMedia Layer
slouken@2898
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@2898
     4
slouken@2898
     5
    This library is free software; you can redistribute it and/or
slouken@2898
     6
    modify it under the terms of the GNU Lesser General Public
slouken@2898
     7
    License as published by the Free Software Foundation; either
slouken@2898
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@2898
     9
slouken@2898
    10
    This library is distributed in the hope that it will be useful,
slouken@2898
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2898
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2898
    13
    Lesser General Public License for more details.
slouken@2898
    14
slouken@2898
    15
    You should have received a copy of the GNU Lesser General Public
slouken@2898
    16
    License along with this library; if not, write to the Free Software
slouken@2898
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2898
    18
slouken@2898
    19
    Sam Lantinga
slouken@2898
    20
    slouken@libsdl.org
slouken@2898
    21
*/
slouken@2898
    22
#include "SDL_config.h"
slouken@2898
    23
slouken@2898
    24
#include "SDL_blit.h"
slouken@2898
    25
slouken@2898
    26
/* This code assumes that r, g, b, a are the source color,
slouken@2898
    27
 * and in the blend and add case, the RGB values are premultiplied by a.
slouken@2898
    28
 */
slouken@2898
    29
slouken@2898
    30
#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
slouken@2898
    31
slouken@2901
    32
#define DRAW_FASTSETPIXEL(x, y, type, bpp, color) \
slouken@2918
    33
    *(type *)((Uint8 *)dst->pixels + y * dst->pitch + x * bpp) = (type) color
slouken@2901
    34
slouken@2901
    35
#define DRAW_FASTSETPIXEL1(x, y) DRAW_FASTSETPIXEL(x, y, Uint8, 1, color);
slouken@2901
    36
#define DRAW_FASTSETPIXEL2(x, y) DRAW_FASTSETPIXEL(x, y, Uint16, 2, color);
slouken@2901
    37
#define DRAW_FASTSETPIXEL4(x, y) DRAW_FASTSETPIXEL(x, y, Uint32, 4, color);
slouken@2901
    38
slouken@2898
    39
#define DRAW_SETPIXEL(setpixel) \
slouken@2898
    40
do { \
slouken@2898
    41
    unsigned sr = r, sg = g, sb = b, sa = a; \
slouken@2898
    42
    setpixel; \
slouken@2898
    43
} while (0)
slouken@2898
    44
slouken@2898
    45
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
slouken@2898
    46
do { \
slouken@2898
    47
    unsigned sr, sg, sb, sa; sa; \
slouken@2898
    48
    getpixel; \
slouken@2898
    49
    sr = DRAW_MUL(inva, sr) + r; \
slouken@2898
    50
    sg = DRAW_MUL(inva, sg) + g; \
slouken@2898
    51
    sb = DRAW_MUL(inva, sb) + b; \
slouken@2898
    52
    setpixel; \
slouken@2898
    53
} while (0)
slouken@2898
    54
slouken@2898
    55
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
slouken@2898
    56
do { \
slouken@2898
    57
    unsigned sr, sg, sb, sa; sa; \
slouken@2898
    58
    getpixel; \
slouken@2898
    59
    sr += r; if (sr > 0xff) sr = 0xff; \
slouken@2898
    60
    sg += g; if (sg > 0xff) sg = 0xff; \
slouken@2898
    61
    sb += b; if (sb > 0xff) sb = 0xff; \
slouken@2898
    62
    setpixel; \
slouken@2898
    63
} while (0)
slouken@2898
    64
slouken@2898
    65
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
slouken@2898
    66
do { \
slouken@2898
    67
    unsigned sr, sg, sb, sa; sa; \
slouken@2898
    68
    getpixel; \
slouken@2898
    69
    sr = DRAW_MUL(sr, r); \
slouken@2898
    70
    sg = DRAW_MUL(sg, g); \
slouken@2898
    71
    sb = DRAW_MUL(sb, b); \
slouken@2898
    72
    setpixel; \
slouken@2898
    73
} while (0)
slouken@2898
    74
slouken@2898
    75
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
slouken@2898
    76
do { \
slouken@2918
    77
    type *pixel = (type *)((Uint8 *)dst->pixels + y * dst->pitch + x * bpp); \
slouken@2898
    78
    op; \
slouken@2898
    79
} while (0)
slouken@2898
    80
slouken@2898
    81
/*
slouken@2898
    82
 * Define draw operators for RGB555
slouken@2898
    83
 */
slouken@2898
    84
slouken@2898
    85
#define DRAW_SETPIXEL_RGB555 \
slouken@2898
    86
    DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
    87
slouken@2898
    88
#define DRAW_SETPIXEL_BLEND_RGB555 \
slouken@2898
    89
    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
slouken@2898
    90
                        RGB555_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
    91
slouken@2898
    92
#define DRAW_SETPIXEL_ADD_RGB555 \
slouken@2898
    93
    DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
slouken@2898
    94
                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
    95
slouken@2898
    96
#define DRAW_SETPIXEL_MOD_RGB555 \
slouken@2898
    97
    DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
slouken@2898
    98
                      RGB555_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
    99
slouken@2898
   100
#define DRAW_SETPIXELXY_RGB555(x, y) \
slouken@2898
   101
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
slouken@2898
   102
slouken@2898
   103
#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
slouken@2898
   104
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
slouken@2898
   105
slouken@2898
   106
#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
slouken@2898
   107
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
slouken@2898
   108
slouken@2898
   109
#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
slouken@2898
   110
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
slouken@2898
   111
slouken@2898
   112
/*
slouken@2898
   113
 * Define draw operators for RGB565
slouken@2898
   114
 */
slouken@2898
   115
slouken@2898
   116
#define DRAW_SETPIXEL_RGB565 \
slouken@2898
   117
    DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   118
slouken@2898
   119
#define DRAW_SETPIXEL_BLEND_RGB565 \
slouken@2898
   120
    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
slouken@2898
   121
                        RGB565_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   122
slouken@2898
   123
#define DRAW_SETPIXEL_ADD_RGB565 \
slouken@2898
   124
    DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
slouken@2898
   125
                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   126
slouken@2898
   127
#define DRAW_SETPIXEL_MOD_RGB565 \
slouken@2898
   128
    DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
slouken@2898
   129
                      RGB565_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   130
slouken@2898
   131
#define DRAW_SETPIXELXY_RGB565(x, y) \
slouken@2898
   132
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
slouken@2898
   133
slouken@2898
   134
#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
slouken@2898
   135
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
slouken@2898
   136
slouken@2898
   137
#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
slouken@2898
   138
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
slouken@2898
   139
slouken@2898
   140
#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
slouken@2898
   141
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
slouken@2898
   142
slouken@2898
   143
/*
slouken@2898
   144
 * Define draw operators for RGB888
slouken@2898
   145
 */
slouken@2898
   146
slouken@2898
   147
#define DRAW_SETPIXEL_RGB888 \
slouken@2898
   148
    DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   149
slouken@2898
   150
#define DRAW_SETPIXEL_BLEND_RGB888 \
slouken@2898
   151
    DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
slouken@2898
   152
                        RGB888_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   153
slouken@2898
   154
#define DRAW_SETPIXEL_ADD_RGB888 \
slouken@2898
   155
    DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
slouken@2898
   156
                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   157
slouken@2898
   158
#define DRAW_SETPIXEL_MOD_RGB888 \
slouken@2898
   159
    DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
slouken@2898
   160
                      RGB888_FROM_RGB(*pixel, sr, sg, sb))
slouken@2898
   161
slouken@2898
   162
#define DRAW_SETPIXELXY_RGB888(x, y) \
slouken@2898
   163
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
slouken@2898
   164
slouken@2898
   165
#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
slouken@2898
   166
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
slouken@2898
   167
slouken@2898
   168
#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
slouken@2898
   169
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
slouken@2898
   170
slouken@2898
   171
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
slouken@2898
   172
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
slouken@2898
   173
slouken@2898
   174
/*
slouken@2899
   175
 * Define draw operators for ARGB8888
slouken@2899
   176
 */
slouken@2899
   177
slouken@2899
   178
#define DRAW_SETPIXEL_ARGB8888 \
slouken@2899
   179
    DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
slouken@2899
   180
slouken@2899
   181
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
slouken@2899
   182
    DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
slouken@2899
   183
                        ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
slouken@2899
   184
slouken@2899
   185
#define DRAW_SETPIXEL_ADD_ARGB8888 \
slouken@2899
   186
    DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
slouken@2899
   187
                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
slouken@2899
   188
slouken@2899
   189
#define DRAW_SETPIXEL_MOD_ARGB8888 \
slouken@2899
   190
    DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
slouken@2899
   191
                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
slouken@2899
   192
slouken@2899
   193
#define DRAW_SETPIXELXY_ARGB8888(x, y) \
slouken@2899
   194
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
slouken@2899
   195
slouken@2899
   196
#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
slouken@2899
   197
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
slouken@2899
   198
slouken@2899
   199
#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
slouken@2899
   200
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
slouken@2899
   201
slouken@2899
   202
#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
slouken@2899
   203
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
slouken@2899
   204
slouken@2899
   205
/*
slouken@2898
   206
 * Define draw operators for general RGB
slouken@2898
   207
 */
slouken@2898
   208
slouken@2898
   209
#define DRAW_SETPIXEL_RGB \
slouken@2898
   210
    DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
slouken@2898
   211
slouken@2898
   212
#define DRAW_SETPIXEL_BLEND_RGB \
slouken@2898
   213
    DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
slouken@2898
   214
                        PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
slouken@2898
   215
slouken@2898
   216
#define DRAW_SETPIXEL_ADD_RGB \
slouken@2898
   217
    DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
slouken@2898
   218
                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
slouken@2898
   219
slouken@2898
   220
#define DRAW_SETPIXEL_MOD_RGB \
slouken@2898
   221
    DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
slouken@2898
   222
                      PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
slouken@2898
   223
slouken@2898
   224
#define DRAW_SETPIXELXY2_RGB(x, y) \
slouken@2898
   225
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
slouken@2898
   226
slouken@2898
   227
#define DRAW_SETPIXELXY4_RGB(x, y) \
slouken@2898
   228
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
slouken@2898
   229
slouken@2898
   230
#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
slouken@2898
   231
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
slouken@2898
   232
slouken@2898
   233
#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
slouken@2898
   234
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
slouken@2898
   235
slouken@2898
   236
#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
slouken@2898
   237
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
slouken@2898
   238
slouken@2898
   239
#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
slouken@2898
   240
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
slouken@2898
   241
slouken@2898
   242
#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
slouken@2898
   243
    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
slouken@2898
   244
slouken@2898
   245
#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
slouken@2898
   246
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
slouken@2898
   247
slouken@2898
   248
slouken@2898
   249
/*
slouken@2898
   250
 * Define draw operators for general RGBA
slouken@2898
   251
 */
slouken@2898
   252
slouken@2898
   253
#define DRAW_SETPIXEL_RGBA \
slouken@2898
   254
    DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
slouken@2898
   255
slouken@2898
   256
#define DRAW_SETPIXEL_BLEND_RGBA \
slouken@2898
   257
    DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
slouken@2898
   258
                        PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
slouken@2898
   259
slouken@2898
   260
#define DRAW_SETPIXEL_ADD_RGBA \
slouken@2898
   261
    DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
slouken@2898
   262
                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
slouken@2898
   263
slouken@2898
   264
#define DRAW_SETPIXEL_MOD_RGBA \
slouken@2898
   265
    DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
slouken@2898
   266
                      PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
slouken@2898
   267
slouken@2898
   268
#define DRAW_SETPIXELXY4_RGBA(x, y) \
slouken@2898
   269
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
slouken@2898
   270
slouken@2898
   271
#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
slouken@2898
   272
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
slouken@2898
   273
slouken@2898
   274
#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
slouken@2898
   275
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
slouken@2898
   276
slouken@2898
   277
#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
slouken@2898
   278
    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
slouken@2898
   279
slouken@2898
   280
/*
slouken@2898
   281
 * Define line drawing macro
slouken@2898
   282
 */
slouken@2898
   283
slouken@2898
   284
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
slouken@2898
   285
slouken@2903
   286
#define BRESENHAM(x1, y1, x2, y2, op) \
slouken@2898
   287
{ \
slouken@2903
   288
    int i, deltax, deltay, numpixels; \
slouken@2903
   289
    int d, dinc1, dinc2; \
slouken@2903
   290
    int x, xinc1, xinc2; \
slouken@2903
   291
    int y, yinc1, yinc2; \
slouken@2903
   292
 \
slouken@2903
   293
    deltax = ABS(x2 - x1); \
slouken@2903
   294
    deltay = ABS(y2 - y1); \
slouken@2898
   295
 \
slouken@2903
   296
    if (deltax >= deltay) { \
slouken@2903
   297
        numpixels = deltax + 1; \
slouken@2903
   298
        d = (2 * deltay) - deltax; \
slouken@2903
   299
        dinc1 = deltay * 2; \
slouken@2903
   300
        dinc2 = (deltay - deltax) * 2; \
slouken@2903
   301
        xinc1 = 1; \
slouken@2903
   302
        xinc2 = 1; \
slouken@2903
   303
        yinc1 = 0; \
slouken@2903
   304
        yinc2 = 1; \
slouken@2898
   305
    } else { \
slouken@2903
   306
        numpixels = deltay + 1; \
slouken@2903
   307
        d = (2 * deltax) - deltay; \
slouken@2903
   308
        dinc1 = deltax * 2; \
slouken@2903
   309
        dinc2 = (deltax - deltay) * 2; \
slouken@2903
   310
        xinc1 = 0; \
slouken@2903
   311
        xinc2 = 1; \
slouken@2903
   312
        yinc1 = 1; \
slouken@2903
   313
        yinc2 = 1; \
slouken@2898
   314
    } \
slouken@2903
   315
 \
slouken@2903
   316
    if (x1 > x2) { \
slouken@2903
   317
        xinc1 = -xinc1; \
slouken@2903
   318
        xinc2 = -xinc2; \
slouken@2903
   319
    } \
slouken@2903
   320
    if (y1 > y2) { \
slouken@2903
   321
        yinc1 = -yinc1; \
slouken@2903
   322
        yinc2 = -yinc2; \
slouken@2898
   323
    } \
slouken@2903
   324
 \
slouken@2903
   325
    x = x1; \
slouken@2903
   326
    y = y1; \
slouken@2903
   327
 \
slouken@3063
   328
    for (i = 0; i < numpixels; ++i) { \
slouken@2903
   329
        op(x, y); \
slouken@2903
   330
        if (d < 0) { \
slouken@2903
   331
            d += dinc1; \
slouken@2903
   332
            x += xinc1; \
slouken@2903
   333
            y += yinc1; \
slouken@2903
   334
        } else { \
slouken@2903
   335
            d += dinc2; \
slouken@2903
   336
            x += xinc2; \
slouken@2903
   337
            y += yinc2; \
slouken@2898
   338
        } \
slouken@2898
   339
    } \
slouken@2898
   340
}
slouken@2900
   341
#define DRAWLINE(x0, y0, x1, y1, op)	BRESENHAM(x0, y0, x1, y1, op)
slouken@2898
   342
slouken@2898
   343
/*
slouken@2898
   344
 * Define blend fill macro
slouken@2898
   345
 */
slouken@2898
   346
slouken@2900
   347
#define FILLRECT(type, op) \
slouken@2898
   348
do { \
slouken@3536
   349
    int width = rect->w; \
slouken@3536
   350
    int height = rect->h; \
slouken@2898
   351
    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
slouken@2898
   352
    int skip = pitch - width; \
slouken@3536
   353
    type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
slouken@2898
   354
    while (height--) { \
slouken@2898
   355
        { int n = (width+3)/4; \
slouken@2898
   356
            switch (width & 3) { \
slouken@2898
   357
            case 0: do {   op; pixel++; \
slouken@2898
   358
            case 3:        op; pixel++; \
slouken@2898
   359
            case 2:        op; pixel++; \
slouken@2898
   360
            case 1:        op; pixel++; \
slouken@2898
   361
                    } while ( --n > 0 ); \
slouken@2898
   362
            } \
slouken@2898
   363
        } \
slouken@2898
   364
        pixel += skip; \
slouken@2898
   365
    } \
slouken@2898
   366
} while (0)
slouken@2898
   367
slouken@2898
   368
/*
slouken@2898
   369
 * Define blend line macro
slouken@2898
   370
 */
slouken@2898
   371
slouken@2898
   372
/* vi: set ts=4 sw=4 expandtab: */