VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/drv.c@ 31634

Last change on this file since 31634 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.4 KB
Line 
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 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will 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
56void 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
80BOOL 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#ifndef VBOX_WITH_HGSMI
104#define VBVA_OPERATION(__psoDest, __fn, __a) do { \
105 if (bIsScreenSurface(__psoDest)) \
106 { \
107 PPDEV ppdev = (PPDEV)__psoDest->dhpdev; \
108 \
109 if (ppdev->pInfo && vboxHwBufferBeginUpdate (ppdev)) \
110 { \
111 vbva##__fn __a; \
112 \
113 if ( ppdev->pInfo->hostEvents.fu32Events \
114 & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET) \
115 { \
116 vrdpReset (ppdev); \
117 \
118 ppdev->pInfo->hostEvents.fu32Events &= \
119 ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET; \
120 } \
121 \
122 if (ppdev->vbva.pVbvaMemory->fu32ModeFlags \
123 & VBVA_F_MODE_VRDP) \
124 { \
125 vrdp##__fn __a; \
126 } \
127 \
128 vboxHwBufferEndUpdate (ppdev); \
129 } \
130 } \
131} while (0)
132#else
133#define VBVA_OPERATION(__psoDest, __fn, __a) do { \
134 if (bIsScreenSurface(__psoDest)) \
135 { \
136 PPDEV ppdev = (PPDEV)__psoDest->dhpdev; \
137 \
138 if (ppdev->bHGSMISupported && vboxHwBufferBeginUpdate (ppdev)) \
139 { \
140 vbva##__fn __a; \
141 \
142 if ( ppdev->pVBVA->hostFlags.u32HostEvents \
143 & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET) \
144 { \
145 vrdpReset (ppdev); \
146 \
147 ppdev->pVBVA->hostFlags.u32HostEvents &= \
148 ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET; \
149 } \
150 \
151 if (ppdev->pVBVA->hostFlags.u32HostEvents \
152 & VBVA_F_MODE_VRDP) \
153 { \
154 vrdp##__fn __a; \
155 } \
156 \
157 vboxHwBufferEndUpdate (ppdev); \
158 } \
159 } \
160} while (0)
161#endif /* VBOX_WITH_HGSMI */
162
163//#undef VBVA_OPERATION
164//#define VBVA_OPERATION(_psoDest, __fn, __a) do { } while (0)
165
166
167#if 0
168typedef struct _SURFOBJ {
169+00 DHSURF dhsurf;
170+04 HSURF hsurf;
171+08 DHPDEV dhpdev;
172+0c HDEV hdev;
173+10 SIZEL sizlBitmap;
174+18 ULONG cjBits;
175+1c PVOID pvBits;
176+20 PVOID pvScan0;
177+24 LONG lDelta;
178+28 ULONG iUniq;
179+2c ULONG iBitmapFormat;
180+30 USHORT iType;
181+32 USHORT fjBitmap;
182} SURFOBJ;
183#endif
184
185BOOL APIENTRY DrvBitBlt(
186 SURFOBJ *psoTrg,
187 SURFOBJ *psoSrc,
188 SURFOBJ *psoMask,
189 CLIPOBJ *pco,
190 XLATEOBJ *pxlo,
191 RECTL *prclTrg,
192 POINTL *pptlSrc,
193 POINTL *pptlMask,
194 BRUSHOBJ *pbo,
195 POINTL *pptlBrush,
196 ROP4 rop4
197 )
198{
199 BOOL bRc;
200
201 DISPDBG((1, "%s\n", __FUNCTION__));
202
203 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",
204 psoTrg, psoSrc, psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4));
205
206 STATDRVENTRY(BitBlt, psoTrg);
207
208 bRc = EngBitBlt(CONV_SURF(psoTrg), CONV_SURF(psoSrc), psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4);
209
210 VBVA_OPERATION(psoTrg,
211 BitBlt,
212 (psoTrg, psoSrc, psoMask, pco, pxlo, prclTrg, pptlSrc, pptlMask, pbo, pptlBrush, rop4));
213
214 return bRc;
215}
216
217BOOL APIENTRY DrvTextOut(
218 SURFOBJ *pso,
219 STROBJ *pstro,
220 FONTOBJ *pfo,
221 CLIPOBJ *pco,
222 RECTL *prclExtra, // Obsolete, always NULL
223 RECTL *prclOpaque,
224 BRUSHOBJ *pboFore,
225 BRUSHOBJ *pboOpaque,
226 POINTL *pptlOrg,
227 MIX mix
228 )
229{
230 BOOL bRc;
231
232 DISPDBG((1, "%s\n", __FUNCTION__));
233
234 STATDRVENTRY(TextOut, pso);
235
236 bRc = EngTextOut(CONV_SURF(pso), pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix);
237
238 VBVA_OPERATION(pso,
239 TextOut,
240 (pso, pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix));
241
242 return bRc;
243}
244
245
246BOOL APIENTRY DrvLineTo(
247 SURFOBJ *pso,
248 CLIPOBJ *pco,
249 BRUSHOBJ *pbo,
250 LONG x1,
251 LONG y1,
252 LONG x2,
253 LONG y2,
254 RECTL *prclBounds,
255 MIX mix
256 )
257{
258 BOOL bRc;
259
260 DISPDBG((1, "%s\n", __FUNCTION__));
261
262 STATDRVENTRY(LineTo, pso);
263
264 bRc = EngLineTo(CONV_SURF(pso), pco, pbo, x1, y1, x2, y2, prclBounds, mix);
265
266 VBVA_OPERATION(pso,
267 LineTo,
268 (pso, pco, pbo, x1, y1, x2, y2, prclBounds, mix));
269
270 return bRc;
271}
272
273BOOL APIENTRY DrvStretchBlt(
274 SURFOBJ *psoDest,
275 SURFOBJ *psoSrc,
276 SURFOBJ *psoMask,
277 CLIPOBJ *pco,
278 XLATEOBJ *pxlo,
279 COLORADJUSTMENT *pca,
280 POINTL *pptlHTOrg,
281 RECTL *prclDest,
282 RECTL *prclSrc,
283 POINTL *pptlMask,
284 ULONG iMode
285 )
286{
287 BOOL bRc;
288
289 DISPDBG((1, "%s\n", __FUNCTION__));
290
291 STATDRVENTRY(StretchBlt, psoDest);
292
293 bRc = EngStretchBlt(CONV_SURF(psoDest), CONV_SURF(psoSrc), psoMask, pco, pxlo, pca, pptlHTOrg,
294 prclDest, prclSrc, pptlMask, iMode);
295
296 VBVA_OPERATION(psoDest,
297 StretchBlt,
298 (psoDest, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
299 prclDest, prclSrc, pptlMask, iMode));
300
301 return bRc;
302}
303
304
305BOOL APIENTRY DrvCopyBits(
306 SURFOBJ *psoDest,
307 SURFOBJ *psoSrc,
308 CLIPOBJ *pco,
309 XLATEOBJ *pxlo,
310 RECTL *prclDest,
311 POINTL *pptlSrc
312 )
313{
314 RECTL rclDest = *prclDest;
315 POINTL ptlSrc = *pptlSrc;
316
317 BOOL bRc;
318 BOOL bDo = TRUE;
319
320 DISPDBG((1, "%s\n", __FUNCTION__));
321
322 DISPDBG((1, "psoDest = %p, psoSrc = %p, pco = %p, pxlo = %p, prclDest = %p, pptlSrc = %p\n",
323 psoDest, psoSrc, pco, pxlo, prclDest, pptlSrc));
324
325 STATDRVENTRY(CopyBits, psoDest);
326
327 dumpsurf(psoSrc, "psoSrc");
328 dumpsurf(psoDest, "psoDest");
329
330 STATPRINT;
331
332#ifdef VBOX_VBVA_ADJUST_RECT
333 /* Experimental fix for too large bitmap updates.
334 *
335 * Some application do a large bitmap update event if only
336 * a small part of the bitmap is actually changed.
337 *
338 * The driver will find the changed rectangle by comparing
339 * the current framebuffer content with the source bitmap.
340 *
341 * The optimization is only active when:
342 * - the VBVA extension is enabled;
343 * - the source bitmap is not cacheable;
344 * - the bitmap formats of both the source and the screen surfaces are equal.
345 *
346 */
347 if ( psoSrc
348 && !bIsScreenSurface(psoSrc)
349 && bIsScreenSurface(psoDest))
350 {
351 PPDEV ppdev = (PPDEV)psoDest->dhpdev;
352
353#ifndef VBOX_WITH_HGSMI
354 VBVAMEMORY *pVbvaMemory = ppdev->vbva.pVbvaMemory;
355
356 DISPDBG((1, "offscreen->screen\n"));
357
358 if ( pVbvaMemory
359 && (pVbvaMemory->fu32ModeFlags & VBVA_F_MODE_ENABLED))
360#else
361 DISPDBG((1, "offscreen->screen\n"));
362
363 if ( ppdev->pVBVA
364 && (ppdev->pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED))
365#endif /* VBOX_WITH_HGSMI */
366 {
367 if ( (psoSrc->fjBitmap & BMF_DONTCACHE) != 0
368 || psoSrc->iUniq == 0)
369 {
370 DISPDBG((1, "non-cacheable %d->%d (ppdev %p)\n", psoSrc->iBitmapFormat, psoDest->iBitmapFormat, ppdev));
371
372 /* It is possible to apply the fix. */
373 bDo = vbvaFindChangedRect (CONV_SURF(psoDest), CONV_SURF(psoSrc), &rclDest, &ptlSrc);
374 }
375 }
376 }
377
378 if (!bDo)
379 {
380 /* The operation is a NOP. Just return success. */
381 return TRUE;
382 }
383#endif /* VBOX_VBVA_ADJUST_RECT */
384
385 bRc = EngCopyBits(CONV_SURF(psoDest), CONV_SURF(psoSrc), pco, pxlo, &rclDest, &ptlSrc);
386
387 VBVA_OPERATION(psoDest,
388 CopyBits,
389 (psoDest, psoSrc, pco, pxlo, &rclDest, &ptlSrc));
390
391 return bRc;
392}
393
394BOOL APIENTRY DrvPaint(
395 SURFOBJ *pso,
396 CLIPOBJ *pco,
397 BRUSHOBJ *pbo,
398 POINTL *pptlBrushOrg,
399 MIX mix
400 )
401{
402 BOOL bRc;
403
404 DISPDBG((1, "%s\n", __FUNCTION__));
405
406 STATDRVENTRY(Paint, pso);
407
408 bRc = EngPaint (CONV_SURF(pso), pco, pbo, pptlBrushOrg, mix);
409
410 VBVA_OPERATION(pso,
411 Paint,
412 (pso, pco, pbo, pptlBrushOrg, mix));
413
414 return bRc;
415}
416
417BOOL APIENTRY DrvFillPath(
418 SURFOBJ *pso,
419 PATHOBJ *ppo,
420 CLIPOBJ *pco,
421 BRUSHOBJ *pbo,
422 POINTL *pptlBrushOrg,
423 MIX mix,
424 FLONG flOptions
425 )
426{
427 BOOL bRc;
428
429 DISPDBG((1, "%s\n", __FUNCTION__));
430
431 STATDRVENTRY(FillPath, pso);
432
433 bRc = EngFillPath(CONV_SURF(pso), ppo, pco, pbo, pptlBrushOrg, mix, flOptions);
434
435 VBVA_OPERATION(pso,
436 FillPath,
437 (pso, ppo, pco, pbo, pptlBrushOrg, mix, flOptions));
438
439 return bRc;
440}
441
442
443
444BOOL APIENTRY DrvStrokePath(
445 SURFOBJ *pso,
446 PATHOBJ *ppo,
447 CLIPOBJ *pco,
448 XFORMOBJ *pxo,
449 BRUSHOBJ *pbo,
450 POINTL *pptlBrushOrg,
451 LINEATTRS *plineattrs,
452 MIX mix
453 )
454{
455 BOOL bRc;
456
457 DISPDBG((1, "%s\n", __FUNCTION__));
458
459 STATDRVENTRY(StrokePath, pso);
460
461 bRc = EngStrokePath(CONV_SURF(pso), ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix);
462
463 VBVA_OPERATION(pso,
464 StrokePath,
465 (pso, ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix));
466
467 return bRc;
468}
469
470BOOL APIENTRY DrvStrokeAndFillPath(
471 SURFOBJ *pso,
472 PATHOBJ *ppo,
473 CLIPOBJ *pco,
474 XFORMOBJ *pxo,
475 BRUSHOBJ *pboStroke,
476 LINEATTRS *plineattrs,
477 BRUSHOBJ *pboFill,
478 POINTL *pptlBrushOrg,
479 MIX mixFill,
480 FLONG flOptions
481 )
482{
483 BOOL bRc;
484
485 DISPDBG((1, "%s\n", __FUNCTION__));
486
487 STATDRVENTRY(StrokeAndFillPath, pso);
488
489 bRc = EngStrokeAndFillPath(CONV_SURF(pso), ppo, pco, pxo, pboStroke, plineattrs, pboFill, pptlBrushOrg, mixFill, flOptions);
490
491 VBVA_OPERATION(pso,
492 StrokeAndFillPath,
493 (pso, ppo, pco, pxo, pboStroke, plineattrs, pboFill, pptlBrushOrg, mixFill, flOptions));
494
495 return bRc;
496}
497
498static void ssbDiscardTopSlot (PPDEV ppdev)
499{
500 SSB *pSSB = &ppdev->aSSB[--ppdev->cSSB];
501
502 if (pSSB->pBuffer)
503 {
504 EngFreeMem (pSSB->pBuffer);
505 pSSB->pBuffer = NULL;
506 }
507
508 pSSB->ident = 0;
509}
510
511static void ssbDiscardUpperSlots (PPDEV ppdev, ULONG_PTR ident)
512{
513 while (ppdev->cSSB > ident)
514 {
515 ssbDiscardTopSlot (ppdev);
516 }
517}
518
519static BOOL ssbCopy (SSB *pSSB, SURFOBJ *pso, RECTL *prcl, BOOL bToScreen)
520{
521 BYTE *pSrc;
522 BYTE *pDst;
523
524 LONG lDeltaSrc;
525 LONG lDeltaDst;
526
527 ULONG cWidth;
528 ULONG cHeight;
529
530 int cbPixel = format2BytesPerPixel(pso);
531
532 DISPDBG((1, "ssbCopy: pSSB = %p, pso = %p, prcl = %p, bToScreen = %d\n", pSSB, pso, prcl, bToScreen));
533
534 if (cbPixel == 0)
535 {
536 DISPDBG((1, "ssbCopy: unsupported pixel format!!!\n"));
537 return FALSE;
538 }
539
540 cWidth = prcl->right - prcl->left;
541 cHeight = prcl->bottom - prcl->top;
542
543 if (bToScreen)
544 {
545 if (pSSB->pBuffer == NULL)
546 {
547 DISPDBG((1, "ssbCopy: source buffer is NULL!!!\n"));
548 return FALSE;
549 }
550
551 pSrc = pSSB->pBuffer;
552 lDeltaSrc = cWidth * cbPixel;
553
554 pDst = (BYTE *)pso->pvScan0 +
555 pso->lDelta * prcl->top +
556 cbPixel * prcl->left;
557 lDeltaDst = pso->lDelta;
558 }
559 else
560 {
561 if (pSSB->pBuffer != NULL)
562 {
563 DISPDBG((1, "ssbCopy: source buffer is not NULL!!!\n"));
564 return FALSE;
565 }
566
567 pSSB->pBuffer = (BYTE *)EngAllocMem (0, cWidth * cHeight * cbPixel, ALLOC_TAG);
568
569 if (pSSB->pBuffer == NULL)
570 {
571 DISPDBG((1, "ssbCopy: Failed to allocate buffer!!!\n"));
572 return FALSE;
573 }
574
575 pDst = pSSB->pBuffer;
576 lDeltaDst = cWidth * cbPixel;
577
578 pSrc = (BYTE *)pso->pvScan0 +
579 pso->lDelta * prcl->top +
580 cbPixel * prcl->left;
581 lDeltaSrc = pso->lDelta;
582 }
583
584 DISPDBG((1, "ssbCopy: cHeight = %d, pDst = %p, pSrc = %p, lDeltaSrc = %d, lDeltaDst = %d\n",
585 cHeight, pDst, pSrc, lDeltaSrc, lDeltaDst));
586
587 while (cHeight--)
588 {
589 memcpy (pDst, pSrc, cWidth * cbPixel);
590
591 pDst += lDeltaDst;
592 pSrc += lDeltaSrc;
593 }
594
595 DISPDBG((1, "ssbCopy: completed.\n"));
596 return TRUE;
597}
598
599
600ULONG_PTR APIENTRY DrvSaveScreenBits(
601 SURFOBJ *pso,
602 ULONG iMode,
603 ULONG_PTR ident,
604 RECTL *prcl
605 )
606{
607 ULONG_PTR rc = 0; /* 0 means the function failure for every iMode. */
608
609 RECTL rcl;
610 SSB *pSSB;
611
612 SURFOBJ *psoOrg = pso;
613
614 BOOL bCallVBVA = FALSE;
615
616 PPDEV ppdev = (PPDEV)pso->dhpdev;
617
618 DISPDBG((1, "%s: %p, %d, %d, %d,%d %d,%d\n",
619 __FUNCTION__, pso, iMode, ident, prcl->left, prcl->top, prcl->right, prcl->bottom));
620
621 if (!ppdev)
622 {
623 return rc;
624 }
625
626 pso = CONV_SURF(pso);
627
628 /* Order the rectangle. */
629 if (prcl->left <= prcl->right)
630 {
631 rcl.left = prcl->left;
632 rcl.right = prcl->right;
633 }
634 else
635 {
636 rcl.left = prcl->right;
637 rcl.right = prcl->left;
638 }
639
640 if (prcl->top <= prcl->bottom)
641 {
642 rcl.top = prcl->top;
643 rcl.bottom = prcl->bottom;
644 }
645 else
646 {
647 rcl.top = prcl->bottom;
648 rcl.bottom = prcl->top;
649 }
650
651 /* Implementation of the save/restore is a bit complicated because RDP
652 * requires "the sequencing of saves and restores is such that they
653 * behave as a last-in, first-out stack.".
654 */
655 switch (iMode)
656 {
657 case SS_SAVE:
658 {
659 DISPDBG((1, "DrvSaveScreenBits: SS_SAVE %d\n", ppdev->cSSB));
660
661 if (ppdev->cSSB >= RT_ELEMENTS(ppdev->aSSB))
662 {
663 /* All slots are already in use. Fail. */
664 DISPDBG((1, "DrvSaveScreenBits: no more slots %d!!!\n", ppdev->cSSB));
665 break;
666 }
667
668 /* Get pointer to the slot where bits will be saved. */
669 pSSB = &ppdev->aSSB[ppdev->cSSB];
670
671 /* Allocate memory for screen bits and copy them to the buffer. */
672 if (ssbCopy (pSSB, pso, &rcl, FALSE /* bToScreen */))
673 {
674 /* Bits where successfully copied. Increase the active slot number
675 * and call VBVA levels, 'ident' is also assigned, the VBVA level
676 * will use it even for the SS_SAVE.
677 */
678 ident = rc = pSSB->ident = ++ppdev->cSSB;
679 bCallVBVA = TRUE;
680 }
681 } break;
682
683 case SS_RESTORE:
684 {
685 DISPDBG((1, "DrvSaveScreenBits: SS_RESTORE\n"));
686
687 if ( ppdev->cSSB == 0
688 || ident == 0
689 || ident > ppdev->cSSB)
690 {
691 DISPDBG((1, "DrvSaveScreenBits: no slot: ppdev->cSSB = %d!!!\n", ppdev->cSSB));
692 break;
693 }
694
695 if (ident < ppdev->cSSB)
696 {
697 ssbDiscardUpperSlots (ppdev, ident);
698 }
699
700 VBVA_ASSERT(ident == ppdev->cSSB);
701 VBVA_ASSERT(ident != 0);
702
703 pSSB = &ppdev->aSSB[ident - 1];
704
705 ssbCopy (pSSB, pso, &rcl, TRUE /* bToScreen */);
706
707 /* Bits must be discarded. */
708 ssbDiscardTopSlot (ppdev);
709
710 rc = TRUE;
711 bCallVBVA = TRUE;
712 } break;
713
714 case SS_FREE:
715 {
716 DISPDBG((1, "DrvSaveScreenBits: SS_FREE\n"));
717
718 if ( ppdev->cSSB == 0
719 || ident == 0
720 || ident > ppdev->cSSB)
721 {
722 DISPDBG((1, "DrvSaveScreenBits: no slot: ppdev->cSSB = %d!!!\n", ppdev->cSSB));
723 break;
724 }
725
726 if (ident < ppdev->cSSB)
727 {
728 ssbDiscardUpperSlots (ppdev, ident);
729 }
730
731 VBVA_ASSERT(ident == ppdev->cSSB);
732 VBVA_ASSERT(ident != 0);
733
734 /* Bits must be discarded. */
735 ssbDiscardTopSlot (ppdev);
736
737 rc = TRUE;
738 } break;
739 }
740
741 /* Now call the VBVA/VRDP levels. */
742 if (bCallVBVA)
743 {
744 DISPDBG((1, "DrvSaveScreenBits: calling VBVA\n"));
745 VBVA_OPERATION(psoOrg,
746 SaveScreenBits,
747 (psoOrg, iMode, ident, &rcl));
748 }
749
750 return rc;
751}
752
753BOOL APIENTRY DrvRealizeBrush(
754 BRUSHOBJ *pbo,
755 SURFOBJ *psoTarget,
756 SURFOBJ *psoPattern,
757 SURFOBJ *psoMask,
758 XLATEOBJ *pxlo,
759 ULONG iHatch
760 )
761{
762 BOOL bRc = FALSE;
763
764 DISPDBG((1, "%s\n", __FUNCTION__));
765
766 if (bIsScreenSurface(psoTarget))
767 {
768 PPDEV ppdev = (PPDEV)psoTarget->dhpdev;
769
770#ifndef VBOX_WITH_HGSMI
771 if ( ppdev->vbva.pVbvaMemory
772 && (ppdev->vbva.pVbvaMemory->fu32ModeFlags & VBVA_F_MODE_ENABLED))
773 {
774 if (ppdev->vbva.pVbvaMemory->fu32ModeFlags
775 & VBVA_F_MODE_VRDP_RESET)
776 {
777 vrdpReset (ppdev);
778
779 ppdev->vbva.pVbvaMemory->fu32ModeFlags &=
780 ~VBVA_F_MODE_VRDP_RESET;
781 }
782
783 if (ppdev->vbva.pVbvaMemory->fu32ModeFlags
784 & VBVA_F_MODE_VRDP)
785 {
786 bRc = vrdpRealizeBrush (pbo, psoTarget, psoPattern, psoMask, pxlo, iHatch);
787 }
788 }
789#else
790 if ( ppdev->pVBVA
791 && (ppdev->pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED))
792 {
793 if (ppdev->pVBVA->hostFlags.u32HostEvents
794 & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET)
795 {
796 vrdpReset (ppdev);
797
798 ppdev->pVBVA->hostFlags.u32HostEvents &=
799 ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
800 }
801
802 if (ppdev->pVBVA->hostFlags.u32HostEvents
803 & VBVA_F_MODE_VRDP)
804 {
805 bRc = vrdpRealizeBrush (pbo, psoTarget, psoPattern, psoMask, pxlo, iHatch);
806 }
807 }
808#endif /* VBOX_WITH_HGSMI */
809 }
810
811 return bRc;
812}
813
814#ifdef STAT_sunlover
815ULONG gStatCopyBitsOffscreenToScreen = 0;
816ULONG gStatCopyBitsScreenToScreen = 0;
817ULONG gStatBitBltOffscreenToScreen = 0;
818ULONG gStatBitBltScreenToScreen = 0;
819ULONG gStatUnchangedOffscreenToScreen = 0;
820ULONG gStatUnchangedOffscreenToScreenCRC = 0;
821ULONG gStatNonTransientEngineBitmaps = 0;
822ULONG gStatTransientEngineBitmaps = 0;
823ULONG gStatUnchangedBitmapsCRC = 0;
824ULONG gStatUnchangedBitmapsDeviceCRC = 0;
825ULONG gStatBitmapsCRC = 0;
826ULONG gStatBitBltScreenPattern = 0;
827ULONG gStatBitBltScreenSquare = 0;
828ULONG gStatBitBltScreenPatternReported = 0;
829ULONG gStatBitBltScreenSquareReported = 0;
830ULONG gStatCopyBitsScreenSquare = 0;
831
832ULONG gStatEnablePDEV = 0;
833ULONG gStatCompletePDEV = 0;
834ULONG gStatDisablePDEV = 0;
835ULONG gStatEnableSurface = 0;
836ULONG gStatDisableSurface = 0;
837ULONG gStatAssertMode = 0;
838ULONG gStatDisableDriver = 0;
839ULONG gStatCreateDeviceBitmap = 0;
840ULONG gStatDeleteDeviceBitmap = 0;
841ULONG gStatDitherColor = 0;
842ULONG gStatStrokePath = 0;
843ULONG gStatFillPath = 0;
844ULONG gStatStrokeAndFillPath = 0;
845ULONG gStatPaint = 0;
846ULONG gStatBitBlt = 0;
847ULONG gStatCopyBits = 0;
848ULONG gStatStretchBlt = 0;
849ULONG gStatSetPalette = 0;
850ULONG gStatTextOut = 0;
851ULONG gStatSetPointerShape = 0;
852ULONG gStatMovePointer = 0;
853ULONG gStatLineTo = 0;
854ULONG gStatSynchronize = 0;
855ULONG gStatGetModes = 0;
856ULONG gStatGradientFill = 0;
857ULONG gStatStretchBltROP = 0;
858ULONG gStatPlgBlt = 0;
859ULONG gStatAlphaBlend = 0;
860ULONG gStatTransparentBlt = 0;
861
862void statPrint (void)
863{
864 DISPDBG((0,
865 "BMPSTAT:\n"
866 " gStatCopyBitsOffscreenToScreen = %u\n"
867 " gStatCopyBitsScreenToScreen = %u\n"
868 " gStatBitBltOffscreenToScreen = %u\n"
869 " gStatBitBltScreenToScreen = %u\n"
870 " gStatUnchangedOffscreenToScreen = %u\n"
871 " gStatUnchangedOffscreenToScreenCRC = %u\n"
872 " gStatNonTransientEngineBitmaps = %u\n"
873 " gStatTransientEngineBitmaps = %u\n"
874 " gStatUnchangedBitmapsCRC = %u\n"
875 " gStatUnchangedBitmapsDeviceCRC = %u\n"
876 " gStatBitmapsCRC = %u\n"
877 " gStatBitBltScreenPattern = %u\n"
878 " gStatBitBltScreenSquare = %u\n"
879 " gStatBitBltScreenPatternReported = %u\n"
880 " gStatBitBltScreenSquareReported = %u\n"
881 " gStatCopyBitsScreenSquare = %u\n"
882 "\n"
883 " gStatEnablePDEV = %u\n"
884 " gStatCompletePDEV = %u\n"
885 " gStatDisablePDEV = %u\n"
886 " gStatEnableSurface = %u\n"
887 " gStatDisableSurface = %u\n"
888 " gStatAssertMode = %u\n"
889 " gStatDisableDriver = %u\n"
890 " gStatCreateDeviceBitmap = %u\n"
891 " gStatDeleteDeviceBitmap = %u\n"
892 " gStatDitherColor = %u\n"
893 " gStatStrokePath = %u\n"
894 " gStatFillPath = %u\n"
895 " gStatStrokeAndFillPath = %u\n"
896 " gStatPaint = %u\n"
897 " gStatBitBlt = %u\n"
898 " gStatCopyBits = %u\n"
899 " gStatStretchBlt = %u\n"
900 " gStatSetPalette = %u\n"
901 " gStatTextOut = %u\n"
902 " gStatSetPointerShape = %u\n"
903 " gStatMovePointer = %u\n"
904 " gStatLineTo = %u\n"
905 " gStatSynchronize = %u\n"
906 " gStatGetModes = %u\n"
907 " gStatGradientFill = %u\n"
908 " gStatStretchBltROP = %u\n"
909 " gStatPlgBlt = %u\n"
910 " gStatAlphaBlend = %u\n"
911 " gStatTransparentBlt = %u\n",
912 gStatCopyBitsOffscreenToScreen,
913 gStatCopyBitsScreenToScreen,
914 gStatBitBltOffscreenToScreen,
915 gStatBitBltScreenToScreen,
916 gStatUnchangedOffscreenToScreen,
917 gStatUnchangedOffscreenToScreenCRC,
918 gStatNonTransientEngineBitmaps,
919 gStatTransientEngineBitmaps,
920 gStatUnchangedBitmapsCRC,
921 gStatUnchangedBitmapsDeviceCRC,
922 gStatBitmapsCRC,
923 gStatBitBltScreenPattern,
924 gStatBitBltScreenSquare,
925 gStatBitBltScreenPatternReported,
926 gStatBitBltScreenSquareReported,
927 gStatCopyBitsScreenSquare,
928 gStatEnablePDEV,
929 gStatCompletePDEV,
930 gStatDisablePDEV,
931 gStatEnableSurface,
932 gStatDisableSurface,
933 gStatAssertMode,
934 gStatDisableDriver,
935 gStatCreateDeviceBitmap,
936 gStatDeleteDeviceBitmap,
937 gStatDitherColor,
938 gStatStrokePath,
939 gStatFillPath,
940 gStatStrokeAndFillPath,
941 gStatPaint,
942 gStatBitBlt,
943 gStatCopyBits,
944 gStatStretchBlt,
945 gStatSetPalette,
946 gStatTextOut,
947 gStatSetPointerShape,
948 gStatMovePointer,
949 gStatLineTo,
950 gStatSynchronize,
951 gStatGetModes,
952 gStatGradientFill,
953 gStatStretchBltROP,
954 gStatPlgBlt,
955 gStatAlphaBlend,
956 gStatTransparentBlt
957 ));
958}
959#endif /* STAT_sunlover */
960
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette