Separate SelectPalette function from User and move it to GDI.

svn path=/trunk/; revision=33846
This commit is contained in:
James Tabor 2008-06-04 05:08:46 +00:00
parent 528fc30198
commit 833d68c273
3 changed files with 57 additions and 41 deletions

View file

@ -909,45 +909,17 @@ NtUserGetDC(HWND hWnd)
*
* \todo implement ForceBackground == TRUE
*/
HPALETTE STDCALL NtUserSelectPalette(HDC hDC,
HPALETTE hpal,
BOOL ForceBackground)
HPALETTE
STDCALL
NtUserSelectPalette(HDC hDC,
HPALETTE hpal,
BOOL ForceBackground)
{
PDC dc;
HPALETTE oldPal = NULL;
PPALGDI PalGDI;
// FIXME: mark the palette as a [fore\back]ground pal
dc = DC_LockDc(hDC);
if (!dc)
{
return NULL;
}
/* Check if this is a valid palette handle */
PalGDI = PALETTE_LockPalette(hpal);
if (!PalGDI)
{
DC_UnlockDc(dc);
return NULL;
}
/* Is this a valid palette for this depth? */
if ((dc->w.bitsPerPixel <= 8 && PalGDI->Mode == PAL_INDEXED) ||
(dc->w.bitsPerPixel > 8 && PalGDI->Mode != PAL_INDEXED))
{
oldPal = dc->DcLevel.hpal;
dc->DcLevel.hpal = hpal;
}
else if (8 < dc->w.bitsPerPixel && PAL_INDEXED == PalGDI->Mode)
{
oldPal = dc->DcLevel.hpal;
dc->DcLevel.hpal = hpal;
}
PALETTE_UnlockPalette(PalGDI);
DC_UnlockDc(dc);
HPALETTE oldPal;
UserEnterExclusive();
// Implement window checks
oldPal = GdiSelectPalette( hDC, hpal, ForceBackground);
UserLeave();
return oldPal;
}

View file

@ -1454,7 +1454,7 @@ IntGdiCopyFromSaveState(PDC dc, PDC dcs, HDC hDC)
IntGdiSetBkColor( hDC, sDc_Attr->crBackgroundClr);
IntGdiSetTextColor( hDC, sDc_Attr->crForegroundClr);
NtUserSelectPalette( hDC, dcs->DcLevel.hpal, FALSE );
GdiSelectPalette( hDC, dcs->DcLevel.hpal, FALSE );
#if 0
GDISelectPalette16( hDC, dcs->DcLevel.hpal, FALSE );
@ -2107,6 +2107,50 @@ NtGdiSelectPen(
return hOrgPen;
}
HPALETTE
FASTCALL
GdiSelectPalette(HDC hDC,
HPALETTE hpal,
BOOL ForceBackground)
{
PDC dc;
HPALETTE oldPal = NULL;
PPALGDI PalGDI;
// FIXME: mark the palette as a [fore\back]ground pal
dc = DC_LockDc(hDC);
if (!dc)
{
return NULL;
}
/* Check if this is a valid palette handle */
PalGDI = PALETTE_LockPalette(hpal);
if (!PalGDI)
{
DC_UnlockDc(dc);
return NULL;
}
/* Is this a valid palette for this depth? */
if ((dc->w.bitsPerPixel <= 8 && PalGDI->Mode == PAL_INDEXED) ||
(dc->w.bitsPerPixel > 8 && PalGDI->Mode != PAL_INDEXED))
{
oldPal = dc->DcLevel.hpal;
dc->DcLevel.hpal = hpal;
}
else if (8 < dc->w.bitsPerPixel && PAL_INDEXED == PalGDI->Mode)
{
oldPal = dc->DcLevel.hpal;
dc->DcLevel.hpal = hpal;
}
PALETTE_UnlockPalette(PalGDI);
DC_UnlockDc(dc);
return oldPal;
}
WORD STDCALL
IntGdiSetHookFlags(HDC hDC, WORD Flags)
{

View file

@ -794,7 +794,7 @@ NtGdiStretchDIBitsInternal(
if(Usage == DIB_PAL_COLORS)
{
hPal = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE);
hPal = NtUserSelectPalette(hdcMem, hPal, FALSE);
hPal = GdiSelectPalette(hdcMem, hPal, FALSE);
}
if (BitsInfo->bmiHeader.biCompression == BI_RLE4 ||
@ -835,7 +835,7 @@ NtGdiStretchDIBitsInternal(
SrcWidth, SrcHeight, ROP, 0);
if(hPal)
NtUserSelectPalette(hdcMem, hPal, FALSE);
GdiSelectPalette(hdcMem, hPal, FALSE);
NtGdiSelectBitmap(hdcMem, hOldBitmap);
NtGdiDeleteObjectApp(hdcMem);