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 >
C/C++ Source or Header  |  1989-11-07  |  4KB  |  132 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that 
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation, and that the name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23. /***********************************************************
  24. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  25. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  26.  
  27.             All Rights Reserved
  28.  
  29. Permission to use, copy, modify, and distribute this software and its
  30. documentation for any purpose and without fee is hereby granted,
  31. provided that the above copyright notice appear in all copies and that
  32. both that copyright notice and this permission notice appear in
  33. supporting documentation, and that the names of Digital or MIT not be
  34. used in advertising or publicity pertaining to distribution of the
  35. software without specific, written prior permission.
  36.  
  37. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  38. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  39. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  40. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  41. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  42. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  43. SOFTWARE.
  44.  
  45. ******************************************************************/
  46.  
  47. #include "X.h"
  48. #include "Xproto.h"
  49. #include "misc.h"
  50. #include "gcstruct.h"
  51. #include "scrnintstr.h"
  52. #include "region.h"
  53. #include "pixmapstr.h"
  54.  
  55. void
  56. ppcDestroyClip(pGC)
  57.     GCPtr    pGC;
  58. {
  59.     if(pGC->clientClipType == CT_NONE)
  60.     return;
  61.     else if (pGC->clientClipType == CT_PIXMAP)
  62.     {
  63.     mfbDestroyPixmap((PixmapPtr)(pGC->clientClip));
  64.     }
  65.     else
  66.     {
  67.     /* we know we'll never have a list of rectangles, since
  68.        ChangeClip immediately turns them into a region 
  69.     */
  70.         (*pGC->pScreen->RegionDestroy)(pGC->clientClip);
  71.     }
  72.     pGC->clientClip = NULL;
  73.     pGC->clientClipType = CT_NONE;
  74. }
  75.  
  76. void
  77. ppcChangeClip(pGC, type, pvalue, nrects)
  78.     GCPtr        pGC;
  79.     unsigned int    type;
  80.     pointer        pvalue;
  81.     int            nrects;
  82. {
  83.     ppcDestroyClip(pGC);
  84.     if(type == CT_PIXMAP)
  85.     {
  86.     /* convert the pixmap to a region */
  87.     pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue);
  88.     /* you wouldn't do this if you were leaving the pixmap in
  89.        rather than converting it.
  90.     */
  91.     (*pGC->pScreen->DestroyPixmap)(pvalue);
  92.     }
  93.     else if (type == CT_REGION)
  94.     {
  95.     /* stuff the region in the GC */
  96.     pGC->clientClip = pvalue;
  97.     }
  98.     else if (type != CT_NONE)
  99.     {
  100.     pGC->clientClip = (pointer) (*pGC->pScreen->RectsToRegion)(nrects,
  101.                             (xRectangle *)pvalue,
  102.                             type);
  103.     xfree(pvalue);
  104.     }
  105.     pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION :
  106.         CT_NONE;
  107.     pGC->stateChanges |= GCClipMask;
  108. }
  109.  
  110. void
  111. ppcCopyClip (pgcDst, pgcSrc)
  112.     GCPtr pgcDst, pgcSrc;
  113. {
  114.     RegionPtr prgnNew;
  115.  
  116.     switch(pgcSrc->clientClipType)
  117.     {
  118.       case CT_PIXMAP:
  119.     ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
  120.     /* Fall through !! */
  121.       case CT_NONE:
  122.     ppcChangeClip(pgcDst, pgcSrc->clientClipType, pgcSrc->clientClip, 0);
  123.     break;
  124.       case CT_REGION:
  125.     prgnNew = (*pgcSrc->pScreen->RegionCreate)(NULL, 1);
  126.     (*pgcSrc->pScreen->RegionCopy)(prgnNew,
  127.                        (RegionPtr)(pgcSrc->clientClip));
  128.     ppcChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0);
  129.     break;
  130.     }
  131. }
  132.