draw_region = pixman_region_create (); if (draw_region == NULL) { status = CAIRO_STATUS_NO_MEMORY; goto BAIL0; }  _cairo_traps_extents (traps, &extents);
_cairo_rectangle_intersect (&extents, &gstate->clip.rect);
_cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,					     cairo_pattern_t *src,					     cairo_operator_t operator,					     cairo_surface_t *dst,					     cairo_traps_t *traps){    cairo_status_t status;    cairo_pattern_t pattern;    cairo_box_t extents;    int x_src, y_src;    if (traps->num_traps == 0)	return CAIRO_STATUS_SUCCESS;    if (gstate->clip.surface) {	cairo_fixed_t xoff, yoff;	cairo_trapezoid_t *t;	int i;	cairo_surface_t *intermediate;	cairo_color_t empty_color;	pixman_box16_t *draw_extents;	pixman_region16_t *draw_region;	draw_region = pixman_region_create ();	if (draw_region == NULL)	{	    status = CAIRO_STATUS_NO_MEMORY;	    goto BAIL0;	}		_cairo_traps_extents (traps, &extents);	status = _calculate_region_for_intermediate_clip_surface (draw_region,								  &extents,								  &gstate->clip);	if (status)	    goto BAIL1;	/* Shortcut if empty */	if (!pixman_region_not_empty (draw_region)) {	    status = CAIRO_STATUS_SUCCESS;	    goto BAIL1;	}		draw_extents = pixman_region_extents (draw_region);	/* Ugh. The cairo_composite/(Render) interface doesn't allow           an offset for the trapezoids. Need to manually shift all           the coordinates to align with the offset origin of the	   intermediate surface. */	xoff = _cairo_fixed_from_int (draw_extents->x1);	yoff = _cairo_fixed_from_int (draw_extents->y1);	for (i=0, t=traps->traps; i < traps->num_traps; i++, t++) {	    t->top -= yoff;	    t->bottom -= yoff;	    t->left.p1.x -= xoff;	    t->left.p1.y -= yoff;	    t->left.p2.x -= xoff;	    t->left.p2.y -= yoff;	    t->right.p1.x -= xoff;	    t->right.p1.y -= yoff;	    t->right.p2.x -= xoff;	    t->right.p2.y -= yoff;	}	if (traps->traps[0].left.p1.y < traps->traps[0].left.p2.y) {	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p1.x);	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p1.y);	} else {	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p2.x);	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p2.y);	}	_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);	_cairo_pattern_set_alpha (&pattern, 1.0);	status = _cairo_gstate_create_pattern (gstate, &pattern, &extents);	if (status)	    goto BAIL1;	_cairo_color_init (&empty_color);	_cairo_color_set_alpha (&empty_color, 0.);	intermediate = _cairo_surface_create_similar_solid (gstate->clip.surface,							    CAIRO_FORMAT_A8,							    draw_extents->x2 - draw_extents->x1,							    draw_extents->y2 - draw_extents->y1,							    &empty_color);    	if (intermediate == NULL) {	    status = CAIRO_STATUS_NO_MEMORY;	    goto BAIL2;	}		status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,						      pattern.source, intermediate,						      x_src,						      y_src,						      traps->traps,						      traps->num_traps);	if (status)	    goto BAIL3;	status = _cairo_surface_composite (CAIRO_OPERATOR_IN,					   gstate->clip.surface,					   NULL,					   intermediate,					   draw_extents->x1 - gstate->clip.x,					   draw_extents->y1 - gstate->clip.y, 					   0, 0,					   0, 0,					   draw_extents->x2 - draw_extents->x1,					   draw_extents->y2 - draw_extents->y1);	if (status)	    goto BAIL3;    	_cairo_pattern_fini (&pattern);    	_cairo_pattern_init_copy (&pattern, src);    	extents.p1.x = _cairo_fixed_from_int (draw_extents->x1);	extents.p1.y = _cairo_fixed_from_int (draw_extents->y1);	extents.p2.x = _cairo_fixed_from_int (draw_extents->x2);	extents.p2.y = _cairo_fixed_from_int (draw_extents->y2);	status = _cairo_gstate_create_pattern (gstate, &pattern, &extents);	if (status)	    goto BAIL3;	if (dst == gstate->clip.surface)	    xoff = yoff = 0;		status = _cairo_surface_composite (operator,					   pattern.source, intermediate, dst,					   0, 0,					   0, 0,					   xoff >> 16,					   yoff >> 16,					   draw_extents->x2 - draw_extents->x1,					   draw_extents->y2 - draw_extents->y1);	    BAIL3:	cairo_surface_destroy (intermediate);    BAIL2:	_cairo_pattern_fini (&pattern);    BAIL1:	pixman_region_destroy (draw_region);    BAIL0:	if (status)	    return status;	    } else {	if (traps->traps[0].left.p1.y < traps->traps[0].left.p2.y) {	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p1.x);	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p1.y);	} else {	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p2.x);	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p2.y);	}	_cairo_pattern_init_copy (&pattern, src);		_cairo_traps_extents (traps, &extents);	status = _cairo_gstate_create_pattern (gstate, &pattern, &extents);	if (status)	    return status;	status = _cairo_surface_composite_trapezoids (gstate->operator,						      pattern.source, dst,						      x_src - pattern.source_offset.x,						      y_src - pattern.source_offset.y,						      traps->traps,						      traps->num_traps);	_cairo_pattern_fini (&pattern);    	if (status)	    return status;    }        return CAIRO_STATUS_SUCCESS;}