home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
x
/
xibm.zip
/
ppc
/
ppcClip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-07
|
4KB
|
132 lines
/*
* Copyright IBM Corporation 1987,1988,1989
*
* All Rights Reserved
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of IBM not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
*/
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#include "X.h"
#include "Xproto.h"
#include "misc.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "region.h"
#include "pixmapstr.h"
void
ppcDestroyClip(pGC)
GCPtr pGC;
{
if(pGC->clientClipType == CT_NONE)
return;
else if (pGC->clientClipType == CT_PIXMAP)
{
mfbDestroyPixmap((PixmapPtr)(pGC->clientClip));
}
else
{
/* we know we'll never have a list of rectangles, since
ChangeClip immediately turns them into a region
*/
(*pGC->pScreen->RegionDestroy)(pGC->clientClip);
}
pGC->clientClip = NULL;
pGC->clientClipType = CT_NONE;
}
void
ppcChangeClip(pGC, type, pvalue, nrects)
GCPtr pGC;
unsigned int type;
pointer pvalue;
int nrects;
{
ppcDestroyClip(pGC);
if(type == CT_PIXMAP)
{
/* convert the pixmap to a region */
pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue);
/* you wouldn't do this if you were leaving the pixmap in
rather than converting it.
*/
(*pGC->pScreen->DestroyPixmap)(pvalue);
}
else if (type == CT_REGION)
{
/* stuff the region in the GC */
pGC->clientClip = pvalue;
}
else if (type != CT_NONE)
{
pGC->clientClip = (pointer) (*pGC->pScreen->RectsToRegion)(nrects,
(xRectangle *)pvalue,
type);
xfree(pvalue);
}
pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION :
CT_NONE;
pGC->stateChanges |= GCClipMask;
}
void
ppcCopyClip (pgcDst, pgcSrc)
GCPtr pgcDst, pgcSrc;
{
RegionPtr prgnNew;
switch(pgcSrc->clientClipType)
{
case CT_PIXMAP:
((PixmapPtr) pgcSrc->clientClip)->refcnt++;
/* Fall through !! */
case CT_NONE:
ppcChangeClip(pgcDst, pgcSrc->clientClipType, pgcSrc->clientClip, 0);
break;
case CT_REGION:
prgnNew = (*pgcSrc->pScreen->RegionCreate)(NULL, 1);
(*pgcSrc->pScreen->RegionCopy)(prgnNew,
(RegionPtr)(pgcSrc->clientClip));
ppcChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0);
break;
}
}