Re: [AD] public state store/restore API

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


On Thu, 2008-09-04 at 05:40 +1000, Peter Wang wrote:
> On 2008-09-03, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> > We briefly talked about this in #allegro-dev, so I made a patch. It's
> > simply two functions:
> > 
> > void al_store_state(ALLEGRO_STATE *state, int flags);
> > void al_restore_state(ALLEGRO_STATE *state, int flags);
> 
> One variant of this would be to remember the flags so the restore call
> is a bit simpler.  Of course it's less flexible, but also less error
> prone.

True. I removed the flags parameter from al_restore_state.

> 
> I'm mainly interested in saving and restoring the bitmap format
> and target.
> 

I added ALLEGRO_STATE_BITMAP for storing bitmap format and target and
also ALLEGRO_STATE_ALL to simply store everything.

> 
> To hide the internals, I suggest
> 
>     typedef struct ALLEGRO_STATE {
> 	int32_t __pad[32];
>     } ALLEGRO_STATE;
> 
> or however much, so that sizeof(ALLEGRO_STATE) is big enough
> plus some for the future.
> 

Good idea. I simply re-used thread_local_state internally and put an
ASSERT making sure the size is big enough. Maybe we can remove all those
backup copies in thread_local_state now and make backups on the locals
stack using the two new functions - I'll have a look at that next.

The patch plus mentioned changes is applied now to SVN.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





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