[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sun, 27 Feb 2011 21:45:43 +0000 (21:45 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sun, 27 Feb 2011 21:45:43 +0000 (21:45 +0000)
  - 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

svn path=/trunk/; revision=50928

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

index fcbb7a0..5e7ca97 100644 (file)
@@ -232,8 +232,6 @@ IntGetSystemPaletteEntries(HDC  hDC,
                            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);
index f4843c2..0f77537 100644 (file)
@@ -562,8 +562,8 @@ NtGdiMaskBlt(
     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 @@ NtGdiMaskBlt(
     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 */
index 75e1b1c..eb4d376 100644 (file)
@@ -941,7 +941,7 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
                     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;
index a0e29d9..963f152 100644 (file)
@@ -193,9 +193,8 @@ IntGetDIBColorTable(
 {
     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 @@ IntGetDIBColorTable(
         return 0;
     }
 
-    biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
-    if (biBitCount <= 8 &&
-            StartIndex < (1 << biBitCount))
-    {
-        if (StartIndex + Entries > (1 << biBitCount))
-            Entries = (1 << biBitCount) - StartIndex;
+    ppal = psurf->ppal;
+    ASSERT(ppal);
 
-        if (psurf->ppal == NULL)
-        {
-            DC_UnlockDc(dc);
-            EngSetLastError(ERROR_INVALID_HANDLE);
-            return 0;
-        }
-
-        PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
+    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);
index 38a4532..c7656e0 100644 (file)
@@ -725,58 +725,39 @@ UINT
 FASTCALL
 IntGdiRealizePalette(HDC hDC)
 {
-  /*
-   * This function doesn't do any real work now and there's plenty
-   * of bugs in it.
-   */
+    UINT i, realize = 0;
+    PDC pdc;
+    PALETTE *ppalSurf, *ppalDC;
 
-  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;
-  }
+    pdc = DC_LockDc(hDC);
+    if(!pdc)
+    {
+        EngSetLastError(ERROR_INVALID_HANDLE);
+        return 0;
+    }
 
-  sysGDI = PALETTE_LockPalette(systemPalette);
+    ppalSurf = pdc->dclevel.pSurface->ppal;
+    ppalDC = pdc->dclevel.ppal;
 
-  if (sysGDI == NULL)
-  {
-    DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n");
-    PALETTE_UnlockPalette(palGDI);
-    DC_UnlockDc(dc);
-    return 0;
-  }
+    if(!(ppalSurf->flFlags & PAL_INDEXED))
+    {
+        // FIXME : set error?
+        goto cleanup;
+    }
 
-  // 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");
-  }
+    ASSERT(ppalDC->flFlags & PAL_INDEXED);
 
-  // need to pass this to IntEngCreateXlate with palettes unlocked
-  PALETTE_UnlockPalette(sysGDI);
-  PALETTE_UnlockPalette(palGDI);
+    // FIXME : should we resize ppalSurf if it's too small?
+    realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : ppalSurf->NumColors;
 
-  DC_UnlockDc(dc);
+    for(i=0; i<realize; i++)
+    {
+        InterlockedExchange((LONG*)&ppalSurf->IndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]);
+    }
 
-  return realized;
+cleanup:
+    DC_UnlockDc(pdc);
+    return realize;
 }
 
 UINT APIENTRY