Exemplo n.º 1
0
static __inline int
FbClipImageReg (pixman_region16_t	*region,
                pixman_region16_t	*clip,
                int		dx,
                int		dy)
{
    if (pixman_region_num_rects (region) == 1 &&
            pixman_region_num_rects (clip) == 1)
    {
        pixman_box16_t *pRbox = pixman_region_rects (region);
        pixman_box16_t *pCbox = pixman_region_rects (clip);
        int	v;

        if (pRbox->x1 < (v = pCbox->x1 + dx))
            pRbox->x1 = BOUND(v);
        if (pRbox->x2 > (v = pCbox->x2 + dx))
            pRbox->x2 = BOUND(v);
        if (pRbox->y1 < (v = pCbox->y1 + dy))
            pRbox->y1 = BOUND(v);
        if (pRbox->y2 > (v = pCbox->y2 + dy))
            pRbox->y2 = BOUND(v);
        if (pRbox->x1 >= pRbox->x2 ||
                pRbox->y1 >= pRbox->y2)
        {
            pixman_region_empty (region);
        }
    }
    else
    {
        pixman_region_translate (region, dx, dy);
        pixman_region_intersect (region, clip, region);
        pixman_region_translate (region, -dx, -dy);
    }
    return 1;
}
Exemplo n.º 2
0
int
pixman_image_set_clip_region (pixman_image_t	*image,
                              pixman_region16_t	*region)
{
    pixman_image_destroyClip (image);
    if (region) {
        image->clientClip = pixman_region_create ();
        pixman_region_copy (image->clientClip, region);
        image->clientClipType = CT_REGION;
    }

    if (image->freeCompClip)
        pixman_region_destroy (image->pCompositeClip);
    image->pCompositeClip = pixman_region_create();
    pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
                              0, 0, image->pixels->width, image->pixels->height);
    image->freeCompClip = 1;
    if (region) {
        pixman_region_translate (image->pCompositeClip,
                                 - image->clipOrigin.x,
                                 - image->clipOrigin.y);
        pixman_region_intersect (image->pCompositeClip,
                                 image->pCompositeClip,
                                 region);
        pixman_region_translate (image->pCompositeClip,
                                 image->clipOrigin.x,
                                 image->clipOrigin.y);
    }

    image->stateChanges |= CPClipMask;
    return 0;
}
Exemplo n.º 3
0
static inline pixman_bool_t
miClipPictureReg(pixman_region16_t * pRegion,
                 pixman_region16_t * pClip, int dx, int dy)
{
    if (pixman_region_n_rects(pRegion) == 1 &&
        pixman_region_n_rects(pClip) == 1) {
        pixman_box16_t *pRbox = pixman_region_rectangles(pRegion, NULL);
        pixman_box16_t *pCbox = pixman_region_rectangles(pClip, NULL);
        int v;

        if (pRbox->x1 < (v = pCbox->x1 + dx))
            pRbox->x1 = BOUND(v);
        if (pRbox->x2 > (v = pCbox->x2 + dx))
            pRbox->x2 = BOUND(v);
        if (pRbox->y1 < (v = pCbox->y1 + dy))
            pRbox->y1 = BOUND(v);
        if (pRbox->y2 > (v = pCbox->y2 + dy))
            pRbox->y2 = BOUND(v);
        if (pRbox->x1 >= pRbox->x2 || pRbox->y1 >= pRbox->y2) {
            pixman_region_init(pRegion);
        }
    }
    else if (!pixman_region_not_empty(pClip))
        return FALSE;
    else {
        if (dx || dy)
            pixman_region_translate(pRegion, -dx, -dy);
        if (!pixman_region_intersect(pRegion, pRegion, pClip))
            return FALSE;
        if (dx || dy)
            pixman_region_translate(pRegion, dx, dy);
    }
    return pixman_region_not_empty(pRegion);
}
Exemplo n.º 4
0
cairo_status_t
_cairo_clip_intersect_to_region (cairo_clip_t      *clip,
				 pixman_region16_t *region)
{
    if (!clip)
	return CAIRO_STATUS_SUCCESS;

    if (clip->path) {
	/* Intersect clip path into region. */
    }

    if (clip->region)
	pixman_region_intersect (region, clip->region, region);

    if (clip->surface) {
	pixman_region16_t *clip_rect;
	pixman_region_status_t pixman_status;
	cairo_status_t status = CAIRO_STATUS_SUCCESS;

	clip_rect = _cairo_region_create_from_rectangle (&clip->surface_rect);
	if (clip_rect == NULL)
	    return CAIRO_STATUS_NO_MEMORY;

	pixman_status = pixman_region_intersect (region,
						 clip_rect,
						 region);
	if (pixman_status != PIXMAN_REGION_STATUS_SUCCESS)
	    status = CAIRO_STATUS_NO_MEMORY;

	pixman_region_destroy (clip_rect);

	if (status)
	    return status;
    }

    return CAIRO_STATUS_SUCCESS;
}
Exemplo n.º 5
0
static inline pixman_bool_t
miClipPictureSrc (pixman_region16_t *	pRegion,
		  pixman_image_t *	pPicture,
		  int		dx,
		  int		dy)
{
    /* XXX what to do with clipping from transformed pictures? */
    if (pPicture->common.transform || pPicture->type != BITS)
	return TRUE;

    if (pPicture->common.repeat)
    {
	/* If the clip region was set by a client, then it should be intersected
	 * with the composite region since it's interpreted as happening
	 * after the repeat algorithm.
	 *
	 * If the clip region was not set by a client, then it was imposed by
	 * boundaries of the pixmap, or by sibling or child windows, which means
	 * it should in theory be repeated along. FIXME: we ignore that case.
	 * It is only relevant for windows that are (a) clipped by siblings/children
	 * and (b) used as source. However this case is not useful anyway due
	 * to lack of GraphicsExpose events.
	 */
	if (pPicture->common.has_client_clip)
	{
	    pixman_region_translate ( pRegion, dx, dy);
	    
	    if (!pixman_region_intersect (pRegion, pRegion, 
					  (pixman_region16_t *) pPicture->common.src_clip))
		return FALSE;
	    
	    pixman_region_translate ( pRegion, -dx, -dy);
	}
	    
	return TRUE;
    }
    else
    {
	return miClipPictureReg (pRegion,
				 pPicture->common.src_clip,
				 dx,
				 dy);
    }
}
Exemplo n.º 6
0
static __inline int
FbClipImageSrc (pixman_region16_t	*region,
                pixman_image_t		*image,
                int		dx,
                int		dy)
{
    /* XXX what to do with clipping from transformed pictures? */
    if (image->transform)
        return 1;
    if (image->repeat)
    {
        /* XXX no source clipping */
        if (image->compositeClipSource &&
                image->clientClipType != CT_NONE)
        {
            pixman_region_translate (region,
                                     dx - image->clipOrigin.x,
                                     dy - image->clipOrigin.y);
            pixman_region_intersect (region, image->clientClip, region);
            pixman_region_translate (region,
                                     - (dx - image->clipOrigin.x),
                                     - (dy - image->clipOrigin.y));
        }
        return 1;
    }
    else
    {
        pixman_region16_t   *clip;

        if (image->compositeClipSource)
            clip = image->pCompositeClip;
        else
            clip = image->pSourceClip;
        return FbClipImageReg (region,
                               clip,
                               dx,
                               dy);
    }
    return 1;
}
Exemplo n.º 7
0
static cairo_status_t
_cairo_clip_intersect_region (cairo_clip_t    *clip,
			      cairo_traps_t   *traps,
			      cairo_surface_t *target)
{
    pixman_region16_t *region;
    cairo_status_t status;

    if (clip->mode != CAIRO_CLIP_MODE_REGION)
	return CAIRO_INT_STATUS_UNSUPPORTED;

    status = _cairo_traps_extract_region (traps, &region);
    if (status)
	return status;

    if (region == NULL)
	return CAIRO_INT_STATUS_UNSUPPORTED;

    status = CAIRO_STATUS_SUCCESS;
    if (clip->region == NULL) {
	clip->region = region;
    } else {
	pixman_region16_t *intersection = pixman_region_create();

	if (pixman_region_intersect (intersection,
				     clip->region, region)
	    == PIXMAN_REGION_STATUS_SUCCESS) {
	    pixman_region_destroy (clip->region);
	    clip->region = intersection;
	} else {
	    status = CAIRO_STATUS_NO_MEMORY;
	}
	pixman_region_destroy (region);
    }

    clip->serial = _cairo_surface_allocate_clip_serial (target);

    return status;
}
Exemplo n.º 8
0
cairo_status_t
_cairo_clip_intersect_to_rectangle (cairo_clip_t            *clip,
				    cairo_rectangle_int16_t *rectangle)
{
    if (!clip)
	return CAIRO_STATUS_SUCCESS;

    if (clip->path) {
	/* Intersect path extents here. */
    }

    if (clip->region) {
	pixman_region16_t *intersection;
	cairo_status_t status = CAIRO_STATUS_SUCCESS;
	pixman_region_status_t pixman_status;

	intersection = _cairo_region_create_from_rectangle (rectangle);
	if (intersection == NULL)
	    return CAIRO_STATUS_NO_MEMORY;

	pixman_status = pixman_region_intersect (intersection,
					  clip->region,
					  intersection);
	if (pixman_status == PIXMAN_REGION_STATUS_SUCCESS)
	    _cairo_region_extents_rectangle (intersection, rectangle);
	else
	    status = CAIRO_STATUS_NO_MEMORY;

	pixman_region_destroy (intersection);

	if (status)
	    return status;
    }

    if (clip->surface)
	_cairo_rectangle_intersect (rectangle, &clip->surface_rect);

    return CAIRO_STATUS_SUCCESS;
}
Exemplo n.º 9
0
EAPI int
ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
{
   return pixman_region_intersect((pixman_region16_t *)dst, (pixman_region16_t *)r1, (pixman_region16_t *)r2);
}
Exemplo n.º 10
0
/* XXX: There are failure cases in this function. Don't we need to
 * propagate the errors out?
 */
void
pixman_composite_trapezoids (pixman_operator_t	      op,
			     pixman_image_t	      *src,
			     pixman_image_t	      *dst,
			     int		      xSrc,
			     int		      ySrc,
			     const pixman_trapezoid_t *traps,
			     int		      ntraps)
{
    pixman_image_t	*image = NULL;
    pixman_box16_t	traps_bounds, dst_bounds, bounds;
    pixman_region16_t	*traps_region, *dst_region;
    int16_t		xDst, yDst;
    int16_t		xRel, yRel;
    pixman_format_t	*format;

    if (ntraps == 0)
	return;

    /*
     * Check for solid alpha add
     */
    if (op == PIXMAN_OPERATOR_ADD && miIsSolidAlpha (src))
    {
	for (; ntraps; ntraps--, traps++)
	    fbRasterizeTrapezoid (dst, traps, 0, 0);
	return;
    }

    xDst = traps[0].left.p1.x >> 16;
    yDst = traps[0].left.p1.y >> 16;
    
    pixman_trapezoid_bounds (ntraps, traps, &traps_bounds);

    traps_region = pixman_region_create_simple (&traps_bounds);

    /* XXX: If the image has a clip region set, we should really be
     * fetching it here instead, but it looks like we don't yet expose
     * a pixman_image_get_clip_region function. */
    dst_bounds.x1 = 0;
    dst_bounds.y1 = 0;
    dst_bounds.x2 = pixman_image_get_width (dst);
    dst_bounds.y2 = pixman_image_get_height (dst);

    dst_region = pixman_region_create_simple (&dst_bounds);

    pixman_region_intersect (traps_region, traps_region, dst_region);

    bounds = *(pixman_region_extents (traps_region));

    pixman_region_destroy (traps_region);
    pixman_region_destroy (dst_region);

    if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
	return;

    format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
    if (!format)
	return;

    image = FbCreateAlphaPicture (dst, format,
				  bounds.x2 - bounds.x1,
				  bounds.y2 - bounds.y1);
    if (!image)
    {
	pixman_format_destroy (format);
	return;
    }

    for (; ntraps; ntraps--, traps++)
    {
	if (!xTrapezoidValid(traps))
	    continue;
	fbRasterizeTrapezoid (image, traps, 
			      -bounds.x1, -bounds.y1);
    }

    xRel = bounds.x1 + xSrc - xDst;
    yRel = bounds.y1 + ySrc - yDst;
    pixman_composite (op, src, image, dst,
		      xRel, yRel, 0, 0, bounds.x1, bounds.y1,
		      bounds.x2 - bounds.x1,
		      bounds.y2 - bounds.y1);
    pixman_image_destroy (image);

    pixman_format_destroy (format);
}
Exemplo n.º 11
0
static void
pixman_color_rects (pixman_image_t	 *dst,
                    pixman_image_t	 *clipPict,
                    pixman_color_t	 *color,
                    int	 nRect,
                    pixman_rectangle_t *rects,
                    int	 xoff,
                    int	 yoff)
{
    pixman_bits_t	pixel;
    pixman_region16_t  *clip;
    pixman_region16_t  *rects_as_region;
    pixman_box16_t     *clipped_rects;
    int	                i, n_clipped_rects;
    FillFunc            func;

    pixman_color_to_pixel (&dst->image_format,
                           color,
                           &pixel);

    /* offset to the right place on the destination image */
    xoff -= dst->pixels->x;
    yoff -= dst->pixels->y;

    clip = pixman_region_create();
    pixman_region_union_rect (clip, clip,
                              dst->pixels->x, dst->pixels->y,
                              dst->pixels->width, dst->pixels->height);

    pixman_region_intersect (clip, clip, clipPict->pCompositeClip);
    if (clipPict->alphaMap)
    {
        pixman_region_translate (clip,
                                 -clipPict->alphaOrigin.x,
                                 -clipPict->alphaOrigin.y);
        pixman_region_intersect (clip, clip, clipPict->alphaMap->pCompositeClip);
        pixman_region_translate (clip,
                                 clipPict->alphaOrigin.x,
                                 clipPict->alphaOrigin.y);
    }

    if (xoff || yoff)
    {
        for (i = 0; i < nRect; i++)
        {
            rects[i].x -= xoff;
            rects[i].y -= yoff;
        }
    }

    rects_as_region = pixman_region_create ();
    for (i = 0; i < nRect; i++)
    {
        pixman_region_union_rect (rects_as_region, rects_as_region,
                                  rects[i].x, rects[i].y,
                                  rects[i].width, rects[i].height);
    }

    pixman_region_intersect (rects_as_region, rects_as_region, clip);
    pixman_region_destroy (clip);

    n_clipped_rects = pixman_region_num_rects (rects_as_region);
    clipped_rects = pixman_region_rects (rects_as_region);

    if (dst->pixels->bpp == 8)
        func = pixman_fill_rect_8bpp;
    else if (dst->pixels->bpp == 32)
        func = pixman_fill_rect_32bpp;
    else if (dst->pixels->bpp == 1)
        func = pixman_fill_rect_1bpp;
    else
        func = pixman_fill_rect_general;

    for (i = 0; i < n_clipped_rects; i++) {
        (*func) (dst,
                 clipped_rects[i].x1,
                 clipped_rects[i].y1,
                 clipped_rects[i].x2 - clipped_rects[i].x1,
                 clipped_rects[i].y2 - clipped_rects[i].y1,
                 &pixel);
    }

    pixman_region_destroy (rects_as_region);

    if (xoff || yoff)
    {
        for (i = 0; i < nRect; i++)
        {
            rects[i].x += xoff;
            rects[i].y += yoff;
        }
    }
}