updated to use libpixregion instead of Xlib region code

This commit is contained in:
Carl Worth 2003-02-25 10:33:10 +00:00
parent 3eaa7a73e7
commit 88bd3a9799
8 changed files with 75 additions and 89 deletions

View file

@ -895,9 +895,9 @@ IcComposite (char op,
int width,
int height)
{
Region region;
PixRegion *region;
int n;
BoxPtr pbox;
PixRegionBox *pbox;
CompositeFunc func;
Bool srcRepeat = iSrc->repeat;
Bool maskRepeat = FALSE;
@ -906,7 +906,6 @@ IcComposite (char op,
Bool dstAlphaMap = iDst->alphaMap != 0;
int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
int w, h, w_this, h_this;
XRectangle rect;
xDst += iDst->pixels->x;
yDst += iDst->pixels->y;
@ -920,12 +919,8 @@ IcComposite (char op,
maskAlphaMap = iMask->alphaMap != 0;
}
region = XCreateRegion();
rect.x = xDst;
rect.y = yDst;
rect.width = width;
rect.height = height;
XUnionRectWithRegion (&rect, region, region);
region = PixRegionCreate();
PixRegionUnionRect (region, region, xDst, yDst, width, height);
if (!IcComputeCompositeRegion (region,
iSrc,
@ -1102,8 +1097,8 @@ IcComposite (char op,
}
break;
}
n = region->numRects;
pbox = region->rects;
n = PixRegionNumRects (region);
pbox = PixRegionRects (region);
while (n--)
{
h = pbox->y2 - pbox->y1;
@ -1159,6 +1154,6 @@ IcComposite (char op,
}
pbox++;
}
XDestroyRegion (region);
PixRegionDestroy (region);
}

View file

@ -25,6 +25,8 @@
#ifndef _IC_H_
#define _IC_H_
#include "pixregion.h"
/* icformat.c */
/* XXX: Perhaps we just want an enum for some standard formats? */

View file

@ -2446,7 +2446,7 @@ IcFetch_transform (IcCompositeOperand *op)
case PictFilterNearest:
y = xFixedToInt (v.vector[1]) + op->u.transform.top_y;
x = xFixedToInt (v.vector[0]) + op->u.transform.left_x;
if (XPointInRegion (op->clip, x, y))
if (PixRegionPointInRegion (op->clip, x, y))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetch) (&op[1]);
@ -2470,7 +2470,7 @@ IcFetch_transform (IcCompositeOperand *op)
xerr = xFixed1 - xFixedFrac (v.vector[0]);
for (x = minx; x <= maxx; x++)
{
if (XPointInRegion (op->clip, x, y))
if (PixRegionPointInRegion (op->clip, x, y))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetch) (&op[1]);
@ -2530,7 +2530,7 @@ IcFetcha_transform (IcCompositeOperand *op)
case PictFilterNearest:
y = xFixedToInt (v.vector[1]) + op->u.transform.left_x;
x = xFixedToInt (v.vector[0]) + op->u.transform.top_y;
if (XPointInRegion (op->clip, x, y))
if (PixRegionPointInRegion (op->clip, x, y))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetcha) (&op[1]);
@ -2554,7 +2554,7 @@ IcFetcha_transform (IcCompositeOperand *op)
xerr = xFixed1 - xFixedFrac (v.vector[0]);
for (x = minx; x <= maxx; x++)
{
if (XPointInRegion (op->clip, x, y))
if (PixRegionPointInRegion (op->clip, x, y))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetcha) (&op[1]);

View file

@ -105,8 +105,6 @@ IcImageCreateForPixels (IcPixels *pixels,
void
IcImageInit (IcImage *image)
{
XRectangle rect;
image->refcnt = 1;
image->repeat = 0;
image->graphicsExposures = FALSE;
@ -132,12 +130,9 @@ IcImageInit (IcImage *image)
image->serialNumber = GC_CHANGE_SERIAL_BIT;
*/
image->pCompositeClip = XCreateRegion();
rect.x = 0;
rect.y = 0;
rect.width = image->pixels->width;
rect.height = image->pixels->height;
XUnionRectWithRegion (&rect, image->pCompositeClip, image->pCompositeClip);
image->pCompositeClip = PixRegionCreate();
PixRegionUnionRect (image->pCompositeClip, image->pCompositeClip,
0, 0, image->pixels->width, image->pixels->height);
image->transform = NULL;
@ -189,7 +184,7 @@ void
IcImageDestroy (IcImage *image)
{
if (image->freeCompClip)
XDestroyRegion (image->pCompositeClip);
PixRegionDestroy (image->pCompositeClip);
}
void
@ -202,7 +197,7 @@ IcImageDestroyClip (IcImage *image)
IcImageDestroy (image->clientClip);
break;
default:
XDestroyRegion (image->clientClip);
PixRegionDestroy (image->clientClip);
break;
}
image->clientClip = NULL;
@ -260,16 +255,16 @@ IcImageChangeClip (IcImage *image,
#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
static __inline Bool
IcClipImageReg (Region region,
Region clip,
IcClipImageReg (PixRegion *region,
PixRegion *clip,
int dx,
int dy)
{
if (region->numRects == 1 &&
clip->numRects == 1)
if (PixRegionNumRects (region) == 1 &&
PixRegionNumRects (clip) == 1)
{
BoxPtr pRbox = region->rects;
BoxPtr pCbox = clip->rects;
PixRegionBox *pRbox = PixRegionRects (region);
PixRegionBox *pCbox = PixRegionRects (clip);
int v;
if (pRbox->x1 < (v = pCbox->x1 + dx))
@ -283,20 +278,20 @@ IcClipImageReg (Region region,
if (pRbox->x1 >= pRbox->x2 ||
pRbox->y1 >= pRbox->y2)
{
EMPTY_REGION (region);
PixRegionEmpty (region);
}
}
else
{
XOffsetRegion (region, dx, dy);
XIntersectRegion (region, clip, region);
XOffsetRegion (region, -dx, -dy);
PixRegionTranslate (region, dx, dy);
PixRegionIntersect (region, clip, region);
PixRegionTranslate (region, -dx, -dy);
}
return TRUE;
}
static __inline Bool
IcClipImageSrc (Region region,
IcClipImageSrc (PixRegion *region,
IcImage *image,
int dx,
int dy)
@ -308,11 +303,11 @@ IcClipImageSrc (Region region,
{
if (image->clientClipType != CT_NONE)
{
XOffsetRegion (region,
PixRegionTranslate (region,
dx - image->clipOrigin.x,
dy - image->clipOrigin.y);
XIntersectRegion (region, image->clientClip, region);
XOffsetRegion (region,
PixRegionIntersect (region, image->clientClip, region);
PixRegionTranslate (region,
- (dx - image->clipOrigin.x),
- (dy - image->clipOrigin.y));
}
@ -494,7 +489,7 @@ SetPictureClipRects (PicturePtr pPicture,
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
PixRegion *clientClip;
int result;
clientClip = RECTS_TO_REGION(pScreen,
@ -515,7 +510,7 @@ SetPictureClipRects (PicturePtr pPicture,
*/
Bool
IcComputeCompositeRegion (Region region,
IcComputeCompositeRegion (PixRegion *region,
IcImage *iSrc,
IcImage *iMask,
IcImage *iDst,
@ -529,24 +524,30 @@ IcComputeCompositeRegion (Region region,
CARD16 height)
{
int v;
int x1, y1, x2, y2;
region->extents.x1 = xDst;
/* XXX: This code previously directly set the extents of the
region here. I need to decide whether removing that has broken
this. Also, it might be necessary to just make the PixRegion
data structure transparent anyway in which case I can just put
the code back. */
x1 = xDst;
v = xDst + width;
region->extents.x2 = BOUND(v);
region->extents.y1 = yDst;
x2 = BOUND(v);
y1 = yDst;
v = yDst + height;
region->extents.y2 = BOUND(v);
y2 = BOUND(v);
/* Check for empty operation */
if (region->extents.x1 >= region->extents.x2 ||
region->extents.y1 >= region->extents.y2)
if (x1 >= x2 ||
y1 >= y2)
{
EMPTY_REGION (region);
PixRegionEmpty (region);
return TRUE;
}
/* clip against src */
if (!IcClipImageSrc (region, iSrc, xDst - xSrc, yDst - ySrc))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
if (iSrc->alphaMap)
@ -555,7 +556,7 @@ IcComputeCompositeRegion (Region region,
xDst - (xSrc + iSrc->alphaOrigin.x),
yDst - (ySrc + iSrc->alphaOrigin.y)))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
}
@ -564,7 +565,7 @@ IcComputeCompositeRegion (Region region,
{
if (!IcClipImageSrc (region, iMask, xDst - xMask, yDst - yMask))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
if (iMask->alphaMap)
@ -573,14 +574,14 @@ IcComputeCompositeRegion (Region region,
xDst - (xMask + iMask->alphaOrigin.x),
yDst - (yMask + iMask->alphaOrigin.y)))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
}
}
if (!IcClipImageReg (region, iDst->pCompositeClip, 0, 0))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
if (iDst->alphaMap)
@ -589,7 +590,7 @@ IcComputeCompositeRegion (Region region,
-iDst->alphaOrigin.x,
-iDst->alphaOrigin.y))
{
XDestroyRegion (region);
PixRegionDestroy (region);
return FALSE;
}
}

View file

@ -144,9 +144,9 @@ struct _IcImage {
unsigned long stateChanges;
unsigned long serialNumber;
Region pCompositeClip;
PixRegion *pCompositeClip;
IcTransform *transform;
IcTransform *transform;
int filter;
xFixed *filter_params;
@ -212,8 +212,8 @@ IcValidatePicture (PicturePtr pPicture,
/* XXX: What should this be?
Bool
IcClipPicture (RegionPtr pRegion,
PicturePtr pPicture,
IcClipPicture (PixRegion *region,
IcImage *image,
INT16 xReg,
INT16 yReg,
INT16 xPict,
@ -221,7 +221,7 @@ IcClipPicture (RegionPtr pRegion,
*/
Bool
IcComputeCompositeRegion (Region region,
IcComputeCompositeRegion (PixRegion *region,
IcImage *iSrc,
IcImage *iMask,
IcImage *iDst,
@ -325,7 +325,7 @@ struct _IcCompositeOperand {
IcCompositeStep down;
IcCompositeSet set;
IcIndexedPtr indexed;
Region clip;
PixRegion *clip;
};
typedef void (*IcCombineFunc) (IcCompositeOperand *src,

View file

@ -27,10 +27,6 @@
/* Need definitions for XFixed, etc. */
#include "X11/extensions/Xrender.h"
/* need this for Xlib Region functions */
#include "Xutil.h"
#include "../../../lib/X11/region.h"
/* XXX: Hack: It would be nice to figure out a cleaner way to
successfully include both Xlib/server header files without having
major clashes over the definition of BoxRec and BoxPtr. */

View file

@ -28,20 +28,8 @@
#include "icint.h"
/*
#include "scrnintstr.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "windowstr.h"
#include "servermd.h"
#include "mi.h"
#include "picturestr.h"
#include "mipict.h"
#include "picturestr.h"
#include "mipict.h"
#include "fbpict.h"
*/
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
IcImage *
IcCreateAlphaPicture (IcImage *dst,
@ -87,7 +75,7 @@ IcLineFixedX (XLineFixed *l, XFixed y, Bool ceil)
}
static void
IcTrapezoidBounds (int ntrap, XTrapezoid *traps, BoxPtr box)
IcTrapezoidBounds (int ntrap, XTrapezoid *traps, PixRegionBox *box)
{
box->y1 = MAXSHORT;
box->y2 = MINSHORT;
@ -130,7 +118,7 @@ IcTrapezoids (char op,
XTrapezoid *traps)
{
IcImage *image = NULL;
BoxRec bounds;
PixRegionBox bounds;
INT16 xDst, yDst;
INT16 xRel, yRel;

View file

@ -30,8 +30,8 @@ IcRasterizeTriangle (IcImage *image,
int x_off,
int y_off);
void
IcPointFixedBounds (int npoint, XPointFixed *points, BoxPtr bounds)
static void
IcPointFixedBounds (int npoint, XPointFixed *points, PixRegionBox *bounds)
{
bounds->x1 = xFixedToInt (points->x);
bounds->x2 = xFixedToInt (xFixedCeil (points->x));
@ -58,8 +58,8 @@ IcPointFixedBounds (int npoint, XPointFixed *points, BoxPtr bounds)
}
}
void
IcTriangleBounds (int ntri, XTriangle *tris, BoxPtr bounds)
static void
IcTriangleBounds (int ntri, XTriangle *tris, PixRegionBox *bounds)
{
IcPointFixedBounds (ntri * 3, (XPointFixed *) tris, bounds);
}
@ -82,10 +82,14 @@ IcRasterizeTriangle (IcImage *image,
if (right->y < top->y) {
t = right; right = top; top = t;
}
/* XXX: This code is broken, left and right must be determined by
comparing the angles of the two edges, (eg. we can only compare
X coordinates if we've already intersected each edge with the
same Y coordinate) */
if (right->x < left->x) {
t = right; right = left; left = t;
}
/*
* Two cases:
*
@ -148,7 +152,7 @@ IcTriangles (char op,
int ntri,
XTriangle *tris)
{
BoxRec bounds;
PixRegionBox bounds;
IcImage *image = NULL;
int xDst, yDst;
int xRel, yRel;
@ -216,7 +220,7 @@ IcTriStrip (char op,
XPointFixed *points)
{
XTriangle tri;
BoxRec bounds;
PixRegionBox bounds;
IcImage *image = NULL;
int xDst, yDst;
int xRel, yRel;
@ -288,7 +292,7 @@ IcTriFan (char op,
XPointFixed *points)
{
XTriangle tri;
BoxRec bounds;
PixRegionBox bounds;
IcImage *image = NULL;
XPointFixed *first;
int xDst, yDst;