|
|
1.1 ! root 1: /******************************Module*Header*******************************\ ! 2: * Module Name: Brush.c ! 3: * ! 4: * S3 Brush support ! 5: * ! 6: * Copyright (c) 1992 Microsoft Corporation ! 7: * ! 8: \**************************************************************************/ ! 9: ! 10: #include "driver.h" ! 11: ! 12: ! 13: /**************************************************************************** ! 14: * ! 15: ***************************************************************************/ ! 16: BOOL DrvRealizeBrush( ! 17: BRUSHOBJ *pbo, ! 18: SURFOBJ *psoTarget, ! 19: SURFOBJ *psoPattern, ! 20: SURFOBJ *psoMask, ! 21: XLATEOBJ *pxlo, ! 22: ULONG iHatch) ! 23: { ! 24: S3BRUSH s3Brush; ! 25: PS3BRUSH ps3Brush; ! 26: INT cjPattern; ! 27: ! 28: INT i, j, cx, cy, lSrcDelta, lDestDelta; ! 29: PBYTE pbSrc, pbDest; ! 30: FLONG flXlate; ! 31: PPDEV ppdev; ! 32: PULONG pulXlate; ! 33: ! 34: ! 35: DISPDBG((3, "S3.DLL!DrvRealizeBrush - Entry\n")); ! 36: ! 37: ppdev = (PPDEV)psoTarget->dhsurf; ! 38: ! 39: // Even if there is a mask accept the brush. ! 40: // We will test the ROP when the brush is rendered and ! 41: // and reject it at that time if we don't want to handle it. ! 42: ! 43: #if DBG ! 44: memset (&s3Brush, 0, sizeof(S3BRUSH)); ! 45: #endif ! 46: ! 47: // Init the stack based s3 brush structure. ! 48: ! 49: s3Brush.nSize = sizeof (S3BRUSH); ! 50: s3Brush.iPatternID = ++(ppdev->gBrushUnique); ! 51: s3Brush.iBrushCacheID = (ULONG) -1; ! 52: s3Brush.iExpansionCacheID = (ULONG) -1; ! 53: s3Brush.iType = psoPattern->iType; ! 54: s3Brush.iBitmapFormat = psoPattern->iBitmapFormat; ! 55: s3Brush.sizlPattern = psoPattern->sizlBitmap; ! 56: ! 57: // Only handle standard bitmap format brushes. ! 58: ! 59: if (s3Brush.iType != STYPE_BITMAP) ! 60: return (FALSE); ! 61: ! 62: // This selects the brush formats we support. ! 63: // It's a switch statement so we can add more as improve the driver. ! 64: ! 65: switch (s3Brush.iBitmapFormat) ! 66: { ! 67: case BMF_1BPP: ! 68: case BMF_8BPP: ! 69: break; ! 70: ! 71: default: ! 72: return(FALSE); ! 73: ! 74: } ! 75: ! 76: // For now, if this is not an 8 X 8 pattern then reject it. !!! ! 77: // This will change to handle patterns up to the size of the !!! ! 78: // source bitmap cache area. !!! ! 79: ! 80: if (s3Brush.sizlPattern.cx != 8 || s3Brush.sizlPattern.cy != 8) ! 81: return (FALSE); ! 82: ! 83: // Note: In all cases the brush is just copied into some storage ! 84: // that we have allocated in GDI. The expansion and/or ! 85: // color translation is done when the brush is put into the ! 86: // graphics memory cache. ! 87: ! 88: cjPattern = psoPattern->cjBits; ! 89: s3Brush.nSize += cjPattern; ! 90: ! 91: if (psoPattern->fjBitmap & BMF_TOPDOWN) ! 92: s3Brush.lDeltaPattern = psoPattern->lDelta; ! 93: else ! 94: s3Brush.lDeltaPattern = -(psoPattern->lDelta); ! 95: ! 96: // If its a mono brush record the foreground and background colors. ! 97: ! 98: if (s3Brush.iBitmapFormat == BMF_1BPP) ! 99: { ! 100: if (pxlo->flXlate & XO_TABLE) ! 101: { ! 102: pulXlate = pxlo->pulXlate; ! 103: } ! 104: else ! 105: { ! 106: pulXlate = XLATEOBJ_piVector(pxlo); ! 107: } ! 108: ! 109: s3Brush.ulForeColor = pulXlate[1]; ! 110: s3Brush.ulBackColor = pulXlate[0]; ! 111: } ! 112: ! 113: // Allocate some GDI storage for the Brush. !!! ! 114: // Note: This should be moved up and the stack stuff should be !!! ! 115: // removed since we can now simply calculate the size of !!! ! 116: // the brush. !!! ! 117: ! 118: ps3Brush = (PS3BRUSH) BRUSHOBJ_pvAllocRbrush(pbo, s3Brush.nSize); ! 119: ! 120: // Assign all the static info we built on the stack. !!! ! 121: // This should be removed. !!! ! 122: ! 123: *ps3Brush = s3Brush; ! 124: ! 125: // If there is an XlatObj, we may have to translate the ! 126: // indicies. ! 127: ! 128: flXlate = 0; ! 129: if (pxlo != NULL) ! 130: { ! 131: flXlate = pxlo->flXlate; ! 132: ! 133: if (flXlate & XO_TABLE) ! 134: { ! 135: pulXlate = pxlo->pulXlate; ! 136: } ! 137: else ! 138: { ! 139: pulXlate = XLATEOBJ_piVector(pxlo); ! 140: } ! 141: } ! 142: ! 143: // Note: We should be able to remove this if, since this is not !!! ! 144: // a time critcal spot in the code. !!! ! 145: ! 146: // We may have to invert the Y if it's not in a top-down format. ! 147: // We have already adjusted the BrushDelta if this inversion is necessary. ! 148: ! 149: if (psoPattern->fjBitmap & BMF_TOPDOWN) ! 150: { ! 151: pbSrc = psoPattern->pvBits; ! 152: pbDest = ps3Brush->ajPattern; ! 153: ! 154: if ((flXlate & XO_TABLE) && ! 155: (psoPattern->iBitmapFormat == BMF_8BPP)) ! 156: { ! 157: for (j = 0; j < cjPattern; j++) ! 158: { ! 159: pbDest[j] = (BYTE) pulXlate[pbSrc[j]]; ! 160: } ! 161: } ! 162: else ! 163: { ! 164: memcpy(ps3Brush->ajPattern, psoPattern->pvBits, cjPattern); ! 165: } ! 166: } ! 167: else ! 168: { ! 169: ! 170: cx = s3Brush.sizlPattern.cx; ! 171: cy = s3Brush.sizlPattern.cy; ! 172: ! 173: pbSrc = psoPattern->pvScan0; ! 174: pbDest = ps3Brush->ajPattern; ! 175: lSrcDelta = psoPattern->lDelta; ! 176: lDestDelta = -lSrcDelta; ! 177: ! 178: for (i = 0; i < cy; i++) ! 179: { ! 180: // We may have to translate the indices. ! 181: ! 182: if ((flXlate & XO_TABLE) && ! 183: (psoPattern->iBitmapFormat == BMF_8BPP)) ! 184: { ! 185: for (j = 0; j < cx; j++) ! 186: { ! 187: pbDest[j] = (BYTE) pulXlate[pbSrc[j]]; ! 188: } ! 189: } ! 190: else ! 191: { ! 192: memcpy(pbDest, pbSrc, cx); ! 193: } ! 194: ! 195: pbSrc += lSrcDelta; ! 196: pbDest += lDestDelta; ! 197: ! 198: } ! 199: } ! 200: ! 201: return (TRUE); ! 202: ! 203: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.