From 5de8339cd196e2bc01ac631e677010a939b2d083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 27 Feb 2011 21:45:43 +0000 Subject: [PATCH] [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 svn path=/trunk/; revision=50928 --- .../subsystems/win32/win32k/include/intgdi.h | 2 - .../subsystems/win32/win32k/objects/bitblt.c | 8 +-- .../subsystems/win32/win32k/objects/bitmaps.c | 2 +- .../subsystems/win32/win32k/objects/dibobj.c | 30 +++----- .../subsystems/win32/win32k/objects/palette.c | 71 +++++++------------ 5 files changed, 40 insertions(+), 73 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/intgdi.h b/reactos/subsystems/win32/win32k/include/intgdi.h index fcbb7a08e10..5e7ca97d68f 100644 --- a/reactos/subsystems/win32/win32k/include/intgdi.h +++ b/reactos/subsystems/win32/win32k/include/intgdi.h @@ -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); diff --git a/reactos/subsystems/win32/win32k/objects/bitblt.c b/reactos/subsystems/win32/win32k/objects/bitblt.c index f4843c2c0b2..0f7753728ba 100644 --- a/reactos/subsystems/win32/win32k/objects/bitblt.c +++ b/reactos/subsystems/win32/win32k/objects/bitblt.c @@ -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 */ diff --git a/reactos/subsystems/win32/win32k/objects/bitmaps.c b/reactos/subsystems/win32/win32k/objects/bitmaps.c index 75e1b1c2be6..eb4d37653f9 100644 --- a/reactos/subsystems/win32/win32k/objects/bitmaps.c +++ b/reactos/subsystems/win32/win32k/objects/bitmaps.c @@ -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; diff --git a/reactos/subsystems/win32/win32k/objects/dibobj.c b/reactos/subsystems/win32/win32k/objects/dibobj.c index a0e29d92b19..963f152acbd 100644 --- a/reactos/subsystems/win32/win32k/objects/dibobj.c +++ b/reactos/subsystems/win32/win32k/objects/dibobj.c @@ -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)) + ppal = psurf->ppal; + ASSERT(ppal); + + if (ppal->flFlags & PAL_INDEXED) { - 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); 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); diff --git a/reactos/subsystems/win32/win32k/objects/palette.c b/reactos/subsystems/win32/win32k/objects/palette.c index 38a4532f417..c7656e03d1c 100644 --- a/reactos/subsystems/win32/win32k/objects/palette.c +++ b/reactos/subsystems/win32/win32k/objects/palette.c @@ -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; + pdc = DC_LockDc(hDC); + if(!pdc) + { + EngSetLastError(ERROR_INVALID_HANDLE); + return 0; + } - dc = DC_LockDc(hDC); - if (!dc) return 0; + ppalSurf = pdc->dclevel.pSurface->ppal; + ppalDC = pdc->dclevel.ppal; - systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE); - palGDI = PALETTE_LockPalette(dc->dclevel.hpal); + if(!(ppalSurf->flFlags & PAL_INDEXED)) + { + // FIXME : set error? + goto cleanup; + } - if (palGDI == NULL) - { - DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n"); - DC_UnlockDc(dc); - return 0; - } + ASSERT(ppalDC->flFlags & PAL_INDEXED); - sysGDI = PALETTE_LockPalette(systemPalette); + // FIXME : should we resize ppalSurf if it's too small? + realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : ppalSurf->NumColors; - if (sysGDI == NULL) - { - DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n"); - PALETTE_UnlockPalette(palGDI); - DC_UnlockDc(dc); - return 0; - } + for(i=0; iIndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]); + } - // 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; +cleanup: + DC_UnlockDc(pdc); + return realize; } UINT APIENTRY