|
|
1.1 root 1: /******************************Module*Header*******************************\
2: * Module Name: rleblt.c
3: *
4: * Blt from RLE format bitmap to VGA.
5: *
6: * Copyright (c) 1992 Microsoft Corporation
7: \**************************************************************************/
8: #include "driver.h"
9: #include "bitblt.h"
10:
11: typedef struct _RLEINFO
12: {
13: PBYTE pjTrg;
14: PBYTE pjSrc;
15: PBYTE pjSrcEnd;
16: PRECTL prclClip;
17: PULONG pulXlate;
18: LONG xBegin;
19: SIZE_T lNextScan; // Offset to the next scan line - DDB Only.
20: SIZE_T lNextPlane; // Offset to the next plane - DDB Only.
21: PRECTL prclTrg;
22: DWORD Format;
23: PDEVSURF pdsurfTrg;
24: }RLEINFO, *PRLEINFO;
25:
26: VOID vRle8ToVga(PRLEINFO);
27: VOID vRle4ToVga(PRLEINFO);
28: BOOL DrvIntersectRect(PRECTL, PRECTL, PRECTL);
29: typedef VOID (*PFN_RleToVga)(PRLEINFO);
30:
31: /******************************Public*Routine******************************\
32: * BOOL bRleBlt(*psoTrg, *psoSrc, *pco, *pxlo, *prclTrg, *pptlSrc)
33: *
34: * Blt from RLE format bitmap to VGA.
35: *
36: \**************************************************************************/
37:
38: BOOL bRleBlt
39: (
40: SURFOBJ *psoTrg, // Target surface
41: SURFOBJ *psoSrc, // Source surface
42: CLIPOBJ *pco, // Clip through this
43: XLATEOBJ *pxlo, // Color translation
44: RECTL *prclTrg, // Target offset and extent
45: POINTL *pptlSrc // Source offset
46: )
47: {
48: BOOL bMore; // Clip continuation flag
49: ULONG ircl; // Clip enumeration rectangle index
50: RECT_ENUM bben; // Clip enumerator
51: PFN_RleToVga pfnRleToVga; // Pointer to either Rle8ToVga or Rle4ToVga
52:
53: PDEVSURF pdsurf;
54: RECTL rclTrg;
55: PDEV *ppdevTrg;
56: RLEINFO rleInfo;
57: PRECTL prcl; // Pointer to the current cliprect
58: PRECTL prclNext; // Pointer to the next cliprect
59:
60: PBYTE pjTrgTmp; // For saving fields in rleInfo.
61: PBYTE pjSrcTmp;
62: LONG lTrgBottomTmp;
63: LONG xBeginTmp;
64: LONG yScanSrc;
65:
66: // Get the target surface information. This is guaranteed to be a device
67: // surface or a device format bitmap.
68:
69: // ASSERT((psoTrg->dhsurf != (DHSURF)0),"bRleBlt: invalid dhsurf\n");
70:
71: pdsurf = (PDEVSURF) psoTrg->dhsurf;
72: ppdevTrg = pdsurf->ppdev;
73:
74:
75: // Get the source surface information. Common to the screen and DFB's
76:
77: rleInfo.pjSrc = psoSrc->pvBits;
78: rleInfo.pjSrcEnd = (PBYTE)(psoSrc->pvBits) + (psoSrc->cjBits);
79:
80: // Determine if color translation is required. If so, then get the color
81: // translation vector.
82:
83: // ASSERT(pxlo != NULL,"RleBlt with invalid pxlo\n");
84: rleInfo.pulXlate = pxlo->pulXlate;
85: // ASSERT(rleInfo.pulXlate != (PULONG)NULL,
86: // "RleBlt GetTranslateVecotr failed\n");
87:
88: // Enlarge the destination rectangle to include area that would have to be
89: // drawn if ptlSrc is (0, 0).
90:
91: rclTrg.left = prclTrg->left - pptlSrc->x;
92: rclTrg.top = prclTrg->top;
93: rclTrg.right = prclTrg->right;
94: rclTrg.bottom = prclTrg->top + psoSrc->sizlBitmap.cy - pptlSrc->y;
95:
96: rleInfo.prclTrg = &rclTrg;
97: rleInfo.xBegin = rclTrg.left;
98:
99: // Calculate our starting address in the bitmap & get our blt function
100:
101: // First (bottom) dest scan, *exclusive*
102: // Offset within bitmap of first (bottom) dest scan, *inclusive*
103: rleInfo.pjTrg = (PBYTE) ((rclTrg.bottom - 1) * pdsurf->lNextScan);
104: rleInfo.pdsurfTrg = pdsurf;
105: if (psoSrc->iBitmapFormat == BMF_8RLE)
106: pfnRleToVga = vRle8ToVga;
107: else
108: pfnRleToVga = vRle4ToVga;
109:
110: // Everything is ready. Let's go draw on the VGA. Shooby Doobie Doo. Whee.
111:
112: switch(pco->iDComplexity)
113: {
114: case DC_TRIVIAL:
115: rleInfo.prclClip = prclTrg;
116: pfnRleToVga(&rleInfo);
117: break;
118:
119: case DC_RECT:
120: rleInfo.prclClip = &pco->rclBounds;
121: pfnRleToVga(&rleInfo);
122: break;
123:
124: case DC_COMPLEX:
125: CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_RIGHTUP, ENUM_RECT_LIMIT);
126:
127: do
128: {
129: // Fill n slots with (n - 1) rectangles.
130:
131: bMore = CLIPOBJ_bEnum(pco,(ULONG) (sizeof(bben) - sizeof(RECT)),
132: (PVOID) &bben);
133:
134: // Force save and restore rleInfo for the last rect.
135:
136: bben.arcl[bben.c].bottom = bben.arcl[bben.c - 1].bottom;
137:
138: for (ircl = 0; ircl < bben.c; ircl++)
139: {
140: prcl = &bben.arcl[ircl];
141:
142: // If the clipping rect is above the target rect, don't
143: // enumerate any more clipprect. Since the direction of
144: // enumeration is bottom up, nothing is visible in new cliprect.
145:
146: if (prcl->bottom <= rleInfo.prclTrg->top)
147: {
148: break;
149: bMore = FALSE;
150: }
151:
152: // We check for NULL or inverted rectanges because we may get them.
153:
154: if ((prcl->top < prcl->bottom) && (prcl->left < prcl->right))
155: {
156: rleInfo.prclClip = prcl;
157: prclNext = &bben.arcl[ircl + 1];
158:
159: // Pass the same rleInfo for next cliprect if the next
160: // cliprect is on the same scan as the current cliprect
161:
162: if (prcl->bottom == prclNext->bottom)
163: {
164: // save rleInfo.
165:
166: pjTrgTmp = rleInfo.pjTrg;
167: pjSrcTmp = rleInfo.pjSrc;
168: lTrgBottomTmp = rleInfo.prclTrg->bottom;
169: xBeginTmp = rleInfo.xBegin;
170:
171:
172: pfnRleToVga(&rleInfo);
173:
174: // restore rleinfo
175:
176: rleInfo.pjTrg = pjTrgTmp;
177: rleInfo.pjSrc = pjSrcTmp;
178: rleInfo.prclTrg->bottom = lTrgBottomTmp;
179: rleInfo.xBegin = xBeginTmp;
180: }
181: else
182: {
183: pfnRleToVga(&rleInfo);
184: }
185: }
186: }
187: } while(bMore);
188:
189: //DbgBreakPoint();
190:
191: break;
192:
193: default:
194: RIP("ERROR bRleBlt invalid clip complexity\n");
195: return(FALSE);
196: }
197:
198: return(TRUE);
199: }
200:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.