https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c89ac107ce760d2e344abd2d1ac063dc188c0461

commit c89ac107ce760d2e344abd2d1ac063dc188c0461
Author:     Hervé Poussineau <[email protected]>
AuthorDate: Sun Mar 20 18:03:43 2022 +0100
Commit:     hpoussin <[email protected]>
CommitDate: Fri Apr 15 23:09:16 2022 +0200

    [WIN32SS] Handle Graphics acceleration level (registry key 
Acceleration.Level)
    
    - store the acceleration level in PDEVOBJ
    - when searching a pdev, search a pdev with required acceleration level
    - disable some functions when not at full acceleration level
      (levels 3 and 5 are not implemented)
---
 win32ss/gdi/eng/mdevobj.c |  4 ++-
 win32ss/gdi/eng/pdevobj.c | 66 +++++++++++++++++++++++++++++++++++++++++++++--
 win32ss/gdi/eng/pdevobj.h |  2 ++
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/win32ss/gdi/eng/mdevobj.c b/win32ss/gdi/eng/mdevobj.c
index 98d835e6c5a..2bc3b54d03f 100644
--- a/win32ss/gdi/eng/mdevobj.c
+++ b/win32ss/gdi/eng/mdevobj.c
@@ -64,6 +64,7 @@ MDEVOBJ_Create(
     DEVMODEW dmDefault;
     PDEVMODEW localPdm;
     ULONG iDevNum = 0;
+    ULONG dwAccelerationLevel = 0;
 
     TRACE("MDEVOBJ_Create('%wZ' '%dx%dx%d (%d Hz)')\n",
         pustrDeviceName,
@@ -152,13 +153,14 @@ MDEVOBJ_Create(
             READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput", 
DM_DISPLAYFIXEDOUTPUT);
             READ(dmPosition.x, "Attach.RelativeX", DM_POSITION);
             READ(dmPosition.y, "Attach.RelativeY", DM_POSITION);
+            RegReadDWORD(hKey, L"Acceleration.Level", &dwAccelerationLevel);
             ZwClose(hKey);
         }
 
         /* Get or create a PDEV for these settings */
         if (LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, pdm ? pdm : 
&dmDefault, &localPdm, !pdm))
         {
-            ppdev = PDEVOBJ_Create(pGraphicsDevice, localPdm, 
LDEV_DEVICE_DISPLAY);
+            ppdev = PDEVOBJ_Create(pGraphicsDevice, localPdm, 
dwAccelerationLevel, LDEV_DEVICE_DISPLAY);
         }
         else
         {
diff --git a/win32ss/gdi/eng/pdevobj.c b/win32ss/gdi/eng/pdevobj.c
index 1642b94763e..689e8653f97 100644
--- a/win32ss/gdi/eng/pdevobj.c
+++ b/win32ss/gdi/eng/pdevobj.c
@@ -243,6 +243,62 @@ PDEVOBJ_vCompletePDEV(
     ppdev->pldev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
 }
 
+static
+VOID
+PDEVOBJ_vFilterDriverHooks(
+    _In_ PPDEVOBJ ppdev)
+{
+    PLDEVOBJ pldev = ppdev->pldev;
+    ULONG dwAccelerationLevel = ppdev->dwAccelerationLevel;
+
+    if (!pldev->pGdiDriverInfo)
+        return;
+    if (pldev->ldevtype != LDEV_DEVICE_DISPLAY)
+        return;
+
+    if (dwAccelerationLevel >= 1)
+    {
+        ppdev->apfn[INDEX_DrvSetPointerShape] = NULL;
+        ppdev->apfn[INDEX_DrvCreateDeviceBitmap] = NULL;
+    }
+
+    if (dwAccelerationLevel >= 2)
+    {
+        /* Remove sophisticated display accelerations */
+        ppdev->pSurface->flags &= ~(HOOK_STRETCHBLT |
+                                    HOOK_FILLPATH |
+                                    HOOK_GRADIENTFILL |
+                                    HOOK_LINETO |
+                                    HOOK_ALPHABLEND |
+                                    HOOK_TRANSPARENTBLT);
+    }
+
+    if (dwAccelerationLevel >= 3)
+    {
+        /* Disable DirectDraw and Direct3D accelerations */
+        /* FIXME: need to call DxDdSetAccelLevel */
+        UNIMPLEMENTED;
+    }
+
+    if (dwAccelerationLevel >= 4)
+    {
+        /* Remove almost all display accelerations */
+        ppdev->pSurface->flags &= ~HOOK_FLAGS |
+                                   HOOK_BITBLT |
+                                   HOOK_COPYBITS |
+                                   HOOK_TEXTOUT |
+                                   HOOK_STROKEPATH |
+                                   HOOK_SYNCHRONIZE;
+
+    }
+
+    if (dwAccelerationLevel >= 5)
+    {
+        /* Disable all display accelerations */
+        UNIMPLEMENTED;
+    }
+}
+
 PSURFACE
 NTAPI
 PDEVOBJ_pSurface(
@@ -354,6 +410,7 @@ PPDEVOBJ
 PDEVOBJ_Create(
     _In_opt_ PGRAPHICS_DEVICE pGraphicsDevice,
     _In_opt_ PDEVMODEW pdm,
+    _In_ ULONG dwAccelerationLevel,
     _In_ ULONG ldevtype)
 {
     PPDEVOBJ ppdev, ppdevMatch = NULL;
@@ -375,7 +432,8 @@ PDEVOBJ_Create(
             {
                 PDEVOBJ_vReference(ppdev);
 
-                if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)))
+                if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)) &&
+                    ppdev->dwAccelerationLevel == dwAccelerationLevel)
                 {
                     PDEVOBJ_vReference(ppdev);
                     ppdevMatch = ppdev;
@@ -441,6 +499,7 @@ PDEVOBJ_Create(
 
     /* Initialize PDEV */
     ppdev->pldev = pldev;
+    ppdev->dwAccelerationLevel = dwAccelerationLevel;
 
     /* Call the driver to enable the PDEV */
     if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
@@ -467,6 +526,9 @@ PDEVOBJ_Create(
         return NULL;
     }
 
+    /* Remove some acceleration capabilities from driver */
+    PDEVOBJ_vFilterDriverHooks(ppdev);
+
     /* Set MovePointer function */
     ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
     if (!ppdev->pfnMovePointer)
@@ -580,7 +642,7 @@ PDEVOBJ_bSwitchMode(
     }
 
     /* 2. Create new PDEV */
-    ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 
LDEV_DEVICE_DISPLAY);
+    ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 0, 
LDEV_DEVICE_DISPLAY);
     if (!ppdevTmp)
     {
         DPRINT1("Failed to create a new PDEV\n");
diff --git a/win32ss/gdi/eng/pdevobj.h b/win32ss/gdi/eng/pdevobj.h
index c39717db0bf..3eeacb97fef 100644
--- a/win32ss/gdi/eng/pdevobj.h
+++ b/win32ss/gdi/eng/pdevobj.h
@@ -128,6 +128,7 @@ typedef struct _PDEVOBJ
     PDEVMODEW                 pdmwDev;        /* Ptr->DEVMODEW.dmSize + 
dmDriverExtra == alloc size. */
 //  DWORD                     Unknown3;
     FLONG                     DxDd_Flags;     /* DxDD active status flags. */
+    DWORD                     dwAccelerationLevel;
 //  LONG                      devAttr;
 //  PVOID                     WatchDogContext;
 //  ULONG                     WatchDogs;
@@ -224,6 +225,7 @@ PPDEVOBJ
 PDEVOBJ_Create(
     _In_opt_ PGRAPHICS_DEVICE pGraphicsDevice,
     _In_opt_ PDEVMODEW pdm,
+    _In_ ULONG dwAccelerationLevel,
     _In_ ULONG ldevtype);
 
 /* Change display settings:

Reply via email to