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