#ifndef lint static char sccsid[] = "@(#)mem_region.c 9.2 88/01/19 SMI"; #endif /* * Copyright 1986 by Sun Microsystems, Inc. */ /* * Memory region-to-pixrect conversion */ #include #ifdef REF #include #endif #include #include #include extern char *snoopalloc(); Pixrect * mem_region(pr, x, y, w, h) Pixrect *pr; int x, y, w, h; { struct pr_subregion srcreg; static struct pr_prpos nulpos = { 0, { 0, 0 } }; register Pixrect *newpr; register struct mprp_data *mprd, *newmprd; /* allocate new pixrect and pixrect data */ if ((newpr = (Pixrect *) snoopalloc("mem_region.c", sizeof (Pixrect))) == 0) return 0; mprd = (struct mprp_data *) pr->pr_data; if ((newmprd = (struct mprp_data *) snoopalloc("mem_region.c", (mprd->mpr.md_flags & MP_PLANEMASK) ? sizeof (struct mprp_data) : sizeof (struct mpr_data))) == 0) { free(newpr); return 0; } /* compute region offset, size */ srcreg.pr = pr; srcreg.pos.x = x; srcreg.pos.y = y; srcreg.size.x = w; srcreg.size.y = h; pr_clip(&srcreg, &nulpos); /* copy old pixrect; set size, data pointer */ *newpr = *pr; newpr->pr_size = srcreg.size; newpr->pr_data = (caddr_t) newmprd; /* copy old pixrect data */ if (mprd->mpr.md_flags & MP_PLANEMASK) *newmprd = *mprd; else newmprd->mpr = mprd->mpr; /* this is a secondary pixrect */ newmprd->mpr.md_primary = 0; /* set offsets */ newmprd->mpr.md_offset.x += srcreg.pos.x; newmprd->mpr.md_offset.y += srcreg.pos.y; return newpr; }