xref: /reactos/win32ss/reactx/ntddraw/dxeng.c (revision 4561998a)
1 /*
2  * PROJECT:          ReactOS Win32 Subsystem
3  * LICENSE:          GPL - See COPYING in the top level directory
4  * FILE:             win32ss/reactx/ntddraw/dxeng.c
5  * PURPOSE:          Implementation of DxEng functions
6  * PROGRAMMERS:      Magnus Olsen (magnus@greatlord.com)
7  */
8 
9 #include <win32k.h>
10 #include <debug.h>
11 
12 HSEMAPHORE  ghsemShareDevLock = NULL;
13 
14 ULONG gcEngFuncs = DXENG_INDEX_DxEngLoadImage + 1;
15 DRVFN gaEngFuncs[] =
16 {
17     {0, (PFN) NULL},
18     {DXENG_INDEX_DxEngNUIsTermSrv, (PFN)DxEngNUIsTermSrv},
19     {DXENG_INDEX_DxEngScreenAccessCheck, (PFN)DxEngScreenAccessCheck},
20     {DXENG_INDEX_DxEngRedrawDesktop, (PFN)DxEngRedrawDesktop},
21     {DXENG_INDEX_DxEngDispUniq, (PFN)DxEngDispUniq},
22     {DXENG_INDEX_DxEngIncDispUniq, (PFN)DxEngIncDispUniq},
23     {DXENG_INDEX_DxEngVisRgnUniq, (PFN)DxEngVisRgnUniq},
24     {DXENG_INDEX_DxEngLockShareSem, (PFN)DxEngLockShareSem},
25     {DXENG_INDEX_DxEngUnlockShareSem, (PFN)DxEngUnlockShareSem},
26     {DXENG_INDEX_DxEngEnumerateHdev, (PFN)DxEngEnumerateHdev},
27     {DXENG_INDEX_DxEngLockHdev, (PFN)DxEngLockHdev},
28     {DXENG_INDEX_DxEngUnlockHdev, (PFN)DxEngUnlockHdev},
29     {DXENG_INDEX_DxEngIsHdevLockedByCurrentThread, (PFN)DxEngIsHdevLockedByCurrentThread},
30     {DXENG_INDEX_DxEngReferenceHdev, (PFN)DxEngReferenceHdev},
31     {DXENG_INDEX_DxEngUnreferenceHdev, (PFN)DxEngUnreferenceHdev},
32     {DXENG_INDEX_DxEngGetDeviceGammaRamp, (PFN)DxEngGetDeviceGammaRamp},
33     {DXENG_INDEX_DxEngSetDeviceGammaRamp, (PFN)DxEngSetDeviceGammaRamp},
34     {DXENG_INDEX_DxEngSpTearDownSprites, (PFN)DxEngSpTearDownSprites},
35     {DXENG_INDEX_DxEngSpUnTearDownSprites, (PFN)DxEngSpUnTearDownSprites},
36     {DXENG_INDEX_DxEngSpSpritesVisible, (PFN)DxEngSpSpritesVisible},
37     {DXENG_INDEX_DxEngGetHdevData, (PFN)DxEngGetHdevData},
38     {DXENG_INDEX_DxEngSetHdevData, (PFN)DxEngSetHdevData},
39     {DXENG_INDEX_DxEngCreateMemoryDC, (PFN)DxEngCreateMemoryDC},
40     {DXENG_INDEX_DxEngGetDesktopDC, (PFN)DxEngGetDesktopDC},
41     {DXENG_INDEX_DxEngDeleteDC, (PFN)DxEngDeleteDC},
42     {DXENG_INDEX_DxEngCleanDC, (PFN)DxEngCleanDC},
43     {DXENG_INDEX_DxEngSetDCOwner, (PFN)DxEngSetDCOwner},
44     {DXENG_INDEX_DxEngLockDC, (PFN)DxEngLockDC},
45     {DXENG_INDEX_DxEngUnlockDC, (PFN)DxEngUnlockDC},
46     {DXENG_INDEX_DxEngSetDCState, (PFN)DxEngSetDCState},
47     {DXENG_INDEX_DxEngGetDCState, (PFN)DxEngGetDCState},
48     {DXENG_INDEX_DxEngSelectBitmap, (PFN)DxEngSelectBitmap},
49     {DXENG_INDEX_DxEngSetBitmapOwner, (PFN)DxEngSetBitmapOwner},
50     {DXENG_INDEX_DxEngDeleteSurface, (PFN)DxEngDeleteSurface},
51     {DXENG_INDEX_DxEngGetSurfaceData, (PFN)DxEngGetSurfaceData},
52     {DXENG_INDEX_DxEngAltLockSurface, (PFN)DxEngAltLockSurface},
53     {DXENG_INDEX_DxEngUploadPaletteEntryToSurface, (PFN)DxEngUploadPaletteEntryToSurface},
54     {DXENG_INDEX_DxEngMarkSurfaceAsDirectDraw, (PFN)DxEngMarkSurfaceAsDirectDraw},
55     {DXENG_INDEX_DxEngSelectPaletteToSurface, (PFN)DxEngSelectPaletteToSurface},
56     {DXENG_INDEX_DxEngSyncPaletteTableWithDevice, (PFN)DxEngSyncPaletteTableWithDevice},
57     {DXENG_INDEX_DxEngSetPaletteState, (PFN)DxEngSetPaletteState},
58     {DXENG_INDEX_DxEngGetRedirectionBitmap, (PFN)DxEngGetRedirectionBitmap},
59     {DXENG_INDEX_DxEngLoadImage, (PFN)DxEngLoadImage}
60 };
61 
62 
63 /*++
64 * @name DxEngDispUniq
65 * @implemented
66 *
67 * The function DxEngDispUniq returns the DisplayUniqVisrgn counter value from GDI shared memory
68 *
69 * @return
70 * Returns the DisplayUniqVisrgn counter value from GDI shared memory
71 *
72 * @remarks.
73 * none
74 *
75 *--*/
76 ULONG
77 APIENTRY
78 DxEngDispUniq(VOID)
79 {
80     DPRINT1("ReactX Calling : DxEngDispUniq\n");
81     return GdiHandleTable->flDeviceUniq;
82 }
83 
84 /*++
85 * @name DxEngGetDeviceGammaRamp
86 * @implemented
87 *
88 * The function DxEngGetDeviceGammaRamp gets the gamma ramp to dxg.sys.
89 
90 * @param HDEV hPDev
91 * The hdev.
92 *
93 * @param PGAMMARAMP Ramp
94 * Pointer to store the gamma ramp value in.
95 *
96 * @return
97 *Returns TRUE for success, FALSE for failure
98 *
99 * @remarks.
100 * None
101 *
102 *--*/
103 BOOL
104 APIENTRY
105 DxEngGetDeviceGammaRamp(HDEV hPDev, PGAMMARAMP Ramp)
106 {
107     DPRINT1("ReactX Calling : DxEngGetDeviceGammaRamp\n");
108     return IntGetDeviceGammaRamp(hPDev, Ramp);
109 }
110 
111 
112 /*++
113 * @name DxEngLockDC
114 * @implemented
115 *
116 * The function DxEngLockDC locks a hdc from dxg.sys
117 *
118 * @param HDC hDC
119 * The handle we want to lock
120 *
121 * @return
122 * Returns PDC if lock succeeded or NULL if it failed.
123 *
124 * @remarks.
125 * none
126 *
127 *--*/
128 PDC
129 APIENTRY
130 DxEngLockDC(HDC hDC)
131 {
132     DPRINT1("ReactX Calling : DxEngLockDC\n");
133     return DC_LockDc(hDC);
134 }
135 
136 
137 /*++
138 * @name DxEngUnlockDC
139 * @implemented
140 *
141 * The function DxEngUnlockDC unlocks a pDC (hdc) from dxg.sys.
142 
143 * @param PDC pDC
144 * The handle we want to unlock.
145 *
146 * @return
147 * This function returns TRUE no matter what.
148 *
149 * @remarks.
150 * none
151 *
152 *--*/
153 BOOLEAN
154 APIENTRY
155 DxEngUnlockDC(PDC pDC)
156 {
157     DPRINT1("ReactX Calling : DxEngUnlockDC\n");
158     DC_UnlockDc(pDC);
159     return TRUE;
160 }
161 
162 /*++
163 * @name DxEngLockShareSem
164 * @implemented
165 *
166 * The function DxEngLockShareSem locks a struct of type ghsemShareDevLock that can be shared.
167 *
168 * @return
169 * This function returns TRUE for success and FALSE for failure.
170 * FALSE must mean the struct has already been locked.
171 *
172 * @remarks.
173 * It is being used in various ntuser* functions and ntgdi*
174 * ReactOS specific: It is not in use yet?
175 *SystemResourcesList
176 *--*/
177 BOOLEAN
178 APIENTRY
179 DxEngLockShareSem(VOID)
180 {
181     DPRINT1("ReactX Calling : DxEngLockShareSem\n");
182     if(!ghsemShareDevLock) ghsemShareDevLock = EngCreateSemaphore(); // Hax, should be in dllmain.c
183     EngAcquireSemaphore(ghsemShareDevLock);
184     return TRUE;
185 }
186 
187 /*++
188 * @name DxEngUnlockShareSem
189 * @implemented
190 *
191 * The function DxEngUnlockShareSem unlocks the struct of type ghsemShareDevLock.
192 *
193 * @return
194 * This function returns TRUE no matter what.
195 *
196 * @remarks.
197 * ReactOS specific: It is not in use yet?
198 *
199 *--*/
200 BOOLEAN
201 APIENTRY
202 DxEngUnlockShareSem(VOID)
203 {
204     DPRINT1("ReactX Calling : DxEngUnlockShareSem\n");
205     EngReleaseSemaphore(ghsemShareDevLock);
206     return TRUE;
207 }
208 
209 /*++
210 * @name DxEngSetDeviceGammaRamp
211 * @implemented
212 *
213 * The function DxEngSetDeviceGammaRamp sets gamma ramp from dxg.sys
214 
215 * @param HDEV hPDev
216 * The hdev
217 *
218 * @param PGAMMARAMP Ramp
219 * Value to change gamma ramp to.
220 *
221 * @param BOOL Test
222 * Whether gamma should be tested. TRUE to test, FALSE to not test.
223 *
224 * @return
225 *Returns TRUE for success, FALSE for failure.
226 *
227 * @remarks.
228 * None
229 *
230 *--*/
231 BOOLEAN
232 APIENTRY
233 DxEngSetDeviceGammaRamp(HDEV hPDev, PGAMMARAMP Ramp, BOOL Test)
234 {
235     DPRINT1("ReactX Calling : DxEngSetDeviceGammaRamp\n");
236     return IntSetDeviceGammaRamp(hPDev, Ramp, Test);
237 }
238 
239 /*++
240 * @name DxEngGetHdevData
241 * @implemented
242 *
243 * The function DxEngGetHdevData retrieves a value from the HDEV
244 
245 * @param HDEV hPDev
246 * The HDEV
247 *
248 * @param DXEGSHDEVDATA Type
249 * The following typs are supported
250 * Type                                            Purpose
251 * DxEGShDevData_Surface      Retrieve pointer to Surface handle.
252 * DxEGShDevData_hSpooler     Device object of graphics driver.
253 * DxEGShDevData_DitherFmt    Retrieve the device iDitherFormat
254 * DxEGShDevData_FxCaps       Retrieve the device flGraphicsCaps
255 * DxEGShDevData_FxCaps2      Retrieve the device flGraphicsCaps2
256 * DxEGShDevData_DrvFuncs     Retrieve the device DriverFunctions function table
257 * DxEGShDevData_dhpdev       Retrieve the device hPDev, the real DHPDEV
258 * DxEGShDevData_eddg         Retrieve the device pEDDgpl
259 * DxEGShDevData_dd_nCount    Retrieve the device DxDd_nCount
260 * DxEGShDevData_dd_flags     Retrieve the device DxDd_Flags
261 * DxEGShDevData_disable      See if the device pdev is disabled
262 * DxEGShDevData_metadev      See if the device pdev is a meta device
263 * DxEGShDevData_display      See if the device is the primary display driver
264 * DxEGShDevData_Parent       Retrieve the ppdevParent
265 * DxEGShDevData_OpenRefs     Retrieve the pdevOpenRefs counter
266 * DxEGShDevData_palette      See if the device RC_PALETTE is set
267 * DxEGShDevData_ldev         ATM we do not support the Loader Device driver structure
268 * DxEGShDevData_GDev         Retrieve the device pGraphicsDevice
269 * DxEGShDevData_clonedev     Retrieve the device PDEV_CLONE_DEVICE flag is set or not
270 *
271 * @return
272 * Returns the data we requested
273 *
274 * @remarks.
275 * ReactOS specific: Implementation is incomplete, I do not save the value into the hdev yet.
276 *
277 *--*/
278 DWORD_PTR
279 APIENTRY
280 DxEngGetHdevData(HDEV hDev,
281                  DXEGSHDEVDATA Type)
282 {
283     DWORD_PTR retVal = 0;
284     PPDEVOBJ PDev = (PPDEVOBJ)hDev;
285 
286     DPRINT1("ReactX Calling : DxEngGetHdevData DXEGSHDEVDATA : %ld\n", Type);
287 
288 #if 1
289     DPRINT1("HDEV hDev %p\n", hDev);
290 #endif
291 
292     switch ( Type )
293     {
294       case DxEGShDevData_Surface:
295         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_Surface\n");
296         retVal = (DWORD_PTR) PDev->pSurface; // ptr to Surface handle.
297         break;
298       case DxEGShDevData_hSpooler:
299         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_hSpooler\n");
300         retVal = (DWORD_PTR) PDev->hSpooler;
301         break;
302       case DxEGShDevData_DitherFmt:
303         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_DitherFmt\n");
304         retVal = (DWORD_PTR) PDev->devinfo.iDitherFormat;
305         break;
306       case DxEGShDevData_FxCaps:
307         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_FxCaps\n");
308         retVal = (DWORD_PTR) PDev->devinfo.flGraphicsCaps;
309         break;
310       case DxEGShDevData_FxCaps2:
311         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_FxCaps2\n");
312         retVal = (DWORD_PTR) PDev->devinfo.flGraphicsCaps2;
313         break;
314       case DxEGShDevData_DrvFuncs:
315         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_DrvFuncs\n");
316         retVal = (DWORD_PTR) &PDev->DriverFunctions;
317         break;
318       case DxEGShDevData_dhpdev:
319         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dhpdev\n");
320         retVal = (DWORD_PTR) PDev->dhpdev; // DHPDEV
321         break;
322       case DxEGShDevData_eddg:
323         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_eddg\n");
324         retVal = (DWORD_PTR) PDev->pEDDgpl;
325         break;
326       case DxEGShDevData_dd_nCount:
327         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dd_nCount\n");
328         retVal = (DWORD_PTR) PDev->DxDd_nCount;
329         break;
330       case DxEGShDevData_dd_flags:
331         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dd_flags\n");
332         retVal = (DWORD_PTR) PDev->DxDd_Flags;
333         break;
334       case DxEGShDevData_disable:
335         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_disable\n");
336         retVal = (DWORD_PTR) PDev->flFlags & PDEV_DISABLED;
337         break;
338       case DxEGShDevData_metadev:
339         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_metadev\n");
340         retVal = (DWORD_PTR) PDev->flFlags & PDEV_META_DEVICE;
341         break;
342       case DxEGShDevData_display:
343         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_display\n");
344         retVal = (DWORD_PTR) PDev->flFlags & PDEV_DISPLAY;
345         break;
346       case DxEGShDevData_Parent:
347         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_Parent\n");
348         retVal = (DWORD_PTR) PDev->ppdevParent;
349         break;
350       case DxEGShDevData_OpenRefs:
351         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_OpenRefs\n");
352         retVal = (DWORD_PTR) PDev->cPdevOpenRefs != 0;
353         break;
354       case DxEGShDevData_palette:
355         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_palette\n");
356         retVal = (DWORD_PTR) PDev->gdiinfo.flRaster & RC_PALETTE;
357         break;
358       case DxEGShDevData_ldev:
359         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_ldev\n");
360         retVal = (DWORD_PTR) PDev->pldev;
361         break;
362       case DxEGShDevData_GDev:
363         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_GDev\n");
364         retVal = (DWORD_PTR) PDev->pGraphicsDevice; // P"GRAPHICS_DEVICE"
365         break;
366       case DxEGShDevData_clonedev:
367         DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_clonedev\n");
368         retVal = (DWORD_PTR) PDev->flFlags & PDEV_CLONE_DEVICE;
369         break;
370 
371       default:
372         break;
373     }
374 
375 #if 1
376     DPRINT1("return value %08lx\n", retVal);
377 #endif
378 
379     return retVal;
380 
381 }
382 
383 /*++
384 * @name DxEngSetHdevData
385 * @implemented
386 *
387 * The function DxEngSetHdevData sets a value in hdev
388 
389 * @param HDEV hPDev
390 * The hdev
391 *
392 * @param DXEGSHDEVDATA Type
393 * Supports only DxEGShDevData_dd_nCount. It is an internal counter on how many times hdev has been locked and unlocked
394 *
395 * @param DWORD Data
396 * The value to be saved to hdev's internal counter.
397 *
398 * @return
399 * Returns TRUE for success, FALSE for failure
400 *
401 * @remarks.
402 * none
403 *
404 *--*/
405 BOOLEAN
406 APIENTRY
407 DxEngSetHdevData(HDEV hDev,
408                  DXEGSHDEVDATA Type,
409                  DWORD_PTR Data)
410 {
411     BOOLEAN retVal = FALSE; // Default, no set.
412 
413     DPRINT1("ReactX Calling : DxEngSetHdevData DXEGSHDEVDATA : %ld\n", Type);
414 
415     if ( Type == DxEGShDevData_dd_nCount )
416     {
417         ((PPDEVOBJ)hDev)->DxDd_nCount = Data;
418         retVal = TRUE; // Set
419     }
420     return retVal;
421 }
422 
423 /*++
424 * @name DxEngGetDCState
425 * @implemented
426 *
427 * The function DxEngGetDCState is capable of returning three
428 * DC states depending on what value is passed in its second parameter:
429 * 1. If the DC is full screen
430 * 2. Get Complexity of visible region
431 * 3. Get Driver hdev, which is ppdev
432 *
433 * @param HDC hdc
434 * The DC handle
435 *
436 * @param DWORD type
437 * value 1 = Is DC fullscreen
438 * value 2 = Get Complexity of visible region.
439 * value 3 = Get Driver hdev, which is a ppdev.
440 *
441 * @return
442 * Return one of the type values
443 *
444 * @remarks.
445 * We do not have type 2 implemented yet
446 *
447 *--*/
448 DWORD_PTR
449 APIENTRY
450 DxEngGetDCState(HDC hDC,
451                 DWORD type)
452 {
453     PDC pDC = DC_LockDc(hDC);
454     DWORD_PTR retVal = 0;
455 
456     DPRINT1("ReactX Calling : DxEngGetDCState type : %lu\n", type);
457 
458     if (pDC)
459     {
460         switch (type)
461         {
462             case 1:
463                 retVal = (DWORD_PTR) pDC->fs & DC_FLAG_FULLSCREEN;
464                 break;
465             case 2:
466                 UNIMPLEMENTED;
467                 break;
468             case 3:
469             {
470                 /* Return the HDEV of this DC. */
471                 retVal = (DWORD_PTR) pDC->ppdev;
472                 break;
473             }
474             default:
475                 /* If a valid type is not found, zero is returned */
476                 DPRINT1("Warning: did not find type %lu\n", type);
477                 break;
478         }
479         DC_UnlockDc(pDC);
480     }
481 
482     return retVal;
483 }
484 
485 /*++
486 * @name DxEngIncDispUniq
487 * @implemented
488 *
489 * The function DxEngIncDispUniq increments the DisplayUniqVisrgn counter from GDI shared memory.
490 *
491 * @return
492 * This function returns TRUE no matter what.
493 *
494 * @remarks.
495 * none
496 *
497 *--*/
498 BOOLEAN
499 APIENTRY
500 DxEngIncDispUniq(VOID)
501 {
502     DPRINT1("ReactX Calling : DxEngIncDispUniq \n");
503 
504     InterlockedIncrement((LONG*)&GdiHandleTable->flDeviceUniq);
505     return TRUE;
506 }
507 
508 /*++
509 * @name DxEngLockHdev
510 * @implemented
511 *
512 * The function DxEngLockHdev lock the internal PDEV
513 *
514 * @param HDEV type
515 * it is a pointer to win32k internal pdev struct known as PPDEVOBJ
516 
517 * @return
518 * This function returns TRUE no matter what.
519 *
520 * @remarks.
521 * none
522 *
523 *--*/
524 BOOLEAN
525 APIENTRY
526 DxEngLockHdev(HDEV hDev)
527 {
528     PPDEVOBJ ppdev = (PPDEVOBJ)hDev;
529     PERESOURCE Resource;
530 
531     DPRINT1("ReactX Calling : DxEngLockHdev \n");
532 
533     DPRINT1("hDev                   : 0x%p\n",hDev);
534 
535     Resource = (PERESOURCE)ppdev->hsemDevLock;
536 
537     if (Resource)
538     {
539         KeEnterCriticalRegion();
540         ExAcquireResourceExclusiveLite( Resource , TRUE); // Lock monitor.
541     }
542     return TRUE;
543 }
544 
545 /*++
546 * @name DxEngUnlockHdev
547 * @implemented
548 *
549 * The function DxEngUnlockHdev unlock the internal PDEV
550 *
551 * @param HDEV type
552 * it is a pointer to win32k internal pdev struct known as PPDEVOBJ
553 
554 * @return
555 * This function returns TRUE no matter what.
556 *
557 * @remarks.
558 * none
559 *
560 *--*/
561 BOOLEAN
562 APIENTRY
563 DxEngUnlockHdev(HDEV hDev)
564 {
565     PPDEVOBJ ppdev = (PPDEVOBJ)hDev;
566     PERESOURCE Resource = (PERESOURCE)ppdev->hsemDevLock;
567 
568     DPRINT1("ReactX Calling : DxEngUnlockHdev \n");
569 
570     if (Resource)
571     {
572         ExReleaseResourceLite( Resource );
573         KeLeaveCriticalRegion();
574     }
575     return TRUE;
576 }
577 
578 
579 /************************************************************************/
580 /* DxEngReferenceHdev                                                   */
581 /************************************************************************/
582 BOOLEAN
583 APIENTRY
584 DxEngReferenceHdev(HDEV hDev)
585 {
586     IntGdiReferencePdev((PPDEVOBJ) hDev);
587     /* ALWAYS return true */
588     return TRUE;
589 }
590 
591 /************************************************************************/
592 /* DxEngNUIsTermSrv                                                     */
593 /************************************************************************/
594 
595 /* Notes: Check if terminal server got connections or not */
596 BOOLEAN
597 APIENTRY
598 DxEngNUIsTermSrv(VOID)
599 {
600     /* FIXME: ReactOS does not suport terminal server yet, we can not check if we got connections or not */
601     UNIMPLEMENTED;
602     return FALSE;
603 }
604 
605 /************************************************************************/
606 /* DxEngRedrawDesktop                                                   */
607 /************************************************************************/
608 
609 /* Notes: it always returns TRUE, and it updates whole screen
610    (redraws current desktop) */
611 BOOLEAN
612 APIENTRY
613 DxEngRedrawDesktop(VOID)
614 {
615     UserRedrawDesktop();
616     return TRUE;
617 }
618 
619 
620 ULONG gulVisRgnUniqueness; // Increase count everytime client region is updated.
621 
622 /************************************************************************/
623 /* DxEngVisRgnUniq                                                      */
624 /************************************************************************/
625 /* Notes: returns the VisRgnUniq counter for win32k */
626 ULONG
627 APIENTRY
628 DxEngVisRgnUniq(VOID)
629 {
630     DPRINT1("ReactX Calling : DxEngVisRgnUniq \n");
631 
632     return gulVisRgnUniqueness;
633 }
634 
635 /************************************************************************/
636 /* DxEngEnumerateHdev                                                   */
637 /************************************************************************/
638 /* Enumerate all drivers in win32k */
639 HDEV *
640 APIENTRY
641 DxEngEnumerateHdev(HDEV *hdev)
642 {
643     /* FIXME: Enumerate all drivers in win32k */
644     UNIMPLEMENTED;
645     return FALSE;
646 }
647 
648 /************************************************************************/
649 /* DxEngCreateMemoryDC                                                  */
650 /************************************************************************/
651 HDC
652 APIENTRY
653 DxEngCreateMemoryDC(HDEV hDev)
654 {
655     return IntGdiCreateDisplayDC(hDev, DC_TYPE_MEMORY, FALSE);
656 }
657 
658 /************************************************************************/
659 /* DxEngScreenAccessCheck                                               */
660 /************************************************************************/
661 DWORD APIENTRY DxEngScreenAccessCheck(VOID)
662 {
663     UNIMPLEMENTED;
664 
665     /* We're cheating here and telling dxg.sys it has always had permissions to access the screen */
666     return TRUE;
667 }
668 
669 /************************************************************************/
670 /* DxEngIsHdevLockedByCurrentThread                                     */
671 /************************************************************************/
672 BOOLEAN
673 APIENTRY
674 DxEngIsHdevLockedByCurrentThread(HDEV hDev)
675 {   // Based on EngIsSemaphoreOwnedByCurrentThread w/o the Ex call.
676     PERESOURCE pSem = (PERESOURCE)(((PPDEVOBJ)hDev)->hsemDevLock);
677     return pSem->OwnerEntry.OwnerThread == (ERESOURCE_THREAD)PsGetCurrentThread();
678 }
679 
680 
681 /************************************************************************/
682 /* DxEngUnreferenceHdev                                                 */
683 /************************************************************************/
684 BOOLEAN
685 APIENTRY
686 DxEngUnreferenceHdev(HDEV hDev)
687 {
688     IntGdiUnreferencePdev((PPDEVOBJ) hDev, 0);
689     return TRUE; // Always true.
690 }
691 
692 /************************************************************************/
693 /* DxEngGetDesktopDC                                                    */
694 /************************************************************************/
695 HDC
696 APIENTRY
697 DxEngGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
698 {
699     return UserGetDesktopDC(DcType, EmptyDC, ValidatehWnd);
700 }
701 
702 /************************************************************************/
703 /* DxEngDeleteDC                                                        */
704 /************************************************************************/
705 BOOLEAN
706 APIENTRY
707 DxEngDeleteDC(HDC hdc, BOOL Force)
708 {
709    return IntGdiDeleteDC(hdc, Force);
710 }
711 
712 /************************************************************************/
713 /* DxEngCleanDC                                                         */
714 /************************************************************************/
715 BOOLEAN
716 APIENTRY
717 DxEngCleanDC(HDC hdc)
718 {
719     return IntGdiCleanDC(hdc);
720 }
721 
722 /************************************************************************/
723 /* DxEngSetDCOwner                                                      */
724 /************************************************************************/
725 BOOL APIENTRY DxEngSetDCOwner(HGDIOBJ hObject, DWORD OwnerMask)
726 {
727     DPRINT1("ReactX Calling : DxEngSetDCOwner \n");
728 
729     return GreSetDCOwner(hObject, OwnerMask);
730 }
731 
732 /************************************************************************/
733 /* DxEngSetDCState                                                      */
734 /************************************************************************/
735 BOOLEAN
736 APIENTRY
737 DxEngSetDCState(HDC hDC, DWORD SetType, DWORD Set)
738 {
739    BOOLEAN Ret = FALSE;
740    PDC pDC = DC_LockDc(hDC);
741 
742    if (pDC)
743    {
744       if (SetType == 1)
745       {
746         if ( Set )
747             pDC->fs |= DC_FLAG_FULLSCREEN;
748         else
749             pDC->fs &= ~DC_FLAG_FULLSCREEN;
750         Ret = TRUE;
751       }
752       DC_UnlockDc(pDC);
753       return Ret; // Everything else returns FALSE.
754    }
755    return Ret;
756 }
757 
758 /************************************************************************/
759 /* DxEngSelectBitmap                                                    */
760 /************************************************************************/
761 DWORD APIENTRY DxEngSelectBitmap(DWORD x1, DWORD x2)
762 {
763     UNIMPLEMENTED;
764     return FALSE;
765 }
766 
767 /************************************************************************/
768 /* DxEngSetBitmapOwner                                                  */
769 /************************************************************************/
770 DWORD APIENTRY DxEngSetBitmapOwner(DWORD x1, DWORD x2)
771 {
772     UNIMPLEMENTED;
773     return FALSE;
774 }
775 
776 /************************************************************************/
777 /* DxEngDeleteSurface                                                   */
778 /************************************************************************/
779 DWORD APIENTRY DxEngDeleteSurface(DWORD x1)
780 {
781     UNIMPLEMENTED;
782     return FALSE;
783 }
784 
785 /************************************************************************/
786 /* DxEngGetSurfaceData                                                  */
787 /************************************************************************/
788 DWORD APIENTRY DxEngGetSurfaceData(DWORD x1, DWORD x2)
789 {
790     UNIMPLEMENTED;
791     return FALSE;
792 }
793 
794 /************************************************************************/
795 /* DxEngAltLockSurface                                                  */
796 /************************************************************************/
797 DWORD APIENTRY DxEngAltLockSurface(DWORD x1)
798 {
799     UNIMPLEMENTED;
800     return FALSE;
801 }
802 
803 /************************************************************************/
804 /* DxEngUploadPaletteEntryToSurface                                     */
805 /************************************************************************/
806 DWORD APIENTRY DxEngUploadPaletteEntryToSurface(DWORD x1, DWORD x2,DWORD x3, DWORD x4)
807 {
808     UNIMPLEMENTED;
809     return FALSE;
810 }
811 
812 /************************************************************************/
813 /* DxEngMarkSurfaceAsDirectDraw                                         */
814 /************************************************************************/
815 DWORD APIENTRY DxEngMarkSurfaceAsDirectDraw(DWORD x1, DWORD x2)
816 {
817     UNIMPLEMENTED;
818     return FALSE;
819 }
820 
821 /************************************************************************/
822 /* DxEngSelectPaletteToSurface                                          */
823 /************************************************************************/
824 DWORD APIENTRY DxEngSelectPaletteToSurface(DWORD x1, DWORD x2)
825 {
826     UNIMPLEMENTED;
827     return FALSE;
828 }
829 
830 /************************************************************************/
831 /* DxEngSyncPaletteTableWithDevice                                      */
832 /************************************************************************/
833 DWORD APIENTRY DxEngSyncPaletteTableWithDevice(DWORD x1, DWORD x2)
834 {
835     UNIMPLEMENTED;
836     return FALSE;
837 }
838 
839 /************************************************************************/
840 /* DxEngSetPaletteState                                                 */
841 /************************************************************************/
842 DWORD APIENTRY DxEngSetPaletteState(DWORD x1, DWORD x2, DWORD x3)
843 {
844     UNIMPLEMENTED;
845     return FALSE;
846 }
847 
848 /************************************************************************/
849 /* DxEngGetRedirectionBitmap                                            */
850 /************************************************************************/
851 DWORD
852 APIENTRY
853 DxEngGetRedirectionBitmap(DWORD x1)
854 {
855     return FALSE; // Normal return.
856 }
857 
858 /************************************************************************/
859 /* DxEngLoadImage                                                       */
860 /************************************************************************/
861 DWORD APIENTRY DxEngLoadImage(DWORD x1,DWORD x2)
862 {
863     UNIMPLEMENTED;
864     return FALSE;
865 }
866 
867 /************************************************************************/
868 /* DxEngSpTearDownSprites                                               */
869 /************************************************************************/
870 DWORD APIENTRY DxEngSpTearDownSprites(DWORD x1, DWORD x2, DWORD x3)
871 {
872     UNIMPLEMENTED;
873     return FALSE;
874 }
875 
876 /************************************************************************/
877 /* DxEngSpUnTearDownSprites                                             */
878 /************************************************************************/
879 DWORD APIENTRY DxEngSpUnTearDownSprites(DWORD x1, DWORD x2, DWORD x3)
880 {
881     UNIMPLEMENTED;
882     return FALSE;
883 }
884 
885 /************************************************************************/
886 /* DxEngSpSpritesVisible                                                */
887 /************************************************************************/
888 DWORD APIENTRY DxEngSpSpritesVisible(DWORD x1)
889 {
890     UNIMPLEMENTED;
891     return FALSE;
892 }
893