[0.4.7][WIN32SS][NTDDRAW] Fix ddraw palette regression CORE-13714
authorJoachim Henze <Joachim.Henze@reactos.org>
Tue, 6 Oct 2020 21:20:10 +0000 (23:20 +0200)
committerJoachim Henze <Joachim.Henze@reactos.org>
Tue, 6 Oct 2020 21:20:10 +0000 (23:20 +0200)
This nice patch of Jerome Gardou improves palette
when VBEMP & inbuilt Mesa is used for
Diablo II, MS Age Of Empires 1, Anno 1602
to the state we had in SVN r75060 and below.

Palette still not perfect in fullscreen but at least as good as it was before
it regressed by SVN r75061 == git
4b0ee92f91c75dc0a273ff24e4d9884c38aa379f

We do intend to improve on the remaining fullscreen palette issues in CORE-10738.

fix cherry picked from 0.4.9-dev-675-g
14f0e62f9a3895699f9202335516f16e610dd24d

win32ss/reactx/ntddraw/d3dkmt.c

index 2dae7ba..cc0852e 100644 (file)
@@ -86,6 +86,17 @@ NtGdiDdDDICreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc)
     /* Get the handle for the bitmap */
     desc->hBitmap = (HBITMAP)psurf->SurfObj.hsurf;
 
+    /* Allocate a palette for this surface */
+    if (format->bit_count <= 8)
+    {
+        PPALETTE palette = PALETTE_AllocPalette(PAL_INDEXED, 1 << format->bit_count, NULL, 0, 0, 0);
+        if (palette)
+        {
+            SURFACE_vSetPalette(psurf, palette);
+            PALETTE_ShareUnlockPalette(palette);
+        }
+    }
+
     /* Unlock the surface and return */
     SURFACE_UnlockSurface(psurf);