Ejemplo n.º 1
0
static cairo_int_status_t
_scissor_and_clip (cairo_gl_context_t		*ctx,
		   cairo_gl_composite_t		*setup,
		   cairo_composite_rectangles_t	*composite,
		   cairo_bool_t			*used_stencil_buffer)
{
    cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface;
    cairo_rectangle_int_t *bounds = &composite->unbounded;
    cairo_clip_t *clip = composite->clip;
    cairo_rectangle_int_t r;

    *used_stencil_buffer = FALSE;

    if (_cairo_composite_rectangles_can_reduce_clip (composite, clip)) {
	_scissor_to_rectangle (dst, bounds);
	return CAIRO_INT_STATUS_SUCCESS;
    }

    /* If we cannot reduce the clip to a rectangular region,
       we scissor and clip using the stencil buffer */
    if (clip->num_boxes > 1 || clip->path != NULL) {
	*used_stencil_buffer = TRUE;
	_scissor_to_rectangle (dst, bounds);
	return _draw_clip_to_stencil_buffer (ctx, setup, clip);
    }

    /* Always interpret the clip path as ANTIALIAS_NONE */
    _cairo_box_round_to_rectangle (clip->boxes, &r);
    _scissor_to_rectangle (dst, &r);
    return CAIRO_INT_STATUS_SUCCESS;
}
Ejemplo n.º 2
0
static void
_cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx,
						     unsigned int count)
{
    int i, num_rectangles;

    if (!ctx->clip_region) {
	_cairo_gl_composite_draw_triangles (ctx, count);
	return;
    }

    num_rectangles = cairo_region_num_rectangles (ctx->clip_region);
    for (i = 0; i < num_rectangles; i++) {
	cairo_rectangle_int_t rect;

	cairo_region_get_rectangle (ctx->clip_region, i, &rect);

	_scissor_to_rectangle (ctx->current_target, &rect);
	_cairo_gl_composite_draw_triangles (ctx, count);
    }
}