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 / ppcFillSp.c < prev    next >
C/C++ Source or Header  |  1989-11-14  |  26KB  |  774 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/ppcFillSp.c,v 9.4 89/05/07 15:22:52 paul Exp $ */
  49. /* $Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcFillSp.c,v $ */
  50.  
  51. #ifndef lint
  52. static char *rcsid = "$Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcFillSp.c,v 9.4 89/05/07 15:22:52 paul Exp $" ;
  53. #endif
  54.  
  55.  
  56. #include "X.h"
  57. #include "misc.h"
  58. #include "gcstruct.h"
  59. #include "window.h"
  60. #include "pixmapstr.h"
  61. #include "scrnintstr.h"
  62. #include "windowstr.h"
  63.  
  64. #include "mfb.h"
  65. #include "maskbits.h"
  66.  
  67. #include "OScompiler.h"
  68.  
  69. #include "ppc.h"
  70. #include "ppcSpMcro.h"
  71.  
  72. #include "ibmTrace.h"
  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 scnalines created by clipping ==
  82. MaxRectsPerBand * nSpans.
  83. ********** ********** ********** ********** ********** ********** **********
  84. */
  85.  
  86. void ppcSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  87.     DrawablePtr pDrawable ;
  88.     GCPtr    pGC ;
  89.     int        nInit ;            /* number of spans to fill */
  90.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  91.     int        *pwidthInit ;        /* pointer to list of n widths */
  92.     int     fSorted ;
  93. {
  94.     register unsigned long int pm, npm ;
  95.     register unsigned long int fg ;
  96.     register int alu ;
  97.                 /* next three parameters are post-clip */
  98.     int n ;            /* number of spans to fill */
  99.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  100.     register int *pwidth ;    /* pointer to list of n widths */
  101.     unsigned char *addrlBase ;        /* pointer to start of bitmap */
  102.     int width ;            /* width in bytes of bitmap */
  103.     register unsigned char *addrl ;    /* pointer to current longword in bitmap */
  104.     int i ;
  105.     int *pwidthFree ;        /* copies of the pointers to free */
  106.     DDXPointPtr pptFree ;
  107.  
  108.     TRACE(("ppcSolidPixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  109.  
  110.     if ( pDrawable->type != DRAWABLE_PIXMAP ) {
  111.     ErrorF("ppcSolidPixmapFS: drawable is not a pixmap\n") ;
  112.     return ;
  113.     }
  114.  
  115.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  116.     return ;
  117.  
  118.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  119.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  120.  
  121.     {
  122.     n = nInit * miFindMaxBand( ( (ppcPrivGC *) pGC->devPriv )->pCompositeClip ) ;
  123.     if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
  124.         return ;
  125.     if ( !( ppt = (DDXPointRec *)
  126.             ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
  127.         DEALLOCATE_LOCAL( pwidth ) ;
  128.         return ;
  129.             }
  130.     pwidthFree = pwidth ;
  131.     pptFree = ppt ;
  132.     n = miClipSpans( ( (ppcPrivGC *) pGC->devPriv )->pCompositeClip,
  133.         pptInit, pwidthInit, nInit,
  134.         ppt, pwidth, fSorted ) ;
  135.     }
  136.  
  137.  
  138.     addrlBase = (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate ) ;
  139.     width = (int) ( ( (PixmapPtr) pDrawable )->devKind ) ;
  140.     npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
  141.  
  142.     while ( n-- ) {
  143.         addrl = addrlBase + (ppt->y * width) + ppt->x ;
  144.  
  145.     for ( i = *pwidth ; i-- ; addrl++ )
  146.         *addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ;
  147.     pwidth++ ;
  148.     ppt++ ;
  149.     }
  150.     DEALLOCATE_LOCAL(pptFree) ;
  151.     DEALLOCATE_LOCAL(pwidthFree) ;
  152.     return ;
  153. }
  154.  
  155. void 
  156. ppcSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  157.     DrawablePtr pDrawable ;
  158.     GCPtr    pGC ;
  159.     int        nInit ;            /* number of spans to fill */
  160.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  161.     int        *pwidthInit ;        /* pointer to list of n widths */
  162.     int     fSorted ;
  163. {
  164.     register void (*fnp)() ;
  165.     register unsigned long int pm ;
  166.     register unsigned long int fg ;
  167.     register int alu ;
  168.                 /* next three parameters are post-clip */
  169.     int n ;            /* number of spans to fill */
  170.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  171.     register int *pwidth ;    /* pointer to list of n widths */
  172.     int *pwidthFree ;        /* copies of the pointers to free */
  173.     DDXPointPtr pptFree ;
  174.  
  175.     TRACE(("ppcSolidWindowFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  176.  
  177.     if ( pDrawable->type != DRAWABLE_WINDOW ) {
  178.     ErrorF( "ppcSolidWindowFS: drawable is not a window\n") ;
  179.     return ;
  180.     }
  181.  
  182.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  183.     return ;
  184.  
  185.     n = nInit * miFindMaxBand( ( (ppcPrivGC *) pGC->devPriv )->pCompositeClip ) ;
  186.     if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
  187.         return ;
  188.     if ( !( ppt = (DDXPointRec *)
  189.             ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
  190.         DEALLOCATE_LOCAL( pwidth ) ;
  191.         return ;
  192.             }
  193.     pwidthFree = pwidth ;
  194.     pptFree = ppt ;
  195.     n = miClipSpans( ( (ppcPrivGC *) pGC->devPriv )->pCompositeClip,
  196.         pptInit, pwidthInit, nInit,
  197.         ppt, pwidth, fSorted ) ;
  198.  
  199.     fnp = ((ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->solidFill ;
  200.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  201.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  202.  
  203.     while ( n-- ) {
  204.     if ( *pwidth )
  205.         (*fnp)( fg,alu,pm,ppt->x,ppt->y,*pwidth,1) ;
  206.     ppt++ ; pwidth++ ;
  207.     }
  208.  
  209.     DEALLOCATE_LOCAL(pptFree) ;
  210.     DEALLOCATE_LOCAL(pwidthFree) ;
  211.     return ;
  212. }
  213.  
  214. void
  215. ppcStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  216. DrawablePtr pDrawable ;
  217. GC        *pGC ;
  218. int        nInit ;        /* number of spans to fill */
  219. DDXPointPtr pptInit ;        /* pointer to list of start points */
  220. int *pwidthInit ;        /* pointer to list of n widths */
  221. int fSorted ;
  222. {
  223.     register unsigned char *pdst ; /* pointer to current word in bitmap */
  224.     register int *psrc ;        /* pointer to current word in tile */
  225.     register unsigned long int pm, npm ;
  226.     register unsigned long int fg ;
  227.     register int alu ;
  228.                 /* next three parameters are post-clip */
  229.     int n ;            /* number of spans to fill */
  230.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  231.     register int *pwidth ;    /* pointer to list of n widths */
  232.     int        iline ;        /* first line of tile to use */
  233.     unsigned char *addrlBase ;    /* pointer to start of bitmap */
  234.     int         nlwidth ;    /* width in longwords of bitmap */
  235.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  236.     int        width,  x, xSrc, ySrc ;
  237.     int     tlwidth, tileWidth, *psrcT ;
  238.     int *pwidthFree ;        /* copies of the pointers to free */
  239.     DDXPointPtr pptFree ;
  240.     int xoff, count, stip, i ;
  241.  
  242.     TRACE(("ppcStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n",
  243.          pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  244.  
  245.     if ( pDrawable->type != DRAWABLE_PIXMAP ) {
  246.     ErrorF( "ppcStippleWindowFS: drawable is not a pixmap\n") ;
  247.     return ;
  248.     }
  249.     if ( pGC->stipple->drawable.depth != 1 ) {
  250.     ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
  251.         pDrawable->type, pGC->stipple->drawable.depth ) ;
  252.     return ;
  253.     }
  254.  
  255.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  256.     return ;
  257.  
  258.     SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
  259.         ppt, pwidthFree, pptFree, fSorted ) ;
  260.  
  261.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  262.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  263.  
  264.     addrlBase = (unsigned char *) ((PixmapPtr)pDrawable)->devPrivate ;
  265.     nlwidth = (int) ( ( (PixmapPtr) pDrawable )->devKind ) ;
  266.  
  267.     pTile = pGC->stipple ;
  268.     tlwidth = pTile->devKind >> 2 ;
  269.  
  270.     tileWidth = pTile->width ;
  271.  
  272.     npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
  273.  
  274.     /* this replaces rotating the stipple.  Instead, we just adjust the offset
  275.      * at which we start grabbing bits from the stipple */
  276.     xSrc = pGC->patOrg.x ;
  277.     ySrc = pGC->patOrg.y ;
  278.     while ( n-- ) {
  279.     iline = (ppt->y - ySrc) % pTile->height ;
  280.         pdst = addrlBase + (ppt->y * nlwidth) + (ppt->x) ;
  281.         psrcT = (int *) pTile->devPrivate + (iline * tlwidth) ;
  282.     x = ppt->x ;
  283.  
  284.     xoff = ( x + xSrc ) % tileWidth ;
  285.     psrc = psrcT + ( xoff >> 5 ) ;
  286.     for ( width = *pwidth ; width ; psrc++, width -= count ) {
  287.         if ( psrc >= ( psrcT + tlwidth ) )
  288.         psrc = psrcT ;
  289.         if ( ( psrc != ( psrcT + tlwidth - 1 ) )
  290.           || !( count = ( tileWidth & 0x1F ) ) )
  291.         count = 32 ;
  292.         if ( count > width )
  293.         count = width ;
  294.         getbits(psrc, xoff & 0x1F, count, stip) ;
  295.         for ( i = count ; i-- ; ) {
  296.         if ( stip & LeftMostBitInScreenLongWord )
  297.             *pdst = ( *pdst & npm ) | ( pm & DoRop(alu, fg, *pdst) ) ;
  298.         pdst++ ;
  299.         stip = SCRLEFT( stip, 1 ) ;
  300.         }
  301.     }
  302.     ppt++ ;
  303.     pwidth++ ;
  304.     }
  305.     DEALLOCATE_LOCAL(pptFree) ;
  306.     DEALLOCATE_LOCAL(pwidthFree) ;
  307.     return ;
  308. }
  309.  
  310. void
  311. ppcStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  312. DrawablePtr pDrawable ;
  313. GC        *pGC ;
  314. int        nInit ;        /* number of spans to fill */
  315. DDXPointPtr pptInit ;        /* pointer to list of start points */
  316. int *pwidthInit ;        /* pointer to list of n widths */
  317. int fSorted ;
  318. {
  319.     register void (*fnp)() ;
  320.     register unsigned long int pm ;
  321.     register unsigned long int fg ;
  322.     register int alu ;
  323.                 /* next three parameters are post-clip */
  324.     int n ;            /* number of spans to fill */
  325.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  326.     register int *pwidth ;    /* pointer to list of n widths */
  327.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  328.     int        xSrc, ySrc ;
  329.     int *pwidthFree ;        /* copies of the pointers to free */
  330.     DDXPointPtr pptFree ;
  331.  
  332.     TRACE(("ppcStippleWindowFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n",
  333.          pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  334.  
  335.     if ( pDrawable->type != DRAWABLE_WINDOW ) {
  336.     ErrorF( "ppcStippleWindowFS: drawable is not a window\n" ) ;
  337.     return ;
  338.     }
  339.  
  340.     if ( pGC->stipple->drawable.depth != 1 ) {
  341.     ErrorF("ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
  342.         pDrawable->type, pGC->stipple->drawable.depth) ;
  343.     return ;
  344.     }
  345.  
  346.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  347.     return ;
  348.  
  349.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit,
  350.         ppt, pwidthFree, pptFree, fSorted) ;
  351.  
  352.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  353.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  354.  
  355.     xSrc = pGC->patOrg.x + ( (WindowPtr) pDrawable )->absCorner.x ;
  356.     ySrc = pGC->patOrg.y + ( (WindowPtr) pDrawable )->absCorner.y ;
  357.     pTile = pGC->stipple ;
  358.     fnp = ( (ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->stipFill ;
  359.  
  360.     while ( n-- ) {
  361.     (*fnp)(pTile,fg,alu,pm,ppt->x,ppt->y,*pwidth,1,xSrc,ySrc) ;
  362.     ppt++ ; pwidth++ ;
  363.     }
  364.  
  365.     DEALLOCATE_LOCAL(pptFree) ;
  366.     DEALLOCATE_LOCAL(pwidthFree) ;
  367.  
  368.     return ;
  369. }
  370.  
  371. void
  372. ppcOpStipplePixmapFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  373. DrawablePtr pDrawable ;
  374. GC        *pGC ;
  375. int        nInit ;        /* number of spans to fill */
  376. DDXPointPtr pptInit ;        /* pointer to list of start points */
  377. int *pwidthInit ;        /* pointer to list of n widths */
  378. int fSorted ;
  379. {
  380.     register unsigned char *pdst ;    /* pointer to current word in bitmap */
  381.     register unsigned long int pm, npm ;
  382.     register unsigned long int fg, bg ;
  383.     register int alu ;
  384.                 /* next three parameters are post-clip */
  385.     int n ;            /* number of spans to fill */
  386.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  387.     register int *pwidth ;    /* pointer to list of n widths */
  388.     int        iline ;        /* first line of tile to use */
  389.     unsigned char        *addrlBase ;    /* pointer to start of bitmap */
  390.     int         nlwidth ;    /* width in longwords of bitmap */
  391.     register int *psrc ;        /* pointer to current word in tile */
  392.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  393.     int        width,  x, xSrc, ySrc ;
  394.     int     tlwidth, tileWidth, *psrcT ;
  395.     int *pwidthFree ;        /* copies of the pointers to free */
  396.     DDXPointPtr pptFree ;
  397.     int xoff, count, stip, i ;
  398.  
  399.     TRACE(("ppcOpStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  400.  
  401.     if ( pGC->stipple->drawable.depth != 1 ) {
  402.     ErrorF("ppcOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n",
  403.         pDrawable->type, pGC->stipple->drawable.depth ) ;
  404.     return ;
  405.     }
  406.  
  407.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  408.     return ;
  409.  
  410.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit,
  411.         ppt, pwidthFree, pptFree, fSorted) ;
  412.  
  413.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  414.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  415.     bg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.bgPixel ;
  416.  
  417.     addrlBase = (unsigned char *) ((PixmapPtr)pDrawable)->devPrivate ;
  418.     nlwidth = (int)(((PixmapPtr)pDrawable)->devKind) ;
  419.  
  420.     npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
  421.  
  422.     pTile = pGC->stipple ;
  423.     tlwidth = pTile->devKind >> 2 ;
  424.  
  425.     tileWidth = pTile->width ;
  426.  
  427.     /* this replaces rotating the stipple.  Instead, we just adjust the offset
  428.      * at which we start grabbing bits from the stipple */
  429.     xSrc = pGC->patOrg.x ;
  430.     ySrc = pGC->patOrg.y ;
  431.     while ( n-- ) {
  432.     iline = (ppt->y - ySrc) % pTile->height ;
  433.         pdst = addrlBase + (ppt->y * nlwidth) + (ppt->x) ;
  434.         psrcT = (int *) pTile->devPrivate + (iline * tlwidth) ;
  435.     x = ppt->x ;
  436.  
  437.     xoff = ( x + xSrc ) % tileWidth ;
  438.     psrc = psrcT + ( xoff >> 5 ) ;
  439.     for ( width = *pwidth ; width ; psrc++, width -= count ) {
  440.         if ( psrc >= ( psrcT + tlwidth ) )
  441.         psrc = psrcT ;
  442.         if ( ( psrc != ( psrcT + tlwidth - 1 ) )
  443.          || !( count = tileWidth & 0x1F ) )
  444.             count = 32 ;
  445.         if ( count > width )
  446.         count = width ;
  447.         getbits( psrc, xoff & 0x1F, count, stip) ;
  448.         for ( i = count ; i-- ; ) {
  449.         if ( stip & LeftMostBitInScreenLongWord )
  450.             *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst) ) ;
  451.         else
  452.             *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst) ) ;
  453.         pdst++ ;
  454.         stip = SCRLEFT( stip, 1 ) ;
  455.         }
  456.     }
  457.     ppt++ ;
  458.     pwidth++ ;
  459.     }
  460.     DEALLOCATE_LOCAL(pptFree) ;
  461.     DEALLOCATE_LOCAL(pwidthFree) ;
  462.     return ;
  463. }
  464.  
  465. void
  466. ppcOpStippleWindowFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  467. DrawablePtr pDrawable ;
  468. GC        *pGC ;
  469. int        nInit ;        /* number of spans to fill */
  470. DDXPointPtr pptInit ;        /* pointer to list of start points */
  471. int *pwidthInit ;        /* pointer to list of n widths */
  472. int fSorted ;
  473. {
  474.     register void (*fnp)() ;
  475.     unsigned long int pm ;
  476.     unsigned long int fg, bg ;
  477.     int alu ;
  478.                 /* next three parameters are post-clip */
  479.     int n ;            /* number of spans to fill */
  480.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  481.     register int *pwidth ;    /* pointer to list of n widths */
  482.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  483.     int        xSrc, ySrc ;
  484.     int *pwidthFree ;        /* copies of the pointers to free */
  485.     DDXPointPtr pptFree ;
  486.  
  487.     TRACE(("ppcOpStippleWindowFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  488.  
  489.     if ( pGC->stipple->drawable.depth != 1 ) {
  490.     ErrorF( "ppcOpStippleWindowFS: bad depth\ntype = %d, depth = %d\n",
  491.         pDrawable->type, pGC->stipple->drawable.depth) ;
  492.     return ;
  493.     }
  494.  
  495.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  496.     return ;
  497.  
  498.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit,
  499.         ppt, pwidthFree, pptFree, fSorted) ;
  500.  
  501.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  502.     fg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fgPixel ;
  503.     bg = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.bgPixel ;
  504.  
  505.     xSrc = pGC->patOrg.x ;
  506.     ySrc = pGC->patOrg.y ;
  507.     pTile =pGC->stipple ;
  508.     fnp = ((ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->opstipFill ;
  509.  
  510.     while ( n-- ) {
  511.     (*fnp)( pTile, fg, bg, alu, pm,
  512.         ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  513.     ppt++ ; pwidth++ ;
  514.     }
  515.  
  516.     DEALLOCATE_LOCAL(pptFree) ;
  517.     DEALLOCATE_LOCAL(pwidthFree) ;
  518.     return ;
  519. }
  520.  
  521. void
  522. ppcTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  523. DrawablePtr pDrawable ;
  524. GC        *pGC ;
  525. int        nInit ;        /* number of spans to fill */
  526. DDXPointPtr pptInit ;        /* pointer to list of start points */
  527. int *pwidthInit ;        /* pointer to list of n widths */
  528. int fSorted ;
  529. {
  530.     int        iline ;        /* first line of tile to use */
  531.                 /* next three parameters are post-clip */
  532.     int n ;            /* number of spans to fill */
  533.     register DDXPointPtr ppt ;    /* pointer to list of start points */
  534.     register int *pwidth ;    /* pointer to list of n widths */
  535.     unsigned char    *addrlBase ;    /* pointer to start of bitmap */
  536.     int         nlwidth ;    /* width in longwords of bitmap */
  537.     register unsigned char *pdst ;    /* pointer to current word in bitmap */
  538.     register unsigned char *psrc ;    /* pointer to current word in tile */
  539.     PixmapPtr    pTile ;        /* pointer to tile we want to fill with */
  540.     int        xSrc, ySrc ;
  541.     int     tlwidth, tileWidth ;
  542.     unsigned char *psrcT ;
  543.     int *pwidthFree ;        /* copies of the pointers to free */
  544.     DDXPointPtr pptFree ;
  545.     unsigned char pm, npm ;
  546.     int i, alu ;
  547.  
  548.     TRACE(("ppcTileFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  549.  
  550.     if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) {
  551.     mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
  552.     return ;
  553.     }
  554.     if ( !ppcDepthOK( pDrawable, pGC->tile->drawable.depth ) ) {
  555.     ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n",
  556.         pDrawable->type, pDrawable->depth) ;
  557.     return ;
  558.     }
  559.  
  560.     if ( ( alu = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu ) == GXnoop )
  561.     return ;
  562.     pm = ( (ppcPrivGC *) pGC->devPriv )->colorRrop.planemask ;
  563.     pTile= pGC->tile ;
  564.  
  565.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit,
  566.         ppt, pwidthFree, pptFree, fSorted) ;
  567.  
  568.     if ( pDrawable->type == DRAWABLE_WINDOW ) {
  569.     void (* fnp)() ;
  570.  
  571.         xSrc = pGC->patOrg.x + (((WindowPtr)pDrawable)->absCorner.x) ;
  572.         ySrc = pGC->patOrg.y + (((WindowPtr)pDrawable)->absCorner.y) ;
  573.     fnp = (((ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->tileFill) ;
  574.         while (n--) {
  575.         (* fnp)(pTile,alu,pm,ppt->x,ppt->y,*pwidth,1,xSrc,ySrc) ;
  576.         ppt++ ;
  577.         pwidth++ ;
  578.     }
  579.         DEALLOCATE_LOCAL(pptFree) ;
  580.         DEALLOCATE_LOCAL(pwidthFree) ;
  581.     return ;
  582.     }
  583.  
  584.     /* the following code is for 8 bits per pixel addressable memory only */
  585.     addrlBase = (unsigned char *) ((PixmapPtr)pDrawable)->devPrivate ;
  586.     nlwidth = (int)(((PixmapPtr)pDrawable)->devKind) ;
  587.     npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
  588.     tlwidth = pTile->devKind ;
  589.     tileWidth = pTile->width ;
  590.  
  591.     /* this replaces rotating the tile. Instead we just adjust the offset
  592.      * at which we start grabbing bits from the tile */
  593.     xSrc = pGC->patOrg.x ;
  594.     ySrc = pGC->patOrg.y ;
  595.  
  596.     while (n--)
  597.     {
  598.     iline = (ppt->y - ySrc) % pTile->height ;
  599.         pdst = addrlBase + (ppt->y * nlwidth) + (ppt->x) ;
  600.         psrcT = (unsigned char *) pTile->devPrivate + (iline * tlwidth) ;
  601.  
  602.     psrc = psrcT + ( ( xSrc + ppt->x ) % tileWidth ) ;
  603.     for ( i = *pwidth ; i-- ; ) {
  604.         if ( psrc >= ( psrcT + tileWidth ) )
  605.         psrc = psrcT ;
  606.         *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst) ) ;
  607.         pdst++ ;
  608.         psrc++ ;
  609.     }
  610.     ppt++ ;
  611.     pwidth++ ;
  612.     }
  613.     DEALLOCATE_LOCAL(pptFree) ;
  614.     DEALLOCATE_LOCAL(pwidthFree) ;
  615.     return ;
  616. }
  617.  
  618. void ppcOpStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  619.     DrawablePtr pDrawable ;
  620.     GCPtr    pGC ;
  621.     int        nInit ;            /* number of spans to fill */
  622.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  623.     int        *pwidthInit ;        /* pointer to list of n widths */
  624.     int     fSorted ;
  625. {
  626.     TRACE(("ppcOpStippleFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  627.  
  628.     (* ( ( pDrawable->type == DRAWABLE_PIXMAP )
  629.      ? ppcOpStipplePixmapFS
  630.      : ppcOpStippleWindowFS ) )( pDrawable, pGC, nInit, pptInit,
  631.                      pwidthInit, fSorted ) ;
  632.  
  633.     return ;
  634. }
  635.  
  636. void ppcStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  637.     DrawablePtr pDrawable ;
  638.     GCPtr    pGC ;
  639.     int        nInit ;            /* number of spans to fill */
  640.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  641.     int        *pwidthInit ;        /* pointer to list of n widths */
  642.     int     fSorted ;
  643. {
  644.     TRACE(("ppcStippleFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  645.  
  646.     (* ( ( pDrawable->type == DRAWABLE_PIXMAP )
  647.      ? ppcStipplePixmapFS 
  648.      : ppcStippleWindowFS ) )( pDrawable, pGC, nInit, pptInit,
  649.                    pwidthInit, fSorted ) ;
  650.  
  651.     return ;
  652. }
  653.  
  654. void ppcSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  655.     DrawablePtr pDrawable ;
  656.     GCPtr    pGC ;
  657.     int        nInit ;            /* number of spans to fill */
  658.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  659.     int        *pwidthInit ;        /* pointer to list of n widths */
  660.     int     fSorted ;
  661. {
  662. register void (*spanFunc)() ;
  663.  
  664.     TRACE(("ppcSolidFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  665.  
  666. if ( pDrawable->type == DRAWABLE_WINDOW ) {
  667. #ifdef PAQUINDOESNTLIKETHIS
  668.     if ( pDrawable->depth == 1 )
  669.     {
  670.     ErrorF("ppcSolidFS: window depth == 1\n") ;
  671.     return ;
  672.     }
  673.     else
  674. #endif PAQUINDOESNTLIKETHIS
  675.     spanFunc = ppcSolidWindowFS ;
  676. }
  677. else { /* pDrawable->type == DRAWABLE_PIXMAP */
  678.     if ( pDrawable->depth == 1 ) {
  679.     switch ( ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu )
  680.         {
  681.         case GXclear :
  682.         spanFunc = mfbBlackSolidFS ;
  683.         break ;
  684.         case GXset :
  685.         spanFunc = mfbWhiteSolidFS ;
  686.         break ;
  687.         case GXinvert:
  688.         spanFunc = mfbInvertSolidFS ;
  689.         break ;
  690.          default:
  691.         ErrorF( "ppcFillSpans: unexpected Raster-Op" ) ;
  692.         break ;
  693.         }
  694.     }
  695.     else /* pDrawable->depth > 1 */
  696.     spanFunc = ppcSolidPixmapFS ;
  697. }
  698.  
  699. (*spanFunc)( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
  700.  
  701. return ;
  702. }
  703.  
  704. void 
  705. ppcFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  706.     DrawablePtr pDrawable ;
  707.     GCPtr    pGC ;
  708.     int        nInit ;            /* number of spans to fill */
  709.     DDXPointPtr pptInit ;        /* pointer to list of start points */
  710.     int        *pwidthInit ;        /* pointer to list of n widths */
  711.     int     fSorted ;
  712. {
  713. register void (*spanFunc)() ;
  714.  
  715. if ( pDrawable->type == DRAWABLE_WINDOW )
  716.     switch ( ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fillStyle ) {
  717.         case FillSolid :
  718.             spanFunc = ppcSolidWindowFS ;
  719.             break ;
  720.         case FillStippled :
  721.             spanFunc = ppcStippleWindowFS ;
  722.             break ;
  723.         case FillOpaqueStippled :
  724.            spanFunc = ppcOpStippleWindowFS ;
  725.            break ;
  726.         case FillTiled :
  727.             spanFunc = ppcTileFS ;
  728.             break ;
  729.         default :
  730.             ErrorF( "ppcFillSpans: unknown Fill Style" ) ;
  731.             break ;
  732.     }
  733. else /* pDrawable->type == DRAWABLE_PIXMAP */
  734.     switch ( ( (ppcPrivGC *) pGC->devPriv )->colorRrop.fillStyle ) {
  735.         case FillSolid :
  736.             if ( pDrawable->depth == 1 ) {
  737.             switch ( ( (ppcPrivGC *) pGC->devPriv )->colorRrop.alu )
  738.                 {
  739.                 case GXclear :
  740.                 spanFunc = mfbBlackSolidFS ;
  741.                 break ;
  742.                 case GXset :
  743.                 spanFunc = mfbWhiteSolidFS ;
  744.                 break ;
  745.                 case GXinvert:
  746.                 spanFunc = mfbInvertSolidFS ;
  747.                 break ;
  748.                  default:
  749.                 ErrorF( "ppcFillSpans: unexpected Raster-Op" ) ;
  750.                 break ;
  751.                 }
  752.             }
  753.             else /* pDrawable->depth > 1 */
  754.             spanFunc = ppcSolidPixmapFS ;
  755.             break ;
  756.         case FillStippled :
  757.             spanFunc = ppcStipplePixmapFS ;
  758.             break ;
  759.         case FillOpaqueStippled :
  760.             spanFunc = ppcOpStipplePixmapFS ;
  761.             break ;
  762.         case FillTiled :
  763.             spanFunc = ppcTileFS ;
  764.             break ;
  765.         default :
  766.             ErrorF( "ppcFillSpans: unknown Fill Style" ) ;
  767.             break ;
  768.     }
  769.  
  770. (*spanFunc)( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
  771.  
  772. return ;
  773. }
  774.