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 / brcGBlt.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  8KB  |  261 lines

  1. /*
  2.  * $Id: brcGBlt.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.  *  Hardware interface routines for IBM 8514/A adapter for
  32.  *  X.11 server(s) on IBM equipment.
  33.  *
  34.  */
  35.  
  36. /* 
  37.  * Image Glyph Blit
  38.  * For use when font cache is full
  39.  *
  40.  */
  41.  
  42. #include "X.h"
  43. #include "Xmd.h"
  44. #include "Xproto.h"
  45. #include "scrnintstr.h"
  46. #include "dixfontstr.h"
  47. #include "gcstruct.h"
  48. #include "windowstr.h"
  49. #include "pixmapstr.h"
  50. #include "regionstr.h"
  51.  
  52. #include "OScompiler.h"
  53.  
  54. #include "ppc.h"
  55.  
  56. #include "x8514.h"
  57.  
  58. #include "ibmTrace.h"
  59.  
  60. extern int ibm8514cursorSemaphore;
  61. extern int mfbGCPrivateIndex;
  62.  
  63. void
  64. ibm8514ImageGlyphBlt( pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
  65.     DrawablePtr pDrawable;
  66.     GC         *pGC;
  67.     int     x, y;
  68.     unsigned int nglyph;
  69.     CharInfoPtr *ppci;        /* array of character info */
  70.     unsigned char *pglyphBase;    /* start of array of glyphs */
  71. {
  72.     int CursorIsSaved;
  73.     ExtentInfoRec info;    /* used by QueryGlyphExtents() */
  74.     BoxRec bbox;    /* string's bounding box */
  75.     xRectangle backrect;/* backing rectangle to paint.
  76.                in the general case, NOT necessarily
  77.                the same as the string's bounding box
  78.             */
  79.     CharInfoPtr pci;
  80.     int xorg, yorg;    /* origin of drawable in bitmap */
  81.     int w;        /* width of glyph in bits */
  82.     int h;        /* height of glyph */
  83.     unsigned char *pglyph;
  84.             /* pointer to current row of glyph */
  85.     int nbox;
  86.     BoxPtr pbox;
  87.     int i ;
  88.     RegionPtr pRegion;
  89.     unsigned long int pm, bg, fg ;
  90.     int x0, y0 ;
  91.  
  92.     TRACE(("ibm8514ImageGlyphBlt( pDrawable = 0x%x, pGC = 0x%x, x=%d, y=%d, nglyph=%d, ppci= 0x%x, pglyphBase= 0x%x)\n", pDrawable, pGC, x, y, nglyph, ppci, pglyphBase));
  93.     if ( !( pGC->planemask & ibm8514ALLPLANES ) )
  94.     return ;
  95.  
  96.     xorg = pDrawable->x;
  97.     yorg = pDrawable->y;
  98.  
  99.     QueryGlyphExtents(pGC->font, ppci, nglyph, &info);
  100.  
  101.     x += xorg;
  102.     y += yorg;
  103.  
  104.     backrect.x = x + info.overallLeft;
  105.     backrect.y = y - FONTASCENT(pGC->font);
  106.     backrect.width = info.overallRight - info.overallLeft;
  107.     backrect.width = MAX( backrect.width, info.overallWidth );
  108.     backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
  109.  
  110.     bbox.x1 = x + info.overallLeft;
  111.     bbox.x2 = x + info.overallRight;
  112.     bbox.y1 = y - info.overallAscent;
  113.     bbox.y2 = y + info.overallDescent;
  114.  
  115.     pRegion = ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip;
  116.     nbox = REGION_NUM_RECTS(pRegion);
  117.     if ( nbox == 0 )
  118.     return;
  119.  
  120.  
  121.     pbox = REGION_RECTS(pRegion);
  122.     pm =  pGC->planemask;
  123.     fg =  pGC->fgPixel;
  124.     bg =  pGC->bgPixel;
  125.     CursorIsSaved = !ibm8514cursorSemaphore && ibm8514CheckCursor( backrect.x, backrect.y, backrect.width, backrect.height );
  126.     for ( i = nbox ; i-- ; pbox++ ) {
  127.     ibm8514ClearQueue(4);
  128.     SETXMIN(pbox->x1);
  129.     SETYMIN(pbox->y1);
  130.     SETXMAX(pbox->x2-1);
  131.     SETYMAX(pbox->y2-1);
  132.     ibm8514DrawRectangle( bg, GXcopy, pm,
  133.         backrect.x, backrect.y,
  134.         backrect.width, backrect.height);
  135.     }
  136.  
  137.     ibm8514ClearQueue(4);
  138.     SETXMIN(0);
  139.     SETYMIN(0);
  140.     SETXMAX(_8514_SCREEN_WIDTH-1);
  141.     SETYMAX( 1023 ) ;
  142.  
  143.     if ( CursorIsSaved )
  144.     ibm8514ReplaceCursor();
  145.  
  146.     CursorIsSaved = !ibm8514cursorSemaphore && ibm8514CheckCursor( bbox.x1, bbox.y1, bbox.x2-bbox.x1, bbox.y2-bbox.y1 );
  147.  
  148.     switch ( (*pGC->pScreen->RectIn)(
  149.           ( (ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, &bbox ) )
  150.     {
  151.       case rgnOUT:
  152.     break;
  153.       case rgnIN:
  154.  
  155.         while (nglyph--)
  156.         {
  157.         pci = *ppci;
  158.         pglyph = FONTGLYPHBITS(pglyphBase, pci);
  159.         w = GLYPHWIDTHPIXELS(pci);
  160.         h = GLYPHHEIGHTPIXELS(pci);
  161.         x0 = x + pci->metrics.leftSideBearing;
  162.         y0 = y - pci->metrics.ascent;
  163.         /* draw offscreen */
  164.         ibm8514ByteAlignMonoImage( MONO_STAGE_WPLANE, GXcopy,
  165.                        MONO_STAGE_X, MONO_STAGE_Y,
  166.                        w, h, pglyph ) ;
  167.         /* blit onscreen */
  168.         ibm8514BlitFG( MONO_STAGE_RPLANE, pm, fg, GXcopy,
  169.                MONO_STAGE_X, MONO_STAGE_Y, x0, y0, w, h ) ;
  170.  
  171.         /* update character origin */
  172.         x += pci->metrics.characterWidth;
  173.         ppci++;
  174.         } /* while nglyph-- */
  175.     break;
  176.       case rgnPART:
  177.       {
  178.     RegionPtr prgnClip;
  179.     BoxRec    cbox;
  180.     int       glx, gly;
  181.  
  182.         while (nglyph--)
  183.         {
  184.         pci = *ppci;
  185.         pglyph = FONTGLYPHBITS(pglyphBase, pci);
  186.         w = GLYPHWIDTHPIXELS(pci);
  187.         h = GLYPHHEIGHTPIXELS(pci);
  188.         cbox.x1 = glx = x + pci->metrics.leftSideBearing;
  189.         cbox.y1 = gly = y - pci->metrics.ascent;
  190.         cbox.x2 = cbox.x1 + w;
  191.         cbox.y2 = cbox.y1 + h;
  192.  
  193.         switch ((*pGC->pScreen->RectIn)(
  194.           ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, &cbox))
  195.  
  196.         {
  197.           case rgnOUT:
  198.         break;
  199.           case rgnIN:
  200.         /* draw offscreen */
  201.             ibm8514ByteAlignMonoImage( MONO_STAGE_WPLANE, GXcopy,
  202.                            MONO_STAGE_X, MONO_STAGE_Y,
  203.                            w, h, pglyph ) ;
  204.         /* blit onscreen */
  205.             ibm8514BlitFG( MONO_STAGE_RPLANE, pm, fg, GXcopy,
  206.                    MONO_STAGE_X, MONO_STAGE_Y,
  207.                    glx, gly, w, h ) ;
  208.         break;
  209.           case rgnPART:
  210.         prgnClip =
  211.           (* ((WindowPtr)pDrawable)->drawable.pScreen->RegionCreate)(
  212.           &cbox, 
  213.           REGION_NUM_RECTS(((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip)) ;
  214.         (* ((WindowPtr)pDrawable)->drawable.pScreen->Intersect)
  215.             ( prgnClip, prgnClip, 
  216.               ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip ) ;
  217.         if ( !( nbox = REGION_NUM_RECTS(prgnClip) ) )
  218.             break;
  219.         pbox = REGION_RECTS(prgnClip);
  220.         /* draw offscreen */
  221.             ibm8514ByteAlignMonoImage( MONO_STAGE_WPLANE, GXcopy,
  222.                        MONO_STAGE_X, MONO_STAGE_Y,
  223.                        w, h, pglyph ) ;
  224. /* ****** THIS STINKS & MUST BE FIXED SOMEDAY -- SOON ****** */
  225.         for ( i = nbox ; i-- ; pbox++ ) {
  226.             ibm8514ClearQueue( 4 ) ;
  227.             SETXMIN(pbox->x1);
  228.             SETYMIN(pbox->y1);
  229.             SETXMAX(pbox->x2-1);
  230.             SETYMAX(pbox->y2-1);
  231.             /* blit onscreen*/
  232.                 ibm8514BlitFG( MONO_STAGE_RPLANE, pm, fg, GXcopy,
  233.                        MONO_STAGE_X, MONO_STAGE_Y,
  234.                        glx, gly, w, h ) ;
  235. TRACE(("gbltPARTPART: call BlitFG: x=%d, y=%d, w=%d, h=%d\n", glx,gly,w,h));
  236.         }
  237.  
  238.         (* ((WindowPtr)pDrawable)->drawable.pScreen->RegionDestroy)
  239.             (prgnClip);
  240.         ibm8514ClearQueue( 4 );
  241.         SETXMIN(0);
  242.         SETYMIN(0);
  243.         SETXMAX(_8514_SCREEN_WIDTH-1);
  244.         SETYMAX( 1023 ) ;
  245.         break;
  246.         }
  247.         /* update character origin */
  248.         x += pci->metrics.characterWidth;
  249.         ppci++;
  250.         } /* while nglyph-- */
  251.  
  252.       }
  253.       default:
  254.     break;
  255.     }
  256.  
  257.     if ( CursorIsSaved )
  258.     ibm8514ReplaceCursor();
  259.     return ;
  260. }
  261.