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_image_surface_t * _cairo_quartz_image_surface_map_to_image (void *asurface, const cairo_rectangle_int_t *extents) { cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; return _cairo_surface_map_to_image (&surface->imageSurface->base, extents); }
static cairo_image_surface_t * _cairo_surface_subsurface_map_to_image (void *abstract_surface, const cairo_rectangle_int_t *extents) { cairo_surface_subsurface_t *surface = abstract_surface; cairo_rectangle_int_t target_extents; target_extents.x = extents->x + surface->extents.x; target_extents.y = extents->y + surface->extents.y; target_extents.width = extents->width; target_extents.height = extents->height; return _cairo_surface_map_to_image (surface->target, &target_extents); }
static cairo_image_surface_t * _cairo_win32_display_surface_map_to_image (void *abstract_surface, const cairo_rectangle_int_t *extents) { cairo_win32_display_surface_t *surface = abstract_surface; cairo_status_t status; TRACE ((stderr, "%s (surface=%d)\n", __FUNCTION__, surface->win32.base.unique_id)); if (surface->image) goto done; if (surface->fallback == NULL) { surface->fallback = _cairo_win32_display_surface_create_for_dc (surface->win32.dc, surface->win32.format, surface->win32.extents.width, surface->win32.extents.height); if (unlikely (status = surface->fallback->status)) goto err; if (!BitBlt (to_win32_surface(surface->fallback)->dc, 0, 0, surface->win32.extents.width, surface->win32.extents.height, surface->win32.dc, 0, 0, SRCCOPY)) { status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR); goto err; } } surface = to_win32_display_surface (surface->fallback); done: GdiFlush(); return _cairo_surface_map_to_image (surface->image, extents); err: cairo_surface_destroy (surface->fallback); surface->fallback = NULL; return _cairo_image_surface_create_in_error (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_image_surface_t * _cairo_xcb_surface_map_to_image (void *abstract_surface, const cairo_rectangle_int_t *extents) { cairo_xcb_surface_t *surface = abstract_surface; cairo_surface_t *image; cairo_status_t status; if (surface->fallback) return _cairo_surface_map_to_image (&surface->fallback->base, extents); image = _get_image (surface, TRUE, extents->x, extents->y, extents->width, extents->height); status = cairo_surface_status (image); if (unlikely (status)) { cairo_surface_destroy(image); return _cairo_image_surface_create_in_error (status); } /* Do we have a deferred clear and this image surface does NOT cover the * whole xcb surface? Have to apply the clear in that case, else * uploading the image will handle the problem for us. */ if (surface->deferred_clear && ! (extents->width == surface->width && extents->height == surface->height)) { status = _cairo_xcb_surface_clear (surface); if (unlikely (status)) { cairo_surface_destroy(image); return _cairo_image_surface_create_in_error (status); } } surface->deferred_clear = FALSE; cairo_surface_set_device_offset (image, -extents->x, -extents->y); return (cairo_image_surface_t *) 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; }