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 / ppcPolyPnt.c < prev    next >
C/C++ Source or Header  |  1989-11-07  |  4KB  |  130 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. /***********************************************************
  25. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  26. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  27.  
  28.             All Rights Reserved
  29.  
  30. Permission to use, copy, modify, and distribute this software and its 
  31. documentation for any purpose and without fee is hereby granted, 
  32. provided that the above copyright notice appear in all copies and that
  33. both that copyright notice and this permission notice appear in 
  34. supporting documentation, and that the names of Digital or MIT not be
  35. used in advertising or publicity pertaining to distribution of the
  36. software without specific, written prior permission.  
  37.  
  38. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  39. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  40. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  41. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  42. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  43. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  44. SOFTWARE.
  45.  
  46. ******************************************************************/
  47.  
  48. #include "X.h"
  49. #include "Xprotostr.h"
  50. #include "misc.h"
  51. #include "gcstruct.h"
  52. #include "windowstr.h"
  53. #include "pixmapstr.h"
  54. #include "colormapst.h"
  55. #include "scrnintstr.h"
  56. #include "regionstr.h"
  57. #include "region.h"
  58.  
  59. #include "mistruct.h"
  60.  
  61. #include "OScompiler.h"
  62.  
  63. #include "ppc.h"
  64. #include "ibmTrace.h"
  65.  
  66. extern int mfbGCPrivateIndex;
  67.  
  68. void
  69. ppcPolyPoint( pDrawable, pGC, mode, npt, pptInit )
  70. DrawablePtr    pDrawable ;
  71. GCPtr        pGC ;
  72. int        mode ;                /* Origin or Previous */
  73. int        npt ;
  74. xPoint        *pptInit ;
  75. {
  76. register xPoint *ppt ;
  77. ppcPrivGC *devPriv ;
  78. int alu ;
  79. int nptTmp ;
  80.  
  81. TRACE( ("ppcPolyPoint(0x%x,0x%x,%d,%d,0x%x)\n",
  82.     pDrawable, pGC, mode, npt, pptInit ) ) ;
  83.  
  84. if ( pDrawable->type == DRAWABLE_PIXMAP ) {
  85.     if ( pGC->alu != GXnoop )
  86.         miPolyPoint( pDrawable, pGC, mode, npt, pptInit ) ;
  87.     return ;
  88. }
  89.  
  90. devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ;
  91. if ( ( alu = devPriv->colorRrop.alu ) == GXnoop )
  92.     return ;
  93.  
  94. /* make pointlist origin relative */
  95. if ( mode == CoordModePrevious )
  96.     for ( ppt = pptInit, nptTmp = npt ; --nptTmp ; ) {
  97.         ppt++ ;
  98.         ppt->x += (ppt-1)->x ;
  99.         ppt->y += (ppt-1)->y ;
  100.     }
  101.  
  102. if ( pGC->miTranslate ) {
  103.     register int xorg = pDrawable->x ;
  104.     register int yorg = pDrawable->y ;
  105.     for ( ppt = pptInit, nptTmp = npt ; nptTmp-- ; ppt++ ) {
  106.         ppt->x += xorg ;
  107.         ppt->y += yorg ;
  108.     }
  109. }
  110.  
  111. {
  112.     register int (* PointInRegion)() = pDrawable->pScreen->PointInRegion ;
  113.     register void (* fillFunc)() =
  114.         ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->solidFill ;
  115.     register RegionPtr pRegion = devPriv->pCompositeClip ;
  116.     register unsigned long int fg = devPriv->colorRrop.fgPixel ;
  117.     register unsigned long int pm = devPriv->colorRrop.planemask ;
  118.     BoxRec box ; /* Scratch Space */
  119.  
  120.     if ( ! REGION_NUM_RECTS(pRegion))
  121.         return ;
  122.  
  123.     for ( ppt = pptInit ; npt-- ; ppt++ )
  124.         if ( (* PointInRegion)( pRegion, ppt->x, ppt->y, &box ) )
  125.             (* fillFunc)( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  126. }
  127.  
  128. return ;
  129. }
  130.