Beispiel #1
0
static int _gfx_mesh_expand_buckets(

		GFX_Mesh*     mesh,
		unsigned int  level)
{
	size_t size = _gfx_mesh_bucket_size((GFXMesh*)mesh, UINT_MAX);
	size_t total = gfx_vector_get_size(&mesh->buckets);

	/* First reserve some memory */
	/* Size cannot be zero, so no worries */
	if(!gfx_vector_reserve(
		&mesh->buckets,
		total + (total / size) * sizeof(GFXBucketSource)))
	{
		return 0;
	}

	/* Append an empty source to all buckets */
	GFXBucketSource insert = 0;
	size_t ind = _gfx_mesh_bucket_size((GFXMesh*)mesh, level + 1);

	while(total)
	{
		total -= size;
		gfx_vector_insert_range_at(
			&mesh->buckets,
			sizeof(GFXBucketSource),
			&insert,
			total + ind
		);
	}

	return 1;
}
Beispiel #2
0
static size_t _gfx_x11_init_modes(

		Screen*              scr,
		XRRScreenResources*  res)
{
	/* Split depth */
	GFXColorDepth depth;
	_gfx_split_depth(
		XDefaultDepthOfScreen(scr),
		&depth.redBits,
		&depth.greenBits,
		&depth.blueBits
	);

	/* Reserve space for all modes */
	size_t first = gfx_vector_get_size(&_gfx_x11.modes);
	gfx_vector_reserve(&_gfx_x11.modes, first + res->nmode);

	unsigned int i;
	for(i = 0; i < res->nmode; ++i)
	{
		/* Skip refresh rate of zero */
		unsigned int refresh = 0;
		if(res->modes[i].hTotal && res->modes[i].vTotal)
		{
			refresh =
				(unsigned int)lround((double)res->modes[i].dotClock /
				((double)res->modes[i].hTotal * (double)res->modes[i].vTotal));
		}

		if(refresh)
		{
			/* Create new mode */
			GFX_X11_Mode mode;
			mode.id           = res->modes[i].id;
			mode.mode.width   = res->modes[i].width;
			mode.mode.height  = res->modes[i].height;
			mode.mode.depth   = depth;
			mode.mode.refresh = refresh;

			gfx_vector_insert(&_gfx_x11.modes, &mode, _gfx_x11.modes.end);
		}
	}

	return first;
}