home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / ibm8514 / brcPolyPnt.c < prev    next >
C/C++ Source or Header  |  1991-10-01  |  5KB  |  179 lines

  1. /*
  2.  * $Id: brcPolyPnt.c,v 1.3 1991/10/01 06:56:18 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that 
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25.  
  26. /***********************************************************
  27. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  28. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  29.  
  30.             All Rights Reserved
  31.  
  32. Permission to use, copy, modify, and distribute this software and its 
  33. documentation for any purpose and without fee is hereby granted, 
  34. provided that the above copyright notice appear in all copies and that
  35. both that copyright notice and this permission notice appear in 
  36. supporting documentation, and that the names of Digital or MIT not be
  37. used in advertising or publicity pertaining to distribution of the
  38. software without specific, written prior permission.  
  39.  
  40. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  41. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  42. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  43. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  44. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  45. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  46. SOFTWARE.
  47.  
  48. ******************************************************************/
  49.  
  50. #include "X.h"
  51. #include "Xprotostr.h"
  52. #include "misc.h"
  53. #include "gcstruct.h"
  54. #include "windowstr.h"
  55. #include "pixmapstr.h"
  56. #include "colormapst.h"
  57. #include "scrnintstr.h"
  58. #include "regionstr.h"
  59. #include "region.h"
  60.  
  61. #include "mistruct.h"
  62.  
  63. #include "OScompiler.h"
  64.  
  65. #include "ppc.h"
  66. #include "x8514.h"
  67. #include "ibmTrace.h"
  68.  
  69. extern int mfbGCPrivateIndex;
  70. extern int mergexlate[] ;
  71. extern int ibm8514cursorSemaphore ;
  72.  
  73. void
  74. ibm8514PolyPoint( pDrawable, pGC, mode, npt, pptInit )
  75.      DrawablePtr    pDrawable ;
  76.      GCPtr        pGC ;
  77.      int        mode ;            /* Origin or Previous */
  78.      int        npt ;
  79.      xPoint        *pptInit ;
  80. {
  81.     int        CursorIsSaved;
  82.     xPoint     *ppt ;
  83.     ppcPrivGC     *devPriv ;
  84.     int     nptTmp ;
  85.     int     (* PointInRegion)();
  86.     RegionPtr    pRegion ;
  87.     BoxRec    box ;        /* Scratch Space */
  88.  
  89.  
  90.     TRACE( ("ibm8514PolyPoint(0x%x,0x%x,%d,%d,0x%x)\n",
  91.         pDrawable, pGC, mode, npt, pptInit ) ) ;
  92.  
  93.     /* This function only works on WINDOWS use miPolyPoint() on PIXMAP */
  94.  
  95.     devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ;
  96.  
  97.     if ( devPriv->colorRrop.alu == GXnoop )
  98.     return ;
  99.  
  100.     /* make pointlist origin relative */
  101.     if ( mode == CoordModePrevious )
  102.     {
  103.     for ( ppt = pptInit, nptTmp = npt ; --nptTmp ; )
  104.     {
  105.         ppt++ ;
  106.         ppt->x += (ppt-1)->x ;
  107.         ppt->y += (ppt-1)->y ;
  108.     }
  109.     }
  110.  
  111.     if ( pGC->miTranslate )
  112.     {
  113.     int xorg = pDrawable->x ;
  114.     int yorg = pDrawable->y ;
  115.     for ( ppt = pptInit, nptTmp = npt ; nptTmp-- ; ppt++ )
  116.     {
  117.         ppt->x += xorg ;
  118.         ppt->y += yorg ;
  119.     }
  120.     }
  121.  
  122.     PointInRegion = pDrawable->pScreen->PointInRegion ;
  123.     pRegion          = devPriv->pCompositeClip ;
  124.  
  125.     if ( (! REGION_NUM_RECTS(pRegion)) || (! npt) )
  126.     return ;
  127.  
  128.     if ( npt == 1 )
  129.     CursorIsSaved = (!ibm8514cursorSemaphore &&
  130.              ibm8514CheckCursor(pptInit->x, pptInit->y, 1, 1));
  131.     else
  132.     {
  133.     int xmin, ymin, xmax, ymax;
  134.     xmin = xmax = pptInit->x;
  135.     ymin = ymax = pptInit->y;
  136.  
  137.     for (ppt = pptInit + 1, nptTmp = npt - 1; nptTmp ; nptTmp-- ,ppt++)
  138.     {
  139.         if (xmin > ppt->x)
  140.         xmin = ppt->x;
  141.         else if (ppt->x > xmax)
  142.         xmax = ppt->x;
  143.         if (ymin > ppt->y)
  144.         ymin = ppt->y;
  145.         else if (ppt->y > ymax)
  146.         ymax = ppt->y;
  147.     }
  148.     CursorIsSaved = (!ibm8514cursorSemaphore &&
  149.              ibm8514CheckCursor(xmin, ymin, xmax-xmin+1,
  150.                         ymax-ymin+1));
  151.     }
  152.         
  153.  
  154.     ibm8514ATRNotBusy ;
  155.     ibm8514CheckQueue(5) ;
  156.     SETFN1(FNCOLOR1, mergexlate[devPriv->colorRrop.alu]) ;
  157.     SETCOL1(devPriv->colorRrop.fgPixel) ;
  158.     PLNWENBL(devPriv->colorRrop.planemask) ;
  159.     SETLY(0) ;
  160.     SETLX(0) ;
  161.     for ( ppt = pptInit ; npt-- ; ppt++ )
  162.     {
  163.     if ( (* PointInRegion)( pRegion, ppt->x, ppt->y, &box ) )
  164.     {
  165.         ibm8514CheckQueue(3) ;
  166.         SETY0(ppt->y) ;
  167.         SETX0(ppt->x) ;
  168.         COMMAND(0x80b3) ;    /* Horizontal Rect operation,
  169.                    DX = DY = 'increasing'*/
  170.     }
  171.     }
  172.     ibm8514ClearQueue(2) ;
  173.     PLNWENBL( ibm8514ALLPLANES ) ;
  174.     SETFN1(FNCOLOR1, FNREPLACE) ;
  175.  
  176.     if (CursorIsSaved)
  177.     ibm8514ReplaceCursor() ;
  178. }
  179.