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 / ppcWindowFS.c < prev    next >
C/C++ Source or Header  |  1989-11-14  |  11KB  |  303 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. /* $Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v 1.1 89/05/07 15:23:36 jeff Exp $ */
  49. /* $Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v $ */
  50.  
  51. #ifndef lint
  52. static char *rcsid = "$Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v 1.1 89/05/07 15:23:36 jeff Exp $" ;
  53. #endif
  54.  
  55. #include "X.h"
  56. #include "misc.h"
  57. #include "gcstruct.h"
  58. #include "window.h"
  59. #include "pixmapstr.h"
  60. #include "scrnintstr.h"
  61. #include "windowstr.h"
  62.  
  63. #include "mfb.h"
  64. #include "maskbits.h"
  65.  
  66. #include "OScompiler.h"
  67.  
  68. #include "ppc.h"
  69. #include "ppcSpMcro.h"
  70.  
  71. #include "ibmTrace.h"
  72. extern int mfbGCPrivateIndex;
  73.  
  74. #define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 )
  75. /*
  76. ********** ********** ********** ********** ********** ********** **********
  77.    these routines all clip.  they assume that anything that has called
  78. them has already translated the points (i.e. pGC->miTranslate is
  79. non-zero, which is howit gets set in mfbCreateGC().)
  80.  
  81.    the number of new scanlines created by clipping ==
  82. MaxRectsPerBand * nSpans.
  83. ********** ********** ********** ********** ********** ********** **********
  84. */
  85.  
  86. void
  87. ppcSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  88.     DrawablePtr pDrawable ;
  89.     GCPtr    pGC ;
  90.     int        nInit ;            /* number of spans to fill */
  91.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  92.     int        *pwidthInit ;        /* pointer to list of n widths */
  93.     int     fSorted ;
  94. {
  95.     register void (*fnp)() ;
  96.     register unsigned long int pm ;
  97.     register unsigned long int fg ;
  98.     register int alu ;
  99.                 /* next three parameters are post-clip */
  100.     int n ;            /* number of spans to fill */
  101.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  102.     register int *pwidth ;    /* pointer to list of n widths */
  103.     int *pwidthFree ;        /* copies of the pointers to free */
  104.     DDXPointPtr pptFree ;
  105.  
  106.     TRACE( ( "ppcSolidWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
  107.         pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
  108.  
  109.     if ( pDrawable->type != DRAWABLE_WINDOW ) {
  110.     ErrorF( "ppcSolidWindowFS: drawable is not a window\n") ;
  111.     return ;
  112.     }
  113.  
  114.     if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
  115.     return ;
  116.  
  117.     n = nInit * miFindMaxBand( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip ) ;
  118.     if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
  119.     return ;
  120.     pwidthFree = pwidth ;
  121.  
  122.     if ( !( ppt = (DDXPointRec *)
  123.             ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
  124.     DEALLOCATE_LOCAL( pwidth ) ;
  125.     return ;
  126.     }
  127.     pptFree = ppt ;
  128.  
  129.     n = miClipSpans( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip,
  130.              pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ;
  131.  
  132.     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->solidFill ;
  133.     pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  134.     fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  135.  
  136.     for ( ; n-- ; ppt++, pwidth++ )
  137.     if ( *pwidth )
  138.         (* fnp)( fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ;
  139.  
  140.     DEALLOCATE_LOCAL( pptFree ) ;
  141.     DEALLOCATE_LOCAL( pwidthFree ) ;
  142.     return ;
  143. }
  144.  
  145. void
  146. ppcStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  147. DrawablePtr pDrawable ;
  148. register GC *pGC ;
  149. int nInit ;            /* number of spans to fill */
  150. DDXPointPtr pptInit ;        /* pointer to list of start points */
  151. int *pwidthInit ;        /* pointer to list of n widths */
  152. int fSorted ;
  153. {
  154.     register void (*fnp)() ;
  155.     register unsigned long int pm ;
  156.     register unsigned long int fg ;
  157.     register int alu ;
  158.                 /* next three parameters are post-clip */
  159.     int n ;            /* number of spans to fill */
  160.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  161.     register int *pwidth ;    /* pointer to list of n widths */
  162.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  163.     int xSrc ;
  164.     int ySrc ;
  165.     int *pwidthFree ;        /* copies of the pointers to free */
  166.     DDXPointPtr pptFree ;
  167.  
  168.     TRACE( ( "ppcStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
  169.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
  170.  
  171.     if ( pDrawable->type != DRAWABLE_WINDOW ) {
  172.     ErrorF( "ppcStippleWindowFS: drawable is not a window\n" ) ;
  173.     return ;
  174.     }
  175.  
  176.     if ( pGC->stipple->drawable.depth != 1 ) {
  177.     ErrorF("ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
  178.         pDrawable->type, pGC->stipple->drawable.depth ) ;
  179.     return ;
  180.     }
  181.  
  182.     if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
  183.     return ;
  184.  
  185.     SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
  186.          ppt, pwidthFree, pptFree, fSorted ) ;
  187.  
  188.     pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  189.     fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  190.  
  191.     xSrc = pGC->patOrg.x + pDrawable->x ;
  192.     ySrc = pGC->patOrg.y + pDrawable->y ;
  193.     pTile = pGC->stipple ;
  194.     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->stipFill ;
  195.  
  196.     for ( ; n-- ; ppt++, pwidth++ )
  197.     (* fnp)( pTile, fg, alu, pm, ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  198.  
  199.     DEALLOCATE_LOCAL( pptFree ) ;
  200.     DEALLOCATE_LOCAL( pwidthFree ) ;
  201.  
  202.     return ;
  203. }
  204.  
  205. void
  206. ppcOpStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  207. DrawablePtr pDrawable ;
  208. register GC *pGC ;
  209. int nInit ;            /* number of spans to fill */
  210. DDXPointPtr pptInit ;        /* pointer to list of start points */
  211. int *pwidthInit ;        /* pointer to list of n widths */
  212. int fSorted ;
  213. {
  214.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  215.     register int *pwidth ;    /* pointer to list of n widths */
  216.     register void (*fnp)() ;
  217.     int n ;            /* number of spans to fill */
  218.     int xSrc ;
  219.     int ySrc ;
  220.     unsigned long int pm ;
  221.     unsigned long int fg, bg ;
  222.     int alu ;
  223.     int *pwidthFree ;        /* copies of the pointers to free */
  224.     DDXPointPtr pptFree ;
  225.  
  226.     TRACE( ( "ppcOpStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
  227.         pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
  228.  
  229.     if ( pGC->stipple->drawable.depth != 1 ) {
  230.     ErrorF( "ppcOpStippleWindowFS: bad depth\ntype = %d, depth = %d\n",
  231.         pDrawable->type, pGC->stipple->drawable.depth ) ;
  232.     return ;
  233.     }
  234.  
  235.     if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
  236.     return ;
  237.  
  238.     SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
  239.          ppt, pwidthFree, pptFree, fSorted ) ;
  240.  
  241.     pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  242.     fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  243.     bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ;
  244.  
  245.     xSrc = pGC->patOrg.x + pDrawable->x ;
  246.     ySrc = pGC->patOrg.y + pDrawable->y ;
  247.  
  248.     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->opstipFill ;
  249.  
  250.     for ( ; n-- ; ppt++, pwidth++ )
  251.     (*fnp)( pGC->stipple, fg, bg, alu, pm,
  252.         ppt->x, ppt->y, *pwidth, 1,
  253.         xSrc, ySrc ) ;
  254.  
  255.     DEALLOCATE_LOCAL( pptFree ) ;
  256.     DEALLOCATE_LOCAL( pwidthFree ) ;
  257.     return ;
  258. }
  259.  
  260. void
  261. ppcTileWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  262. DrawablePtr pDrawable ;
  263. register GC *pGC ;
  264. int nInit ;            /* number of spans to fill */
  265. DDXPointPtr pptInit ;        /* pointer to list of start points */
  266. int *pwidthInit ;        /* pointer to list of n widths */
  267. int fSorted ;
  268. {
  269.     register void (* fnp)() ;
  270.                 /* next three parameters are post-clip */
  271.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  272.     register int *pwidth ;    /* pointer to list of n widths */
  273.     int n ;            /* number of spans to fill */
  274.     unsigned char pm ;
  275.     int alu ;
  276.     int xSrc ;
  277.     int ySrc ;
  278.     int *pwidthFree ;        /* copies of the pointers to free */
  279.     DDXPointPtr pptFree ;
  280.  
  281.     TRACE( ( "ppcTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
  282.         pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
  283.  
  284.     if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
  285.     return ;
  286.  
  287.     SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
  288.          ppt, pwidthFree, pptFree, fSorted ) ;
  289.  
  290.     xSrc = pGC->patOrg.x + pDrawable->x ;
  291.     ySrc = pGC->patOrg.y + pDrawable->y ;
  292.     pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  293.     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->tileFill ;
  294.  
  295.     for ( ; n-- ; ppt++, pwidth++ )
  296.         (* fnp)( pGC->tile.pixmap, alu, pm,
  297.              ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  298.  
  299.     DEALLOCATE_LOCAL( pptFree ) ;
  300.     DEALLOCATE_LOCAL( pwidthFree ) ;
  301.     return ;
  302. }
  303.