[Japanese]
SDL_BlitPool Library




Blit pool (static) library for the SDL.
This remove overlapped area and divide the back surface blit operation.
According to circumstances does very fast blit operation.
This is written in plain ANSI-C.



Download SDL_BlitPool Release 2 (194KB: 04/Apr/2005)
(add BlitPool_Optimize, BlitPool_GetArea, BlitPool_PostByDescription)

SDL_BlitPool Release 1 (117KB: 21/Mar/2005)


Copyright (C) 2005 strangebug, Licensed under the LGPL.



example: Planet

Big 20 balls(planets) surface drawing.
Optimize 12 fps -> 28-72 fps.



flow:
1. Create a pool object. (BlitPool_CreatePool, BlitPool_SetAllocator)
2. Post the blit/fill operations. (BlitPool_PostSurface, BlitPool_PostPool, BlitPool_PostByDescription)
3. Optimize and execute blit. (BlitPool_Optimize, BlitPool_Execute)
4. Get update rectangles and do update. (BlitPool_InitUpdateRects, BlitPool_GetUpdateRects, )
5. Delete a pool object. (BlitPool_DeletePool, (BlitPool_Release))



technique: Separate the Opaque/Transparent (use BlitPool_PostPool)

Divide the Opaque/Transparent rectangle.
It's post to pool and commit pool after.
see BlitPool_PostByDescription in sample [planet.c].
BlitPool_PostByDescription(
	g.PlanetPool,
	p->PlanetSurface,
	"pos=(0,0):"
	"T:(29,0)-(170,200):"	/*	transparent height belt	*/
	"T:(0,29)-(200,170):"	/*	transparent width belt	*/
	"O:(29,29)-(170,170):"	/*	opaque square	*/
);

BlitPool_Optimize(g.PlanetPool, BLIT_OPT_REMOVEOVERLAP);	/*	delete back operation 	*/



technique: Use original allocator
It's like:
static unsigned char g_buf[1024 * 256];
static unsigned char *g_p;
#define InitAllocator()	g_p = g_buf

static void *Allocator(unsigned long nbyte)
{
	return (void *)((g_p += nbyte) - nbyte);
}
static void Releaser(void *p)
{
	/*	Do Nothing	*/;
}
and
BlitPool_SetAllocator(pool, Allocator, Releaser);
InitAllocator();



technique: disable optimize to mini rectangle blit
if (optimize_cost > blit_cost) then use BLIT_EXEC_NO_OPTIMIZE flag.
example:
BlitPool_PostSurface(
	pool,
	Bullet[angle],		/*	little surface	*/
	NULL,
	&BulletPosition[i],
	BLIT_ALPHA_TRANSPARENT | BLIT_EXEC_NO_OPTIMIZE		/*	<-	*/
);






last update: 5/Apr/2005
Blog (JP)