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 / brcGC.c < prev    next >
C/C++ Source or Header  |  1991-09-28  |  8KB  |  248 lines

  1. /*
  2.  * $Id: brcGC.c,v 1.2 1991/09/28 03:05:45 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.  *  Hardware interface routines for IBM 8514/A adapter for
  32.  *  X.11 server(s) on IBM equipment.
  33.  *
  34.  */
  35.  
  36. /***********************************************************
  37. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  38. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  39.  
  40.             All Rights Reserved
  41.  
  42. Permission to use, copy, modify, and distribute this software and its
  43. documentation for any purpose and without fee is hereby granted,
  44. provided that the above copyright notice appear in all copies and that
  45. both that copyright notice and this permission notice appear in
  46. supporting documentation, and that the names of Digital or MIT not be
  47. used in advertising or publicity pertaining to distribution of the
  48. software without specific, written prior permission.
  49.  
  50. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  51. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  52. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  53. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  54. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  55. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  56. SOFTWARE.
  57.  
  58. ******************************************************************/
  59.  
  60. #include "X.h"
  61. #include "Xproto.h"
  62. #include "windowstr.h"
  63. #include "window.h"
  64. #include "pixmapstr.h"
  65. #include "scrnintstr.h"
  66. #include "misc.h"
  67. #include "font.h"
  68. #include "gcstruct.h"
  69. #include "cursorstr.h"
  70. #include "region.h"
  71.  
  72. #include "mistruct.h"
  73.  
  74. #include "cfb.h"
  75.  
  76. #include "OScompiler.h"
  77.  
  78. #include "ppc.h"
  79. #include "ppcProcs.h"
  80.  
  81. #include "brcProcs.h"
  82. #include "ibmTrace.h"
  83.  
  84. #ifdef Use8514HardwareDashes
  85. extern void ibm8514_do_dashline_gc() ;
  86. extern void ibm8514ZeroDash() ;        /* will be .h */
  87. #endif
  88.  
  89. extern void miWideLine() ;
  90. extern void miPolyPoint() ;
  91.  
  92. extern int mfbGCPrivateIndex;
  93. extern void ibm8514PolyFillRect();
  94. extern void ibm8514ImageText8(); 
  95. extern void ibm8514ImageText16();
  96. extern void ibm8514ImageGlyphBlt();
  97.  
  98. Mask
  99. ibm8514ChangeGCtype( pGC, devPriv )
  100.      GC *pGC ;
  101.      ppcPrivGCPtr devPriv ;
  102. {
  103.     if ( devPriv->lastDrawableType == DRAWABLE_PIXMAP )
  104.     {
  105.     devPriv->FillArea       = mfbSolidInvertArea ;
  106.     pGC->ops->CopyArea      = miCopyArea ;
  107.     pGC->ops->PolyPoint    = miPolyPoint ; 
  108.     pGC->ops->PolyFillRect  = miPolyFillRect ;
  109.     pGC->ops->FillPolygon   = miFillPolygon ;
  110.     pGC->ops->ImageText8    = miImageText8 ;
  111.     pGC->ops->ImageText16   = miImageText16 ;
  112.     pGC->ops->ImageGlyphBlt = miImageGlyphBlt ;
  113.     pGC->ops->PolyText8     = miPolyText8 ;
  114.     pGC->ops->PolyText16    = miPolyText16 ;
  115.     pGC->ops->PushPixels    = miPushPixels ;
  116.     pGC->ops->PolyGlyphBlt  = miPolyGlyphBlt ;
  117.     pGC->ops->PolySegment   = miPolySegment ;
  118.     }
  119.     else
  120.     {
  121.     devPriv->FillArea       = ppcAreaFill ;
  122.     pGC->ops->CopyArea      = ppcCopyArea ;
  123.     pGC->ops->PolyPoint    = ibm8514PolyPoint ; 
  124.     pGC->ops->PolyFillRect  = ibm8514PolyFillRect; /* ppcPolyFillRect ; */
  125.     pGC->ops->FillPolygon   = ibm8514FillPolygon ;
  126.     pGC->ops->ImageText8    = ibm8514ImageText8 ;
  127.     pGC->ops->ImageText16   = ibm8514ImageText16 ;
  128.     pGC->ops->ImageGlyphBlt = ibm8514ImageGlyphBlt ;
  129.     pGC->ops->PolyText8     = ibm8514PolyText8 ;
  130.     pGC->ops->PolyText16    = ibm8514PolyText16 ;
  131.     pGC->ops->PushPixels    = ibm8514PushPixels ;
  132.     pGC->ops->PolyGlyphBlt  = ppcPolyGlyphBlt ;
  133.     pGC->ops->PolySegment   = ppcScrnZeroSegs ;
  134.     }
  135.     return 0;
  136. }
  137.  
  138. Mask
  139. ibm8514ChangeWindowGC( pGC, changes )
  140.      GC *pGC ;
  141.      Mask changes ;
  142. {
  143.     ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr) ;
  144.     unsigned long int index ;    /* used for stepping through bitfields */
  145.     Mask bsChanges = 0 ;
  146.  
  147. #define LOWBIT( x ) ( x & - x ) /* Two's complement */
  148.     while ( index = LOWBIT( changes ) ) {
  149.     switch ( index ) {
  150.  
  151.       case GCLineStyle:
  152.       case GCLineWidth:
  153.         if ( pGC->lineStyle == LineSolid )
  154.         {
  155.         pGC->ops->PolySegment = ( ( pGC->lineWidth == 0 )
  156.                      ? ppcScrnZeroSegs : miPolySegment ) ;
  157.         pGC->ops->Polylines = ( ( pGC->lineWidth == 0 )
  158.                        ? ppcScrnZeroLine : miWideLine ) ;
  159.         pGC->ops->PolyArc = ( ( pGC->lineWidth == 0 )
  160.                      ? ppcPolyZeroArc : miPolyArc ) ;
  161.         }
  162.         else
  163.         {
  164.         pGC->ops->PolySegment = miPolySegment;
  165. #ifdef Use8514HardwareDashes
  166.         if ( pGC->lineWidth == 0 )
  167.             ibm8514_do_dashline_gc( pGC ) ;
  168.         else
  169.             pGC->ops->Polylines = miWideDash ;
  170. #else
  171.         pGC->ops->Polylines = (( pGC->lineWidth == 0 )
  172.                        ? ppcScrnZeroDash : miWideDash );
  173. #endif
  174.         pGC->ops->PolyArc = miPolyArc;
  175.         }
  176.         /*
  177.          * If these are just square boxes with no funny business
  178.          * going on we can call the fast routine that draws
  179.          * rectangles without floating point.
  180.          */
  181.         if ( ( pGC->lineStyle == LineSolid ) 
  182.         && ( pGC->joinStyle == JoinMiter ) 
  183.         && ( pGC->lineWidth != 0 ) )
  184.         pGC->ops->PolyRectangle = ppcPolyRectangle;
  185.         else
  186.         pGC->ops->PolyRectangle = miPolyRectangle;
  187.  
  188.         changes &= ~( GCLineStyle | GCLineWidth ) ;
  189.         break ;
  190.       case GCJoinStyle:
  191.         pGC->ops->LineHelper =
  192.         ( pGC->joinStyle == JoinMiter ) ? miMiter : miNotMiter ;
  193.         /*
  194.          * If these are just square boxes with no funny business
  195.          * going on we can call the fast routine that draws
  196.          * rectangles without floating point.
  197.          */
  198.         if ( ( pGC->lineStyle == LineSolid ) 
  199.         && ( pGC->joinStyle == JoinMiter ) 
  200.         && ( pGC->lineWidth != 0 ) )
  201.         pGC->ops->PolyRectangle = ppcPolyRectangle;
  202.         else
  203.         pGC->ops->PolyRectangle = miPolyRectangle;
  204.         changes &= ~ index ; /* i.e. changes &= ~ GCJoinStyle */
  205.         break ;
  206.  
  207.       case GCBackground:
  208.         if ( pGC->fillStyle != FillOpaqueStippled )
  209.         {
  210.         changes &= ~ index ; /* i.e. changes &= ~GCBackground */
  211.         break ;
  212.         }            /* else Fall Through */
  213.       case GCForeground:
  214.         if ( pGC->fillStyle == FillTiled )
  215.         {
  216.         changes &= ~ index ; /* i.e. changes &= ~GCForeground */
  217.         break ;
  218.         }            /* else Fall Through */
  219.       case GCFunction:
  220.       case GCPlaneMask:
  221.       case GCFillStyle:
  222.         {            /* new_fill */
  223.         int fillStyle = devPriv->colorRrop.fillStyle ;
  224.         /* install a suitable fillspans */
  225.         if ( fillStyle == FillSolid )
  226.             pGC->ops->FillSpans = ibm8514SolidFS ;
  227.         else if ( fillStyle == FillStippled )
  228.             pGC->ops->FillSpans = ppcStippleWindowFS ;
  229.         else if ( fillStyle == FillOpaqueStippled )
  230.             pGC->ops->FillSpans = ppcOpStippleWindowFS ;
  231.         else        /* fillStyle == FillTiled */
  232.             pGC->ops->FillSpans = ibm8514TileFS ;
  233.         pGC->ops->PolyFillArc = ppcPolyFillArc;
  234.         }            /* end of new_fill */
  235.         changes &= ~( GCBackground | GCForeground
  236.              | GCFunction
  237.              | GCPlaneMask | GCFillStyle ) ;
  238.         break ;
  239.  
  240.       default:
  241.         ErrorF( "ibm8514ValidateGC: Unexpected GC Change\n" ) ;
  242.         changes &= ~ index ; /* Remove it anyway */
  243.         break ;
  244.     }
  245.     }
  246.     return bsChanges ;
  247. }
  248.