Re: [AD] XOR drawing under X11 (and what is _xwin_in_gfx_call) |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Elias Pschernig wrote:
Hm. I think it can't work. Just think of cases like this: thread 1: XLOCK(); bmp->vtable = &orig_vtable; *** context switch *** thread 2: draw(bmp); /* will use the wrong vtable method */
In that case, the second thread's draw operation will block on XLOCK until the first thread completes drawing and XUNLOCKs. Dealing with the SIGALRM version may be problematic, but I think this could wait until 4.3 when we drop it.
Maybe we could copy the bitmap, like this: void _some_draw_function() { BITMAP temp = *bmp; for (i = h; i < bmp->h; i++) temp.line[i] = bmp->line[i];
Right there you'd be overwriting memory. Don't forget the line[] pointers reference memory that extend out past the structure.
For Allegro 4.3.x, I think, we could require all access to a bitmap to be locked. That is, a function like putpixel would look like this: acquire_bitmap (); vtable->putpixel release_bitmap () instead of right now: vtable->putpixel /* locking is done by the vtable method */
I thought about this, and here's the thing. Granted putpixel is a poor example here, but if a vtable entry can potentially be hardware accelerated, you need the surface unlocked to do it. Forcing a lock only to have it unlocked by the vtable entry before the operation even takes place is a bit wasteful, don't you think?
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |