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

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

unix.superglobalmegacorp.com

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