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

  1. /*
  2.  * $Id: brcPushPxl.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.  * ibm8514PushPixels
  32.  */
  33. #include "X.h"
  34. #include "misc.h"
  35. #include "gcstruct.h"
  36. #include "scrnintstr.h"
  37. #include "windowstr.h"
  38. #include "regionstr.h"
  39. #include "pixmapstr.h"
  40. #include "miscstruct.h"
  41.  
  42. #include "OScompiler.h"
  43.  
  44. #include "ppc.h"
  45.  
  46. #include "x8514.h"
  47. extern int mfbGCPrivateIndex;
  48.  
  49. void
  50. ibm8514PushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
  51.      GCPtr       pGC;
  52.      PixmapPtr   pBitMap;
  53.      DrawablePtr pDrawable;
  54.      int         dx, dy, xOrg, yOrg;
  55. {
  56.     int          thisX, thisY;
  57.     ppcPrivGC     *gcPriv  = (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ;
  58.     int          alu =     gcPriv->colorRrop.alu;
  59.     int          fillstyle = gcPriv->colorRrop.fillStyle;
  60.     RegionPtr     prgnDst ;
  61.     BoxPtr        pbox ;
  62.     unsigned int  nbox ;
  63.     int       dxInWords, wInWords, i;
  64.     unsigned char *data;
  65.     ScreenPtr      pScrn;
  66.  
  67.     if (alu == GXnoop)
  68.     return;
  69.  
  70.     if (dy > MONO_STAGE_SIZE) 
  71.     {
  72.     ppcPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
  73.     return;
  74.     }
  75.  
  76.     switch (fillstyle)
  77.     {
  78.       case FillSolid:
  79.     break;
  80.       case FillTiled:
  81.       case FillOpaqueStippled:
  82.       case FillStippled:
  83.     ppcPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
  84.     return;
  85.     default :
  86.     ErrorF( "ibm8514PushPixels: Unknown fill Style\n" ) ;
  87.     return ;
  88.     }
  89.  
  90.     /* Find The Actual Regions To Fill
  91.      * by intersecting the destination's clip-region with
  92.      * the box defined by our arguments.
  93.      */
  94.     {
  95.         BoxRec          dstBox ;
  96.  
  97.         dstBox.x2 = ( dstBox.x1 = xOrg ) + dx ;
  98.         dstBox.y2 = ( dstBox.y1 = yOrg ) + dy ;
  99.  
  100.     pScrn = (ScreenPtr) pDrawable->pScreen ;
  101.  
  102.         prgnDst = (* pScrn->RegionCreate )( &dstBox,
  103.                        REGION_NUM_RECTS(gcPriv->pCompositeClip)) ;
  104.         (* pScrn->Intersect)( prgnDst, prgnDst, gcPriv->pCompositeClip ) ;
  105.         if ( !( nbox = REGION_NUM_RECTS(prgnDst) ) )
  106.     {
  107.         (* pScrn->RegionDestroy )( prgnDst);
  108.         return ;
  109.     }
  110.         pbox = REGION_RECTS(prgnDst) ;
  111.     }
  112.  
  113.     dx =  MIN(dx,_8514_SCREEN_WIDTH);
  114.  
  115.     dxInWords = (dx+31) >> 5;
  116.     wInWords = (pBitMap->drawable.width + 31) >> 5;
  117.  
  118.     if (dxInWords < wInWords)
  119.     {
  120.     /* fill the stage line by line */
  121.     data = pBitMap->devPrivate.ptr;
  122.     for ( i = 0 ; i < dy ; i++ )
  123.     {
  124.         /* since I know I'm one line high, I can lie about
  125.            end-of-line padding and use ByteAlign */
  126.         ibm8514ByteAlignMonoImage(MONO_STAGE_WPLANE, GXcopy,
  127.                       MONO_STAGE_X,  MONO_STAGE_Y+i,
  128.                       dx, 1, data);
  129.         data += pBitMap->devKind;
  130.     }
  131.     }
  132.     else 
  133.     ibm8514AlignMonoImage(MONO_STAGE_WPLANE, GXcopy,
  134.                   MONO_STAGE_X,  MONO_STAGE_Y,
  135.                   dx, dy, pBitMap->devPrivate.ptr );
  136.  
  137.     /* OK, the bitmap is on the stage */
  138.     switch (fillstyle)
  139.     {
  140.       case FillSolid:
  141.     for ( nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst) ;
  142.          nbox-- ;
  143.          pbox++ )
  144.     {
  145.         thisX = pbox->x1;
  146.         thisY = pbox->y1;
  147.         ibm8514BlitFG(MONO_STAGE_RPLANE, 
  148.               gcPriv->colorRrop.planemask,
  149.               gcPriv->colorRrop.fgPixel, alu, 
  150.               MONO_STAGE_X + thisX - xOrg,
  151.               MONO_STAGE_Y + thisY - yOrg,
  152.               thisX, thisY,
  153.               pbox->x2 - thisX,
  154.               pbox->y2 - thisY  );
  155.     }
  156.     break;
  157.       case FillTiled:
  158.       case FillOpaqueStippled:
  159.       case FillStippled:
  160.     ErrorF(
  161.            "ibm8514PushPixels: Serious Error. Unsupported fill Style\n" ) ;
  162.     break;
  163.     default :
  164.     ErrorF( "ibm8514PushPixels: Unknown fill Style\n" ) ;
  165.     break;
  166.     }
  167.     (* pScrn->RegionDestroy )( prgnDst);
  168.     return ;
  169. }
  170.