Author: jgardou
Date: Sun Feb 27 21:45:43 2011
New Revision: 50928

URL: http://svn.reactos.org/svn/reactos?rev=50928&view=rev
Log:
[WIN32K]
  - remove duplicate prototype
  - use RGB macro where possible
  - we create BGR palette for RGB DIB sections, let's do the other way around
  - simplify overcomplicated IntGetDIBColorTable
  - Add a first implementation of IntRealizePalette
No, it's not the VLC icons bugfix

Modified:
    trunk/reactos/subsystems/win32/win32k/include/intgdi.h
    trunk/reactos/subsystems/win32/win32k/objects/bitblt.c
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
    trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
    trunk/reactos/subsystems/win32/win32k/objects/palette.c

Modified: trunk/reactos/subsystems/win32/win32k/include/intgdi.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/intgdi.h?rev=50928&r1=50927&r2=50928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] Sun Feb 
27 21:45:43 2011
@@ -232,8 +232,6 @@
                            UINT  StartIndex,
                            UINT  Entries,
                            LPPALETTEENTRY  pe);
-UINT APIENTRY
-IntGetDIBColorTable(HDC hDC, UINT StartIndex, UINT Entries, RGBQUAD *Colors);
 
 UINT APIENTRY
 IntSetDIBColorTable(HDC hDC, UINT StartIndex, UINT Entries, CONST RGBQUAD 
*Colors);

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitblt.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitblt.c?rev=50928&r1=50927&r2=50928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] Sun Feb 
27 21:45:43 2011
@@ -562,8 +562,8 @@
     NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, 
BKGND_ROP3(dwRop), 0, 0);
 
     /* 2.4 Erase the foreground pixels */
-    IntGdiSetBkColor(hdcBack, 0xffffffff);
-    IntGdiSetTextColor(hdcBack, 0);
+    IntGdiSetBkColor(hdcBack, RGB(0xFF, 0xFF, 0xFF));
+    IntGdiSetTextColor(hdcBack, RGB(0, 0, 0));
     NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 
0, 0);
 
     /* 3. Create masked Foreground bitmap */
@@ -583,8 +583,8 @@
     NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, 
FRGND_ROP3(dwRop), 0,0);
 
     /* 2.4 Erase the background pixels */
-    IntGdiSetBkColor(hdcFore, 0);
-    IntGdiSetTextColor(hdcFore, 0xffffffff);
+    IntGdiSetBkColor(hdcFore, RGB(0, 0, 0));
+    IntGdiSetTextColor(hdcFore, RGB(0xFF, 0xFF, 0xFF));
     NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 
0, 0);
 
     /* 3. Combine the fore and background into the background bitmap */

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=50928&r1=50927&r2=50928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sun 
Feb 27 21:45:43 2011
@@ -941,7 +941,7 @@
                     break;
 
                 case BMF_32BPP:
-                    if (psurf->ppal->flFlags & PAL_RGB)
+                    if (psurf->ppal->flFlags & (PAL_RGB|PAL_BGR))
                         pds->dsBmih.biCompression = BI_RGB;
                     else
                         pds->dsBmih.biCompression = BI_BITFIELDS;

Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dibobj.c?rev=50928&r1=50927&r2=50928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sun Feb 
27 21:45:43 2011
@@ -193,9 +193,8 @@
 {
     PDC dc;
     PSURFACE psurf;
-    PPALETTE PalGDI;
+    PPALETTE ppal;
     UINT Index, Count = 0;
-    ULONG biBitCount;
 
     if (!(dc = DC_LockDc(hDC))) return 0;
     if (dc->dctype == DC_TYPE_INFO)
@@ -219,33 +218,22 @@
         return 0;
     }
 
-    biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
-    if (biBitCount <= 8 &&
-            StartIndex < (1 << biBitCount))
-    {
-        if (StartIndex + Entries > (1 << biBitCount))
-            Entries = (1 << biBitCount) - StartIndex;
-
-        if (psurf->ppal == NULL)
-        {
-            DC_UnlockDc(dc);
-            EngSetLastError(ERROR_INVALID_HANDLE);
-            return 0;
-        }
-
-        PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
+    ppal = psurf->ppal;
+    ASSERT(ppal);
+
+    if (ppal->flFlags & PAL_INDEXED)
+    {
 
         for (Index = StartIndex;
-             Index < StartIndex + Entries && Index < PalGDI->NumColors;
+             Index < StartIndex + Entries && Index < ppal->NumColors;
              Index++)
         {
-            Colors[Index - StartIndex].rgbRed = 
PalGDI->IndexedColors[Index].peRed;
-            Colors[Index - StartIndex].rgbGreen = 
PalGDI->IndexedColors[Index].peGreen;
-            Colors[Index - StartIndex].rgbBlue = 
PalGDI->IndexedColors[Index].peBlue;
+            Colors[Index - StartIndex].rgbRed = 
ppal->IndexedColors[Index].peRed;
+            Colors[Index - StartIndex].rgbGreen = 
ppal->IndexedColors[Index].peGreen;
+            Colors[Index - StartIndex].rgbBlue = 
ppal->IndexedColors[Index].peBlue;
             Colors[Index - StartIndex].rgbReserved = 0;
             Count++;
         }
-        PALETTE_UnlockPalette(PalGDI);
     }
 
     DC_UnlockDc(dc);

Modified: trunk/reactos/subsystems/win32/win32k/objects/palette.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/palette.c?rev=50928&r1=50927&r2=50928&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] Sun 
Feb 27 21:45:43 2011
@@ -725,58 +725,39 @@
 FASTCALL
 IntGdiRealizePalette(HDC hDC)
 {
-  /*
-   * This function doesn't do any real work now and there's plenty
-   * of bugs in it.
-   */
-
-  PPALETTE palGDI, sysGDI;
-  int realized = 0;
-  PDC dc;
-  HPALETTE systemPalette;
-
-  dc = DC_LockDc(hDC);
-  if (!dc) return 0;
-
-  systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
-  palGDI = PALETTE_LockPalette(dc->dclevel.hpal);
-
-  if (palGDI == NULL)
-  {
-    DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n");
-    DC_UnlockDc(dc);
-    return 0;
-  }
-
-  sysGDI = PALETTE_LockPalette(systemPalette);
-
-  if (sysGDI == NULL)
-  {
-    DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n");
-    PALETTE_UnlockPalette(palGDI);
-    DC_UnlockDc(dc);
-    return 0;
-  }
-
-  // The RealizePalette function modifies the palette for the device 
associated with the specified device context. If the
-  // device context is a memory DC, the color table for the bitmap selected 
into the DC is modified. If the device
-  // context is a display DC, the physical palette for that device is modified.
-  if(dc->dctype == DC_TYPE_MEMORY)
-  {
-    // Memory managed DC
-    DPRINT1("RealizePalette unimplemented for memory managed DCs\n");
-  } else
-  {
-    DPRINT1("RealizePalette unimplemented for device DCs\n");
-  }
-
-  // need to pass this to IntEngCreateXlate with palettes unlocked
-  PALETTE_UnlockPalette(sysGDI);
-  PALETTE_UnlockPalette(palGDI);
-
-  DC_UnlockDc(dc);
-
-  return realized;
+    UINT i, realize = 0;
+    PDC pdc;
+    PALETTE *ppalSurf, *ppalDC;
+
+    pdc = DC_LockDc(hDC);
+    if(!pdc)
+    {
+        EngSetLastError(ERROR_INVALID_HANDLE);
+        return 0;
+    }
+
+    ppalSurf = pdc->dclevel.pSurface->ppal;
+    ppalDC = pdc->dclevel.ppal;
+
+    if(!(ppalSurf->flFlags & PAL_INDEXED))
+    {
+        // FIXME : set error?
+        goto cleanup;
+    }
+
+    ASSERT(ppalDC->flFlags & PAL_INDEXED);
+
+    // FIXME : should we resize ppalSurf if it's too small?
+    realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : 
ppalSurf->NumColors;
+
+    for(i=0; i<realize; i++)
+    {
+        InterlockedExchange((LONG*)&ppalSurf->IndexedColors[i], 
*(LONG*)&ppalDC->IndexedColors[i]);
+    }
+
+cleanup:
+    DC_UnlockDc(pdc);
+    return realize;
 }
 
 UINT APIENTRY


Reply via email to