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 / emulOpStip.c next >
C/C++ Source or Header  |  1989-11-07  |  3KB  |  107 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. /* ppc OpaqueStipple
  24.  *
  25.  * Based on the private stipple; does a foreground, and then an inverted
  26.  * on the background 
  27.  *
  28.  */
  29.  
  30. #include "X.h"
  31. #include "pixmapstr.h"
  32. #include "scrnintstr.h"
  33.  
  34. #include "ppc.h"
  35. #include "OScompiler.h"
  36. #include "ibmTrace.h"
  37.  
  38. extern PixmapPtr ppcCopyPixmap();
  39.  
  40. void 
  41. ppcOpaqueStipple( pStipple, fg, bg, alu, planes, x, y, w, h, xSrc, ySrc )
  42. register PixmapPtr pStipple ;
  43. unsigned long int fg ;
  44. unsigned long int bg ;
  45. int alu ;
  46. unsigned long int planes ;
  47. register int x, y, w, h ;
  48. int xSrc, ySrc ;
  49. {
  50.     ppcScrnPriv *devPriv =(ppcScrnPriv *)pStipple->drawable.pScreen->devPrivate;
  51.  
  52.     /* DO BACKGROUND */
  53.     switch ( alu ) {
  54.     /* Easy Cases -- i.e. Final Result Doesn't Depend On Initial Dest. */
  55.     case GXclear:        /* 0x0 Zero 0 */
  56.     case GXset:        /* 0xf 1 */
  57.          /* Foreground And Background Are Both The Same !! */
  58.         (* devPriv->solidFill )( bg, alu, planes, x, y, w, h ) ;
  59.     case GXnoop:        /* 0x5 dst */
  60.         break ;
  61.     case GXcopy:        /* 0x3 src */
  62.     case GXcopyInverted:    /* 0xc NOT src */
  63.         { /* Special Case Code */
  64.          register int vtarget, htarget ;
  65.  
  66.          /* We Can Draw Just One Copy Then Blit The Rest !! */
  67.         /* Draw The One Copy */
  68.         htarget = MIN( w, pStipple->drawable.width ) ;
  69.         vtarget = MIN( h, pStipple->drawable.height ) ;
  70.  
  71.         /* First The Background */
  72.         (* devPriv->solidFill)( bg, alu, planes, x, y,
  73.                     htarget, vtarget ) ;
  74.         /* Then The Foreground */
  75.         (* devPriv->stipFill)( pStipple, fg, alu, planes,
  76.                        x, y, htarget, vtarget,
  77.                        xSrc, ySrc ) ;
  78.  
  79.         /* Here We Double The Size Of The BLIT Each Iteration */
  80.         (* devPriv->replicateArea)( x, y, planes, w, h,
  81.                         htarget, vtarget,
  82.                         pStipple->drawable.pScreen ) ;
  83.         }
  84.         break ;
  85.     default:
  86.     /* Hard Cases -- i.e. Final Result DOES Depend On Initial Dest. */
  87.         { /* Do The Background */
  88.         register void (*fnp)() = devPriv->stipFill ;
  89.         register int i, j;
  90.         register PixmapPtr pInvPixmap = ppcCopyPixmap( pStipple ) ;
  91.         register unsigned char *data = pInvPixmap->devPrivate.ptr ;
  92.  
  93.         /* INVERT PIXMAP  OK, jeff, this is for you */
  94.         for ( i = pInvPixmap->drawable.height ; i-- ; )
  95.             for ( j = pInvPixmap->devKind ; j-- ; data++ )
  96.                 *data = ~ ( *data ) ;
  97.  
  98.             (*fnp)( pInvPixmap, bg, alu, planes, x, y, w, h, xSrc, ySrc );
  99.             mfbDestroyPixmap( pInvPixmap ) ;
  100.             /* DO FOREGROUND */
  101.             (*fnp)( pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc );
  102.         }
  103.     break ;
  104.     }
  105.     return;
  106. }
  107.