mirror of
https://github.com/reactos/reactos.git
synced 2025-05-17 16:27:00 +00:00
[WIN32K]
- Get rid of hDIBPalette in SURFACE structure This allows more code cleanness svn path=/branches/reactos-yarotows/; revision=47190
This commit is contained in:
parent
38a2853dc1
commit
421a63ff44
10 changed files with 45 additions and 86 deletions
|
@ -35,11 +35,7 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
|
|||
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);
|
||||
|
|
|
@ -130,10 +130,6 @@ SURFACE_Cleanup(PVOID ObjectBody)
|
|||
ExFreePool(psurf->SurfObj.pvBits);
|
||||
}
|
||||
|
||||
if (psurf->hDIBPalette != NULL)
|
||||
{
|
||||
GreDeleteObject(psurf->hDIBPalette);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free palette */
|
||||
|
|
|
@ -618,11 +618,7 @@ EXLATEOBJ_vInitXlateFromDCs(
|
|||
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 @@ EXLATEOBJ_vInitXlateFromDCs(
|
|||
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 @@ EXLATEOBJ_vInitBrushXlate(
|
|||
COLORREF crForegroundClr,
|
||||
COLORREF crBackgroundClr)
|
||||
{
|
||||
PPALETTE ppalDst, ppalPattern;
|
||||
PPALETTE ppalDst;
|
||||
SURFACE *psurfPattern;
|
||||
|
||||
ASSERT(pexlo);
|
||||
|
@ -707,11 +699,7 @@ EXLATEOBJ_vInitBrushXlate(
|
|||
|
||||
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 @@ EXLATEOBJ_vInitBrushXlate(
|
|||
else
|
||||
{
|
||||
/* Default: use the patterns' palette */
|
||||
ppalPattern = PALETTE_LockPalette(psurfPattern->hDIBPalette);
|
||||
if (ppalPattern)
|
||||
if (psurfPattern->ppal)
|
||||
{
|
||||
EXLATEOBJ_vInitialize(pexlo, &gpalRGB, ppalDst, 0, 0, 0);
|
||||
PALETTE_UnlockPalette(ppalPattern);
|
||||
EXLATEOBJ_vInitialize(pexlo, psurfPattern->ppal, ppalDst, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct _SURFACE
|
|||
DWORD dwOffset;
|
||||
|
||||
/* reactos specific */
|
||||
HPALETTE hDIBPalette;
|
||||
DWORD dsBitfields[3]; // hack, should probably use palette instead
|
||||
DWORD biClrUsed;
|
||||
DWORD biClrImportant;
|
||||
|
|
|
@ -394,9 +394,7 @@ NtGdiTransparentBlt(
|
|||
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 ;
|
||||
|
|
|
@ -219,15 +219,17 @@ IntCreateCompatibleBitmap(
|
|||
{
|
||||
/* Copy the color table */
|
||||
UINT Index;
|
||||
PPALETTE PalGDI = PALETTE_LockPalette(psurf->hDIBPalette);
|
||||
PPALETTE PalGDI;
|
||||
|
||||
if (!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;
|
||||
Index++)
|
||||
|
@ -363,9 +365,7 @@ NtGdiGetPixel(HDC hDC, INT XPos, INT YPos)
|
|||
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 @@ BITMAP_CopyBitmap(HBITMAP hBitmap)
|
|||
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);
|
||||
|
|
|
@ -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 @@ typedef struct _GDI_OBJ_ATTR_FREELIST
|
|||
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 @@ AllocateObjectAttr(VOID)
|
|||
PGDI_OBJ_ATTR_FREELIST pGdiObjAttrFreeList;
|
||||
PGDI_OBJ_ATTR_ENTRY pGdiObjAttrEntry;
|
||||
int i;
|
||||
|
||||
|
||||
pti = PsGetCurrentThreadWin32Thread();
|
||||
if (pti->pgdiBrushAttr)
|
||||
{
|
||||
|
@ -127,9 +127,9 @@ FreeObjectAttr(PVOID pAttr)
|
|||
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 @@ IntGdiCreateDIBBrush(
|
|||
UINT PaletteEntryCount;
|
||||
PSURFACE psurfPattern;
|
||||
INT PaletteType;
|
||||
HPALETTE hpal ;
|
||||
|
||||
if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
|
||||
{
|
||||
|
@ -417,7 +418,10 @@ IntGdiCreateDIBBrush(
|
|||
|
||||
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();
|
||||
|
|
|
@ -109,14 +109,15 @@ IntSetDIBColorTable(
|
|||
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;
|
||||
Index++)
|
||||
|
@ -181,14 +182,15 @@ IntGetDIBColorTable(
|
|||
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;
|
||||
Index++)
|
||||
|
@ -276,12 +278,7 @@ IntSetDIBits(
|
|||
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 @@ NtGdiSetDIBitsToDeviceInternal(
|
|||
}
|
||||
|
||||
/* 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 @@ NtGdiGetDIBitsInternal(
|
|||
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 @@ DIB_CreateDIBSection(
|
|||
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 @@ DIB_CreateDIBSection(
|
|||
ExFreePoolWithTag(lpRGB, TAG_COLORMAP);
|
||||
}
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
GreDeleteObject(bmp);
|
||||
GreDeleteObject(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1554,16 +1544,20 @@ DIB_CreateDIBSection(
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -935,11 +935,7 @@ IntGdiGradientFill(
|
|||
/* 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 @@ NtGdiExtFloodFill(
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (psurf->hDIBPalette)
|
||||
{
|
||||
ppal = PALETTE_ShareLockPalette(psurf->hDIBPalette);
|
||||
}
|
||||
else if (psurf->ppal)
|
||||
if (psurf->ppal)
|
||||
{
|
||||
ppal = psurf->ppal;
|
||||
GDIOBJ_IncrementShareCount(&ppal->BaseObject);
|
||||
|
|
|
@ -3439,11 +3439,7 @@ GreExtTextOutW(
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue