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