From: <Sie...@us...> - 2009-02-06 02:05:40
|
Revision: 11553 http://alleg.svn.sourceforge.net/alleg/?rev=11553&view=rev Author: SiegeLord Date: 2009-02-06 02:05:36 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Altered high level primitives caching mechanism Modified Paths: -------------- allegro/branches/4.9/addons/primitives/high_primitives.c Modified: allegro/branches/4.9/addons/primitives/high_primitives.c =================================================================== --- allegro/branches/4.9/addons/primitives/high_primitives.c 2009-02-06 01:50:00 UTC (rev 11552) +++ allegro/branches/4.9/addons/primitives/high_primitives.c 2009-02-06 02:05:36 UTC (rev 11553) @@ -42,15 +42,24 @@ static ALLEGRO_VBUFFER* cache_buffer; static float* cache_point_buffer; +static int cache_point_size; static void verify_cache(void) { if (!cache_buffer) { cache_buffer = al_create_vbuff(ALLEGRO_VBUFF_CACHE_SIZE, ALLEGRO_VBUFFER_SOFT | ALLEGRO_VBUFFER_WRITE | ALLEGRO_VBUFFER_READ); - cache_point_buffer = malloc(2 * sizeof(float) * ALLEGRO_VBUFF_CACHE_SIZE); } } +static void update_point_cache(int size) +{ + if(size >= cache_point_size) { + free(cache_point_buffer); + cache_point_buffer = malloc(2 * sizeof(float) * size); + cache_point_size = size; + } +} + /* Function: al_draw_line_ex */ void al_draw_line_ex(float x1, float y1, float x2, float y2, @@ -514,6 +523,7 @@ ASSERT(vbuff); ASSERT(points); + update_point_cache(num_segments); dt = 1.0 / (num_segments - 1); dt2 = (dt * dt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |