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 / ppcPntWin.c < prev    next >
C/C++ Source or Header  |  1989-11-07  |  6KB  |  190 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. #include "X.h"
  49.  
  50. #include "windowstr.h"
  51. #include "regionstr.h"
  52. #include "pixmapstr.h"
  53. #include "scrnintstr.h"
  54.  
  55. #include "mfb.h"
  56. #include "ppc.h"
  57.  
  58. #include "ibmTrace.h"
  59.  
  60. /* NOTE: These functions only work for visuals up to 31-bits deep */
  61. void ppcPaintWindowSolid();
  62. void ppcPaintWindowTile();
  63.  
  64. void
  65. ppcPaintWindow(pWin, pRegion, what)
  66.     WindowPtr    pWin;
  67.     RegionPtr    pRegion;
  68.     int        what;
  69. {
  70.  
  71.     register mfbPrivWin    *pPrivWin;
  72.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  73.  
  74.     TRACE(("ppcPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
  75.                             pWin,pRegion,what));
  76.     
  77.     switch (what) {
  78.     case PW_BACKGROUND:
  79.     switch (pWin->backgroundState) {
  80.     case None:
  81.         return;
  82.     case ParentRelative:
  83.         do {
  84.         pWin = pWin->parent;
  85.         } while (pWin->backgroundState == ParentRelative);
  86.         (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
  87.                                  what);
  88.         return;
  89.     case BackgroundPixmap:
  90.         if (pPrivWin->fastBackground)
  91.         {
  92.         ppcPaintWindowTile(pWin, pRegion, what);
  93.         return;
  94.         }
  95.         break;
  96.     case BackgroundPixel:
  97.         ppcPaintWindowSolid(pWin, pRegion, what);
  98.         return;
  99.         }
  100.         break;
  101.     case PW_BORDER:
  102.     if (pWin->borderIsPixel)
  103.     {
  104.         ppcPaintWindowSolid(pWin, pRegion, what);
  105.         return;
  106.     }
  107.     else if (pPrivWin->fastBorder)
  108.     {
  109.             ppcPaintWindowTile(pWin, pRegion, what);
  110.         return;
  111.     }
  112.     break;
  113.     }
  114.     miPaintWindow(pWin, pRegion, what);
  115. }
  116.  
  117. void
  118. ppcPaintWindowSolid(pWin, pRegion, what)
  119.     register WindowPtr pWin;
  120.     register RegionPtr pRegion;
  121.     int what;        
  122. {
  123.     register int nbox;
  124.     register BoxPtr pbox;
  125.     register unsigned long int pixel;
  126.     register void (*fnp)();
  127.     register unsigned long int pm ;
  128.  
  129.     TRACE(("ppcPaintWindowSolid(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
  130.  
  131.     if ( !( nbox = REGION_NUM_RECTS(pRegion)))
  132.     return ;
  133.     pbox = REGION_RECTS(pRegion);
  134.  
  135.     if (what == PW_BACKGROUND)
  136.     pixel = pWin->background.pixel;
  137.     else
  138.     pixel = pWin->border.pixel; 
  139.  
  140.     pm = ( 1 << pWin->drawable.depth ) - 1 ;
  141.     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->solidFill;
  142.     for ( ; nbox-- ; pbox++ ) {
  143.     /*
  144.      * call fill routine, the parms are:
  145.      *     fill(color, alu, planes, x, y, width, height);
  146.      */
  147.     (* fnp)( pixel, GXcopy, pm, pbox->x1, pbox->y1, 
  148.         pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; 
  149.     }
  150.     return ;
  151. }
  152.  
  153. void
  154. ppcPaintWindowTile(pWin, pRegion, what)
  155.     register WindowPtr pWin;
  156.     register RegionPtr pRegion;
  157.     int what;        
  158. {
  159.     register int nbox;
  160.     register BoxPtr pbox;
  161.     register PixmapPtr pTile;
  162.     register void (*fnp)();
  163.     register unsigned long int pm ;
  164.  
  165.     TRACE(("ppcPaintWindowTile(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
  166.  
  167.     if ( !( nbox = REGION_NUM_RECTS(pRegion)))
  168.     return ;
  169.     pbox = REGION_RECTS(pRegion);
  170.  
  171.     if (what == PW_BACKGROUND)
  172.     pTile = pWin->background.pixmap;
  173.     else
  174.     pTile = pWin->border.pixmap;
  175.  
  176.     pm = ( 1 << pWin->drawable.depth ) - 1 ;
  177.     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->tileFill;
  178.     for ( ; nbox-- ; pbox++ ) {
  179.     /*
  180.      * call tile routine, the parms are:
  181.      *     tile(tile, alu, planes, x, y, width, height,xSrc,ySrc);
  182.      */
  183.     (* fnp)(pTile, GXcopy, pm, 
  184.         pbox->x1, pbox->y1, 
  185.         pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
  186.         pWin->drawable.x, pWin->drawable.y );
  187.     }
  188.     return ;
  189. }
  190.