#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "scrnintstr.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "windowstr.h"
#include "migc.h"
_X_EXPORT void
miChangeGC(pGC, mask)
GCPtr pGC;
unsigned long mask;
{
return;
}
_X_EXPORT void
miDestroyGC(pGC)
GCPtr pGC;
{
if (pGC->pRotatedPixmap)
(*pGC->pScreen->DestroyPixmap) (pGC->pRotatedPixmap);
if (pGC->freeCompClip)
REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
miDestroyGCOps(pGC->ops);
}
_X_EXPORT GCOpsPtr
miCreateGCOps(prototype)
GCOpsPtr prototype;
{
GCOpsPtr ret;
Must_have_memory = TRUE;
ret = (GCOpsPtr) xalloc(sizeof(GCOps));
Must_have_memory = FALSE;
if (!ret)
return 0;
*ret = *prototype;
ret->devPrivate.val = 1;
return ret;
}
_X_EXPORT void
miDestroyGCOps(ops)
GCOpsPtr ops;
{
if (ops->devPrivate.val)
xfree(ops);
}
_X_EXPORT void
miDestroyClip(pGC)
GCPtr pGC;
{
if (pGC->clientClipType == CT_NONE)
return;
else if (pGC->clientClipType == CT_PIXMAP)
{
(*pGC->pScreen->DestroyPixmap) ((PixmapPtr) (pGC->clientClip));
}
else
{
REGION_DESTROY(pGC->pScreen, pGC->clientClip);
}
pGC->clientClip = NULL;
pGC->clientClipType = CT_NONE;
}
_X_EXPORT void
miChangeClip(pGC, type, pvalue, nrects)
GCPtr pGC;
int type;
pointer pvalue;
int nrects;
{
(*pGC->funcs->DestroyClip) (pGC);
if (type == CT_PIXMAP)
{
pGC->clientClip = (pointer) BITMAP_TO_REGION(pGC->pScreen,
(PixmapPtr) pvalue);
(*pGC->pScreen->DestroyPixmap) (pvalue);
}
else if (type == CT_REGION)
{
pGC->clientClip = pvalue;
}
else if (type != CT_NONE)
{
pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects,
(xRectangle *) pvalue,
type);
xfree(pvalue);
}
pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION : CT_NONE;
pGC->stateChanges |= GCClipMask;
}
_X_EXPORT void
miCopyClip(pgcDst, pgcSrc)
GCPtr pgcDst, pgcSrc;
{
RegionPtr prgnNew;
switch (pgcSrc->clientClipType)
{
case CT_PIXMAP:
((PixmapPtr) pgcSrc->clientClip)->refcnt++;
case CT_NONE:
(*pgcDst->funcs->ChangeClip) (pgcDst, (int) pgcSrc->clientClipType,
pgcSrc->clientClip, 0);
break;
case CT_REGION:
prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1);
REGION_COPY(pgcDst->pScreen, prgnNew,
(RegionPtr) (pgcSrc->clientClip));
(*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (pointer) prgnNew, 0);
break;
}
}
_X_EXPORT void
miCopyGC(pGCSrc, changes, pGCDst)
GCPtr pGCSrc;
unsigned long changes;
GCPtr pGCDst;
{
return;
}
_X_EXPORT void
miComputeCompositeClip(pGC, pDrawable)
GCPtr pGC;
DrawablePtr pDrawable;
{
ScreenPtr pScreen;
pGC->pScreen = pScreen = pGC->pScreen;
if (pDrawable->type == DRAWABLE_WINDOW)
{
WindowPtr pWin = (WindowPtr) pDrawable;
RegionPtr pregWin;
Bool freeTmpClip, freeCompClip;
if (pGC->subWindowMode == IncludeInferiors)
{
pregWin = NotClippedByChildren(pWin);
freeTmpClip = TRUE;
}
else
{
pregWin = &pWin->clipList;
freeTmpClip = FALSE;
}
freeCompClip = pGC->freeCompClip;
if (pGC->clientClipType == CT_NONE)
{
if (freeCompClip)
REGION_DESTROY(pScreen, pGC->pCompositeClip);
pGC->pCompositeClip = pregWin;
pGC->freeCompClip = freeTmpClip;
}
else
{
REGION_TRANSLATE(pScreen, pGC->clientClip,
pDrawable->x + pGC->clipOrg.x,
pDrawable->y + pGC->clipOrg.y);
if (freeCompClip)
{
REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
pregWin, pGC->clientClip);
if (freeTmpClip)
REGION_DESTROY(pScreen, pregWin);
}
else if (freeTmpClip)
{
REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
pGC->pCompositeClip = pregWin;
}
else
{
pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
REGION_INTERSECT(pScreen, pGC->pCompositeClip,
pregWin, pGC->clientClip);
}
pGC->freeCompClip = TRUE;
REGION_TRANSLATE(pScreen, pGC->clientClip,
-(pDrawable->x + pGC->clipOrg.x),
-(pDrawable->y + pGC->clipOrg.y));
}
}
else
{
BoxRec pixbounds;
pixbounds.x1 = pDrawable->x;
pixbounds.y1 = pDrawable->y;
pixbounds.x2 = pDrawable->x + pDrawable->width;
pixbounds.y2 = pDrawable->y + pDrawable->height;
if (pGC->freeCompClip)
{
REGION_RESET(pScreen, pGC->pCompositeClip, &pixbounds);
}
else
{
pGC->freeCompClip = TRUE;
pGC->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
}
if (pGC->clientClipType == CT_REGION)
{
if(pDrawable->x || pDrawable->y) {
REGION_TRANSLATE(pScreen, pGC->clientClip,
pDrawable->x + pGC->clipOrg.x,
pDrawable->y + pGC->clipOrg.y);
REGION_INTERSECT(pScreen, pGC->pCompositeClip,
pGC->pCompositeClip, pGC->clientClip);
REGION_TRANSLATE(pScreen, pGC->clientClip,
-(pDrawable->x + pGC->clipOrg.x),
-(pDrawable->y + pGC->clipOrg.y));
} else {
REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
-pGC->clipOrg.x, -pGC->clipOrg.y);
REGION_INTERSECT(pScreen, pGC->pCompositeClip,
pGC->pCompositeClip, pGC->clientClip);
REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
pGC->clipOrg.x, pGC->clipOrg.y);
}
}
}
}