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 / ppcGetSp.c < prev    next >
C/C++ Source or Header  |  1991-01-10  |  5KB  |  129 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: /afs/rel-eng.athena.mit.edu/project/release/current/source/third/common/X11R4/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v 1.2 91/01/10 15:18:11 jfc Exp $ */
  49. /* $Source: /afs/rel-eng.athena.mit.edu/project/release/current/source/third/common/X11R4/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v $ */
  50.  
  51. #ifndef lint
  52. static char *rcsid = "$Header: /afs/rel-eng.athena.mit.edu/project/release/current/source/third/common/X11R4/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v 1.2 91/01/10 15:18:11 jfc Exp $" ;
  53. #endif
  54.  
  55. #include "X.h"
  56. #include "servermd.h"
  57. #include "scrnintstr.h"
  58. #include "region.h"
  59. #include "gcstruct.h"
  60. #include "windowstr.h"
  61. #include "pixmapstr.h"
  62.  
  63. #include "OScompiler.h"
  64.  
  65. #include "ppcGCstr.h"
  66. #include "ppcScrn.h"
  67.  
  68. #include "ibmTrace.h"
  69.  
  70. /* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
  71.  * and continuing for pwidth[i] bits
  72.  * Each scanline returned will be server scanline padded, i.e., it will come
  73.  * out to an integral number of words.
  74.  */
  75. void
  76. ppcGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart )
  77.     DrawablePtr        pDrawable ;    /* drawable from which to get bits */
  78.     int            wMax ;        /* largest value of all *pwidths */
  79.     register DDXPointPtr ppt ;        /* points to start copying from */
  80.     int            *pwidth ;    /* list of number of bits to copy */
  81.     register int    nspans ;    /* number of scanlines to copy */
  82.     unsigned char     *pdstStart ;
  83. {
  84.     register int        j ;
  85.     register unsigned char    *pdst ;    /* where to put the bits */
  86.     register unsigned char    *psrc ;    /* where to get the bits */
  87.     register int        pixmapStride ;
  88.  
  89.  
  90.     TRACE( ( "ppcGetSpans(pDrawable=0x%x,wMax=%d,ppt=0x%x,pwidth=0x%x,nspans=%d)\n", 
  91.     pDrawable, wMax, ppt, pwidth, nspans ) ) ;
  92.  
  93.     if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) )
  94.     {
  95.     mfbGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart ) ;
  96.     return;
  97.     }
  98.  
  99.     pixmapStride = PixmapBytePad( wMax, pDrawable->depth ) ;
  100.     pdst = pdstStart ;
  101.  
  102.     if ( pDrawable->type == DRAWABLE_WINDOW ) {
  103.          register void (* fnp)()
  104.        = ((ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->imageRead ;
  105.     for ( ; nspans-- ; ppt++, pwidth++ ) {
  106.         (* fnp)( ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride ) ;
  107.         pdst += j ; /* width is in 32 bit words */
  108.         j = ( -j ) & 3 ;
  109.         while ( j-- ) /* Pad out to 32-bit boundary */
  110.             *pdst++ = 0 ;
  111.     }
  112.     }
  113.     else {  /* OK, if we are here, we had better be a DRAWABLE PIXMAP */
  114.     register int widthSrc =  /* width of pixmap in bytes */
  115.      (int) ( (PixmapPtr) pDrawable )->devKind ;
  116.  
  117.     psrc = (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ;
  118.     for ( ; nspans-- ; ppt++, pwidth++ ) {
  119.         MOVE( psrc + ( ppt->y * widthSrc ) + ppt->x,
  120.           pdst, j = *pwidth ) ;
  121.         pdst += j ;
  122.         j = ( -j ) & 3 ;
  123.         while ( j-- ) /* Pad out to 32-bit boundary */
  124.             *pdst++ = 0 ;
  125.     }
  126.     }
  127.     return ;
  128. }
  129.