cairo_surface_t *
_cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image,
					      cairo_format_t  format)
{
    cairo_image_surface_t *surface;

    surface = malloc (sizeof (cairo_image_surface_t));
    if (surface == NULL) {
	_cairo_error (CAIRO_STATUS_NO_MEMORY);
	return (cairo_surface_t*) &_cairo_surface_nil;
    }

    _cairo_surface_init (&surface->base, &cairo_image_surface_backend);

    surface->pixman_image = pixman_image;

    surface->format = format;
    surface->data = (unsigned char *) pixman_image_get_data (pixman_image);
    surface->owns_data = FALSE;
    surface->has_clip = FALSE;

    surface->width = pixman_image_get_width (pixman_image);
    surface->height = pixman_image_get_height (pixman_image);
    surface->stride = pixman_image_get_stride (pixman_image);
    surface->depth = pixman_image_get_depth (pixman_image);

    return &surface->base;
}
Beispiel #2
0
cairo_surface_t *
_cairo_image_surface_create_for_pixman_image (pixman_image_t		*pixman_image,
					      pixman_format_code_t	 pixman_format)
{
    cairo_image_surface_t *surface;

    surface = malloc (sizeof (cairo_image_surface_t));
    if (surface == NULL)
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    _cairo_surface_init (&surface->base, &_cairo_image_surface_backend,
			 _cairo_content_from_pixman_format (pixman_format));

    surface->pixman_image = pixman_image;

    surface->pixman_format = pixman_format;
    surface->format = _cairo_format_from_pixman_format (pixman_format);
    surface->data = (unsigned char *) pixman_image_get_data (pixman_image);
    surface->owns_data = FALSE;
    surface->has_clip = FALSE;
    surface->transparency = CAIRO_IMAGE_UNKNOWN;

    surface->width = pixman_image_get_width (pixman_image);
    surface->height = pixman_image_get_height (pixman_image);
    surface->stride = pixman_image_get_stride (pixman_image);
    surface->depth = pixman_image_get_depth (pixman_image);

    return &surface->base;
}
void
_cairo_image_surface_init (cairo_image_surface_t *surface,
			   pixman_image_t	*pixman_image,
			   pixman_format_code_t	 pixman_format)
{
    surface->parent = NULL;
    surface->pixman_image = pixman_image;

    surface->pixman_format = pixman_format;
    surface->format = _cairo_format_from_pixman_format (pixman_format);
    surface->data = (uint8_t *) pixman_image_get_data (pixman_image);
    surface->owns_data = FALSE;
    surface->transparency = CAIRO_IMAGE_UNKNOWN;
    surface->color = CAIRO_IMAGE_UNKNOWN_COLOR;

    surface->width = pixman_image_get_width (pixman_image);
    surface->height = pixman_image_get_height (pixman_image);
    surface->stride = pixman_image_get_stride (pixman_image);
    surface->depth = pixman_image_get_depth (pixman_image);

    surface->base.is_clear = surface->width == 0 || surface->height == 0;

    surface->compositor = _cairo_image_spans_compositor_get ();
}
Beispiel #4
0
static inline void combine_to_pixmap_from_pixmap(const RedDrawable_p* dest,
                                                 const SpiceRect& area,
                                                 const SpicePoint& offset,
                                                 const PixelsSource_p* source,
                                                 int src_x, int src_y,
                                                 RedDrawable::CombineOP op)
{
    pixman_image_t *dest_surface =  dest->source.pixmap.pixman_image;
    pixman_image_t *src_surface = source->pixmap.pixman_image;

    SpiceROP rop;
    switch (op) {
    case RedDrawable::OP_COPY:
        rop = SPICE_ROP_COPY;
        break;
    case RedDrawable::OP_AND:
        rop = SPICE_ROP_AND;
        break;
    case RedDrawable::OP_XOR:
        rop = SPICE_ROP_XOR;
        break;
    default:
        THROW("invalid op %d", op);
    }


    if (pixman_image_get_depth (src_surface) == 1) {
        pixman_color_t white = { 0xffff, 0xffff, 0xffff, 0xffff };
        pixman_image_t *solid;
        pixman_image_t *temp;

        /* Create a temporary rgb32 image that is black where mask is 0
           and white where mask is 1 */
        temp = pixman_image_create_bits(pixman_image_get_depth(dest_surface) == 24 ?
                                        PIXMAN_x8r8g8b8 : PIXMAN_a8r8g8b8,
                                        area.right - area.left,
                                        area.bottom - area.top, NULL, 0);
        solid = pixman_image_create_solid_fill(&white);
        pixman_image_composite32(PIXMAN_OP_SRC,
                                 solid, src_surface, temp,
                                 0, 0,
                                 src_x + offset.x,
                                 src_y + offset.y,
                                 0, 0,
                                 area.right - area.left,
                                 area.bottom - area.top);
        pixman_image_unref(solid);

        /* ROP the temp image on the destination */
        spice_pixman_blit_rop(dest_surface,
                              temp,
                              0,
                              0,
                              area.left + offset.x,
                              area.top + offset.y,
                              area.right - area.left,
                              area.bottom - area.top,
                              rop);
        pixman_image_unref(temp);

    } else {
        spice_pixman_blit_rop(dest_surface,
                              src_surface,
                              src_x + offset.x,
                              src_y + offset.y,
                              area.left + offset.x,
                              area.top + offset.y,
                              area.right - area.left,
                              area.bottom - area.top,
                              rop);
    }
}
Beispiel #5
0
uint8 PixmanBitmap::bpp() const {
	return (pixman_image_get_depth(bitmap) + 7) / 8;
}