[AD] bugfix in create_video_bitmap()

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


Hello,
It seems that the screen subdivision algorithm in create_video_bitmap()
is a bit confused about how it works :-). It will fail to find an
existing free location for a video bitmap in some cases when you first
create some video bitmaps, then destroy a particular subset of them (I
can be more specific on request). Probably it doesn't make any big
difference in most common cases, because you usually allocate a fixed
set of video bitmaps in the initialization, then keep them forever.

With the attached patch it always finds empty space to put the new
bitmap in if it exists ("proof": assume there exists some location in
video memory where the new video bitmap can be placed. Then we can move
this location up- and leftwards until both [the left edge hits either
the right edge of another video bmp or the left edge of video memory]
and [the top edge hits either the bottom edge of another video bmp or
top edge of video memory]. So it is sufficient to look for locations
with [left edge adjacent to either right edge of another video bmp or
left edge of video memory] and [top edge adjacent to either bottom of
another video bmp or top of video memory], which is what the new
algorithm does. I hope that made some sense :-)

Btw, it's still very slow (running time is cubic in the number of
existing video bitmaps if it fails), I'll try to optimize it later.

-- 
Sven Sandberg    svsa1977@xxxxxxxxxx    home.student.uu.se/svsa1977

Attachment: graphics.c.diff.gz
Description: GNU Zip compressed data



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