Esempio n. 1
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_t *target_surface;
    cairo_t *cr2, *cr3;

    target_surface = cairo_get_group_target (cr);

    cr2 = cairo_create (target_surface);

    /* Draw a diagonal line and clip to it */

    cairo_move_to (cr2, BORDER,                     BORDER);
    cairo_line_to (cr2, BORDER + LINE_WIDTH,        BORDER);
    cairo_line_to (cr2, SIZE - BORDER,              SIZE - BORDER);
    cairo_line_to (cr2, SIZE - BORDER - LINE_WIDTH, SIZE - BORDER);

    cairo_clip (cr2);
    cairo_set_source_rgb (cr2, 0, 0, 1); /* Blue */
    cairo_paint (cr2);

    /* Clipping affects this cairo_t */

    cairo_set_source_rgb (cr2, 1, 1, 1); /* White */
    cairo_rectangle (cr2,
		     SIZE / 2 - LINE_WIDTH / 2, BORDER,
		     LINE_WIDTH,                SIZE - 2 * BORDER);
    cairo_fill (cr2);

    /* But doesn't affect another cairo_t that we create temporarily for
     * the same surface
     */
    cr3 = cairo_create (target_surface);
    cairo_set_source_rgb (cr3, 1, 1, 1); /* White */
    cairo_rectangle (cr3,
		     SIZE - BORDER - LINE_WIDTH, BORDER,
		     LINE_WIDTH,                 SIZE - 2 * BORDER);
    cairo_fill (cr3);

    _propagate_status (cr, cr3);
    cairo_destroy (cr3);

    _propagate_status (cr, cr2);
    cairo_destroy (cr2);

    /* And doesn't affect anything after this cairo_t is destroyed */

    cairo_set_source_rgb (cr, 1, 1, 1); /* White */
    cairo_rectangle (cr,
		     BORDER,     BORDER,
		     LINE_WIDTH, SIZE - 2 * BORDER);
    cairo_fill (cr);

    return CAIRO_TEST_SUCCESS;

}
Esempio n. 2
0
static void
use_similar (cairo_t *cr,
	    double red,
	    double green,
	    double blue)
{
    cairo_t *cr2;

    if (cairo_status (cr))
	return;

    cr2 = _cairo_create_similar (cr, 1, 1);

    _draw (cr2, red, green, blue);

    _propagate_status (cr, cr2);
    cairo_destroy (cr2);
}
Esempio n. 3
0
static void
use_image (cairo_t *cr,
	   cairo_format_t format,
	   double red,
	   double green,
	   double blue)
{
    cairo_t *cr2;

    if (cairo_status (cr))
	return;

    cr2 = _cairo_create_image (cr, format, 1, 1);

    _draw (cr2, red, green, blue);

    _propagate_status (cr, cr2);
    cairo_destroy (cr2);
}