static cairo_int_status_t
_cairo_win32_display_surface_unmap_image (void                    *abstract_surface,
					  cairo_image_surface_t   *image)
{
    cairo_win32_display_surface_t *surface = abstract_surface;

    /* Delay the download until the next flush, which means we also need
     * to make sure our sources rare flushed.
     */
    TRACE ((stderr, "%s (surface=%d)\n",
	    __FUNCTION__, to_win32_surface(surface)->base.unique_id));

    if (surface->fallback) {
	cairo_rectangle_int_t r;

	r.x = image->base.device_transform_inverse.x0;
	r.y = image->base.device_transform_inverse.y0;
	r.width  = image->width;
	r.height = image->height;

	TRACE ((stderr, "%s: adding damage (%d,%d)x(%d,%d)\n",
		__FUNCTION__, r.x, r.y, r.width, r.height));
	surface->fallback->damage =
	    _cairo_damage_add_rectangle (surface->fallback->damage, &r);
	surface = to_win32_display_surface (surface->fallback);
    }

    return _cairo_surface_unmap_image (surface->image, image);
}
static cairo_int_status_t
_cairo_surface_subsurface_unmap_image (void *abstract_surface,
				       cairo_image_surface_t *image)
{
    cairo_surface_subsurface_t *surface = abstract_surface;
    return _cairo_surface_unmap_image (surface->target, image);
}
static cairo_int_status_t
_cairo_fallback_compositor_stroke (const cairo_compositor_t	*_compositor,
				   cairo_composite_rectangles_t *extents,
				   const cairo_path_fixed_t	*path,
				   const cairo_stroke_style_t	*style,
				   const cairo_matrix_t		*ctm,
				   const cairo_matrix_t		*ctm_inverse,
				   double			 tolerance,
				   cairo_antialias_t		 antialias)
{
    cairo_image_surface_t *image;
    cairo_int_status_t status;

    TRACE ((stderr, "%s\n", __FUNCTION__));

    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);

    status = _cairo_surface_offset_stroke (&image->base,
					   extents->unbounded.x,
					   extents->unbounded.y,
					   extents->op,
					   &extents->source_pattern.base,
					   path, style,
					   ctm, ctm_inverse,
					   tolerance,
					   antialias,
					   extents->clip);

    return _cairo_surface_unmap_image (extents->surface, image);
}
static cairo_int_status_t
_cairo_fallback_compositor_glyphs (const cairo_compositor_t	*_compositor,
				   cairo_composite_rectangles_t *extents,
				   cairo_scaled_font_t		*scaled_font,
				   cairo_glyph_t		*glyphs,
				   int				 num_glyphs,
				   cairo_bool_t			 overlap)
{
    cairo_image_surface_t *image;
    cairo_int_status_t status;

    TRACE ((stderr, "%s\n", __FUNCTION__));

    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);

    status = _cairo_surface_offset_glyphs (&image->base,
					   extents->unbounded.x,
					   extents->unbounded.y,
					   extents->op,
					   &extents->source_pattern.base,
					   scaled_font, glyphs, num_glyphs,
					   extents->clip);

    return _cairo_surface_unmap_image (extents->surface, image);
}
static cairo_int_status_t
_cairo_quartz_image_surface_unmap_image (void *asurface,
					 cairo_image_surface_t *image)
{
    cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface;
    return _cairo_surface_unmap_image (&surface->imageSurface->base, image);
}
Exemple #6
0
static cairo_int_status_t
_cairo_xcb_surface_unmap (void *abstract_surface,
			  cairo_image_surface_t *image)
{
    cairo_xcb_surface_t *surface = abstract_surface;
    cairo_int_status_t status;

    if (surface->fallback)
	return _cairo_surface_unmap_image (&surface->fallback->base, image);

    status = _put_image (abstract_surface, image);

    cairo_surface_finish (&image->base);
    cairo_surface_destroy (&image->base);

    return status;
}
static cairo_int_status_t
_cairo_fallback_compositor_paint (const cairo_compositor_t	*_compositor,
				  cairo_composite_rectangles_t	*extents)
{
    cairo_image_surface_t *image;
    cairo_int_status_t status;

    TRACE ((stderr, "%s\n", __FUNCTION__));

    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);

    status = _cairo_surface_offset_paint (&image->base,
					  extents->unbounded.x,
					  extents->unbounded.y,
					  extents->op,
					  &extents->source_pattern.base,
					  extents->clip);

    return _cairo_surface_unmap_image (extents->surface, image);
}
static cairo_status_t
_cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
				 const cairo_pattern_t *_src,
				 cairo_gl_surface_t *dst,
				 const cairo_rectangle_int_t *extents)
{
    cairo_status_t status;
    cairo_gl_surface_t *surface;
    cairo_gl_context_t *ctx;
    cairo_image_surface_t *image;
    cairo_bool_t src_is_gl_surface = FALSE;
    cairo_rectangle_int_t map_extents;

    if (_src->type == CAIRO_PATTERN_TYPE_SURFACE) {
	cairo_surface_t* src_surface = ((cairo_surface_pattern_t *) _src)->surface;
	src_is_gl_surface = src_surface->type == CAIRO_SURFACE_TYPE_GL;
    }

    status = _cairo_gl_context_acquire (dst->base.device, &ctx);
    if (unlikely (status))
	return status;

    surface = (cairo_gl_surface_t *)
	_cairo_gl_surface_create_scratch (ctx,
					  CAIRO_CONTENT_COLOR_ALPHA,
					  extents->width, extents->height);
    map_extents = *extents;
    map_extents.x = map_extents.y = 0;
    image = _cairo_surface_map_to_image (&surface->base, &map_extents);

    /* If the pattern is a GL surface, it belongs to some other GL context,
       so we need to release this device while we paint it to the image. */
    if (src_is_gl_surface) {
	status = _cairo_gl_context_release (ctx, status);
	if (unlikely (status)) {
	    _cairo_surface_unmap_image (&surface->base, image);
	    goto fail;
	}
    }

    status = _cairo_surface_offset_paint (&image->base, extents->x, extents->y,
					  CAIRO_OPERATOR_SOURCE, _src, NULL);

    if (src_is_gl_surface) {
	status = _cairo_gl_context_acquire (dst->base.device, &ctx);
	if (unlikely (status)) {
	    _cairo_surface_unmap_image (&surface->base, image);
	    goto fail;
	}
    }

    status = _cairo_surface_unmap_image (&surface->base, image);
    status = _cairo_gl_context_release (ctx, status);
    if (unlikely (status))
	goto fail;

    *operand = surface->operand;
    operand->texture.owns_surface = surface;
    operand->texture.attributes.matrix.x0 -= extents->x * operand->texture.attributes.matrix.xx;
    operand->texture.attributes.matrix.y0 -= extents->y * operand->texture.attributes.matrix.yy;
    return CAIRO_STATUS_SUCCESS;

fail:
    cairo_surface_destroy (&surface->base);
    return status;
}