Beispiel #1
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    cairo_surface_t *surface;

    surface = create_source_surface (SOURCE_SIZE);
    if (surface == NULL) /* can't create the source so skip the test */
	return CAIRO_TEST_UNTESTED;

    cairo_surface_destroy (surface);

    return CAIRO_TEST_SUCCESS;
}
Beispiel #2
0
void do_draw(void *ptr)
{
    int width, height;

	rendering=TRUE;
	gdk_drawable_get_size(pixmap, &width, &height);
	//create a gtk-independant surface to draw on
    cairo_surface_t *cst = create_source_surface(width, height);
	//cairo_surface_t* cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
    cairo_t *cr = cairo_create(cst);
	
	//cr = cairo_create(window_surface);
	cairo_status_t status;
	status=cairo_status(cr);
	if(status)
		return;
	
	cairo_save(cr);
	cairo_set_source_rgb(cr, 1, 1, 1);
	cairo_paint(cr);
	cairo_restore(cr);
	
	cairo_save(cr);
	cairo_set_source_rgb(cr, 0, .5, 0.2);
	cairo_set_line_width (cr, 0.5);
	cairo_set_antialias(cr, CAIRO_ANTIALIAS_SUBPIXEL);
//	cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OUT);
	for(int j=0;j<20;j++)
	{
		for(int i=0; i<100; i++)
		{
			cairo_line_to(cr, rand()%width, rand()%height);
		}
	}
	cairo_stroke(cr);
	cairo_restore(cr);
	cairo_destroy(cr);
	
	cairo_t *cr_pixmap = gdk_cairo_create(pixmap);
    cairo_set_source_surface (cr_pixmap, cst, 0, 0);
    cairo_paint(cr_pixmap);
    cairo_destroy(cr_pixmap);

	rendering=FALSE;

}
Beispiel #3
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_t *surface;
    cairo_surface_t *similar;
    cairo_t *cr2;

    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_paint (cr);

    surface = create_source_surface (SOURCE_SIZE);
    if (surface == NULL) /* can't create the source so skip the test */
	return CAIRO_TEST_UNTESTED;

    draw_pattern (&surface, SOURCE_SIZE);

    /* copy a subregion to a smaller intermediate surface */
    similar = cairo_surface_create_similar (surface,
					    CAIRO_CONTENT_COLOR_ALPHA,
					    INTER_SIZE, INTER_SIZE);
    cr2 = cairo_create (similar);
    cairo_surface_destroy (similar);
    cairo_set_source_surface (cr2, surface,
			      (INTER_SIZE - SOURCE_SIZE)/2,
			      (INTER_SIZE - SOURCE_SIZE)/2);
    cairo_paint (cr2);

    /* and then paint onto a small surface for checking */
    cairo_set_source_surface (cr, cairo_get_target (cr2),
			      (width - INTER_SIZE)/2,
			      (height - INTER_SIZE)/2);
    cairo_destroy (cr2);
    cairo_rectangle (cr, 16, 16, 64, 64);
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
    cairo_fill (cr);

    /* destroy the surface last, as this triggers XCloseDisplay */
    cairo_surface_destroy (surface);

    return CAIRO_TEST_SUCCESS;
}