Re: [AD] clipping line algorithm

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Eric Botcazou wrote:
With is_linear_bitmap(), according to its own documentation? See
http://alleg.sourceforge.net/onlinedocs/en/index009.html#is_linear_bitmap

Are you sure that we would not get a bug report from someone who has wired its own putpixel method to a linear bitmap? I think that Allegro has guaranteed up to now that a user-set vtable will be used instead of the default vtable in all cases. This would break the rule.

We break the rule in rotate.c, the function _parallelogram_map_standard(). OK, after looking up the definition of is_linear_bitmap() in include/allegro/inline/gfx.inl, I think I understand the problem: any bitmaps that Allegro knows about are either linear or planar, so there is only one flag for bmp->id that says which of them holds (the flag is called BMP_ID_PLANAR). But an add-on may provide a bitmap type that is not planar (so it would not be correct to set the flag) but does not support _putpixel (so it would not be correct for is_linear_bitmap() to return true). Here's a suggestion to fix this: Introduce a new flag for bmp->id, say BMP_ID_LINEAR. Allegro must set this flag if and only if it does not set BMP_ID_PLANAR. Add-ons that create non-planar non-linear bitmaps must set neither flag. Seems OK?

If we decided to optimize the drawing functions, I think the test could only be something like:

    if (bmp->vtable->putpixel == _linear_vtable->putpixel)
       use _putpixel
    else
       use bmp->vtable->putpixel

_putpixel being the degenerated case (no clipping, no drawing mode) of _linear_vtable->putpixel.

I suppose that would be fine too, although I don't like to force add-ons to break the specification of is_linear_bitmap(). (The advantage of this workaround is of course that it requires less modifications.)

Sven





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/