From: <tj...@us...> - 2008-08-18 10:01:04
|
Revision: 10392 http://alleg.svn.sourceforge.net/alleg/?rev=10392&view=rev Author: tjaden Date: 2008-08-18 10:01:12 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Add an assertion for al_set_target_bitmap(). Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2008-08-18 04:37:53 UTC (rev 10391) +++ allegro/branches/4.9/src/tls.c 2008-08-18 10:01:12 UTC (rev 10392) @@ -386,12 +386,15 @@ */ void al_set_target_bitmap(ALLEGRO_BITMAP *bitmap) { + ALLEGRO_DISPLAY *display = _al_current_display; if ((tls = tls_get()) == NULL) return; tls->target_bitmap = bitmap; if (bitmap != NULL) { - if (!(bitmap->flags & ALLEGRO_MEMORY_BITMAP)) - _al_current_display->vt->set_target_bitmap(_al_current_display, bitmap); + if (!(bitmap->flags & ALLEGRO_MEMORY_BITMAP)) { + ASSERT(display); + display->vt->set_target_bitmap(display, bitmap); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tj...@us...> - 2008-08-29 01:36:18
|
Revision: 10605 http://alleg.svn.sourceforge.net/alleg/?rev=10605&view=rev Author: tjaden Date: 2008-08-29 01:36:28 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Don't use a global variable to temporarily hold a pointer thread-local state. That would allow one thread to see or modify another thread's state (within a small timeframe). Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2008-08-28 23:19:32 UTC (rev 10604) +++ allegro/branches/4.9/src/tls.c 2008-08-29 01:36:28 UTC (rev 10605) @@ -62,9 +62,6 @@ } thread_local_state; -static thread_local_state *tls; - - #if defined ALLEGRO_MINGW32 && (__GNUC__ < 4 || __GNUC_MINOR__ < 2 \ || __GNUC_PATCHLEVEL__ < 1) @@ -236,6 +233,8 @@ */ void al_set_new_display_format(int format) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_display_format = format; @@ -255,6 +254,8 @@ */ void al_set_new_display_refresh_rate(int refresh_rate) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_display_refresh_rate = refresh_rate; @@ -296,6 +297,8 @@ */ void al_set_new_display_flags(int flags) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_display_flags = flags; @@ -309,6 +312,8 @@ */ int al_get_new_display_format(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->new_display_format; @@ -322,6 +327,8 @@ */ int al_get_new_display_refresh_rate(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->new_display_refresh_rate; @@ -335,6 +342,8 @@ */ int al_get_new_display_flags(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->new_display_flags; @@ -350,20 +359,24 @@ */ bool al_set_current_display(ALLEGRO_DISPLAY *display) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return false; if (display) { - if (display->vt->set_current_display(display)) { - tls->current_display = display; - al_set_target_bitmap(al_get_backbuffer()); - return true; - } - else - return false; + if (display->vt->set_current_display(display)) { + tls->current_display = display; + al_set_target_bitmap(al_get_backbuffer()); + return true; + } + else { + return false; + } } - else - tls->current_display = display; + else { + tls->current_display = display; + } return true; } @@ -376,6 +389,8 @@ */ ALLEGRO_DISPLAY *al_get_current_display(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->current_display; @@ -390,6 +405,8 @@ */ void al_set_target_bitmap(ALLEGRO_BITMAP *bitmap) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -411,6 +428,8 @@ */ ALLEGRO_BITMAP *al_get_target_bitmap(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->target_bitmap; @@ -420,6 +439,8 @@ void _al_push_target_bitmap(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->target_bitmap_backup = tls->target_bitmap; @@ -429,6 +450,8 @@ void _al_pop_target_bitmap(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->target_bitmap = tls->target_bitmap_backup; @@ -439,6 +462,8 @@ void _al_push_blender(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -452,6 +477,8 @@ void _al_pop_blender(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -472,6 +499,8 @@ */ void al_set_new_bitmap_format(int format) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_bitmap_format = format; @@ -499,6 +528,8 @@ */ void al_set_new_bitmap_flags(int flags) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_bitmap_flags = flags; @@ -512,6 +543,8 @@ */ int al_get_new_bitmap_format(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->new_bitmap_format; @@ -525,6 +558,8 @@ */ int al_get_new_bitmap_flags(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->new_bitmap_flags; @@ -534,6 +569,8 @@ void _al_push_new_bitmap_parameters(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_bitmap_format_backup = tls->new_bitmap_format; @@ -544,6 +581,8 @@ void _al_pop_new_bitmap_parameters(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->new_bitmap_format = tls->new_bitmap_format_backup; @@ -599,6 +638,8 @@ */ void al_set_blender(int src, int dst, ALLEGRO_COLOR color) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -618,6 +659,8 @@ */ void al_get_blender(int *src, int *dst, ALLEGRO_COLOR *color) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -635,6 +678,8 @@ ALLEGRO_COLOR *_al_get_blend_color() { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return NULL; return &tls->blend_color; @@ -644,6 +689,8 @@ void _al_set_memory_blender(int src, int dst, ALLEGRO_COLOR *color) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; @@ -723,6 +770,8 @@ ALLEGRO_MEMORY_BLENDER _al_get_memory_blender() { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return NULL; return tls->memory_blender; @@ -737,6 +786,8 @@ */ int al_get_errno(void) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return 0; return tls->allegro_errno; @@ -749,6 +800,8 @@ */ void al_set_errno(int errnum) { + thread_local_state *tls; + if ((tls = tls_get()) == NULL) return; tls->allegro_errno = errnum; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <el...@us...> - 2008-12-11 12:31:21
|
Revision: 11288 http://alleg.svn.sourceforge.net/alleg/?rev=11288&view=rev Author: elias Date: 2008-12-11 12:31:08 +0000 (Thu, 11 Dec 2008) Log Message: ----------- Updated al_set_blender documentation to how it works right now. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2008-12-10 16:47:39 UTC (rev 11287) +++ allegro/branches/4.9/src/tls.c 2008-12-11 12:31:08 UTC (rev 11288) @@ -608,44 +608,46 @@ * * Sets the function to use for blending for the current thread. * - * Blending means, the source and destination colors are combined in drawing - * operations. + * Blending means, the source and destination colors are combined in + * drawing operations. * - * Assume, the source color (e.g. color of a rectangle to draw, or pixel of a - * bitmap to draw), is given as its red/green/blue/alpha components: - * sr, sg, sb, sa + * Assume, the source color (e.g. color of a rectangle to draw, or pixel + * of a bitmap to draw), is given as its red/green/blue/alpha + * components (if the bitmap has no alpha, it always is assumed to be + * fully opaque, so 255 for 8-bit or 1.0 for floating point): + * *sr, sg, sb, sa*. * And this color is drawn to a destination, which already has a color: - * dr, dg, db, da + * *dr, dg, db, da*. * - * The conceptional formula used by Allegro to draw any pixel then is: + * Blending formula: + * The conceptional formula used by Allegro to draw any pixel then is + * > r = dr * dst + sr * src + * > g = dg * dst + sg * src + * > b = db * dst + sb * src + * > a = da * dst + sa * src + * + * Blending functions: + * Valid values for <src> and <dst> passed to this function are + * ALLEGRO_ZERO - src, dst = 0 + * ALLEGRO_ONE - src, dst = 1 + * ALLEGRO_ALPHA - src, dst = sa + * ALLEGRO_INVERSE_ALPHA - src, dst = 1 - sa + * + * The color parameter specified the blend color, it is multipled with + * the source color before the above blending operation. * - * > r = dr * dst + sr * src * color.r - * > g = dg * dst + sg * src * color.g - * > b = db * dst + sb * src * color.b - * > a = da * dst + sa * src * color.a - * - * The src, dst and color values are specified by this function. - * Valid values for src and dst are: - * - * ALLEGRO_ZERO - src = 0 / dst = 0 - * ALLEGRO_ONE - src = 1 / dst = 1 - * ALLEGRO_ALPHA - src = sa / dst = sa - * ALLEGRO_INVERSE_ALPHA - src = (1 - sa) / dst = (1 - sa) - * - * So for example, to restore the default of using alpha blending, you would - * use (pseudo code): + * Blending examples: + * So for example, to restore the default of using alpha blending, you + * would use (pseudo code) * > al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, {1, 1, 1, 1}) - * This means, the color is not modified, all source components are - * multipled with the alpha component and combined with the destination - * according to this same alpha value. * - * If you want to tint the result to some specific color, you can also - * change the color from white to some other color. + * If in addition you want to draw half transparently + * > al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, {1, 1, 1, 0.5}) * - * Additive blending would be achieved with: + * Additive blending would be achieved with * > al_set_blender(ALLEGRO_ONE, ALLEGRO_ONE, {1, 1, 1, 1}) * - * Copying the source to the destination (including alpha) unmodified: + * Copying the source to the destination (including alpha) unmodified * > al_set_blender(ALLEGRO_ONE, ALLEGRO_ZERO, {1, 1, 1, 1}) * */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <el...@us...> - 2008-12-12 12:50:04
|
Revision: 11292 http://alleg.svn.sourceforge.net/alleg/?rev=11292&view=rev Author: elias Date: 2008-12-12 12:49:55 +0000 (Fri, 12 Dec 2008) Log Message: ----------- naturaldocs comment formatting fix Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2008-12-12 05:16:59 UTC (rev 11291) +++ allegro/branches/4.9/src/tls.c 2008-12-12 12:49:55 UTC (rev 11292) @@ -628,6 +628,7 @@ * * Blending functions: * Valid values for <src> and <dst> passed to this function are + * * ALLEGRO_ZERO - src, dst = 0 * ALLEGRO_ONE - src, dst = 1 * ALLEGRO_ALPHA - src, dst = sa This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <el...@us...> - 2008-12-30 13:15:36
|
Revision: 11371 http://alleg.svn.sourceforge.net/alleg/?rev=11371&view=rev Author: elias Date: 2008-12-30 13:15:33 +0000 (Tue, 30 Dec 2008) Log Message: ----------- If this #if was supposed to do what I think it was, then it didn't quite work. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2008-12-30 13:12:38 UTC (rev 11370) +++ allegro/branches/4.9/src/tls.c 2008-12-30 13:15:33 UTC (rev 11371) @@ -58,10 +58,10 @@ } thread_local_state; -#if defined ALLEGRO_MINGW32 && (__GNUC__ < 4 || __GNUC_MINOR__ < 2 \ - || __GNUC_PATCHLEVEL__ < 1) +#if defined ALLEGRO_MINGW32 && ( \ + __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) || \ + (__GNUC__ == 4 && __GNUC_MINOR == 2 && __GNUC_PATCHLEVEL__ < 1)) - /* * MinGW doesn't have builtin thread local storage, so we * must use the Windows API. This means that the MinGW This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tj...@us...> - 2009-03-22 21:57:51
|
Revision: 11928 http://alleg.svn.sourceforge.net/alleg/?rev=11928&view=rev Author: tjaden Date: 2009-03-22 21:57:48 +0000 (Sun, 22 Mar 2009) Log Message: ----------- A static variable in tls_get() needed to be thread-local. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2009-03-22 17:46:18 UTC (rev 11927) +++ allegro/branches/4.9/src/tls.c 2009-03-22 21:57:48 UTC (rev 11928) @@ -226,7 +226,7 @@ #ifdef HAVE_NATIVE_TLS static thread_local_state *tls_get(void) { - static thread_local_state *ptr = NULL; + static THREAD_LOCAL thread_local_state *ptr = NULL; if (!ptr) { ptr = &_tls; _al_fill_display_settings(&ptr->new_display_settings); @@ -245,6 +245,7 @@ thread_local_state *tls; if ((tls = tls_get()) == NULL) return; + /* Isn't it true that &tls->new_display_settings == settings? */ memcpy(&tls->new_display_settings, settings, sizeof(ALLEGRO_EXTRA_DISPLAY_SETTINGS)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eg...@us...> - 2009-04-19 21:30:21
|
Revision: 12101 http://alleg.svn.sourceforge.net/alleg/?rev=12101&view=rev Author: eglebbk Date: 2009-04-19 21:30:05 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Work around problems associated with thread local storage and the file I/O module: it's possible that TLS has not been initialised when Allegro loads its config files from disk. This code is a bit weird in that (on OS X) tls_get() does *not* return NULL in this case, but tls->new_file_interface *is* NULL and it tries to work around that. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2009-04-19 18:45:00 UTC (rev 12100) +++ allegro/branches/4.9/src/tls.c 2009-04-19 21:30:05 UTC (rev 12101) @@ -717,14 +717,26 @@ /* Function: al_get_new_file_interface + * FIXME: added a work-around for the situation where TLS has not yet been + * initialised when this function is called. This may happen if Allegro + * tries to load a configuration file before the system has been + * initialised. Should probably rethink the logic here... */ const ALLEGRO_FILE_INTERFACE *al_get_new_file_interface(void) { thread_local_state *tls; if ((tls = tls_get()) == NULL) - return NULL; - return tls->new_file_interface; + return &_al_file_interface_stdio; + + /* FIXME: this situation should never arise because tls_ has the stdio + * interface set as a default, but it arises on OS X if + * pthread_getspecific() is called before osx_thread_init()... + */ + if (tls->new_file_interface) + return tls->new_file_interface; + else + return &_al_file_interface_stdio; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Peter W. <nov...@gm...> - 2009-04-19 23:41:06
|
On 2009-04-19, eg...@us... <eg...@us...> wrote: > Revision: 12101 > http://alleg.svn.sourceforge.net/alleg/?rev=12101&view=rev > Author: eglebbk > Date: 2009-04-19 21:30:05 +0000 (Sun, 19 Apr 2009) > > Log Message: > ----------- > Work around problems associated with thread local storage and the file I/O > module: it's possible that TLS has not been initialised when Allegro loads > its config files from disk. > This code is a bit weird in that (on OS X) tls_get() does *not* return NULL > in this case, but tls->new_file_interface *is* NULL and it tries to work > around that. The workaround is fine. Another (cleaner?) way would be to check for al_get_new_file_interface() returning NULL in al_fopen() and use the stdio driver explicitly there. You might consider calling _al_osx_threads_init() earlier (currently at system driver initialisation). al_set_errno() is thread-specific as well, so that probably is being ignored while Allegro starts up, which could be a problem if someone then checked with al_get_errno(). Peter |
From: <tj...@us...> - 2010-03-03 03:06:21
|
Revision: 13019 http://alleg.svn.sourceforge.net/alleg/?rev=13019&view=rev Author: tjaden Date: 2010-03-03 03:06:15 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Avoid a warning about ?\226?\128?\152__al_debug_channel?\226?\128?\153 not defined on platforms which have native TLS. The single ALLEGRO_DEBUG call that was there didn't seem that helpful anyway. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2010-03-02 22:31:30 UTC (rev 13018) +++ allegro/branches/4.9/src/tls.c 2010-03-03 03:06:15 UTC (rev 13019) @@ -33,8 +33,6 @@ #include "allegro5/internal/aintern_memory.h" #include "allegro5/internal/aintern_fshook.h" -ALLEGRO_DEBUG_CHANNEL("TLS"); - /* Thread local storage for graphics API state */ typedef struct thread_local_state { /* Display parameters */ @@ -183,7 +181,6 @@ void _al_pthreads_tls_init(void) { pthread_key_create(&tls_key, pthreads_thread_destroy); - ALLEGRO_DEBUG("Created TLS key %d\n", (int)tls_key); } static thread_local_state _tls; @@ -193,7 +190,6 @@ /* Allocate and copy the 'template' object */ thread_local_state* ptr = (thread_local_state*)_AL_MALLOC(sizeof(thread_local_state)); memcpy(ptr, &_tls, sizeof(thread_local_state)); - //ALLEGRO_DEBUG("Set specific %p for key %d\n", ptr, (int)tls_key); pthread_setspecific(tls_key, ptr); return ptr; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <el...@us...> - 2010-03-04 21:33:28
|
Revision: 13029 http://alleg.svn.sourceforge.net/alleg/?rev=13029&view=rev Author: elias Date: 2010-03-04 21:33:21 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Eh, how did that happen... broke OSX compile with a weird stray paste. Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2010-03-04 20:24:42 UTC (rev 13028) +++ allegro/branches/4.9/src/tls.c 2010-03-04 21:33:21 UTC (rev 13029) @@ -239,10 +239,8 @@ #endif /* end not defined ALLEGRO_MINGW32 */ -#ifdef ALLEGRO_CFG_PTHREADS_TLS - _al_pthreads_tls_init(); -#endif + void _al_set_new_display_settings(ALLEGRO_EXTRA_DISPLAY_SETTINGS *settings) { thread_local_state *tls; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tr...@us...> - 2010-04-16 01:04:00
|
Revision: 13263 http://alleg.svn.sourceforge.net/alleg/?rev=13263&view=rev Author: trentg Date: 2010-04-16 01:03:54 +0000 (Fri, 16 Apr 2010) Log Message: ----------- Missing understores in __GNUC_MINOR__ Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2010-04-15 22:45:47 UTC (rev 13262) +++ allegro/branches/4.9/src/tls.c 2010-04-16 01:03:54 UTC (rev 13263) @@ -90,7 +90,7 @@ #if (defined ALLEGRO_MINGW32 && ( \ __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) || \ - (__GNUC__ == 4 && __GNUC_MINOR == 2 && __GNUC_PATCHLEVEL__ < 1))) || \ + (__GNUC__ == 4 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ < 1))) || \ defined ALLEGRO_CFG_DLL_TLS /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tr...@us...> - 2010-06-21 02:17:27
|
Revision: 13386 http://alleg.svn.sourceforge.net/alleg/?rev=13386&view=rev Author: trentg Date: 2010-06-21 02:17:21 +0000 (Mon, 21 Jun 2010) Log Message: ----------- Correct some comments Modified Paths: -------------- allegro/branches/4.9/src/tls.c Modified: allegro/branches/4.9/src/tls.c =================================================================== --- allegro/branches/4.9/src/tls.c 2010-06-21 01:22:34 UTC (rev 13385) +++ allegro/branches/4.9/src/tls.c 2010-06-21 02:17:21 UTC (rev 13386) @@ -166,7 +166,7 @@ } -#else /* not defined ALLEGRO_MINGW32 */ +#else /* not MinGW < 4.2.1 */ #if defined(ALLEGRO_MSVC) || defined(ALLEGRO_BCC32) @@ -236,7 +236,7 @@ #endif /* end HAVE_NATIVE_TLS */ -#endif /* end not defined ALLEGRO_MINGW32 */ +#endif /* end not MinGW < 4.2,1 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |