void pixman_image_init (pixman_image_t *image) { image->refcnt = 1; image->repeat = 0; image->graphicsExposures = 0; image->subWindowMode = ClipByChildren; image->polyEdge = PolyEdgeSharp; image->polyMode = PolyModePrecise; /* * In the server this was 0 because the composite clip list * can be referenced from a window (and often is) */ image->freeCompClip = 0; image->freeSourceClip = 0; image->clientClipType = CT_NONE; image->componentAlpha = 0; image->compositeClipSource = 0; image->alphaMap = NULL; image->alphaOrigin.x = 0; image->alphaOrigin.y = 0; image->clipOrigin.x = 0; image->clipOrigin.y = 0; image->clientClip = NULL; image->dither = 0L; image->stateChanges = (1 << (CPLastBit+1)) - 1; /* XXX: What to lodge here? image->serialNumber = GC_CHANGE_SERIAL_BIT; */ image->pCompositeClip = pixman_region_create(); pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip, 0, 0, image->pixels->width, image->pixels->height); image->freeCompClip = 1; image->pSourceClip = pixman_region_create (); pixman_region_union_rect (image->pSourceClip, image->pSourceClip, 0, 0, image->pixels->width, image->pixels->height); image->freeSourceClip = 1; image->transform = NULL; image->filter = PIXMAN_FILTER_NEAREST; image->filter_params = NULL; image->filter_nparams = 0; image->owns_pixels = 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; }
/** * _cairo_region_create_from_rectangle: * @rect: a #cairo_rectangle_t * * Creates a region with extents initialized from the given * rectangle. * * Return value: a newly created #pixman_region16_t or %NULL if * memory couldn't a allocated. **/ pixman_region16_t * _cairo_region_create_from_rectangle (cairo_rectangle_t *rect) { /* We can't use pixman_region_create_simple(), because it doesn't * have an error return */ pixman_region16_t *region = pixman_region_create (); if (pixman_region_union_rect (region, region, rect->x, rect->y, rect->width, rect->height) != PIXMAN_REGION_STATUS_SUCCESS) { pixman_region_destroy (region); return NULL; } return region; }
/** * _cairo_traps_extract_region: * @traps: a #cairo_traps_t * @region: on return, %NULL is stored here if the trapezoids aren't * exactly representable as a pixman region, otherwise a * a pointer to such a region, newly allocated. * (free with pixman region destroy) * * Determines if a set of trapezoids are exactly representable as a * pixman region, and if so creates such a region. * * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY **/ cairo_status_t _cairo_traps_extract_region (cairo_traps_t *traps, pixman_region16_t **region) { int i; for (i = 0; i < traps->num_traps; i++) if (!(traps->traps[i].left.p1.x == traps->traps[i].left.p2.x && traps->traps[i].right.p1.x == traps->traps[i].right.p2.x && _cairo_fixed_is_integer(traps->traps[i].top) && _cairo_fixed_is_integer(traps->traps[i].bottom) && _cairo_fixed_is_integer(traps->traps[i].left.p1.x) && _cairo_fixed_is_integer(traps->traps[i].right.p1.x))) { *region = NULL; return CAIRO_STATUS_SUCCESS; } *region = pixman_region_create (); for (i = 0; i < traps->num_traps; i++) { int x = _cairo_fixed_integer_part(traps->traps[i].left.p1.x); int y = _cairo_fixed_integer_part(traps->traps[i].top); int width = _cairo_fixed_integer_part(traps->traps[i].right.p1.x) - x; int height = _cairo_fixed_integer_part(traps->traps[i].bottom) - y; /* XXX: Sometimes we get degenerate trapezoids from the tesellator, * if we call pixman_region_union_rect(), it bizarrly fails on such * an empty rectangle, so skip them. */ if (width == 0 || height == 0) continue; if (pixman_region_union_rect (*region, *region, x, y, width, height) != PIXMAN_REGION_STATUS_SUCCESS) { pixman_region_destroy (*region); return CAIRO_STATUS_NO_MEMORY; } } return CAIRO_STATUS_SUCCESS; }
void addTaintedArea(const IntRect &rect) { pixman_region_union_rect (&tainted, &tainted, rect.x, rect.y, rect.w, rect.h); }
EAPI int ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect) { return pixman_region_union_rect((pixman_region16_t *)dst, (pixman_region16_t *)src, rect->x, rect->y, rect->width, rect->height); }
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; } } }
void addTaintedArea(const IntRect &rect) { IntRect norm = normalizedRect(rect); pixman_region_union_rect (&tainted, &tainted, norm.x, norm.y, norm.w, norm.h); }