Author: jgardou Date: Thu May 13 00:56:24 2010 New Revision: 47190
URL: http://svn.reactos.org/svn/reactos?rev=47190&view=rev Log: [WIN32K] - Get rid of hDIBPalette in SURFACE structure This allows more code cleanness
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/engbrush.c branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h branches/reactos-yarotows/subsystems/win32/win32k/objects/bitblt.c branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c branches/reactos-yarotows/subsystems/win32/win32k/objects/freetype.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/engbrush.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -35,11 +35,7 @@ pebo->psurfTrg = pdc->dclevel.pSurface; ASSERT(pebo->psurfTrg);
- if (pebo->psurfTrg->hDIBPalette) - { - pebo->ppalSurf = PALETTE_ShareLockPalette(pebo->psurfTrg->hDIBPalette); - } - else if (pebo->psurfTrg->ppal) + if (pebo->psurfTrg->ppal) { pebo->ppalSurf = pebo->psurfTrg->ppal; GDIOBJ_IncrementShareCount(&pebo->ppalSurf->BaseObject);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -130,10 +130,6 @@ ExFreePool(psurf->SurfObj.pvBits); }
- if (psurf->hDIBPalette != NULL) - { - GreDeleteObject(psurf->hDIBPalette); - } }
/* Free palette */
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -618,11 +618,7 @@ return; }
- if (psurfSrc->hDIBPalette) - { - ppalSrc = PALETTE_ShareLockPalette(psurfSrc->hDIBPalette); - } - else if (psurfSrc->ppal) + if (psurfSrc->ppal) { ppalSrc = psurfSrc->ppal; GDIOBJ_IncrementShareCount(&ppalSrc->BaseObject); @@ -633,11 +629,7 @@ if(!ppalSrc) return;
- if (psurfDst->hDIBPalette) - { - ppalDst = PALETTE_ShareLockPalette(psurfDst->hDIBPalette); - } - else if (psurfDst->ppal) + if (psurfDst->ppal) { ppalDst = psurfDst->ppal; GDIOBJ_IncrementShareCount(&ppalDst->BaseObject); @@ -697,7 +689,7 @@ COLORREF crForegroundClr, COLORREF crBackgroundClr) { - PPALETTE ppalDst, ppalPattern; + PPALETTE ppalDst; SURFACE *psurfPattern;
ASSERT(pexlo); @@ -707,11 +699,7 @@
EXLATEOBJ_vInitTrivial(pexlo);
- if (psurfDst->hDIBPalette) - { - ppalDst = PALETTE_ShareLockPalette(psurfDst->hDIBPalette); - } - else if (psurfDst->ppal) + if (psurfDst->ppal) { ppalDst = psurfDst->ppal; GDIOBJ_IncrementShareCount(&ppalDst->BaseObject); @@ -766,11 +754,9 @@ else { /* Default: use the patterns' palette */ - ppalPattern = PALETTE_LockPalette(psurfPattern->hDIBPalette); - if (ppalPattern) - { - EXLATEOBJ_vInitialize(pexlo, &gpalRGB, ppalDst, 0, 0, 0); - PALETTE_UnlockPalette(ppalPattern); + if (psurfPattern->ppal) + { + EXLATEOBJ_vInitialize(pexlo, psurfPattern->ppal, ppalDst, 0, 0, 0); } }
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1] Thu May 13 00:56:24 2010 @@ -37,7 +37,6 @@ DWORD dwOffset;
/* reactos specific */ - HPALETTE hDIBPalette; DWORD dsBitfields[3]; // hack, should probably use palette instead DWORD biClrUsed; DWORD biClrImportant;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitblt.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -394,9 +394,7 @@ goto done; }
- if (BitmapSrc->hDIBPalette) - PalSourceGDI = PALETTE_ShareLockPalette(BitmapSrc->hDIBPalette); - else if (BitmapSrc->ppal) + if (BitmapSrc->ppal) { GDIOBJ_IncrementShareCount(&BitmapSrc->ppal->BaseObject); PalSourceGDI = BitmapSrc->ppal ;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -219,14 +219,16 @@ { /* Copy the color table */ UINT Index; - PPALETTE PalGDI = PALETTE_LockPalette(psurf->hDIBPalette); - - if (!PalGDI) + PPALETTE PalGDI; + + if (!psurf->ppal) { ExFreePoolWithTag(bi, TAG_TEMP); SetLastWin32Error(ERROR_INVALID_HANDLE); return 0; } + + PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
for (Index = 0; Index < 256 && Index < PalGDI->NumColors; @@ -363,9 +365,7 @@ if (psurf) { pso = &psurf->SurfObj; - if(psurf->hDIBPalette) - ppal = PALETTE_ShareLockPalette(psurf->hDIBPalette); - else if (psurf->ppal) + if (psurf->ppal) { ppal = psurf->ppal; GDIOBJ_IncrementShareCount(&ppal->BaseObject); @@ -881,9 +881,7 @@ ExFreePoolWithTag(buf,TAG_BITMAP); resBitmap->flFlags = Bitmap->flFlags; /* Copy palette */ - if(Bitmap->hDIBPalette) - resBitmap->ppal = PALETTE_ShareLockPalette(Bitmap->hDIBPalette); - else if (Bitmap->ppal) + if (Bitmap->ppal) { resBitmap->ppal = Bitmap->ppal ; GDIOBJ_IncrementShareCount(&Bitmap->ppal->BaseObject);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/brush.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS win32 subsystem * PURPOSE: Functions for brushes * FILE: subsystem/win32/win32k/objects/brush.c - * PROGRAMER: + * PROGRAMER: */
#include <win32k.h> @@ -19,7 +19,7 @@ DWORD nEntries; PVOID AttrList[GDIOBJATTRFREE]; } GDI_OBJ_ATTR_FREELIST, *PGDI_OBJ_ATTR_FREELIST; - + typedef struct _GDI_OBJ_ATTR_ENTRY { RGN_ATTR Attr[GDIOBJATTRFREE]; @@ -46,7 +46,7 @@ PGDI_OBJ_ATTR_FREELIST pGdiObjAttrFreeList; PGDI_OBJ_ATTR_ENTRY pGdiObjAttrEntry; int i; - + pti = PsGetCurrentThreadWin32Thread(); if (pti->pgdiBrushAttr) { @@ -127,9 +127,9 @@ PGDI_OBJ_ATTR_FREELIST pGdiObjAttrFreeList;
pti = PsGetCurrentThreadWin32Thread(); - + if (!pti) return; - + if (!pti->pgdiBrushAttr) { // If it is null, just cache it for the next time. pti->pgdiBrushAttr = pAttr; @@ -382,6 +382,7 @@ UINT PaletteEntryCount; PSURFACE psurfPattern; INT PaletteType; + HPALETTE hpal ;
if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER)) { @@ -417,7 +418,10 @@
psurfPattern = SURFACE_LockSurface(hPattern); ASSERT(psurfPattern != NULL); - psurfPattern->hDIBPalette = BuildDIBPalette(BitmapInfo, &PaletteType); + hpal = BuildDIBPalette(BitmapInfo, &PaletteType); + psurfPattern->ppal = PALETTE_ShareLockPalette(hpal); + /* Lazy delete palette, it will be freed when its shared reference is zeroed */ + GreDeleteObject(hpal); SURFACE_UnlockSurface(psurfPattern);
pbrush = BRUSH_AllocBrushWithHandle();
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -109,13 +109,14 @@ if (StartIndex + Entries > (1 << biBitCount)) Entries = (1 << biBitCount) - StartIndex;
- PalGDI = PALETTE_LockPalette(psurf->hDIBPalette); - if (PalGDI == NULL) + if (psurf->ppal == NULL) { DC_UnlockDc(dc); SetLastWin32Error(ERROR_INVALID_HANDLE); return 0; } + + PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
for (Index = StartIndex; Index < StartIndex + Entries && Index < PalGDI->NumColors; @@ -181,13 +182,14 @@ if (StartIndex + Entries > (1 << biBitCount)) Entries = (1 << biBitCount) - StartIndex;
- PalGDI = PALETTE_LockPalette(psurf->hDIBPalette); - if (PalGDI == NULL) + if (psurf->ppal == NULL) { DC_UnlockDc(dc); SetLastWin32Error(ERROR_INVALID_HANDLE); return 0; } + + PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
for (Index = StartIndex; Index < StartIndex + Entries && Index < PalGDI->NumColors; @@ -276,12 +278,7 @@ return 0; }
- // Use hDIBPalette if it exists - if (bitmap->hDIBPalette) - { - ppalDDB = PALETTE_ShareLockPalette(bitmap->hDIBPalette); - } - else if (bitmap->ppal) + if (bitmap->ppal) { ppalDDB = bitmap->ppal; GDIOBJ_IncrementShareCount(&ppalDDB->BaseObject); @@ -523,11 +520,7 @@ }
/* Obtain destination palette */ - if (pSurf && pSurf->hDIBPalette) - { - ppalDDB = PALETTE_ShareLockPalette(pSurf->hDIBPalette); - } - else if (pSurf && pSurf->ppal) + if (pSurf && pSurf->ppal) { ppalDDB = pSurf->ppal; GDIOBJ_IncrementShareCount(&ppalDDB->BaseObject); @@ -672,11 +665,7 @@ return 0; }
- if (psurf->hDIBPalette) - { - ppalSrc = PALETTE_ShareLockPalette(psurf->hDIBPalette); - } - else if (psurf->ppal) + if (psurf->ppal) { ppalSrc = psurf->ppal; GDIOBJ_IncrementShareCount(&ppalSrc->BaseObject); @@ -1357,6 +1346,7 @@ SURFACE *bmp = NULL; void *mapBits = NULL; PDC_ATTR pdcattr; + HPALETTE hpal ;
// Fill BITMAP32 structure with DIB data BITMAPINFOHEADER *bi = &bmi->bmiHeader; @@ -1525,7 +1515,7 @@ ExFreePoolWithTag(lpRGB, TAG_COLORMAP); } SetLastWin32Error(ERROR_INVALID_HANDLE); - GreDeleteObject(bmp); + GreDeleteObject(res); return NULL; }
@@ -1554,15 +1544,19 @@
if (bi->biClrUsed != 0) { - bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(ColorCount, lpRGB); + hpal = PALETTE_AllocPaletteIndexedRGB(ColorCount, lpRGB); } else { - bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL, + hpal = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL, dsBitfields[0], dsBitfields[1], dsBitfields[2]); } + + bmp->ppal = PALETTE_ShareLockPalette(hpal); + /* Lazy delete hpal, it will be freed at surface release */ + GreDeleteObject(hpal);
// Clean up in case of errors if (!res || !bmp || !bm.bmBits)
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -935,11 +935,7 @@ /* FIXME - psurf can be NULL!!! Don't assert but handle this case gracefully! */ ASSERT(psurf);
- if (psurf->hDIBPalette) - { - PalDestGDI = PALETTE_ShareLockPalette(psurf->hDIBPalette); - } - else if (psurf->ppal) + if (psurf->ppal) { PalDestGDI = psurf->ppal; GDIOBJ_IncrementShareCount(&PalDestGDI->BaseObject); @@ -1142,11 +1138,7 @@ goto cleanup; }
- if (psurf->hDIBPalette) - { - ppal = PALETTE_ShareLockPalette(psurf->hDIBPalette); - } - else if (psurf->ppal) + if (psurf->ppal) { ppal = psurf->ppal; GDIOBJ_IncrementShareCount(&ppal->BaseObject);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/freetype.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] Thu May 13 00:56:24 2010 @@ -3439,11 +3439,7 @@ SurfObj = &psurf->SurfObj ;
/* Create the xlateobj */ - if (psurf->hDIBPalette) - { - ppalDst = PALETTE_ShareLockPalette(psurf->hDIBPalette); - } - else if (psurf->ppal) + if (psurf->ppal) { ppalDst = psurf->ppal; GDIOBJ_IncrementShareCount(&ppalDst->BaseObject);