Annotation of ntddk/src/video/displays/vga256/paint.c, revision 1.1

1.1     ! root        1: /******************************Module*Header*******************************\
        !             2: * Module Name: paint.c
        !             3: *
        !             4: * Copyright (c) 1992 Microsoft Corporation
        !             5: \**************************************************************************/
        !             6: 
        !             7: #include "driver.h"
        !             8: 
        !             9: /******************************Public*Data*********************************\
        !            10: * MIX translation table
        !            11: *
        !            12: * Translates a mix 1-16, into an old style Rop 0-255.
        !            13: *
        !            14: \**************************************************************************/
        !            15: 
        !            16: BYTE gaMix[] =
        !            17: {
        !            18:     0xFF,  // R2_WHITE        - Allow rop = gaMix[mix & 0x0F]
        !            19:     0x00,  // R2_BLACK
        !            20:     0x05,  // R2_NOTMERGEPEN
        !            21:     0x0A,  // R2_MASKNOTPEN
        !            22:     0x0F,  // R2_NOTCOPYPEN
        !            23:     0x50,  // R2_MASKPENNOT
        !            24:     0x55,  // R2_NOT
        !            25:     0x5A,  // R2_XORPEN
        !            26:     0x5F,  // R2_NOTMASKPEN
        !            27:     0xA0,  // R2_MASKPEN
        !            28:     0xA5,  // R2_NOTXORPEN
        !            29:     0xAA,  // R2_NOP
        !            30:     0xAF,  // R2_MERGENOTPEN
        !            31:     0xF0,  // R2_COPYPEN
        !            32:     0xF5,  // R2_MERGEPENNOT
        !            33:     0xFA,  // R2_MERGEPEN
        !            34:     0xFF   // R2_WHITE
        !            35: };
        !            36: 
        !            37: /******************************Public*Routine******************************\
        !            38: * vTrgTrap(ppdev, ptrap, mix, iColor)
        !            39: *
        !            40: * Blit to a trapezoid.
        !            41: *
        !            42: \**************************************************************************/
        !            43: 
        !            44: VOID vTrgTrap
        !            45: (
        !            46:     PPDEV        ppdev,
        !            47:     TRAPEZOID   *ptrap,
        !            48:     MIX          mix,
        !            49:     RBRUSH_COLOR rbc,
        !            50:     POINTL      *pptlBrush,
        !            51:     PFNFILL      pfnFill
        !            52: )
        !            53: {
        !            54:     DDAENUM ddae;
        !            55:     RECTL   rcl[MAX_DDA_RECTS], *prcl;
        !            56:     ULONG   culrcl;
        !            57:     LONG   *px;
        !            58:     LONG    yRow;
        !            59: 
        !            60:     if (!DDAOBJ_bEnum(ppdev->pdda, (PVOID) ptrap, sizeof(ddae),
        !            61:                       (DDALIST *) &ddae, JD_ENUM_TRAPEZOID))
        !            62:         return;
        !            63: 
        !            64:     do {
        !            65:         culrcl = 0;
        !            66:         prcl = rcl;
        !            67:         px = &ddae.axPairs[0];
        !            68: 
        !            69:         // Accumulate the rectangles for this trapezoid enumeration burst,
        !            70:         // then send them to the solid filler as a group
        !            71:         for (yRow = ddae.yTop; yRow < ddae.yBottom; yRow++) {
        !            72:             if (*px < *(px+1)) {
        !            73:                 prcl->top    = yRow;
        !            74:                 prcl->left   = *px;
        !            75:                 prcl->bottom = yRow + 1;
        !            76:                 prcl++->right  = *(px+1);
        !            77:                 culrcl++;
        !            78:             }
        !            79: 
        !            80:             px += 2;
        !            81: 
        !            82:         }
        !            83: 
        !            84:         // Draw the rectangles, if there are any
        !            85:         if (culrcl > 0) {
        !            86:             (*pfnFill)(ppdev, culrcl, rcl, mix, rbc, pptlBrush);
        !            87:         }
        !            88: 
        !            89:     } while (DDAOBJ_bEnum(ppdev->pdda, (PVOID) NULL, sizeof(ddae),
        !            90:             (DDALIST *) &ddae, JD_ENUM_TRAPEZOID));
        !            91: }
        !            92: 
        !            93: /******************************Public*Routine******************************\
        !            94: * bPaintRgn
        !            95: *
        !            96: * Paint the clipping region with the specified color and mode
        !            97: *
        !            98: \**************************************************************************/
        !            99: 
        !           100: BOOL bPaintRgn
        !           101: (
        !           102:     SURFOBJ      *pso,
        !           103:     CLIPOBJ      *pco,
        !           104:     MIX          mix,
        !           105:     RBRUSH_COLOR rbc,
        !           106:     POINTL       *pptlBrush,
        !           107:     PFNFILL      pfnFill
        !           108: )
        !           109: {
        !           110:     BBENUM      bben;
        !           111:     BBENUMTRAP  bbent;
        !           112:     PPDEV       ppdev;
        !           113:     ULONG       iRT;
        !           114:     BOOL        bMore;
        !           115: 
        !           116: // Get the target surface information.
        !           117: 
        !           118:     ppdev = (PPDEV) pso->dhsurf;
        !           119: 
        !           120:     switch(pco->iMode) {
        !           121: 
        !           122:         case TC_RECTANGLES:
        !           123: 
        !           124:             // Rectangular clipping can be handled without enumeration.
        !           125:             // Note that trivial clipping is not possible, since the clipping
        !           126:             // region defines the area to fill
        !           127: 
        !           128:             if (pco->iDComplexity == DC_RECT)
        !           129:             {
        !           130:                 (*pfnFill)(ppdev, 1, &pco->rclBounds, mix, rbc, pptlBrush);
        !           131: 
        !           132:             } else {
        !           133: 
        !           134:                 // Enumerate all the rectangles and draw them
        !           135: 
        !           136:                 CLIPOBJ_cEnumStart(pco,TRUE,CT_RECTANGLES,CD_ANY,BB_RECT_LIMIT);
        !           137: 
        !           138:                 do {
        !           139:                     bMore = CLIPOBJ_bEnum(pco, sizeof(bben), (PVOID) &bben);
        !           140: 
        !           141:                     (*pfnFill)(ppdev, bben.c, &bben.arcl[0], mix, rbc, pptlBrush);
        !           142: 
        !           143:                 } while (bMore);
        !           144:             }
        !           145: 
        !           146:             return(TRUE);
        !           147: 
        !           148:         case TC_TRAPEZOIDS:
        !           149: 
        !           150:             // Enumerate all the trapezoids and draw them
        !           151: 
        !           152:             CLIPOBJ_cEnumStart(pco,TRUE,CT_TRAPEZOIDS,CD_ANY,BB_RECT_LIMIT);
        !           153: 
        !           154:             do {
        !           155:                 bMore = CLIPOBJ_bEnum(pco, sizeof(bbent), (PVOID) &bbent);
        !           156: 
        !           157:                 for (iRT = 0; iRT < bbent.c; iRT++)
        !           158:                     vTrgTrap(ppdev, &bbent.atrap[iRT], mix, rbc, pptlBrush, pfnFill);
        !           159: 
        !           160:             } while (bMore);
        !           161: 
        !           162:             return(TRUE);
        !           163: 
        !           164:         default:
        !           165:             RIP("bPaintRgn: unhandled TC_xxx\n");
        !           166:             return(FALSE);
        !           167:     }
        !           168: }
        !           169: 
        !           170: 
        !           171: /**************************************************************************\
        !           172: * DrvPaint
        !           173: *
        !           174: * Paint the clipping region with the specified brush
        !           175: *
        !           176: \**************************************************************************/
        !           177: 
        !           178: BOOL DrvPaint
        !           179: (
        !           180:     SURFOBJ  *pso,
        !           181:     CLIPOBJ  *pco,
        !           182:     BRUSHOBJ *pbo,
        !           183:     POINTL   *pptlBrush,
        !           184:     MIX       mix
        !           185: )
        !           186: {
        !           187:     ROP4         rop4;
        !           188:     RBRUSH_COLOR rbc;
        !           189:     PFNFILL      pfnFill;
        !           190: 
        !           191:     // If this adapter supports planar mode and the foreground and background
        !           192:     // mixes are the same,
        !           193:     // LATER or if there's no brush mask
        !           194:     // then see if we can use the brush accelerators
        !           195:     // LATER handle non-planar also
        !           196: 
        !           197:     if ((((PPDEV) pso->dhsurf)->fl & DRIVER_PLANAR_CAPABLE) &&
        !           198:         ((mix & 0xFF) == ((mix >> 8) & 0xFF))) {
        !           199: 
        !           200:         switch (mix & 0xFF) {
        !           201:             case 0:
        !           202:                 break;
        !           203: 
        !           204:             // vTrgBlt can only handle solid color fills where if the
        !           205:             // destination is inverted, no other action is also required
        !           206: 
        !           207:             case R2_MASKNOTPEN:
        !           208:             case R2_NOTCOPYPEN:
        !           209:             case R2_XORPEN:
        !           210:             case R2_MASKPEN:
        !           211:             case R2_NOTXORPEN:
        !           212:             case R2_MERGENOTPEN:
        !           213:             case R2_COPYPEN:
        !           214:             case R2_MERGEPEN:
        !           215:             case R2_NOTMERGEPEN:
        !           216:             case R2_MASKPENNOT:
        !           217:             case R2_NOTMASKPEN:
        !           218:             case R2_MERGEPENNOT:
        !           219: 
        !           220:                 // vTrgBlt can only handle solid color fills
        !           221: 
        !           222:                 if (pbo->iSolidColor != 0xffffffff)
        !           223:                 {
        !           224:                     rbc.iSolidColor = pbo->iSolidColor;
        !           225:                     pfnFill = vTrgBlt;
        !           226:                 }
        !           227:                 else
        !           228:                 {
        !           229:                     rbc.prb = (RBRUSH*) pbo->pvRbrush;
        !           230:                     if (rbc.prb == NULL)
        !           231:                     {
        !           232:                         rbc.prb = (RBRUSH*) BRUSHOBJ_pvGetRbrush(pbo);
        !           233:                         if (rbc.prb == NULL)
        !           234:                         {
        !           235:                         // If we haven't realized the brush, punt the call:
        !           236: 
        !           237:                             break;
        !           238:                         }
        !           239:                     }
        !           240:                     if (!(rbc.prb->fl & RBRUSH_BLACKWHITE) &&
        !           241:                         ((mix & 0xff) != R2_COPYPEN))
        !           242:                     {
        !           243:                     // Only black/white brushes can handle ROPs other
        !           244:                     // than COPYPEN:
        !           245: 
        !           246:                         break;
        !           247:                     }
        !           248: 
        !           249:                     if (rbc.prb->fl & RBRUSH_NCOLOR)
        !           250:                         pfnFill = vColorPat;
        !           251:                     else
        !           252:                         pfnFill = vMonoPat;
        !           253:                 }
        !           254: 
        !           255:                 return(bPaintRgn(pso, pco, mix, rbc, pptlBrush, pfnFill));
        !           256: 
        !           257:             // Rops that are implicit solid colors
        !           258: 
        !           259:             case R2_NOT:
        !           260:             case R2_WHITE:
        !           261:             case R2_BLACK:
        !           262: 
        !           263:                 // Brush color parameter doesn't matter for these rops
        !           264: 
        !           265:                 return(bPaintRgn(pso, pco, mix, rbc, NULL, vTrgBlt));
        !           266: 
        !           267:             case R2_NOP:
        !           268:                 return(TRUE);
        !           269: 
        !           270:             default:
        !           271:                 break;
        !           272:         }
        !           273:     }
        !           274: 
        !           275:     rop4  = (gaMix[(mix >> 8) & 0x0F]) << 8;
        !           276:     rop4 |= ((ULONG) gaMix[mix & 0x0F]);
        !           277: 
        !           278:     return(DrvBitBlt(
        !           279:         pso,
        !           280:         (SURFOBJ *) NULL,
        !           281:         (SURFOBJ *) NULL,
        !           282:         pco,
        !           283:         (XLATEOBJ *) NULL,
        !           284:         &pco->rclBounds,
        !           285:         (POINTL *)  NULL,
        !           286:         (POINTL *)  NULL,
        !           287:         pbo,
        !           288:         pptlBrush,
        !           289:         rop4));
        !           290: }
        !           291: 

unix.superglobalmegacorp.com

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