Annotation of ntddk/src/video/displays/xga/bitblt.c, revision 1.1

1.1     ! root        1: /******************************Module*Header*******************************\
        !             2: * Module Name: bitblt.c
        !             3: *
        !             4: * XGA bitblit accelerations
        !             5: *
        !             6: * Copyright (c) 1992 Microsoft Corporation
        !             7: *
        !             8: \**************************************************************************/
        !             9: 
        !            10: #include "driver.h"
        !            11: 
        !            12: 
        !            13: BOOL bSpecialBlits(
        !            14:     SURFOBJ  *psoTrg,
        !            15:     SURFOBJ  *psoSrc,
        !            16:     SURFOBJ  *psoMask,
        !            17:     CLIPOBJ  *pco,
        !            18:     XLATEOBJ *pxlo,
        !            19:     RECTL    *prclTrg,
        !            20:     POINTL   *pptlSrc,
        !            21:     POINTL   *pptlMask,
        !            22:     BRUSHOBJ *pbo,
        !            23:     POINTL   *pptlBrush,
        !            24:     ROP4     rop4
        !            25: );
        !            26: 
        !            27: BOOL bScrnToScrnCpy(
        !            28:     SURFOBJ  *psoTrg,
        !            29:     SURFOBJ  *psoSrc,
        !            30:     SURFOBJ  *psoMask,
        !            31:     CLIPOBJ  *pco,
        !            32:     XLATEOBJ *pxlo,
        !            33:     RECTL    *prclTrg,
        !            34:     POINTL   *pptlSrc,
        !            35:     POINTL   *pptlMask,
        !            36:     BRUSHOBJ *pbo,
        !            37:     POINTL   *pptlBrush,
        !            38:     ROP4     rop4
        !            39: );
        !            40: 
        !            41: 
        !            42: BOOL bSolidPattern(
        !            43:     SURFOBJ  *psoTrg,
        !            44:     SURFOBJ  *psoSrc,
        !            45:     SURFOBJ  *psoMask,
        !            46:     CLIPOBJ  *pco,
        !            47:     XLATEOBJ *pxlo,
        !            48:     RECTL    *prclTrg,
        !            49:     POINTL   *pptlSrc,
        !            50:     POINTL   *pptlMask,
        !            51:     BRUSHOBJ *pbo,
        !            52:     POINTL   *pptlBrush,
        !            53:     ROP4     rop4
        !            54: );
        !            55: 
        !            56: 
        !            57: 
        !            58: /******************************Public*Data*********************************\
        !            59: * ROP translation table
        !            60: *
        !            61: * Translates the usual ternary rop into A-vector notation.  Each bit in
        !            62: * this new notation corresponds to a term in a polynomial translation of
        !            63: * the rop.
        !            64: *
        !            65: * Rop(D,S,P) = a + a D + a S + a P + a  DS + a  DP + a  SP + a   DSP
        !            66: *               0   d     s     p     ds      dp      sp      dsp
        !            67: *
        !            68: \**************************************************************************/
        !            69: 
        !            70: BYTE gajRop[] =
        !            71: {
        !            72:     0x00, 0xff, 0xb2, 0x4d, 0xd4, 0x2b, 0x66, 0x99,
        !            73:     0x90, 0x6f, 0x22, 0xdd, 0x44, 0xbb, 0xf6, 0x09,
        !            74:     0xe8, 0x17, 0x5a, 0xa5, 0x3c, 0xc3, 0x8e, 0x71,
        !            75:     0x78, 0x87, 0xca, 0x35, 0xac, 0x53, 0x1e, 0xe1,
        !            76:     0xa0, 0x5f, 0x12, 0xed, 0x74, 0x8b, 0xc6, 0x39,
        !            77:     0x30, 0xcf, 0x82, 0x7d, 0xe4, 0x1b, 0x56, 0xa9,
        !            78:     0x48, 0xb7, 0xfa, 0x05, 0x9c, 0x63, 0x2e, 0xd1,
        !            79:     0xd8, 0x27, 0x6a, 0x95, 0x0c, 0xf3, 0xbe, 0x41,
        !            80:     0xc0, 0x3f, 0x72, 0x8d, 0x14, 0xeb, 0xa6, 0x59,
        !            81:     0x50, 0xaf, 0xe2, 0x1d, 0x84, 0x7b, 0x36, 0xc9,
        !            82:     0x28, 0xd7, 0x9a, 0x65, 0xfc, 0x03, 0x4e, 0xb1,
        !            83:     0xb8, 0x47, 0x0a, 0xf5, 0x6c, 0x93, 0xde, 0x21,
        !            84:     0x60, 0x9f, 0xd2, 0x2d, 0xb4, 0x4b, 0x06, 0xf9,
        !            85:     0xf0, 0x0f, 0x42, 0xbd, 0x24, 0xdb, 0x96, 0x69,
        !            86:     0x88, 0x77, 0x3a, 0xc5, 0x5c, 0xa3, 0xee, 0x11,
        !            87:     0x18, 0xe7, 0xaa, 0x55, 0xcc, 0x33, 0x7e, 0x81,
        !            88:     0x80, 0x7f, 0x32, 0xcd, 0x54, 0xab, 0xe6, 0x19,
        !            89:     0x10, 0xef, 0xa2, 0x5d, 0xc4, 0x3b, 0x76, 0x89,
        !            90:     0x68, 0x97, 0xda, 0x25, 0xbc, 0x43, 0x0e, 0xf1,
        !            91:     0xf8, 0x07, 0x4a, 0xb5, 0x2c, 0xd3, 0x9e, 0x61,
        !            92:     0x20, 0xdf, 0x92, 0x6d, 0xf4, 0x0b, 0x46, 0xb9,
        !            93:     0xb0, 0x4f, 0x02, 0xfd, 0x64, 0x9b, 0xd6, 0x29,
        !            94:     0xc8, 0x37, 0x7a, 0x85, 0x1c, 0xe3, 0xae, 0x51,
        !            95:     0x58, 0xa7, 0xea, 0x15, 0x8c, 0x73, 0x3e, 0xc1,
        !            96:     0x40, 0xbf, 0xf2, 0x0d, 0x94, 0x6b, 0x26, 0xd9,
        !            97:     0xd0, 0x2f, 0x62, 0x9d, 0x04, 0xfb, 0xb6, 0x49,
        !            98:     0xa8, 0x57, 0x1a, 0xe5, 0x7c, 0x83, 0xce, 0x31,
        !            99:     0x38, 0xc7, 0x8a, 0x75, 0xec, 0x13, 0x5e, 0xa1,
        !           100:     0xe0, 0x1f, 0x52, 0xad, 0x34, 0xcb, 0x86, 0x79,
        !           101:     0x70, 0x8f, 0xc2, 0x3d, 0xa4, 0x5b, 0x16, 0xe9,
        !           102:     0x08, 0xf7, 0xba, 0x45, 0xdc, 0x23, 0x6e, 0x91,
        !           103:     0x98, 0x67, 0x2a, 0xd5, 0x4c, 0xb3, 0xfe, 0x01
        !           104: };
        !           105: 
        !           106: 
        !           107: /*****************************************************************************
        !           108:  * XGA DrvBitBlt
        !           109:  ****************************************************************************/
        !           110: BOOL DrvBitBlt(
        !           111: SURFOBJ  *psoTrg,
        !           112: SURFOBJ  *psoSrc,
        !           113: SURFOBJ  *psoMask,
        !           114: CLIPOBJ  *pco,
        !           115: XLATEOBJ *pxlo,
        !           116: RECTL    *prclTrg,
        !           117: POINTL   *pptlSrc,
        !           118: POINTL   *pptlMask,
        !           119: BRUSHOBJ *pbo,
        !           120: POINTL   *pptlBrush,
        !           121: ROP4     rop4)
        !           122: 
        !           123: {
        !           124: BOOL    b;
        !           125: 
        !           126: 
        !           127:         b = bSpecialBlits(psoTrg, psoSrc, psoMask,
        !           128:                           pco, pxlo,
        !           129:                           prclTrg, pptlSrc, pptlMask,
        !           130:                           pbo, pptlBrush,
        !           131:                           rop4);
        !           132:         if (b == TRUE)
        !           133:         {
        !           134:             return (TRUE);
        !           135:         }
        !           136: 
        !           137:         if ((psoTrg) && (psoTrg->iType == STYPE_DEVICE))
        !           138:             psoTrg = ((PPDEV)(psoTrg->dhpdev))->pSurfObj;
        !           139: 
        !           140:         if ((psoSrc) && (psoSrc->iType == STYPE_DEVICE))
        !           141:             psoSrc = ((PPDEV)(psoSrc->dhpdev))->pSurfObj;
        !           142: 
        !           143:         EngBitBlt(psoTrg,
        !           144:                   psoSrc,
        !           145:                   psoMask,
        !           146:                   pco,
        !           147:                   pxlo,
        !           148:                   prclTrg,
        !           149:                   pptlSrc,
        !           150:                   pptlMask,
        !           151:                   pbo,
        !           152:                   pptlBrush,
        !           153:                   rop4);
        !           154: 
        !           155: 
        !           156: }
        !           157: 
        !           158: 
        !           159: /*****************************************************************************
        !           160:  * XGA Special case Blit handler
        !           161:  *
        !           162:  *  Returns TRUE if the blit was handled.
        !           163:  ****************************************************************************/
        !           164: BOOL bSpecialBlits(
        !           165: SURFOBJ  *psoTrg,
        !           166: SURFOBJ  *psoSrc,
        !           167: SURFOBJ  *psoMask,
        !           168: CLIPOBJ  *pco,
        !           169: XLATEOBJ *pxlo,
        !           170: RECTL    *prclTrg,
        !           171: POINTL   *pptlSrc,
        !           172: POINTL   *pptlMask,
        !           173: BRUSHOBJ *pbo,
        !           174: POINTL   *pptlBrush,
        !           175: ROP4     rop4)
        !           176: {
        !           177: BOOL    b;
        !           178: HSURF   hsurfSrc, hsurfTrg;
        !           179: 
        !           180:         b = FALSE;
        !           181: 
        !           182:         DISPDBG((3, "XGA.DLL!bSpecialBlits - rop4: %8.8X\n", rop4));
        !           183:         DISPDBG((3, "XGA.DLL!bSpecialBlits - pbo : %8.8X\n", pbo));
        !           184: 
        !           185:         // Wait for the coprocessor.
        !           186: 
        !           187:         vWaitForCoProcessor((PPDEV)psoTrg->dhpdev, 100);
        !           188: 
        !           189:         // NOTE: If the ForeRop and BackRop are the same implicitly
        !           190:         //       there is no mask.
        !           191: 
        !           192:         // First test for a screen to screen copy.
        !           193: 
        !           194:         if (rop4 == 0x0000CCCC)
        !           195:         {
        !           196: 
        !           197:             if (psoTrg != NULL)
        !           198:                 hsurfTrg = psoTrg->hsurf;
        !           199: 
        !           200:             if (psoSrc != NULL)
        !           201:                 hsurfSrc = psoSrc->hsurf;
        !           202: 
        !           203:             if (hsurfTrg == hsurfSrc)
        !           204:             {
        !           205: 
        !           206:                 if (((PPDEV)psoTrg->dhpdev)->ulfBlitAccelerations_debug & SCRN_TO_SCRN_CPY)
        !           207:                 {
        !           208:                     b = bScrnToScrnCpy(psoTrg, psoSrc, psoMask,
        !           209:                                        pco, pxlo,
        !           210:                                        prclTrg, pptlSrc, pptlMask,
        !           211:                                        pbo, pptlBrush,
        !           212:                                        rop4);
        !           213:                 }
        !           214:                 else
        !           215:                 {
        !           216:                     b = FALSE;
        !           217:                 }
        !           218: 
        !           219:             }
        !           220: 
        !           221:         }
        !           222: 
        !           223:         // Check for a Solid Brush.
        !           224: 
        !           225:         if (rop4 == 0x0000F0F0)
        !           226:         {
        !           227:             if (pbo->iSolidColor != -1)
        !           228:             {
        !           229:                 if (((PPDEV)psoTrg->dhpdev)->ulfBlitAccelerations_debug & SOLID_PATTERN)
        !           230:                 {
        !           231:                     b = bSolidPattern(psoTrg, psoSrc, psoMask,
        !           232:                                       pco, pxlo,
        !           233:                                       prclTrg, pptlSrc, pptlMask,
        !           234:                                       pbo, pptlBrush,
        !           235:                                       rop4);
        !           236:                 }
        !           237:                 else
        !           238:                 {
        !           239:                     b = FALSE;
        !           240:                 }
        !           241: 
        !           242:             }
        !           243: 
        !           244:         }
        !           245: 
        !           246:         return (b);
        !           247: 
        !           248: }
        !           249: 
        !           250: 
        !           251: /*****************************************************************************
        !           252:  * XGA Screen to Screen Copy
        !           253:  *
        !           254:  *  Returns TRUE if the blit was handled.
        !           255:  ****************************************************************************/
        !           256: BOOL bScrnToScrnCpy(
        !           257: SURFOBJ  *psoTrg,
        !           258: SURFOBJ  *psoSrc,
        !           259: SURFOBJ  *psoMask,
        !           260: CLIPOBJ  *pco,
        !           261: XLATEOBJ *pxlo,
        !           262: RECTL    *prclTrg,
        !           263: POINTL   *pptlSrc,
        !           264: POINTL   *pptlMask,
        !           265: BRUSHOBJ *pbo,
        !           266: POINTL   *pptlBrush,
        !           267: ROP4     rop4)
        !           268: {
        !           269: BOOL    b;
        !           270: INT     width,
        !           271:         height,
        !           272:         xTrg,
        !           273:         yTrg,
        !           274:         xSrc,
        !           275:         ySrc;
        !           276: 
        !           277: ULONG   ulDirCode,
        !           278:         XGAPixelOp,
        !           279:         ulXgaMask;
        !           280: 
        !           281: PXGACPREGS pXgaCpRegs = ((PPDEV)psoTrg->dhpdev)->pXgaCpRegs;
        !           282: 
        !           283: 
        !           284:         // Important Note:  When we get time we should test the Coprocessor
        !           285:         // for being busy.  If its not then we should execute the code here.
        !           286:         // If it is busy we should queue the request.  This implies an
        !           287:         // interrupt driven XGA.
        !           288: 
        !           289:         b = bSetXgaClipping((PPDEV)psoTrg->dhpdev, pco, &ulXgaMask);
        !           290:         if (b == FALSE)
        !           291:             return (b);
        !           292: 
        !           293:         // Setup the BitBlt parameters.
        !           294: 
        !           295:         width  = (prclTrg->right - prclTrg->left) - 1;
        !           296:         height = (prclTrg->bottom - prclTrg->top) - 1;
        !           297: 
        !           298:         // We need to determine the direction of the blit.
        !           299: 
        !           300:         ulDirCode = 0;
        !           301:         xTrg      = prclTrg->left;
        !           302:         yTrg      = prclTrg->top;
        !           303:         xSrc      = pptlSrc->x;
        !           304:         ySrc      = pptlSrc->y;
        !           305: 
        !           306:         // The horizontal copy direction.
        !           307: 
        !           308:         if (prclTrg->left > pptlSrc->x)
        !           309:         {
        !           310:             // R to L
        !           311: 
        !           312:             xTrg = prclTrg->right - 1;
        !           313:             xSrc = pptlSrc->x + width;
        !           314:             ulDirCode |= OCT_DX;
        !           315:         }
        !           316: 
        !           317:         // The vertical copy direction.
        !           318: 
        !           319:         if (prclTrg->top > pptlSrc->y)
        !           320:         {
        !           321:             // B to T
        !           322: 
        !           323:             yTrg = prclTrg->bottom - 1;
        !           324:             ySrc = pptlSrc->y + height;
        !           325:             ulDirCode |= OCT_DY;
        !           326:         }
        !           327: 
        !           328:         pXgaCpRegs->XGAOpDim1 = width;
        !           329:         pXgaCpRegs->XGAOpDim2 = height;
        !           330: 
        !           331:         pXgaCpRegs->XGASourceMapX = xSrc;
        !           332:         pXgaCpRegs->XGASourceMapY = ySrc;
        !           333: 
        !           334:         pXgaCpRegs->XGADestMapX   = xTrg;
        !           335:         pXgaCpRegs->XGADestMapY   = yTrg;
        !           336: 
        !           337:         pXgaCpRegs->XGAForeGrMix = XGA_S;
        !           338:         pXgaCpRegs->XGABackGrMix = XGA_S;
        !           339: 
        !           340: 
        !           341:         // Now build the Pel Operation Register Op Code;
        !           342: 
        !           343:         XGAPixelOp = BS_SRC_PEL_MAP  | FS_SRC_PEL_MAP |
        !           344:                      STEP_PX_BLT     |
        !           345:                      SRC_PEL_MAP_A   | DST_PEL_MAP_A  |
        !           346:                      PATT_FOREGROUND;
        !           347: 
        !           348:         XGAPixelOp |= ulDirCode;
        !           349:         XGAPixelOp |= ulXgaMask;
        !           350: 
        !           351:         pXgaCpRegs->XGAPixelOp = XGAPixelOp;
        !           352: 
        !           353: 
        !           354:         return (TRUE);
        !           355: 
        !           356: 
        !           357: }
        !           358: 
        !           359: /*****************************************************************************
        !           360:  * XGA Solid Pattern
        !           361:  *
        !           362:  *  Returns TRUE if the blit was handled.
        !           363:  ****************************************************************************/
        !           364: BOOL bSolidPattern(
        !           365: SURFOBJ  *psoTrg,
        !           366: SURFOBJ  *psoSrc,
        !           367: SURFOBJ  *psoMask,
        !           368: CLIPOBJ  *pco,
        !           369: XLATEOBJ *pxlo,
        !           370: RECTL    *prclTrg,
        !           371: POINTL   *pptlSrc,
        !           372: POINTL   *pptlMask,
        !           373: BRUSHOBJ *pbo,
        !           374: POINTL   *pptlBrush,
        !           375: ROP4     rop4)
        !           376: {
        !           377: BOOL    b;
        !           378: INT     width,
        !           379:         height;
        !           380: 
        !           381: ULONG   XGAPixelOp,
        !           382:         ulXgaMask;
        !           383: 
        !           384: PXGACPREGS pXgaCpRegs = ((PPDEV)psoTrg->dhpdev)->pXgaCpRegs;
        !           385: 
        !           386: 
        !           387:         DISPDBG((2, "XGA.DLL!bSolidPattern - Entry\n"));
        !           388: 
        !           389:         b = bSetXgaClipping((PPDEV)psoTrg->dhpdev,pco, &ulXgaMask);
        !           390:         if (b == FALSE)
        !           391:             return (b);
        !           392: 
        !           393:         // Setup the BitBlt parameters.
        !           394: 
        !           395:         width  = (prclTrg->right - prclTrg->left) - 1;
        !           396:         height = (prclTrg->bottom - prclTrg->top) - 1;
        !           397: 
        !           398:         pXgaCpRegs->XGAOpDim1 = width;
        !           399:         pXgaCpRegs->XGAOpDim2 = height;
        !           400: 
        !           401:         pXgaCpRegs->XGADestMapX   = (USHORT) prclTrg->left;
        !           402:         pXgaCpRegs->XGADestMapY   = (USHORT) prclTrg->top;
        !           403: 
        !           404:         pXgaCpRegs->XGAForeGrMix = XGA_S;
        !           405:         pXgaCpRegs->XGABackGrMix = XGA_S;
        !           406: 
        !           407:         pXgaCpRegs->XGAForeGrColorReg = pbo->iSolidColor;
        !           408:         pXgaCpRegs->XGABackGrColorReg = pbo->iSolidColor;
        !           409: 
        !           410:         // Now build the Pel Operation Register Op Code;
        !           411: 
        !           412:         XGAPixelOp = BS_BACK_COLOR  | FS_FORE_COLOR |
        !           413:                      STEP_PX_BLT     |
        !           414:                      SRC_PEL_MAP_A   | DST_PEL_MAP_A  |
        !           415:                      PATT_FOREGROUND;
        !           416: 
        !           417:         XGAPixelOp |= ulXgaMask;
        !           418: 
        !           419:         pXgaCpRegs->XGAPixelOp = XGAPixelOp;
        !           420: 
        !           421:         return (TRUE);
        !           422: 
        !           423: }
        !           424: 
        !           425: /*****************************************************************************
        !           426:  * XGA DrvCopyBits
        !           427:  ****************************************************************************/
        !           428: BOOL DrvCopyBits(
        !           429: SURFOBJ  *psoDest,
        !           430: SURFOBJ  *psoSrc,
        !           431: CLIPOBJ  *pco,
        !           432: XLATEOBJ *pxlo,
        !           433: RECTL    *prclDest,
        !           434: POINTL   *pptlSrc)
        !           435: {
        !           436: BOOL    b;
        !           437: 
        !           438: CLIPOBJ coLocal;
        !           439: SURFOBJ *pso;
        !           440: 
        !           441:         DISPDBG((2, "XGA.DLL: DrvCopyBits - Entry\n"));
        !           442: 
        !           443:         // Need to determine which surface is the display.
        !           444:         // So we can pickup the address of the XGA coprocessor regs.
        !           445: 
        !           446:         if ((psoDest) && (psoDest->iType == STYPE_DEVICE))
        !           447:             pso = psoDest;
        !           448: 
        !           449:         else if ((psoSrc) && (psoSrc->iType == STYPE_DEVICE))
        !           450:             pso = psoSrc;
        !           451: 
        !           452:         else
        !           453:         {
        !           454:             RIP ("XGA.DLL!DrvCopyBits - neither surface is a device surface\n");
        !           455:             return (TRUE);
        !           456:         }
        !           457: 
        !           458:         // Wait for the coprocessor.
        !           459: 
        !           460:         vWaitForCoProcessor((PPDEV)pso->dhpdev, 100);
        !           461: 
        !           462:         // Protect this routine from a potentially NULL clip object
        !           463: 
        !           464:         if (pco == NULL)
        !           465:         {
        !           466:             coLocal.iDComplexity    = DC_RECT;
        !           467: 
        !           468:             coLocal.rclBounds.left   = 0;
        !           469:             coLocal.rclBounds.top    = 0;
        !           470:             coLocal.rclBounds.right  = ((PPDEV)pso->dhpdev)->cxScreen;
        !           471:             coLocal.rclBounds.bottom = ((PPDEV)pso->dhpdev)->cyScreen;
        !           472: 
        !           473:             pco = &coLocal;
        !           474: 
        !           475:         }
        !           476: 
        !           477:         // Check for a Screen to Screen or a Host to Screen blit.
        !           478: 
        !           479:         b = FALSE;
        !           480: 
        !           481:         if ((psoDest->iType == STYPE_DEVICE) &&
        !           482:             (psoSrc->iType == STYPE_DEVICE) &&
        !           483:             (((PPDEV)psoDest->dhpdev)->ulfBlitAccelerations_debug & SCRN_TO_SCRN_CPY))
        !           484:         {
        !           485:             b = bScrnToScrnCpy(psoDest,
        !           486:                                psoSrc,
        !           487:                                NULL,
        !           488:                                pco,
        !           489:                                pxlo,
        !           490:                                prclDest,
        !           491:                                pptlSrc,
        !           492:                                NULL,
        !           493:                                NULL,
        !           494:                                NULL,
        !           495:                                0xcccc);
        !           496:         }
        !           497: 
        !           498:         if (b == FALSE)
        !           499:         {
        !           500:             if ((psoDest) && (psoDest->iType == STYPE_DEVICE))
        !           501:                 psoDest = ((PPDEV)(psoDest->dhpdev))->pSurfObj;
        !           502: 
        !           503:             if ((psoSrc) && (psoSrc->iType == STYPE_DEVICE))
        !           504:                 psoSrc = ((PPDEV)(psoSrc->dhpdev))->pSurfObj;
        !           505: 
        !           506:             EngCopyBits(psoDest,
        !           507:                         psoSrc,
        !           508:                         pco,
        !           509:                         pxlo,
        !           510:                         prclDest,
        !           511:                         pptlSrc);
        !           512: 
        !           513:         }
        !           514: 
        !           515:         return (TRUE);
        !           516: 
        !           517: }

unix.superglobalmegacorp.com

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