Re: [AD] Simplify al_convert_bitmap

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


On Thu, Aug 14, 2014 at 2:53 AM, SiegeLordEx <slabode@xxxxxxxxxx> wrote:
I've been working a bit on simplifying how al_convert_bitmap worked.
Currently, you have to call it on the parent and all the sub-bitmaps,
which is a pain. Notably, al_convert_bitmaps did not perform this
correctly (i.e. it only called it on the parents, but children were left
in limbo).

I have altered the code to make it so sub-bitmaps inherit the flags and
format from the parent (in the sense that if you call
al_get_bitmap_flags and al_get_bitmap_format, it will always return the
parent's flags and format) which made it so that it was unnecessary to
call al_convert_bitmap on the sub-bitmaps because its state is always up
to date with the parent. Now, calling al_convert_bitmap on the parent,
or any child converts the whole tree (the parent and all the siblings).


Makes a lot of sense.
 
While a simple change in principle, it touched a lot of code because
accessing ALLEGRO_BITMAP::flags and ::format directly is now incorrect
(these values are poisoned to 0 in al_create_sub_bitmap so they can be
detected if accessed improperly). All places which accessed those fields
directly (save for a few where the flags/format are changed) were
changed to use al_get_bitmap_format/flags functions. Strictly speaking,
this is unnecessary in many places (we are guaranteed to have the parent
bitmap) but I thought that was too error prone. Those two function calls
won't have any appreciable overhead.

The WIP diff is here (I haven't tested it on Windows just yet):
https://github.com/liballeg/allegro5/pull/9/files

I'm going to test it to make sure it compiles on Windows and then commit
it (unless there are comments/questions). It might break all other
platforms since I touched all of them, but the changes to fix the builds
should be trivial... I may have missed a variable declaration here and
there.


You could have renamed the flags and format members, so in case you missed any direct access it would give an error now, forcing all platforms to get fixed :)


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