Re: [AD] clipping line algorithm |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Eric Botcazou wrote:
_putpixel() is a very limited version of putpixel() (see the docs for the
limitation). If your version is intended to replace the current line()
function, it must obey the same rules,
But if _putpixel() is more efficient, we can test the bitmap type to see
if it allows for _putpixel(), and only otherwise use
bmp->vtable->putpixel(). I think the correct test would be
if (is_linear_bitmap(bmp) && _drawing_mode == DRAW_MODE_SOLID)
use _putpixel
else
use bmp->vtable->putpixel
I suppose the same could be done for all drawing primitives, so we could
write a function like
typedef void (*PUTPIXEL_METHOD)(BITMAP, int, int, int);
static PUTPIXEL_METHOD select_putpixel(BITMAP *bmp) {
if (is_linear_bitmap(bmp) && _drawing_mode == DRAW_MODE_SOLID) {
switch (bitmap_color_depth(bmp)) {
case 8: return _putpixel;
case 15: return _putpixel15;
case 16: return _putpixel16;
case 24: return _putpixel24;
case 32: return _putpixel32;
}
}
else
return bmp->vtable->putpixel;
}
and then we use this in do_[ellipse|circle|line|arc]() after detecting
that no clipping is necessary. Would it work? What do you think?
--
Sven