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 / brcPoly.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  5KB  |  202 lines

  1. /*
  2.  * $Id: brcPoly.c,v 1.1 1991/09/20 19:10:24 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1990
  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.  * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
  27.  * LICENSED MATERIALS - PROPERTY OF IBM
  28.  * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
  29.  */
  30. /*
  31.  *  Hardware interface routines for IBM 8514/A adapter for
  32.  *  X.11 server(s) on IBM equipment.
  33.  *
  34.  */
  35.  
  36. /* FILL A POLYGON
  37.  *
  38.  */
  39. #include "X.h"
  40. #include "misc.h"
  41. #include "gcstruct.h"
  42. #include "windowstr.h"
  43. #include "colormapst.h"
  44. #include "regionstr.h"
  45.  
  46. #include "OScompiler.h"
  47.  
  48. #include "ppc.h"
  49. #include "ibmTrace.h"
  50.  
  51. #include "x8514.h"
  52.  
  53. extern int ibm8514Disabled ;
  54.  
  55. extern int ibm8514cursorSemaphore ;
  56. extern int mfbGCPrivateIndex ;
  57.  
  58. #define CLEARSTAGE(W,H)    \
  59.     ibm8514DrawRectangle(0,GXclear, MONO_STAGE_WPLANE | FILL_STAGE_WPLANE,\
  60.     MONO_STAGE_X, MONO_STAGE_Y, W, H)
  61.  
  62. static void
  63. ibm8514StageFill(w,h)
  64.      int w,h ;
  65. {
  66.     ibm8514ATRNotBusy ;
  67.     ibm8514CheckQueue(5);
  68.     PLNRENBL(FILL_STAGE_RPLANE);
  69.     SETCOL1(255);
  70.     PLNWENBL(MONO_STAGE_WPLANE);
  71.     SETFN1(FNCOLOR1, FNREPLACE);
  72.     SETX0(MONO_STAGE_X);
  73.     ibm8514CheckQueue(5);
  74.     SETY0(MONO_STAGE_Y);
  75.     SETLX(w);
  76.     SETLY(h);
  77.     SETMODE(M_PLFILL);
  78.     COMMAND(0x42f7);
  79.  
  80.     ibm8514ClearQueue(3);
  81.     PLNWENBL(RPLANES);
  82.     PLNRENBL(RPLANES);
  83.     SETMODE(M_ONES);
  84.     return;
  85. }
  86.  
  87. ibm8514SolidFillPoly( pDraw, pGC, count, pts)
  88.     DrawablePtr pDraw;
  89.     GCPtr    pGC;
  90.     int        count;
  91.     DDXPointPtr    pts;
  92. {
  93.     RegionPtr        pCC;
  94.     int            saved, alu ;
  95.     unsigned long int    wPM ;
  96.     int            nbox, x0, y0;
  97.     int            i, j, miny, minx, maxx, maxy, bboxh, bboxw,
  98.     thisboxh, x1, y1, destx, desty, ydelta;
  99.     unsigned long int    fg ;
  100.     BoxRec        *pbox;
  101.  
  102.     if ( ibm8514Disabled )
  103.     return ;
  104.  
  105.     TRACE(("ibm8514SolidFillPoly: pDraw=x%x, pGC=x%x, count=%d, pts=x%x\n",
  106.        pDraw, pGC, count, pts));
  107.     pCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
  108.  
  109.     if ( !( nbox = REGION_NUM_RECTS(pCC) ) || ( ( alu = pGC->alu ) == GXnoop ) )
  110.     return;
  111.  
  112.     wPM = pGC->planemask;
  113.     fg  = pGC->fgPixel;
  114.   
  115.     minx = miny = _8514_SCREEN_WIDTH;
  116.     maxx = maxy = 0;
  117.     for (i=0; i<count; i++)
  118.     {
  119.     TRACE(("ibm8514SFPoly: pt[%d] = (%d,%d)\n",i,pts[i].x,pts[i].y));
  120.     minx = MIN(minx,pts[i].x);
  121.     miny = MIN(miny,pts[i].y);
  122.     maxx = MAX(maxx,pts[i].x);
  123.     maxy = MAX(maxy,pts[i].y);
  124.     }
  125.  
  126.     desty = miny + pDraw->y;
  127.     destx = minx + pDraw->x;
  128.     bboxw = maxx-minx+1;
  129.     bboxh = maxy-miny+1;
  130.     ydelta = 0;
  131.  
  132.     saved = !ibm8514cursorSemaphore
  133.     && ibm8514CheckCursor(destx, desty, bboxw, bboxh);
  134.     ibm8514cursorSemaphore++ ;
  135.  
  136.     while (bboxh>0)
  137.     {
  138.     /* set up the staging area to do the fill*/
  139.     ibm8514ClearQueue(4);
  140.     SETXMIN(MONO_STAGE_X);
  141.     SETYMIN(MONO_STAGE_Y);
  142.     SETXMAX(1023);
  143.     SETYMAX(1023);
  144.  
  145.     thisboxh = MIN(MONO_STAGE_SIZE,bboxh);
  146.     CLEARSTAGE(bboxw, thisboxh);
  147.  
  148.     /* Draw the edges */
  149.     for (j=0; j<count-1; j++)
  150.     {
  151.         x0 = pts[j].x + MONO_STAGE_X - minx;
  152.         y0 = pts[j].y + MONO_STAGE_Y - miny - ydelta;
  153.         x1 = pts[j+1].x + MONO_STAGE_X - minx;
  154.         y1 = pts[j+1].y + MONO_STAGE_Y - miny - ydelta;
  155.         ibm8514Outline(FILL_STAGE_WPLANE,x0,y0,x1,y1);
  156.     }
  157.     /* close the polygon */
  158.     x0 = pts[count-1].x + MONO_STAGE_X - minx;
  159.     y0 = pts[count-1].y + MONO_STAGE_Y - miny - ydelta;
  160.     x1 = pts[0].x + MONO_STAGE_X - minx;
  161.     y1 = pts[0].y + MONO_STAGE_Y - miny - ydelta;
  162.     ibm8514Outline(FILL_STAGE_WPLANE,x0,y0,x1,y1);
  163.  
  164.     /* do the area fill */
  165.     ibm8514StageFill(bboxw, thisboxh);
  166.  
  167.     /* Now get the stuff up to the real destination */
  168.     pbox = REGION_RECTS(pCC);
  169.     for (i=0; i<nbox; i++, pbox++)
  170.     {
  171.         ibm8514ClearQueue(4);
  172.         SETXMIN(pbox->x1);
  173.         SETYMIN(pbox->y1);
  174.         SETXMAX(pbox->x2-1);
  175.         SETYMAX(pbox->y2-1);
  176.     
  177.         ibm8514BlitFG(MONO_STAGE_RPLANE, wPM,
  178.               fg, alu, 
  179.               MONO_STAGE_X, MONO_STAGE_Y,
  180.               destx, desty,
  181.               bboxw,thisboxh);
  182.     }
  183.  
  184.     desty += MONO_STAGE_SIZE;
  185.     ydelta += MONO_STAGE_SIZE;
  186.     bboxh -= MONO_STAGE_SIZE;
  187.     }
  188.  
  189.  
  190.     ibm8514ClearQueue(6);
  191.     SETYMIN(0);
  192.     SETXMIN(0);
  193.     SETYMAX( 1023 ) ;
  194.     SETXMAX(_8514_SCREEN_WIDTH-1);
  195.     PLNRENBL(RPLANES);
  196.     PLNWENBL(WPLANES);
  197.  
  198.     if ( !--ibm8514cursorSemaphore && saved )
  199.     ibm8514ReplaceCursor();
  200.     return;
  201. }
  202.