Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbwindow.c, revision 1.1.1.1

1.1       root        1: /* $Header: mfbwindow.c,v 1.2 87/09/03 13:48:44 toddb Exp $ */
                      2: /***********************************************************
                      3: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
                      4: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
                      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 names of Digital or MIT not be
                     13: used in advertising or publicity pertaining to distribution of the
                     14: software without specific, written prior permission.  
                     15: 
                     16: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
                     17: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
                     18: DIGITAL 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: #include "X.h"
                     27: #include "scrnintstr.h"
                     28: #include "windowstr.h"
                     29: #include "mfb.h"
                     30: #include "mistruct.h"
                     31: #include "regionstr.h"
                     32: 
                     33: extern WindowRec WindowTable[];
                     34: 
                     35: Bool mfbCreateWindow(pWin)
                     36: register WindowPtr pWin;
                     37: {
                     38:     register mfbPrivWin *pPrivWin;
                     39: 
                     40:     pWin->ClearToBackground = miClearToBackground;
                     41:     pWin->PaintWindowBackground = mfbPaintWindowNone;
                     42:     pWin->PaintWindowBorder = mfbPaintWindowPR;
                     43: 
                     44:     pWin->CopyWindow = mfbCopyWindow;
                     45:     if(!(pPrivWin = (mfbPrivWin *)Xalloc(sizeof(mfbPrivWin))))
                     46:         return (FALSE);
                     47:     pWin->devPrivate = (pointer)pPrivWin;
                     48:     pPrivWin->pRotatedBorder = NullPixmap;
                     49:     pPrivWin->pRotatedBackground = NullPixmap;
                     50:     pPrivWin->fastBackground = 0;
                     51:     pPrivWin->fastBorder = 0;
                     52: 
                     53:     /* backing store stuff 
                     54:        is this ever called with backing store turned on ???
                     55:     */
                     56:     if ((pWin->backingStore == WhenMapped) ||
                     57:        (pWin->backingStore == Always))
                     58:     {
                     59:     }
                     60:     else
                     61:     {
                     62:     }
                     63:     return (TRUE);
                     64: }
                     65: 
                     66: /* This always returns true, because Xfree can't fail.  It might be possible
                     67:  * on some devices for Destroy to fail */
                     68: Bool 
                     69: mfbDestroyWindow(pWin)
                     70: WindowPtr pWin;
                     71: {
                     72:     register mfbPrivWin *pPrivWin;
                     73: 
                     74:     pPrivWin = (mfbPrivWin *)(pWin->devPrivate);
                     75: 
                     76:     /* mfbDestroyPixmap() deals with any NULL pointers */
                     77:     mfbDestroyPixmap(pPrivWin->pRotatedBorder);
                     78:     mfbDestroyPixmap(pPrivWin->pRotatedBackground);
                     79:     Xfree(pWin->devPrivate);
                     80:     return (TRUE);
                     81: }
                     82: 
                     83: Bool mfbMapWindow(pWindow)
                     84: WindowPtr pWindow;
                     85: {
                     86:     return (TRUE);
                     87: }
                     88: 
                     89: /* (x, y) is the upper left corner of the window on the screen 
                     90:    do we really need to pass this?  (is it a;ready in pWin->absCorner?)
                     91:    we only do the rotation for pixmaps that are 32 bits wide (padded
                     92: or otherwise.)
                     93:    mfbChangeWindowAttributes() has already put a copy of the pixmap
                     94: in pPrivWin->pRotated*
                     95: */
                     96: 
                     97: Bool 
                     98: mfbPositionWindow(pWin, x, y)
                     99: register WindowPtr pWin;
                    100: int x, y;
                    101: {
                    102:     register mfbPrivWin *pPrivWin;
                    103: 
                    104:     pPrivWin = (mfbPrivWin *)(pWin->devPrivate);
                    105:     if (IS_VALID_PIXMAP(pWin->backgroundTile) &&
                    106:        (pPrivWin->fastBackground != 0))
                    107:     {
                    108:        mfbXRotatePixmap(pPrivWin->pRotatedBackground,
                    109:                         pWin->absCorner.x - pPrivWin->oldRotate.x);
                    110:        mfbYRotatePixmap(pPrivWin->pRotatedBackground,
                    111:                         pWin->absCorner.y - pPrivWin->oldRotate.y);
                    112:     }
                    113: 
                    114:     if (IS_VALID_PIXMAP(pWin->borderTile) &&
                    115:        (pPrivWin->fastBorder != 0))
                    116:     {
                    117:        mfbXRotatePixmap(pPrivWin->pRotatedBorder,
                    118:                         pWin->absCorner.x - pPrivWin->oldRotate.x);
                    119:        mfbYRotatePixmap(pPrivWin->pRotatedBorder,
                    120:                         pWin->absCorner.y - pPrivWin->oldRotate.y);
                    121:     }
                    122:     if ( (IS_VALID_PIXMAP(pWin->borderTile) &&
                    123:          (pPrivWin->fastBorder != 0))
                    124:        ||
                    125:         (IS_VALID_PIXMAP(pWin->backgroundTile) &&
                    126:          (pPrivWin->fastBackground != 0)))
                    127:     {
                    128:        pPrivWin->oldRotate.x = pWin->absCorner.x;
                    129:        pPrivWin->oldRotate.y = pWin->absCorner.y;
                    130:     }
                    131:     /* Again, we have no failure modes indicated by any of the routines
                    132:      * we've called, so we have to assume it worked */
                    133:     return (TRUE);
                    134: }
                    135: 
                    136: Bool 
                    137: mfbUnmapWindow(pWindow, x, y)
                    138: WindowPtr pWindow;
                    139: int x, y;
                    140: {
                    141:     return (TRUE);
                    142: }
                    143: 
                    144: /* UNCLEAN!
                    145:    this code calls the bitblt helper code directly.
                    146: 
                    147:    mfbCopyWindow copies only the parts of the destination that are
                    148: visible in the source.
                    149: */
                    150: 
                    151: 
                    152: void 
                    153: mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
                    154:     WindowPtr pWin;
                    155:     DDXPointRec ptOldOrg;
                    156:     RegionPtr prgnSrc;
                    157: {
                    158:     DDXPointPtr pptSrc;
                    159:     register DDXPointPtr ppt;
                    160:     RegionPtr prgnDst;
                    161:     register BoxPtr pbox;
                    162:     register int dx, dy;
                    163:     register int i, nbox;
                    164:     WindowPtr pwinRoot;
                    165: 
                    166:     pwinRoot = &WindowTable[pWin->drawable.pScreen->myNum];
                    167: 
                    168:     prgnDst = (* pWin->drawable.pScreen->RegionCreate)(NULL, 
                    169:                                               pWin->borderClip->numRects);
                    170: 
                    171:     dx = ptOldOrg.x - pWin->absCorner.x;
                    172:     dy = ptOldOrg.y - pWin->absCorner.y;
                    173:     (* pWin->drawable.pScreen->TranslateRegion)(prgnSrc, -dx, -dy);
                    174:     (* pWin->drawable.pScreen->Intersect)(prgnDst, pWin->borderClip, prgnSrc);
                    175: 
                    176:     pbox = prgnDst->rects;
                    177:     nbox = prgnDst->numRects;
                    178:     if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL( prgnDst->numRects *
                    179:       sizeof(DDXPointRec))))
                    180:        return;
                    181:     ppt = pptSrc;
                    182: 
                    183:     for (i=0; i<nbox; i++, ppt++, pbox++)
                    184:     {
                    185:        ppt->x = pbox->x1 + dx;
                    186:        ppt->y = pbox->y1 + dy;
                    187:     }
                    188: 
                    189:     mfbDoBitblt(pwinRoot, pwinRoot, GXcopy, prgnDst, pptSrc);
                    190:     DEALLOCATE_LOCAL(pptSrc);
                    191:     (* pWin->drawable.pScreen->RegionDestroy)(prgnDst);
                    192: }
                    193: 
                    194: 
                    195: 
                    196: /* swap in correct PaintWindow* routine.  If we can use a fast output
                    197: routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
                    198: of it in devPrivate.
                    199: */
                    200: Bool
                    201: mfbChangeWindowAttributes(pWin, mask)
                    202:     register WindowPtr pWin;
                    203:     register int mask;
                    204: {
                    205:     register int index;
                    206:     register mfbPrivWin *pPrivWin;
                    207: 
                    208:     pPrivWin = (mfbPrivWin *)(pWin->devPrivate);
                    209:     while(mask)
                    210:     {
                    211:        index = ffs(mask) -1;
                    212:        mask &= ~(index = 1 << index);
                    213:        switch(index)
                    214:        {
                    215:          case CWBackingStore:
                    216: /*
                    217:            if ((pWin->backingStore == WhenMapped) ||
                    218:                (pWin->backingStore == Always))
                    219:            {
                    220:            }
                    221:            else
                    222:            {
                    223:            }
                    224: */
                    225:            break;
                    226: 
                    227:          case CWBackPixmap:
                    228:              switch((int)pWin->backgroundTile)
                    229:              {
                    230:                case None:
                    231:                  pWin->PaintWindowBackground = mfbPaintWindowNone;
                    232:                  pPrivWin->fastBackground = 0;
                    233:                  break;
                    234:                case ParentRelative:
                    235:                  pWin->PaintWindowBackground = mfbPaintWindowPR;
                    236:                  pPrivWin->fastBackground = 0;
                    237:                  break;
                    238:                case USE_BACKGROUND_PIXEL:
                    239:                   pWin->PaintWindowBackground = mfbPaintWindowSolid;
                    240:                  pPrivWin->fastBackground = 0;
                    241:                  break;
                    242:                default:
                    243:                  if(mfbPadPixmap(pWin->backgroundTile))
                    244:                  {
                    245:                      pPrivWin->fastBackground = 1;
                    246:                      pPrivWin->oldRotate.x = pWin->absCorner.x;
                    247:                      pPrivWin->oldRotate.y = pWin->absCorner.y;
                    248:                      if (pPrivWin->pRotatedBackground)
                    249:                          mfbDestroyPixmap(pPrivWin->pRotatedBackground);
                    250:                      pPrivWin->pRotatedBackground =
                    251:                        mfbCopyPixmap(pWin->backgroundTile);
                    252:                      mfbXRotatePixmap(pPrivWin->pRotatedBackground,
                    253:                                       pWin->absCorner.x);
                    254:                      mfbYRotatePixmap(pPrivWin->pRotatedBackground,
                    255:                                       pWin->absCorner.y);
                    256:                      pWin->PaintWindowBackground = mfbPaintWindow32;
                    257:                  }
                    258:                  else
                    259:                  {
                    260:                      pPrivWin->fastBackground = 0;
                    261:                      pWin->PaintWindowBackground = miPaintWindow;
                    262:                  }
                    263:                  break;
                    264:              }
                    265:              break;
                    266: 
                    267:          case CWBackPixel:
                    268:               pWin->PaintWindowBackground = mfbPaintWindowSolid;
                    269:              pPrivWin->fastBackground = 0;
                    270:              break;
                    271: 
                    272:          case CWBorderPixmap:
                    273:              switch((int)pWin->borderTile)
                    274:              {
                    275:                case None:
                    276:                  pWin->PaintWindowBorder = mfbPaintWindowNone;
                    277:                  pPrivWin->fastBorder = 0;
                    278:                  break;
                    279:                case ParentRelative:
                    280:                  pWin->PaintWindowBorder = mfbPaintWindowPR;
                    281:                  pPrivWin->fastBorder = 0;
                    282:                  break;
                    283:                case USE_BORDER_PIXEL:
                    284:                  pWin->PaintWindowBorder = mfbPaintWindowSolid;
                    285:                  pPrivWin->fastBorder = 0;
                    286:                  break;
                    287:                default:
                    288:                  if(mfbPadPixmap(pWin->borderTile))
                    289:                  {
                    290:                      pPrivWin->fastBorder = 1;
                    291:                      pPrivWin->oldRotate.x = pWin->absCorner.x;
                    292:                      pPrivWin->oldRotate.y = pWin->absCorner.y;
                    293:                      if (pPrivWin->pRotatedBorder)
                    294:                          mfbDestroyPixmap(pPrivWin->pRotatedBorder);
                    295:                      pPrivWin->pRotatedBorder =
                    296:                        mfbCopyPixmap(pWin->borderTile);
                    297:                      mfbXRotatePixmap(pPrivWin->pRotatedBorder,
                    298:                                       pWin->absCorner.x);
                    299:                      mfbYRotatePixmap(pPrivWin->pRotatedBorder,
                    300:                                       pWin->absCorner.y);
                    301:                      pWin->PaintWindowBorder = mfbPaintWindow32;
                    302:                  }
                    303:                  else
                    304:                  {
                    305:                      pPrivWin->fastBorder = 0;
                    306:                      pWin->PaintWindowBorder = miPaintWindow;
                    307:                  }
                    308:                  break;
                    309:              }
                    310:              break;
                    311:            case CWBorderPixel:
                    312:              pWin->PaintWindowBorder = mfbPaintWindowSolid;
                    313:              pPrivWin->fastBorder = 0;
                    314:              break;
                    315: 
                    316:        }
                    317:     }
                    318:     /* Again, we have no failure modes indicated by any of the routines
                    319:      * we've called, so we have to assume it worked */
                    320:     return (TRUE);
                    321: }
                    322: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.