All pastes #296756 Raw Edit

Stuff

public c v1 · immutable
#296756 ·published 2006-12-30 14:57 UTC
rendered paste body
/* * groupClearCairoContext * */void groupClearCairoContext(GroupCairoContext *cc){	cairo_t *cr = cc->cairo;	cairo_save(cr);	cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);	cairo_paint(cr);	cairo_restore(cr);}/* * groupDestroyCairoContext * */static voidgroupDestroyCairoContext(GroupSelection *group, CompScreen *s){	GroupTabBar *bar = group->tabBar;	GroupCairoContext *cc = bar->cc;	if (cc->cairo)		cairo_destroy(cc->cairo);	if (cc->surface)		cairo_surface_destroy(cc->surface);	if (cc->texBuf)		free(cc->texBuf);	if (&cc->texture)		finiTexture(s, &cc->texture);	free(cc);}/* * groupCreateCairoContext * */void groupCreateCairoContext(GroupSelection *group, CompScreen *s){	GroupTabBar *bar = group->tabBar;	GroupCairoContext *cc = (GroupCairoContext*) malloc(sizeof(GroupCairoContext));	cc->surface	= NULL;	cc->cairo	= NULL;	cc->texBuf  = NULL;	int w, h;	// thats the width & height of the texture we need	w = group->tabBar->region->extents.x2 - group->tabBar->region->extents.x1;	h = group->tabBar->region->extents.y2 - group->tabBar->region->extents.y1;		// that a beryl intern function which initializes a CompTexture struct	initTexture(s, &cc->texture);	// that our image	cc->texBuf = calloc (4 * w * h, sizeof (unsigned char));	// here we convert it to CompTexture	imageToTexture(s, &cc->texture, cc->texBuf, w, h);	// creating the surface for cairo	cc->surface = cairo_image_surface_create_for_data (cc->texBuf, CAIRO_FORMAT_ARGB32, w, h, 4 * w);	if (cairo_surface_status(cc->surface) != CAIRO_STATUS_SUCCESS)	{		free(cc->texBuf);		finiTexture(s, &cc->texture);        printf ("create_cairo_context() - Couldn't create surface\n");        return;	}	// creating the cairo handler	cc->cairo = cairo_create(cc->surface);	if (cairo_status(cc->cairo) != CAIRO_STATUS_SUCCESS)	{		free(cc->texBuf);		finiTexture(s, &cc->texture);        printf ("create_cairo_context() - Couldn't create context\n");        return;	}	// clean the context	groupClearCairoContext(cc);	bar->cc = cc;}