comparison src/video/SDL_draw.h @ 3593:b931bcfd94a0

In the process of adding rectangle drawing
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Dec 2009 07:03:09 +0000
parents 0267b8b1595c
children c8bed77b0386
comparison
equal deleted inserted replaced
3592:25dc4a86132c 3593:b931bcfd94a0
339 } \ 339 } \
340 } 340 }
341 #define DRAWLINE(x0, y0, x1, y1, op) BRESENHAM(x0, y0, x1, y1, op) 341 #define DRAWLINE(x0, y0, x1, y1, op) BRESENHAM(x0, y0, x1, y1, op)
342 342
343 /* 343 /*
344 * Define blend fill macro 344 * Define draw rect macro
345 */
346 #define DRAWRECT(type, op) \
347 do { \
348 int width = rect->w; \
349 int height = rect->h; \
350 int pitch = (dst->pitch / dst->format->BytesPerPixel); \
351 int skip = pitch - width; \
352 type *pixel; \
353 pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
354 { int n = (width+3)/4; \
355 switch (width & 3) { \
356 case 0: do { op; pixel++; \
357 case 3: op; pixel++; \
358 case 2: op; pixel++; \
359 case 1: op; pixel++; \
360 } while ( --n > 0 ); \
361 } \
362 } \
363 pixel += skip; \
364 width -= 1; \
365 height -= 2; \
366 while (height--) { \
367 op; pixel += width; op; pixel += skip; \
368 } \
369 { int n = (width+3)/4; \
370 switch (width & 3) { \
371 case 0: do { op; pixel++; \
372 case 3: op; pixel++; \
373 case 2: op; pixel++; \
374 case 1: op; pixel++; \
375 } while ( --n > 0 ); \
376 } \
377 } \
378 } while (0)
379
380 /*
381 * Define fill rect macro
345 */ 382 */
346 383
347 #define FILLRECT(type, op) \ 384 #define FILLRECT(type, op) \
348 do { \ 385 do { \
349 int width = rect->w; \ 386 int width = rect->w; \
363 } \ 400 } \
364 pixel += skip; \ 401 pixel += skip; \
365 } \ 402 } \
366 } while (0) 403 } while (0)
367 404
368 /*
369 * Define blend line macro
370 */
371
372 /* vi: set ts=4 sw=4 expandtab: */ 405 /* vi: set ts=4 sw=4 expandtab: */