1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Windows NT/2000/XP guest video driver
|
---|
4 | *
|
---|
5 | * Display driver screen draw entry points.
|
---|
6 | *
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 | /* The driver operates in 3 modes:
|
---|
24 | * 1) BASE : Driver does not report to host about any operations.
|
---|
25 | * All Drv* are immediately routed to Eng*.
|
---|
26 | * 2) VBVA : Driver reports dirty rectangles to host.
|
---|
27 | * 3) VBVA + VRDP : Driver also creates orders pipeline from which VRDP
|
---|
28 | * can reconstruct all drawing operations, including
|
---|
29 | * bitmap updates.
|
---|
30 | *
|
---|
31 | * These modes affect only Drv* functions in this file.
|
---|
32 | *
|
---|
33 | * VBVA mode is enabled by a registry key for the miniport driver
|
---|
34 | * (as it is implemented now).
|
---|
35 | *
|
---|
36 | * VRDP mode is enabled when a VRDP client connects and VBVA is enabled.
|
---|
37 | * The host sets a bit flag in VBVAMemory when VRDP client is connected.
|
---|
38 | *
|
---|
39 | * The VRDP mode pipeline consists of 3 types of commands:
|
---|
40 | *
|
---|
41 | * 1) RDP orders: BitBlt, RectFill, Text.
|
---|
42 | * These are the simpliest ones.
|
---|
43 | *
|
---|
44 | * 2) Caching: Bitmap, glyph, brush.
|
---|
45 | * The driver maintains a bitmap (or other objects) cache.
|
---|
46 | * All source bitmaps are cached. The driver verifies
|
---|
47 | * iUniq and also computes CRC for these bitmaps
|
---|
48 | * for searching. The driver will use SURFOBJ::dhsurf
|
---|
49 | * field to save a pointer to in driver structure, even
|
---|
50 | * for Engine managed bitmaps (hope that will work).
|
---|
51 | *
|
---|
52 | *
|
---|
53 | * 3) Bitmap updates, when given draw operation can not be done
|
---|
54 | * using orders.
|
---|
55 | *
|
---|
56 | */
|
---|
57 |
|
---|
58 | #include "driver.h"
|
---|
59 |
|
---|
60 | #ifdef STAT_sunlover
|
---|
61 | void dumpsurf (SURFOBJ *pso, char *s)
|
---|
62 | {
|
---|
63 | DISPDBG((1, "Surface %s: %p\n", s, pso));
|
---|
64 | if (pso)
|
---|
65 | {
|
---|
66 | DISPDBG((1, " DHSURF dhsurf = %p\n", pso->dhsurf));
|
---|
67 | DISPDBG((1, " HSURF hsurf = %p\n", pso->hsurf));
|
---|
68 | DISPDBG((1, " DHPDEV dhpdev = %p\n", pso->dhpdev));
|
---|
69 | DISPDBG((1, " HDEV hdev = %p\n", pso->hdev));
|
---|
70 | DISPDBG((1, " SIZEL sizlBitmap = %dx%d\n", pso->sizlBitmap.cx, pso->sizlBitmap.cy));
|
---|
71 | DISPDBG((1, " ULONG cjBits = %p\n", pso->cjBits));
|
---|
72 | DISPDBG((1, " PVOID pvBits = %p\n", pso->pvBits));
|
---|
73 | DISPDBG((1, " PVOID pvScan0 = %p\n", pso->pvScan0));
|
---|
74 | DISPDBG((1, " LONG lDelta = %p\n", pso->lDelta));
|
---|
75 | DISPDBG((1, " ULONG iUniq = %p\n", pso->iUniq));
|
---|
76 | DISPDBG((1, " ULONG iBitmapFormat = %p\n", pso->iBitmapFormat));
|
---|
77 | DISPDBG((1, " USHORT iType = %p\n", pso->iType));
|
---|
78 | DISPDBG((1, " USHORT fjBitmap = %p\n", pso->fjBitmap));
|
---|
79 | }
|
---|
80 | }
|
---|
81 | #else
|
---|
82 | #define dumpsurf(a, b)
|
---|
83 | #endif /* STAT_sunlover */
|
---|
84 |
|
---|
85 | BOOL bIsScreenSurface (SURFOBJ *pso)
|
---|
86 | {
|
---|
87 | if (pso)
|
---|
88 | {
|
---|
89 | PPDEV ppdev = (PPDEV)pso->dhpdev;
|
---|
90 | return (ppdev && pso->hsurf == ppdev->hsurfScreen);
|
---|
91 | }
|
---|
92 |
|
---|
93 | return FALSE;
|
---|
94 | }
|
---|
95 |
|
---|
96 | #define VBVA_OPERATION(__psoDest, __fn, __a) do { \
|
---|
97 | if (bIsScreenSurface(__psoDest)) \
|
---|
98 | { \
|
---|
99 | PPDEV ppdev = (PPDEV)__psoDest->dhpdev; \
|
---|
100 | \
|
---|
101 | if (vboxHwBufferBeginUpdate (ppdev)) \
|
---|
102 | { \
|
---|
103 | vbva##__fn __a; \
|
---|
104 | \
|
---|
105 | if (ppdev->vbva.pVbvaMemory->fu32ModeFlags \
|
---|
106 | & VBVA_F_MODE_VRDP_RESET) \
|
---|
107 | { \
|
---|
108 | vrdpReset (ppdev); \
|
---|
109 | \
|
---|
110 | ppdev->vbva.pVbvaMemory->fu32ModeFlags &= \
|
---|
111 | ~VBVA_F_MODE_VRDP_RESET; \
|
---|
112 | } \
|
---|
113 | \
|
---|
114 | if (ppdev->vbva.pVbvaMemory->fu32ModeFlags \
|
---|
115 | & VBVA_F_MODE_VRDP) \
|
---|
116 | { \
|
---|
117 | vrdp##__fn __a; \
|
---|
118 | } \
|
---|
119 | \
|
---|
120 | vboxHwBufferEndUpdate (ppdev); \
|
---|
121 | } \
|
---|
122 | } \
|
---|
123 | } while (0)
|
---|
124 |
|
---|
125 | //#undef VBVA_OPERATION
|
---|
126 | //#define VBVA_OPERATION(_psoDest, __fn, __a) do { } while (0)
|
---|
127 |
|
---|
128 |
|
---|
129 | #if 0
|
---|
130 | typedef struct _SURFOBJ {
|
---|
131 | +00 DHSURF dhsurf;
|
---|
132 | +04 HSURF hsurf;
|
---|
133 | +08 DHPDEV dhpdev;
|
---|
134 | +0c HDEV hdev;
|
---|
135 | +10 SIZEL sizlBitmap;
|
---|
136 | +18 ULONG cjBits;
|
---|
137 | +1c PVOID pvBits;
|
---|
138 | +20 PVOID pvScan0;
|
---|
139 | +24 LONG lDelta;
|
---|
140 | +28 ULONG iUniq;
|
---|
141 | +2c ULONG iBitmapFormat;
|
---|
142 | +30 USHORT iType;
|
---|
143 | +32 USHORT fjBitmap;
|
---|
144 | } SURFOBJ;
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | BOOL APIENTRY DrvBitBlt(
|
---|
148 | SURFOBJ *psoTrg,
|
---|
149 | SURFOBJ *psoSrc,
|
---|
150 | SURFOBJ *psoMask,
|
---|
151 | CLIPOBJ *pco,
|
---|
152 | XLATEOBJ *pxlo,
|
---|
153 | RECTL *prclTrg,
|
---|
154 | POINTL *pptlSrc,
|
---|
155 | POINTL *pptlMask,
|
---|
156 | BRUSHOBJ *pbo,
|
---|
157 | POINTL *pptlBrush,
|
---|
158 | ROP4 rop4
|
---|
159 | )
|
---|
160 | {
|
---|
161 | BOOL bRc;
|
---|
162 |
|
---|
163 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
164 |
|
---|
165 | DISPDBG((1, "psoTrg = %p, psoSrc = %p, psoMask = %p, pco = %p, pxlo = %p, prclTrg = %p, pptlSrc = %p, pptlMask = %p, pbo = %p, pptlBrush = %p, rop4 = %08X\n",
|
---|
166 | psoTrg, psoSrc, psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4));
|
---|
167 |
|
---|
168 | STATDRVENTRY(BitBlt, psoTrg);
|
---|
169 |
|
---|
170 | bRc = EngBitBlt(CONV_SURF(psoTrg), CONV_SURF(psoSrc), psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4);
|
---|
171 |
|
---|
172 | VBVA_OPERATION(psoTrg,
|
---|
173 | BitBlt,
|
---|
174 | (psoTrg, psoSrc, psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4));
|
---|
175 |
|
---|
176 | return bRc;
|
---|
177 | }
|
---|
178 |
|
---|
179 | BOOL APIENTRY DrvTextOut(
|
---|
180 | SURFOBJ *pso,
|
---|
181 | STROBJ *pstro,
|
---|
182 | FONTOBJ *pfo,
|
---|
183 | CLIPOBJ *pco,
|
---|
184 | RECTL *prclExtra, // Obsolete, always NULL
|
---|
185 | RECTL *prclOpaque,
|
---|
186 | BRUSHOBJ *pboFore,
|
---|
187 | BRUSHOBJ *pboOpaque,
|
---|
188 | POINTL *pptlOrg,
|
---|
189 | MIX mix
|
---|
190 | )
|
---|
191 | {
|
---|
192 | BOOL bRc;
|
---|
193 |
|
---|
194 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
195 |
|
---|
196 | STATDRVENTRY(TextOut, pso);
|
---|
197 |
|
---|
198 | bRc = EngTextOut(CONV_SURF(pso), pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix);
|
---|
199 |
|
---|
200 | VBVA_OPERATION(pso,
|
---|
201 | TextOut,
|
---|
202 | (pso, pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix));
|
---|
203 |
|
---|
204 | return bRc;
|
---|
205 | }
|
---|
206 |
|
---|
207 |
|
---|
208 | BOOL APIENTRY DrvLineTo(
|
---|
209 | SURFOBJ *pso,
|
---|
210 | CLIPOBJ *pco,
|
---|
211 | BRUSHOBJ *pbo,
|
---|
212 | LONG x1,
|
---|
213 | LONG y1,
|
---|
214 | LONG x2,
|
---|
215 | LONG y2,
|
---|
216 | RECTL *prclBounds,
|
---|
217 | MIX mix
|
---|
218 | )
|
---|
219 | {
|
---|
220 | BOOL bRc;
|
---|
221 |
|
---|
222 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
223 |
|
---|
224 | STATDRVENTRY(LineTo, pso);
|
---|
225 |
|
---|
226 | bRc = EngLineTo(CONV_SURF(pso), pco, pbo, x1, y1, x2, y2, prclBounds, mix);
|
---|
227 |
|
---|
228 | VBVA_OPERATION(pso,
|
---|
229 | LineTo,
|
---|
230 | (pso, pco, pbo, x1, y1, x2, y2, prclBounds, mix));
|
---|
231 |
|
---|
232 | return bRc;
|
---|
233 | }
|
---|
234 |
|
---|
235 | BOOL APIENTRY DrvStretchBlt(
|
---|
236 | SURFOBJ *psoDest,
|
---|
237 | SURFOBJ *psoSrc,
|
---|
238 | SURFOBJ *psoMask,
|
---|
239 | CLIPOBJ *pco,
|
---|
240 | XLATEOBJ *pxlo,
|
---|
241 | COLORADJUSTMENT *pca,
|
---|
242 | POINTL *pptlHTOrg,
|
---|
243 | RECTL *prclDest,
|
---|
244 | RECTL *prclSrc,
|
---|
245 | POINTL *pptlMask,
|
---|
246 | ULONG iMode
|
---|
247 | )
|
---|
248 | {
|
---|
249 | BOOL bRc;
|
---|
250 |
|
---|
251 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
252 |
|
---|
253 | STATDRVENTRY(StretchBlt, psoDest);
|
---|
254 |
|
---|
255 | bRc = EngStretchBlt(CONV_SURF(psoDest), CONV_SURF(psoSrc), psoMask, pco, pxlo, pca, pptlHTOrg,
|
---|
256 | prclDest, prclSrc, pptlMask, iMode);
|
---|
257 |
|
---|
258 | VBVA_OPERATION(psoDest,
|
---|
259 | StretchBlt,
|
---|
260 | (psoDest, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
|
---|
261 | prclDest, prclSrc, pptlMask, iMode));
|
---|
262 |
|
---|
263 | return bRc;
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 | BOOL APIENTRY DrvCopyBits(
|
---|
268 | SURFOBJ *psoDest,
|
---|
269 | SURFOBJ *psoSrc,
|
---|
270 | CLIPOBJ *pco,
|
---|
271 | XLATEOBJ *pxlo,
|
---|
272 | RECTL *prclDest,
|
---|
273 | POINTL *pptlSrc
|
---|
274 | )
|
---|
275 | {
|
---|
276 | BOOL bRc;
|
---|
277 |
|
---|
278 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
279 |
|
---|
280 | DISPDBG((1, "psoDest = %p, psoSrc = %p, pco = %p, pxlo = %p, prclDest = %p, pptlSrc = %p\n",
|
---|
281 | psoDest, psoSrc, pco, pxlo, prclDest, pptlSrc));
|
---|
282 |
|
---|
283 | STATDRVENTRY(CopyBits, psoDest);
|
---|
284 |
|
---|
285 | dumpsurf(psoSrc, "psoSrc");
|
---|
286 | dumpsurf(psoDest, "psoDest");
|
---|
287 |
|
---|
288 | STATPRINT;
|
---|
289 |
|
---|
290 | bRc = EngCopyBits(CONV_SURF(psoDest), CONV_SURF(psoSrc), pco, pxlo, prclDest, pptlSrc);
|
---|
291 |
|
---|
292 | VBVA_OPERATION(psoDest,
|
---|
293 | CopyBits,
|
---|
294 | (psoDest, psoSrc, pco, pxlo, prclDest, pptlSrc));
|
---|
295 |
|
---|
296 | return bRc;
|
---|
297 | }
|
---|
298 |
|
---|
299 | BOOL APIENTRY DrvPaint(
|
---|
300 | SURFOBJ *pso,
|
---|
301 | CLIPOBJ *pco,
|
---|
302 | BRUSHOBJ *pbo,
|
---|
303 | POINTL *pptlBrushOrg,
|
---|
304 | MIX mix
|
---|
305 | )
|
---|
306 | {
|
---|
307 | BOOL bRc;
|
---|
308 |
|
---|
309 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
310 |
|
---|
311 | STATDRVENTRY(Paint, pso);
|
---|
312 |
|
---|
313 | bRc = EngPaint (CONV_SURF(pso), pco, pbo, pptlBrushOrg, mix);
|
---|
314 |
|
---|
315 | VBVA_OPERATION(pso,
|
---|
316 | Paint,
|
---|
317 | (pso, pco, pbo, pptlBrushOrg, mix));
|
---|
318 |
|
---|
319 | return bRc;
|
---|
320 | }
|
---|
321 |
|
---|
322 | BOOL APIENTRY DrvFillPath(
|
---|
323 | SURFOBJ *pso,
|
---|
324 | PATHOBJ *ppo,
|
---|
325 | CLIPOBJ *pco,
|
---|
326 | BRUSHOBJ *pbo,
|
---|
327 | POINTL *pptlBrushOrg,
|
---|
328 | MIX mix,
|
---|
329 | FLONG flOptions
|
---|
330 | )
|
---|
331 | {
|
---|
332 | BOOL bRc;
|
---|
333 |
|
---|
334 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
335 |
|
---|
336 | STATDRVENTRY(FillPath, pso);
|
---|
337 |
|
---|
338 | bRc = EngFillPath(CONV_SURF(pso), ppo, pco, pbo, pptlBrushOrg, mix, flOptions);
|
---|
339 |
|
---|
340 | VBVA_OPERATION(pso,
|
---|
341 | FillPath,
|
---|
342 | (pso, ppo, pco, pbo, pptlBrushOrg, mix, flOptions));
|
---|
343 |
|
---|
344 | return bRc;
|
---|
345 | }
|
---|
346 |
|
---|
347 |
|
---|
348 |
|
---|
349 | BOOL APIENTRY DrvStrokePath(
|
---|
350 | SURFOBJ *pso,
|
---|
351 | PATHOBJ *ppo,
|
---|
352 | CLIPOBJ *pco,
|
---|
353 | XFORMOBJ *pxo,
|
---|
354 | BRUSHOBJ *pbo,
|
---|
355 | POINTL *pptlBrushOrg,
|
---|
356 | LINEATTRS *plineattrs,
|
---|
357 | MIX mix
|
---|
358 | )
|
---|
359 | {
|
---|
360 | BOOL bRc;
|
---|
361 |
|
---|
362 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
363 |
|
---|
364 | STATDRVENTRY(StrokePath, pso);
|
---|
365 |
|
---|
366 | bRc = EngStrokePath(CONV_SURF(pso), ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix);
|
---|
367 |
|
---|
368 | VBVA_OPERATION(pso,
|
---|
369 | StrokePath,
|
---|
370 | (pso, ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix));
|
---|
371 |
|
---|
372 | return bRc;
|
---|
373 | }
|
---|
374 |
|
---|
375 | static void ssbDiscardTopSlot (PPDEV ppdev)
|
---|
376 | {
|
---|
377 | SSB *pSSB = &ppdev->aSSB[--ppdev->cSSB];
|
---|
378 |
|
---|
379 | if (pSSB->pBuffer)
|
---|
380 | {
|
---|
381 | EngFreeMem (pSSB->pBuffer);
|
---|
382 | pSSB->pBuffer = NULL;
|
---|
383 | }
|
---|
384 |
|
---|
385 | pSSB->ident = 0;
|
---|
386 | }
|
---|
387 |
|
---|
388 | static void ssbDiscardUpperSlots (PPDEV ppdev, ULONG_PTR ident)
|
---|
389 | {
|
---|
390 | while (ppdev->cSSB > ident)
|
---|
391 | {
|
---|
392 | ssbDiscardTopSlot (ppdev);
|
---|
393 | }
|
---|
394 | }
|
---|
395 |
|
---|
396 | static BOOL ssbCopy (SSB *pSSB, SURFOBJ *pso, RECTL *prcl, BOOL bToScreen)
|
---|
397 | {
|
---|
398 | BYTE *pSrc;
|
---|
399 | BYTE *pDst;
|
---|
400 |
|
---|
401 | LONG lDeltaSrc;
|
---|
402 | LONG lDeltaDst;
|
---|
403 |
|
---|
404 | ULONG cWidth;
|
---|
405 | ULONG cHeight;
|
---|
406 |
|
---|
407 | int cbPixel = format2BytesPerPixel(pso);
|
---|
408 |
|
---|
409 | DISPDBG((1, "ssbCopy: pSSB = %p, pso = %p, prcl = %p, bToScreen = %d\n", pSSB, pso, prcl, bToScreen));
|
---|
410 |
|
---|
411 | if (cbPixel == 0)
|
---|
412 | {
|
---|
413 | DISPDBG((1, "ssbCopy: unsupported pixel format!!!\n"));
|
---|
414 | return FALSE;
|
---|
415 | }
|
---|
416 |
|
---|
417 | cWidth = prcl->right - prcl->left;
|
---|
418 | cHeight = prcl->bottom - prcl->top;
|
---|
419 |
|
---|
420 | if (bToScreen)
|
---|
421 | {
|
---|
422 | if (pSSB->pBuffer == NULL)
|
---|
423 | {
|
---|
424 | DISPDBG((1, "ssbCopy: source buffer is NULL!!!\n"));
|
---|
425 | return FALSE;
|
---|
426 | }
|
---|
427 |
|
---|
428 | pSrc = pSSB->pBuffer;
|
---|
429 | lDeltaSrc = cWidth * cbPixel;
|
---|
430 |
|
---|
431 | pDst = (BYTE *)pso->pvScan0 +
|
---|
432 | pso->lDelta * prcl->top +
|
---|
433 | cbPixel * prcl->left;
|
---|
434 | lDeltaDst = pso->lDelta;
|
---|
435 | }
|
---|
436 | else
|
---|
437 | {
|
---|
438 | if (pSSB->pBuffer != NULL)
|
---|
439 | {
|
---|
440 | DISPDBG((1, "ssbCopy: source buffer is not NULL!!!\n"));
|
---|
441 | return FALSE;
|
---|
442 | }
|
---|
443 |
|
---|
444 | pSSB->pBuffer = (BYTE *)EngAllocMem (0, cWidth * cHeight * cbPixel, ALLOC_TAG);
|
---|
445 |
|
---|
446 | if (pSSB->pBuffer == NULL)
|
---|
447 | {
|
---|
448 | DISPDBG((1, "ssbCopy: Failed to allocate buffer!!!\n"));
|
---|
449 | return FALSE;
|
---|
450 | }
|
---|
451 |
|
---|
452 | pDst = pSSB->pBuffer;
|
---|
453 | lDeltaDst = cWidth * cbPixel;
|
---|
454 |
|
---|
455 | pSrc = (BYTE *)pso->pvScan0 +
|
---|
456 | pso->lDelta * prcl->top +
|
---|
457 | cbPixel * prcl->left;
|
---|
458 | lDeltaSrc = pso->lDelta;
|
---|
459 | }
|
---|
460 |
|
---|
461 | DISPDBG((1, "ssbCopy: cHeight = %d, pDst = %p, pSrc = %p, lDeltaSrc = %d, lDeltaDst = %d\n",
|
---|
462 | cHeight, pDst, pSrc, lDeltaSrc, lDeltaDst));
|
---|
463 |
|
---|
464 | while (cHeight--)
|
---|
465 | {
|
---|
466 | memcpy (pDst, pSrc, cWidth * cbPixel);
|
---|
467 |
|
---|
468 | pDst += lDeltaDst;
|
---|
469 | pSrc += lDeltaSrc;
|
---|
470 | }
|
---|
471 |
|
---|
472 | DISPDBG((1, "ssbCopy: completed.\n"));
|
---|
473 | return TRUE;
|
---|
474 | }
|
---|
475 |
|
---|
476 |
|
---|
477 | ULONG_PTR APIENTRY DrvSaveScreenBits(
|
---|
478 | SURFOBJ *pso,
|
---|
479 | ULONG iMode,
|
---|
480 | ULONG_PTR ident,
|
---|
481 | RECTL *prcl
|
---|
482 | )
|
---|
483 | {
|
---|
484 | ULONG_PTR rc = 0; /* 0 means the function failure for every iMode. */
|
---|
485 |
|
---|
486 | RECTL rcl;
|
---|
487 | SSB *pSSB;
|
---|
488 |
|
---|
489 | SURFOBJ *psoOrg = pso;
|
---|
490 |
|
---|
491 | BOOL bCallVBVA = FALSE;
|
---|
492 |
|
---|
493 | PPDEV ppdev = (PPDEV)pso->dhpdev;
|
---|
494 |
|
---|
495 | DISPDBG((1, "%s: %p, %d, %d, %d,%d %d,%d\n",
|
---|
496 | __FUNCTION__, pso, iMode, ident, prcl->left, prcl->top, prcl->right, prcl->bottom));
|
---|
497 |
|
---|
498 | if (!ppdev)
|
---|
499 | {
|
---|
500 | return rc;
|
---|
501 | }
|
---|
502 |
|
---|
503 | pso = CONV_SURF(pso);
|
---|
504 |
|
---|
505 | /* Order the rectangle. */
|
---|
506 | if (prcl->left <= prcl->right)
|
---|
507 | {
|
---|
508 | rcl.left = prcl->left;
|
---|
509 | rcl.right = prcl->right;
|
---|
510 | }
|
---|
511 | else
|
---|
512 | {
|
---|
513 | rcl.left = prcl->right;
|
---|
514 | rcl.right = prcl->left;
|
---|
515 | }
|
---|
516 |
|
---|
517 | if (prcl->top <= prcl->bottom)
|
---|
518 | {
|
---|
519 | rcl.top = prcl->top;
|
---|
520 | rcl.bottom = prcl->bottom;
|
---|
521 | }
|
---|
522 | else
|
---|
523 | {
|
---|
524 | rcl.top = prcl->bottom;
|
---|
525 | rcl.bottom = prcl->top;
|
---|
526 | }
|
---|
527 |
|
---|
528 | /* Implementation of the save/restore is a bit complicated because RDP
|
---|
529 | * requires "the sequencing of saves and restores is such that they
|
---|
530 | * behave as a last-in, first-out stack.".
|
---|
531 | */
|
---|
532 | switch (iMode)
|
---|
533 | {
|
---|
534 | case SS_SAVE:
|
---|
535 | {
|
---|
536 | DISPDBG((1, "DrvSaveScreenBits: SS_SAVE %d\n", ppdev->cSSB));
|
---|
537 |
|
---|
538 | if (ppdev->cSSB >= ELEMENTS(ppdev->aSSB))
|
---|
539 | {
|
---|
540 | /* All slots are already in use. Fail. */
|
---|
541 | DISPDBG((1, "DrvSaveScreenBits: no more slots %d!!!\n", ppdev->cSSB));
|
---|
542 | break;
|
---|
543 | }
|
---|
544 |
|
---|
545 | /* Get pointer to the slot where bits will be saved. */
|
---|
546 | pSSB = &ppdev->aSSB[ppdev->cSSB];
|
---|
547 |
|
---|
548 | /* Allocate memory for screen bits and copy them to the buffer. */
|
---|
549 | if (ssbCopy (pSSB, pso, &rcl, FALSE /* bToScreen */))
|
---|
550 | {
|
---|
551 | /* Bits where successfully copied. Increase the active slot number
|
---|
552 | * and call VBVA levels, 'ident' is also assigned, the VBVA level
|
---|
553 | * will use it even for the SS_SAVE.
|
---|
554 | */
|
---|
555 | ident = rc = pSSB->ident = ++ppdev->cSSB;
|
---|
556 | bCallVBVA = TRUE;
|
---|
557 | }
|
---|
558 | } break;
|
---|
559 |
|
---|
560 | case SS_RESTORE:
|
---|
561 | {
|
---|
562 | DISPDBG((1, "DrvSaveScreenBits: SS_RESTORE\n"));
|
---|
563 |
|
---|
564 | if ( ppdev->cSSB == 0
|
---|
565 | || ident == 0
|
---|
566 | || ident > ppdev->cSSB)
|
---|
567 | {
|
---|
568 | DISPDBG((1, "DrvSaveScreenBits: no slot: ppdev->cSSB = %d!!!\n", ppdev->cSSB));
|
---|
569 | break;
|
---|
570 | }
|
---|
571 |
|
---|
572 | if (ident < ppdev->cSSB)
|
---|
573 | {
|
---|
574 | ssbDiscardUpperSlots (ppdev, ident);
|
---|
575 | }
|
---|
576 |
|
---|
577 | VBVA_ASSERT(ident == ppdev->cSSB);
|
---|
578 | VBVA_ASSERT(ident != 0);
|
---|
579 |
|
---|
580 | pSSB = &ppdev->aSSB[ident - 1];
|
---|
581 |
|
---|
582 | ssbCopy (pSSB, pso, &rcl, TRUE /* bToScreen */);
|
---|
583 |
|
---|
584 | /* Bits must be discarded. */
|
---|
585 | ssbDiscardTopSlot (ppdev);
|
---|
586 |
|
---|
587 | rc = TRUE;
|
---|
588 | bCallVBVA = TRUE;
|
---|
589 | } break;
|
---|
590 |
|
---|
591 | case SS_FREE:
|
---|
592 | {
|
---|
593 | DISPDBG((1, "DrvSaveScreenBits: SS_FREE\n"));
|
---|
594 |
|
---|
595 | if ( ppdev->cSSB == 0
|
---|
596 | || ident == 0
|
---|
597 | || ident > ppdev->cSSB)
|
---|
598 | {
|
---|
599 | DISPDBG((1, "DrvSaveScreenBits: no slot: ppdev->cSSB = %d!!!\n", ppdev->cSSB));
|
---|
600 | break;
|
---|
601 | }
|
---|
602 |
|
---|
603 | if (ident < ppdev->cSSB)
|
---|
604 | {
|
---|
605 | ssbDiscardUpperSlots (ppdev, ident);
|
---|
606 | }
|
---|
607 |
|
---|
608 | VBVA_ASSERT(ident == ppdev->cSSB);
|
---|
609 | VBVA_ASSERT(ident != 0);
|
---|
610 |
|
---|
611 | /* Bits must be discarded. */
|
---|
612 | ssbDiscardTopSlot (ppdev);
|
---|
613 |
|
---|
614 | rc = TRUE;
|
---|
615 | } break;
|
---|
616 | }
|
---|
617 |
|
---|
618 | /* Now call the VBVA/VRDP levels. */
|
---|
619 | if (bCallVBVA)
|
---|
620 | {
|
---|
621 | DISPDBG((1, "DrvSaveScreenBits: calling VBVA\n"));
|
---|
622 | VBVA_OPERATION(psoOrg,
|
---|
623 | SaveScreenBits,
|
---|
624 | (psoOrg, iMode, ident, &rcl));
|
---|
625 | }
|
---|
626 |
|
---|
627 | return rc;
|
---|
628 | }
|
---|
629 |
|
---|
630 | BOOL APIENTRY DrvRealizeBrush(
|
---|
631 | BRUSHOBJ *pbo,
|
---|
632 | SURFOBJ *psoTarget,
|
---|
633 | SURFOBJ *psoPattern,
|
---|
634 | SURFOBJ *psoMask,
|
---|
635 | XLATEOBJ *pxlo,
|
---|
636 | ULONG iHatch
|
---|
637 | )
|
---|
638 | {
|
---|
639 | BOOL bRc = FALSE;
|
---|
640 |
|
---|
641 | DISPDBG((1, "%s\n", __FUNCTION__));
|
---|
642 |
|
---|
643 | if (bIsScreenSurface(psoTarget))
|
---|
644 | {
|
---|
645 | PPDEV ppdev = (PPDEV)psoTarget->dhpdev;
|
---|
646 |
|
---|
647 | if ( ppdev->vbva.pVbvaMemory
|
---|
648 | && (ppdev->vbva.pVbvaMemory->fu32ModeFlags & VBVA_F_MODE_ENABLED))
|
---|
649 | {
|
---|
650 | if (ppdev->vbva.pVbvaMemory->fu32ModeFlags
|
---|
651 | & VBVA_F_MODE_VRDP_RESET)
|
---|
652 | {
|
---|
653 | vrdpReset (ppdev);
|
---|
654 |
|
---|
655 | ppdev->vbva.pVbvaMemory->fu32ModeFlags &=
|
---|
656 | ~VBVA_F_MODE_VRDP_RESET;
|
---|
657 | }
|
---|
658 |
|
---|
659 | if (ppdev->vbva.pVbvaMemory->fu32ModeFlags
|
---|
660 | & VBVA_F_MODE_VRDP)
|
---|
661 | {
|
---|
662 | bRc = vrdpRealizeBrush (pbo, psoTarget, psoPattern, psoMask, pxlo, iHatch);
|
---|
663 | }
|
---|
664 | }
|
---|
665 | }
|
---|
666 |
|
---|
667 | return bRc;
|
---|
668 | }
|
---|
669 |
|
---|
670 | #ifdef STAT_sunlover
|
---|
671 | ULONG gStatCopyBitsOffscreenToScreen = 0;
|
---|
672 | ULONG gStatCopyBitsScreenToScreen = 0;
|
---|
673 | ULONG gStatBitBltOffscreenToScreen = 0;
|
---|
674 | ULONG gStatBitBltScreenToScreen = 0;
|
---|
675 | ULONG gStatUnchangedOffscreenToScreen = 0;
|
---|
676 | ULONG gStatUnchangedOffscreenToScreenCRC = 0;
|
---|
677 | ULONG gStatNonTransientEngineBitmaps = 0;
|
---|
678 | ULONG gStatTransientEngineBitmaps = 0;
|
---|
679 | ULONG gStatUnchangedBitmapsCRC = 0;
|
---|
680 | ULONG gStatUnchangedBitmapsDeviceCRC = 0;
|
---|
681 | ULONG gStatBitmapsCRC = 0;
|
---|
682 | ULONG gStatBitBltScreenPattern = 0;
|
---|
683 | ULONG gStatBitBltScreenSquare = 0;
|
---|
684 | ULONG gStatBitBltScreenPatternReported = 0;
|
---|
685 | ULONG gStatBitBltScreenSquareReported = 0;
|
---|
686 | ULONG gStatCopyBitsScreenSquare = 0;
|
---|
687 |
|
---|
688 | ULONG gStatEnablePDEV = 0;
|
---|
689 | ULONG gStatCompletePDEV = 0;
|
---|
690 | ULONG gStatDisablePDEV = 0;
|
---|
691 | ULONG gStatEnableSurface = 0;
|
---|
692 | ULONG gStatDisableSurface = 0;
|
---|
693 | ULONG gStatAssertMode = 0;
|
---|
694 | ULONG gStatDisableDriver = 0;
|
---|
695 | ULONG gStatCreateDeviceBitmap = 0;
|
---|
696 | ULONG gStatDeleteDeviceBitmap = 0;
|
---|
697 | ULONG gStatDitherColor = 0;
|
---|
698 | ULONG gStatStrokePath = 0;
|
---|
699 | ULONG gStatFillPath = 0;
|
---|
700 | ULONG gStatStrokeAndFillPath = 0;
|
---|
701 | ULONG gStatPaint = 0;
|
---|
702 | ULONG gStatBitBlt = 0;
|
---|
703 | ULONG gStatCopyBits = 0;
|
---|
704 | ULONG gStatStretchBlt = 0;
|
---|
705 | ULONG gStatSetPalette = 0;
|
---|
706 | ULONG gStatTextOut = 0;
|
---|
707 | ULONG gStatSetPointerShape = 0;
|
---|
708 | ULONG gStatMovePointer = 0;
|
---|
709 | ULONG gStatLineTo = 0;
|
---|
710 | ULONG gStatSynchronize = 0;
|
---|
711 | ULONG gStatGetModes = 0;
|
---|
712 | ULONG gStatGradientFill = 0;
|
---|
713 | ULONG gStatStretchBltROP = 0;
|
---|
714 | ULONG gStatPlgBlt = 0;
|
---|
715 | ULONG gStatAlphaBlend = 0;
|
---|
716 | ULONG gStatTransparentBlt = 0;
|
---|
717 |
|
---|
718 | void statPrint (void)
|
---|
719 | {
|
---|
720 | DISPDBG((0,
|
---|
721 | "BMPSTAT:\n"
|
---|
722 | " gStatCopyBitsOffscreenToScreen = %u\n"
|
---|
723 | " gStatCopyBitsScreenToScreen = %u\n"
|
---|
724 | " gStatBitBltOffscreenToScreen = %u\n"
|
---|
725 | " gStatBitBltScreenToScreen = %u\n"
|
---|
726 | " gStatUnchangedOffscreenToScreen = %u\n"
|
---|
727 | " gStatUnchangedOffscreenToScreenCRC = %u\n"
|
---|
728 | " gStatNonTransientEngineBitmaps = %u\n"
|
---|
729 | " gStatTransientEngineBitmaps = %u\n"
|
---|
730 | " gStatUnchangedBitmapsCRC = %u\n"
|
---|
731 | " gStatUnchangedBitmapsDeviceCRC = %u\n"
|
---|
732 | " gStatBitmapsCRC = %u\n"
|
---|
733 | " gStatBitBltScreenPattern = %u\n"
|
---|
734 | " gStatBitBltScreenSquare = %u\n"
|
---|
735 | " gStatBitBltScreenPatternReported = %u\n"
|
---|
736 | " gStatBitBltScreenSquareReported = %u\n"
|
---|
737 | " gStatCopyBitsScreenSquare = %u\n"
|
---|
738 | "\n"
|
---|
739 | " gStatEnablePDEV = %u\n"
|
---|
740 | " gStatCompletePDEV = %u\n"
|
---|
741 | " gStatDisablePDEV = %u\n"
|
---|
742 | " gStatEnableSurface = %u\n"
|
---|
743 | " gStatDisableSurface = %u\n"
|
---|
744 | " gStatAssertMode = %u\n"
|
---|
745 | " gStatDisableDriver = %u\n"
|
---|
746 | " gStatCreateDeviceBitmap = %u\n"
|
---|
747 | " gStatDeleteDeviceBitmap = %u\n"
|
---|
748 | " gStatDitherColor = %u\n"
|
---|
749 | " gStatStrokePath = %u\n"
|
---|
750 | " gStatFillPath = %u\n"
|
---|
751 | " gStatStrokeAndFillPath = %u\n"
|
---|
752 | " gStatPaint = %u\n"
|
---|
753 | " gStatBitBlt = %u\n"
|
---|
754 | " gStatCopyBits = %u\n"
|
---|
755 | " gStatStretchBlt = %u\n"
|
---|
756 | " gStatSetPalette = %u\n"
|
---|
757 | " gStatTextOut = %u\n"
|
---|
758 | " gStatSetPointerShape = %u\n"
|
---|
759 | " gStatMovePointer = %u\n"
|
---|
760 | " gStatLineTo = %u\n"
|
---|
761 | " gStatSynchronize = %u\n"
|
---|
762 | " gStatGetModes = %u\n"
|
---|
763 | " gStatGradientFill = %u\n"
|
---|
764 | " gStatStretchBltROP = %u\n"
|
---|
765 | " gStatPlgBlt = %u\n"
|
---|
766 | " gStatAlphaBlend = %u\n"
|
---|
767 | " gStatTransparentBlt = %u\n",
|
---|
768 | gStatCopyBitsOffscreenToScreen,
|
---|
769 | gStatCopyBitsScreenToScreen,
|
---|
770 | gStatBitBltOffscreenToScreen,
|
---|
771 | gStatBitBltScreenToScreen,
|
---|
772 | gStatUnchangedOffscreenToScreen,
|
---|
773 | gStatUnchangedOffscreenToScreenCRC,
|
---|
774 | gStatNonTransientEngineBitmaps,
|
---|
775 | gStatTransientEngineBitmaps,
|
---|
776 | gStatUnchangedBitmapsCRC,
|
---|
777 | gStatUnchangedBitmapsDeviceCRC,
|
---|
778 | gStatBitmapsCRC,
|
---|
779 | gStatBitBltScreenPattern,
|
---|
780 | gStatBitBltScreenSquare,
|
---|
781 | gStatBitBltScreenPatternReported,
|
---|
782 | gStatBitBltScreenSquareReported,
|
---|
783 | gStatCopyBitsScreenSquare,
|
---|
784 | gStatEnablePDEV,
|
---|
785 | gStatCompletePDEV,
|
---|
786 | gStatDisablePDEV,
|
---|
787 | gStatEnableSurface,
|
---|
788 | gStatDisableSurface,
|
---|
789 | gStatAssertMode,
|
---|
790 | gStatDisableDriver,
|
---|
791 | gStatCreateDeviceBitmap,
|
---|
792 | gStatDeleteDeviceBitmap,
|
---|
793 | gStatDitherColor,
|
---|
794 | gStatStrokePath,
|
---|
795 | gStatFillPath,
|
---|
796 | gStatStrokeAndFillPath,
|
---|
797 | gStatPaint,
|
---|
798 | gStatBitBlt,
|
---|
799 | gStatCopyBits,
|
---|
800 | gStatStretchBlt,
|
---|
801 | gStatSetPalette,
|
---|
802 | gStatTextOut,
|
---|
803 | gStatSetPointerShape,
|
---|
804 | gStatMovePointer,
|
---|
805 | gStatLineTo,
|
---|
806 | gStatSynchronize,
|
---|
807 | gStatGetModes,
|
---|
808 | gStatGradientFill,
|
---|
809 | gStatStretchBltROP,
|
---|
810 | gStatPlgBlt,
|
---|
811 | gStatAlphaBlend,
|
---|
812 | gStatTransparentBlt
|
---|
813 | ));
|
---|
814 | }
|
---|
815 | #endif /* STAT_sunlover */
|
---|
816 |
|
---|