Author: jimtabor
Date: Wed Jun 4 00:08:46 2008
New Revision: 33846
URL:
http://svn.reactos.org/svn/reactos?rev=33846&view=rev
Log:
Separate SelectPalette function from User and move it to GDI.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] Wed Jun 4 00:08:46
2008
@@ -909,45 +909,17 @@
*
* \todo implement ForceBackground == TRUE
*/
-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
+STDCALL
+NtUserSelectPalette(HDC hDC,
+ HPALETTE hpal,
+ BOOL ForceBackground)
+{
+ HPALETTE oldPal;
+ UserEnterExclusive();
+ // Implement window checks
+ oldPal = GdiSelectPalette( hDC, hpal, ForceBackground);
+ UserLeave();
return oldPal;
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] Wed Jun 4 00:08:46
2008
@@ -1454,7 +1454,7 @@
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 @@
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)
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Wed Jun 4
00:08:46 2008
@@ -794,7 +794,7 @@
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 @@
SrcWidth, SrcHeight, ROP, 0);
if(hPal)
- NtUserSelectPalette(hdcMem, hPal, FALSE);
+ GdiSelectPalette(hdcMem, hPal, FALSE);
NtGdiSelectBitmap(hdcMem, hOldBitmap);
NtGdiDeleteObjectApp(hdcMem);