Example #1
0
static void
redraw_handler(struct widget *widget, void *data)
{
	struct demoapp *app = data;
	cairo_t *cr;
	struct rectangle allocation;
	uint32_t time;

	widget_get_allocation(app->widget, &allocation);

	cr = widget_cairo_create(widget);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_rectangle(cr,
			allocation.x,
			allocation.y,
			allocation.width,
			allocation.height);
	cairo_set_source_rgba(cr, 0, 0.8, 0, 0.8);
	cairo_fill(cr);

	time = widget_get_last_time(widget);
	cairo_set_source_rgba(cr, 0.5, 1.0, 0.5, 1.0);
	draw_spinner(cr, &allocation, time);

	cairo_destroy(cr);

	DBG("%dx%d @ %d,%d, last time %u\n",
	    allocation.width, allocation.height,
	    allocation.x, allocation.y, time);
}
Example #2
0
static void
sub_redraw_handler(struct widget *widget, void *data)
{
	struct demoapp *app = data;
	cairo_t *cr;
	struct rectangle allocation;
	uint32_t time;

	widget_get_allocation(app->subsurface, &allocation);

	cr = widget_cairo_create(widget);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);

	/* debug: paint whole surface magenta; no magenta should show */
	cairo_set_source_rgba(cr, 0.9, 0.0, 0.9, 1.0);
	cairo_paint(cr);

	cairo_rectangle(cr,
			allocation.x,
			allocation.y,
			allocation.width,
			allocation.height);
	cairo_clip(cr);

	cairo_set_source_rgba(cr, 0.8, 0, 0, 0.8);
	cairo_paint(cr);

	time = widget_get_last_time(widget);
	cairo_set_source_rgba(cr, 1.0, 0.5, 0.5, 1.0);
	draw_spinner(cr, &allocation, time);

	cairo_destroy(cr);

	if (app->animate)
		widget_schedule_redraw(app->subsurface);
	DBG("%dx%d @ %d,%d, last time %u\n",
	    allocation.width, allocation.height,
	    allocation.x, allocation.y, time);
}
Example #3
0
static void
redraw_handler(struct widget *widget, void *data)
{
	struct smoke *smoke = data;
	uint32_t time = widget_get_last_time(smoke->widget);
	cairo_surface_t *surface;

	diffuse(smoke, time / 30, smoke->b[0].u, smoke->b[1].u);
	diffuse(smoke, time / 30, smoke->b[0].v, smoke->b[1].v);
	project(smoke, time / 30,
		smoke->b[1].u, smoke->b[1].v,
		smoke->b[0].u, smoke->b[0].v);
	advect(smoke, time / 30,
	       smoke->b[1].u, smoke->b[1].v,
	       smoke->b[1].u, smoke->b[0].u);
	advect(smoke, time / 30,
	       smoke->b[1].u, smoke->b[1].v,
	       smoke->b[1].v, smoke->b[0].v);
	project(smoke, time / 30,
		smoke->b[0].u, smoke->b[0].v,
		smoke->b[1].u, smoke->b[1].v);

	diffuse(smoke, time / 30, smoke->b[0].d, smoke->b[1].d);
	advect(smoke, time / 30,
	       smoke->b[0].u, smoke->b[0].v,
	       smoke->b[1].d, smoke->b[0].d);

	surface = window_get_surface(smoke->window);

	render(smoke, surface);

	window_damage(smoke->window, 0, 0, smoke->width, smoke->height);

	cairo_surface_destroy(surface);

	widget_schedule_redraw(smoke->widget);
}