* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: objects.h,v 1.17 2003/08/12 20:08:45 royce Exp $
+/* $Id: objects.h,v 1.18 2003/08/28 12:35:59 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
TEXTMETRICW TextMetric;
} FONTGDI, *PFONTGDI;
-typedef struct _PALGDI {
- ENGOBJ Header;
- PALOBJ PalObj;
-
- ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
- ULONG NumColors;
- ULONG *IndexedColors;
- ULONG RedMask;
- ULONG GreenMask;
- ULONG BlueMask;
-} PALGDI, *PPALGDI;
-
typedef struct _PATHGDI {
ENGOBJ Header;
PATHOBJ PathObj;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: palette.c,v 1.16 2003/07/11 15:59:37 royce Exp $
+/* $Id: palette.c,v 1.17 2003/08/28 12:35:59 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <ddk/winddi.h>
#include <include/object.h>
+#include <include/palette.h>
#include "handle.h"
#define NDEBUG
ULONG Green,
ULONG Blue)
{
- HPALETTE NewPalette;
- PALGDI *PalGDI;
-
- NewPalette = (HPALETTE)CreateGDIHandle(sizeof(PALGDI), sizeof(PALOBJ));
- if( !ValidEngHandle( NewPalette ) )
- return 0;
-
- PalGDI = (PALGDI*) AccessInternalObject( (ULONG) NewPalette );
- ASSERT( PalGDI );
-
- PalGDI->Mode = Mode;
-
- if(Colors != NULL)
- {
- PalGDI->IndexedColors = ExAllocatePool(NonPagedPool, sizeof(PALETTEENTRY) * NumColors);
- RtlCopyMemory(PalGDI->IndexedColors, Colors, sizeof(PALETTEENTRY) * NumColors);
- }
-
- if(Mode==PAL_INDEXED)
- {
- PalGDI->NumColors = NumColors;
- } else
- if(Mode==PAL_BITFIELDS)
- {
- PalGDI->RedMask = Red;
- PalGDI->GreenMask = Green;
- PalGDI->BlueMask = Blue;
- }
-
- return NewPalette;
+ return PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
}
/*
BOOL STDCALL
EngDeletePalette(IN HPALETTE Palette)
{
- FreeGDIHandle((ULONG)Palette);
- return TRUE;
+ return PALETTE_FreePalette(Palette);
}
/*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: surface.c,v 1.24 2003/08/25 23:24:02 rcampbell Exp $
+/* $Id: surface.c,v 1.25 2003/08/28 12:35:59 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FIXME - don't know if GDIOBJ_LockObj's return value is a SURFOBJ or not...
* also, what is HSURF's correct magic #?
*/
+#ifdef TODO
GDIOBJ_LockObj ( Surface, GDI_OBJECT_TYPE_DONTCARE );
+#endif
return (SURFOBJ*)AccessUserObject((ULONG)Surface);
}
/*
* FIXME what is HSURF's correct magic #?
*/
+#ifdef TODO
GDIOBJ_UnlockObj ( Surface->hsurf, GDI_OBJECT_TYPE_DONTCARE );
+#endif
}
/* EOF */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: xlate.c,v 1.22 2003/08/17 17:32:58 royce Exp $
+/* $Id: xlate.c,v 1.23 2003/08/28 12:35:59 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <ddk/ntddvid.h>
#include <include/object.h>
+#include <include/palette.h>
#include "handle.h"
#define NDEBUG
if (NULL != PaletteSource)
{
- SourcePalGDI = (PALGDI*)AccessInternalObject((ULONG)PaletteSource);
+ SourcePalGDI = PALETTE_LockPalette(PaletteSource);
}
- if (NULL != PaletteDest)
+ if (PaletteDest == PaletteSource)
{
- DestPalGDI = (PALGDI*)AccessInternalObject((ULONG)PaletteDest);
+ DestPalGDI = SourcePalGDI;
+ }
+ else if (NULL != PaletteDest)
+ {
+ DestPalGDI = PALETTE_LockPalette(PaletteDest);
}
XlateObj->iSrcType = SourcePalType;
((DestPalType == PAL_BGR) && (SourcePalType == PAL_BGR)) )
{
XlateObj->flXlate |= XO_TRIVIAL;
+ if (NULL != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteSource);
+ }
+ if (NULL != PaletteDest && PaletteDest != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteDest);
+ }
return XlateObj;
}
XlateObj->flXlate |= XO_TRIVIAL;
}
XlateGDI->UseShiftAndMask = TRUE;
+ if (NULL != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteSource);
+ }
+ if (NULL != PaletteDest && PaletteDest != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteDest);
+ }
return XlateObj;
}
// Converting from indexed to RGB
+#ifdef TODO
XLATEOBJ_cGetPalette(XlateObj, XO_SRCPALETTE,
SourcePalGDI->NumColors,
XlateGDI->translationTable);
+#else
+ RtlCopyMemory(XlateGDI->translationTable, SourcePalGDI->IndexedColors, sizeof(ULONG) * SourcePalGDI->NumColors);
+#endif
if (PAL_BITFIELDS == XlateObj->iDstType)
{
for (i = 0; i < SourcePalGDI->NumColors; i++)
// function anyways if pulXlate is NULL and Dest is PAL_INDEXED
// Converting from RGB to indexed
+#ifdef TODO
XLATEOBJ_cGetPalette(XlateObj, XO_DESTPALETTE, DestPalGDI->NumColors, XlateGDI->translationTable);
+#else
+ RtlCopyMemory(XlateGDI->translationTable, DestPalGDI->IndexedColors, sizeof(ULONG) * DestPalGDI->NumColors);
+#endif
}
}
// FIXME: Add support for XO_TO_MONO
+ if (NULL != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteSource);
+ }
+ if (NULL != PaletteDest && PaletteDest != PaletteSource)
+ {
+ PALETTE_UnlockPalette(PaletteDest);
+ }
+
return XlateObj;
}
VOID FASTCALL EngDeleteXlate(XLATEOBJ *XlateObj)
{
- HPALETTE HXlate = (HPALETTE)AccessHandleFromUserObject(XlateObj);
+ HANDLE HXlate = (HANDLE)AccessHandleFromUserObject(XlateObj);
XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObject((ULONG)HXlate);
if(XlateGDI->translationTable!=NULL)
{
PALGDI *PalGDI;
XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
+ ULONG Closest;
// Return the original color if there's no color translation object
if(!XlateObj) return Color;
// FIXME: won't work if destination isn't indexed
// Extract the destination palette
- PalGDI = (PALGDI*)AccessInternalObject((ULONG)XlateGDI->DestPal);
+ PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
// Return closest match for the given color
- return ClosestColorMatch(XlateGDI, Color, PalGDI->IndexedColors, PalGDI->NumColors);
+ Closest = ClosestColorMatch(XlateGDI, Color, PalGDI->IndexedColors, PalGDI->NumColors);
+ PALETTE_UnlockPalette(XlateGDI->DestPal);
+ return Closest;
} else
if(XlateObj->iSrcType == PAL_INDEXED)
{
HPal = XlateGDI->DestPal;
}
- PalGDI = (PALGDI*)AccessInternalObject((ULONG)HPal);
+ PalGDI = PALETTE_LockPalette(HPal);
RtlCopyMemory(OutPal, PalGDI->IndexedColors, sizeof(ULONG)*cPal);
+ PALETTE_UnlockPalette(HPal);
return i;
}
+
/* EOF */
int max;
} ColorShifts;
+typedef struct _PALGDI {
+ PALOBJ PalObj;
+
+ HPALETTE Self;
+ ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
+ ULONG NumColors;
+ ULONG *IndexedColors;
+ ULONG RedMask;
+ ULONG GreenMask;
+ ULONG BlueMask;
+} PALGDI, *PPALGDI;
+
+HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
+ ULONG NumColors,
+ ULONG *Colors,
+ ULONG Red,
+ ULONG Green,
+ ULONG Blue);
+#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE, GDIOBJFLAG_DEFAULT)
+#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
+#define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
+
HPALETTE FASTCALL PALETTE_Init (VOID);
VOID FASTCALL PALETTE_ValidateFlags (PALETTEENTRY* lpPalE, INT size);
INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: bitmaps.c,v 1.36 2003/08/25 23:24:02 rcampbell Exp $ */
+/* $Id: bitmaps.c,v 1.37 2003/08/28 12:35:59 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <include/inteng.h>
#include <include/eng.h>
#include <include/surface.h>
+#include <include/palette.h>
#define NDEBUG
#include <win32k/debug1.h>
PPALGDI PalDestGDI, PalSourceGDI;
PXLATEOBJ XlateObj = NULL;
HPALETTE SourcePalette, DestPalette;
+ ULONG SourceMode, DestMode;
if ( !GDIOBJ_LockMultipleObj(Lock, sizeof(Lock)/sizeof(Lock[0])) )
{
SurfGDISrc = (PSURFGDI)AccessInternalObjectFromUserObject(SurfSrc);
// Retrieve the logical palette of the destination DC
- DCLogPal = (PPALOBJ)AccessUserObject((ULONG)DCDest->w.hPalette);
+ DCLogPal = (PPALOBJ)PALETTE_LockPalette(DCDest->w.hPalette);
if(DCLogPal)
- if(DCLogPal->logicalToSystem)
- XlateObj = DCLogPal->logicalToSystem;
+ {
+ if(DCLogPal->logicalToSystem)
+ {
+ XlateObj = DCLogPal->logicalToSystem;
+ }
+ PALETTE_UnlockPalette(DCDest->w.hPalette);
+ }
// If the source and destination formats differ, create an XlateObj [what if we already have one??]
if((BitsPerFormat(SurfDest->iBitmapFormat) != BitsPerFormat(SurfSrc->iBitmapFormat)) && (XlateObj == NULL))
- {
- if(DCDest->w.hPalette != 0)
- DestPalette = DCDest->w.hPalette;
- else
- DestPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
+ {
+ if(DCDest->w.hPalette != 0)
+ {
+ DestPalette = DCDest->w.hPalette;
+ }
+ else
+ {
+ DestPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
+ }
- if(DCSrc->w.hPalette != 0)
- SourcePalette = DCSrc->w.hPalette;
- else
- SourcePalette = NtGdiGetStockObject(DEFAULT_PALETTE);
+ if(DCSrc->w.hPalette != 0)
+ {
+ SourcePalette = DCSrc->w.hPalette;
+ }
+ else
+ {
+ SourcePalette = NtGdiGetStockObject(DEFAULT_PALETTE);
+ }
- PalDestGDI = (PPALGDI)AccessInternalObject((ULONG)DestPalette);
- PalSourceGDI = (PPALGDI)AccessInternalObject((ULONG)SourcePalette);
+ PalSourceGDI = PALETTE_LockPalette(SourcePalette);
+ SourceMode = PalSourceGDI->Mode;
+ PALETTE_UnlockPalette(SourcePalette);
+ if (DestPalette == SourcePalette)
+ {
+ DestMode = SourceMode;
+ }
+ else
+ {
+ PalDestGDI = PALETTE_LockPalette(DestPalette);
+ DestMode = PalDestGDI->Mode;
+ PALETTE_UnlockPalette(DestPalette);
+ }
- XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
- XlateAlloc = TRUE;
+ XlateObj = (PXLATEOBJ)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
+ XlateAlloc = TRUE;
}
// Perform the bitblt operation
if (SurfDestAlloc) ExFreePool(SurfDest);
if (SurfSrcAlloc) ExFreePool(SurfSrc);
- GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock)/sizeof(Lock[0]));
+ GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock) / sizeof(Lock[0]));
return Status;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: color.c,v 1.22 2003/08/24 21:45:40 fireball Exp $ */
+/* $Id: color.c,v 1.23 2003/08/28 12:35:59 gvg Exp $ */
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
{
PPALOBJ PalObj;
- HPALETTE NewPalette = (HPALETTE)EngCreatePalette(
+ HPALETTE NewPalette = PALETTE_AllocPalette(
PAL_INDEXED,
palette->palNumEntries,
(PULONG)palette->palPalEntry,
0, 0, 0);
ULONG size;
- PalObj = (PPALOBJ)AccessUserObject ( (ULONG)NewPalette );
+ PalObj = (PPALOBJ) PALETTE_LockPalette(NewPalette);
size = sizeof(LOGPALETTE) + (palette->palNumEntries * sizeof(PALETTEENTRY));
PalObj->logpalette = ExAllocatePool(NonPagedPool, size);
PALETTE_ValidateFlags(PalObj->logpalette->palPalEntry, PalObj->logpalette->palNumEntries);
PalObj->logicalToSystem = NULL;
+ PALETTE_UnlockPalette(NewPalette);
+
return NewPalette;
}
PDC dc;
PPALOBJ palObj;
- if( (dc = DC_LockDc(hDC) ) )
- {
- HPALETTE hpal = (dc->w.hPalette)? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE);
- palObj = (PPALOBJ)AccessUserObject((ULONG)hpal);
- if (!palObj) {
-// GDI_ReleaseObj(hdc);
- return nearest;
+ dc = DC_LockDc(hDC);
+ if (NULL != dc)
+ {
+ HPALETTE hpal = (dc->w.hPalette) ? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE);
+ palObj = (PPALOBJ) PALETTE_LockPalette(hpal);
+ if (!palObj)
+ {
+ DC_UnlockDc(hDC);
+ return nearest;
+ }
+
+ nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry,
+ palObj->logpalette->palNumEntries, Color);
+ PALETTE_UnlockPalette(hpal);
+ DC_UnlockDc( hDC );
}
- nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry,
- palObj->logpalette->palNumEntries, Color);
- // FIXME: release hpal!!
-// GDI_ReleaseObj( hpal );
- DC_UnlockDc( hDC );
- }
-
return nearest;
}
UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal,
COLORREF Color)
{
- PPALOBJ palObj = (PPALOBJ)AccessUserObject((ULONG)hpal);
+ PPALOBJ palObj = (PPALOBJ) PALETTE_LockPalette(hpal);
UINT index = 0;
- if( palObj )
- {
- // Return closest match for the given RGB color
- index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE);
-// GDI_ReleaseObj( hpalette );
- }
+ if (NULL != palObj)
+ {
+ /* Return closest match for the given RGB color */
+ index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE);
+ PALETTE_UnlockPalette(hpal);
+ }
return index;
}
PPALOBJ palPtr;
UINT numEntries;
- palPtr = (PPALOBJ)AccessUserObject((ULONG)hpal);
- if (!palPtr) return 0;
+ palPtr = (PPALOBJ) PALETTE_LockPalette(hpal);
+ if (NULL == palPtr)
+ {
+ return 0;
+ }
numEntries = palPtr->logpalette->palNumEntries;
- if (StartIndex + Entries > numEntries) Entries = numEntries - StartIndex;
- if (pe)
- {
- if (StartIndex >= numEntries)
+ if (numEntries < StartIndex + Entries)
{
-// GDI_ReleaseObj( hpalette );
- return 0;
+ Entries = numEntries - StartIndex;
+ }
+ if (NULL != pe)
+ {
+ if (numEntries <= StartIndex)
+ {
+ PALETTE_UnlockPalette(hpal);
+ return 0;
+ }
+ memcpy(pe, &palPtr->logpalette->palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY));
+ for (numEntries = 0; numEntries < Entries; numEntries++)
+ {
+ if (pe[numEntries].peFlags & 0xF0)
+ {
+ pe[numEntries].peFlags = 0;
+ }
+ }
}
- memcpy(pe, &palPtr->logpalette->palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY));
- for(numEntries = 0; numEntries < Entries ; numEntries++)
- if (pe[numEntries].peFlags & 0xF0)
- pe[numEntries].peFlags = 0;
- }
-// GDI_ReleaseObj( hpalette );
+ PALETTE_UnlockPalette(hpal);
return Entries;
}
the dc palette.
-- If it is an RGB palette, then an XLATEOBJ is created between the RGB values and the dc palette.
*/
-UINT STDCALL NtGdiRealizePalette(HDC hDC)
+UINT STDCALL NtGdiRealizePalette(HDC hDC)
{
PPALOBJ palPtr, sysPtr;
PPALGDI palGDI, sysGDI;
if (!dc)
return 0;
- palPtr = (PPALOBJ)AccessUserObject((ULONG)dc->w.hPalette);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG)dc->Surface);
systemPalette = NtGdiGetStockObject((INT)DEFAULT_PALETTE);
- sysPtr = (PPALOBJ)AccessUserObject((ULONG)systemPalette);
- palGDI = (PPALGDI)AccessInternalObject((ULONG)dc->w.hPalette);
- sysGDI = (PPALGDI)AccessInternalObject((ULONG)systemPalette);
+ palGDI = PALETTE_LockPalette(dc->w.hPalette);
+ palPtr = (PPALOBJ) palGDI;
+ sysGDI = PALETTE_LockPalette(systemPalette);
+ sysPtr = (PPALOBJ) sysGDI;
// Step 1: Create mapping of system palette\DC palette
realized = PALETTE_SetMapping(palPtr, 0, palPtr->logpalette->palNumEntries,
palPtr->logicalToSystem = IntEngCreateXlate(sysGDI->Mode, palGDI->Mode, systemPalette, dc->w.hPalette);
}
-// GDI_ReleaseObj(dc->w.hPalette);
+ PALETTE_UnlockPalette(systemPalette);
+ PALETTE_UnlockPalette(dc->w.hPalette);
DC_UnlockDc(hDC);
return realized;
{
PDC dc;
HPALETTE oldPal;
+ PPALGDI PalGDI;
// FIXME: mark the palette as a [fore\back]ground pal
dc = DC_LockDc(hDC);
- if( dc ){
- oldPal = dc->w.hPalette;
- dc->w.hPalette = hpal;
- DC_UnlockDc( hDC );
- }
+ if (NULL != dc)
+ {
+ /* Check if this is a valid palette handle */
+ PalGDI = PALETTE_LockPalette(hpal);
+ if (NULL != PalGDI)
+ {
+ PALETTE_UnlockPalette(hpal);
+ oldPal = dc->w.hPalette;
+ dc->w.hPalette = hpal;
+ }
+ else
+ {
+ oldPal = NULL;
+ }
+ DC_UnlockDc(hDC);
+ }
return oldPal;
}
PPALOBJ palPtr;
WORD numEntries;
- palPtr = (PPALOBJ)AccessUserObject((ULONG)hpal);
+ palPtr = (PPALOBJ)PALETTE_LockPalette(hpal);
if (!palPtr) return 0;
numEntries = palPtr->logpalette->palNumEntries;
if (Start >= numEntries)
- {
-// GDI_ReleaseObj( hpalette );
- return 0;
- }
- if (Start + Entries > numEntries) Entries = numEntries - Start;
+ {
+ PALETTE_UnlockPalette(hpal);
+ return 0;
+ }
+ if (numEntries < Start + Entries)
+ {
+ Entries = numEntries - Start;
+ }
memcpy(&palPtr->logpalette->palPalEntry[Start], pe, Entries * sizeof(PALETTEENTRY));
PALETTE_ValidateFlags(palPtr->logpalette->palPalEntry, palPtr->logpalette->palNumEntries);
ExFreePool(palPtr->logicalToSystem);
palPtr->logicalToSystem = NULL;
-// GDI_ReleaseObj( hpalette );
+ PALETTE_UnlockPalette(hpal);
+
return Entries;
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: dc.c,v 1.74 2003/08/25 23:24:02 rcampbell Exp $
+/* $Id: dc.c,v 1.75 2003/08/28 12:35:59 gvg Exp $
*
* DC.C - Device context functions
*
#include "../eng/handle.h"
#include <include/inteng.h>
#include <include/eng.h>
+#include <include/palette.h>
#define NDEBUG
#include <win32k/debug1.h>
DPRINT("Enabling PDev\n");
+#ifdef TODO
+PrimarySurface.DMW.dmBitsPerPel = 16;
+PrimarySurface.DMW.dmPelsWidth = 1024;
+PrimarySurface.DMW.dmPelsHeight = 768;
+PrimarySurface.DMW.dmDisplayFrequency = 60;
+#endif
PrimarySurface.PDev =
PrimarySurface.DriverFunctions.EnablePDev(&PrimarySurface.DMW,
L"",
COLORREF *ColorMap;
ULONG NumColors, Index;
HRGN hVisRgn;
+ USHORT Mode;
if(!hDC || !hGDIObj) return NULL;
objOrg = (HGDIOBJ)dc->w.hPen;
dc->w.hPen = hGDIObj;
- // Convert the color of the pen to the format of the DC
- PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
- if ( PalGDI )
+ /* Convert the color of the pen to the format of the DC */
+ PalGDI = PALETTE_LockPalette(dc->w.hPalette);
+ if (NULL != PalGDI)
{
- XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
+ Mode = PalGDI->Mode;
+ PALETTE_UnlockPalette(dc->w.hPalette);
+ XlateObj = (PXLATEOBJ)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
ASSERT ( XlateObj );
pen = PENOBJ_LockPen(dc->w.hPen);
if( pen )
objOrg = (HGDIOBJ)dc->w.hBrush;
dc->w.hBrush = (HBRUSH) hGDIObj;
- // Convert the color of the brush to the format of the DC
- PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
- if( PalGDI )
+ /* Convert the color of the brush to the format of the DC */
+ PalGDI = PALETTE_LockPalette(dc->w.hPalette);
+ if (NULL != PalGDI)
{
- XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
+ Mode = PalGDI->Mode;
+ PALETTE_UnlockPalette(dc->w.hPalette);
+ XlateObj = (PXLATEOBJ)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
ASSERT(XlateObj);
brush = BRUSHOBJ_LockBrush(dc->w.hBrush);
if( brush )
pb->ColorMap[Index].rgbGreen,
pb->ColorMap[Index].rgbBlue);
}
- dc->w.hPalette = EngCreatePalette(PAL_INDEXED, NumColors, (ULONG *) ColorMap, 0, 0, 0);
+ dc->w.hPalette = PALETTE_AllocPalette(PAL_INDEXED, NumColors, (ULONG *) ColorMap, 0, 0, 0);
ExFreePool(ColorMap);
}
else if ( 16 == pb->dib->dsBmih.biBitCount )
{
- dc->w.hPalette = EngCreatePalette(PAL_BITFIELDS, pb->dib->dsBmih.biClrUsed, NULL, 0x7c00, 0x03e0, 0x001f);
+ dc->w.hPalette = PALETTE_AllocPalette(PAL_BITFIELDS, pb->dib->dsBmih.biClrUsed, NULL, 0x7c00, 0x03e0, 0x001f);
}
else if(pb->dib->dsBmih.biBitCount >= 24)
{
- dc->w.hPalette = EngCreatePalette(PAL_RGB, pb->dib->dsBmih.biClrUsed, NULL, 0, 0, 0);
+ dc->w.hPalette = PALETTE_AllocPalette(PAL_RGB, pb->dib->dsBmih.biClrUsed, NULL, 0, 0, 0);
}
}
else
/*
- * $Id: dib.c,v 1.30 2003/08/25 23:24:02 rcampbell Exp $
+ * $Id: dib.c,v 1.31 2003/08/28 12:35:59 gvg Exp $
*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
#include <include/dib.h>
#include <internal/safe.h>
#include <include/surface.h>
+#include <include/palette.h>
#define NDEBUG
#include <win32k/debug1.h>
if (!(dc = (PDC)AccessUserObject((ULONG)hDC))) return 0;
- if (!(palette = (PPALOBJ)AccessUserObject((ULONG)dc->DevInfo->hpalDefault)))
+ if (!(palette = (PPALOBJ)PALETTE_LockPalette((ULONG)dc->DevInfo->hpalDefault)))
{
// GDI_ReleaseObj( hdc );
return 0;
Entries = 0;
}
-// GDI_ReleaseObj(dc->DevInfo->hpalDefault);
+ PALETTE_UnlockPalette(dc->DevInfo->hpalDefault);
// GDI_ReleaseObj(hdc);
return Entries;
SourceSurf = (PSURFOBJ)AccessUserObject((ULONG)SourceBitmap);
// Destination palette obtained from the hDC
- hDCPalette = (PPALGDI)AccessInternalObject((ULONG)dc->DevInfo->hpalDefault);
+ hDCPalette = PALETTE_LockPalette(dc->DevInfo->hpalDefault);
DDB_Palette_Type = hDCPalette->Mode;
DDB_Palette = dc->DevInfo->hpalDefault;
+ PALETTE_UnlockPalette(dc->DevInfo->hpalDefault);
// Source palette obtained from the BITMAPINFO
DIB_Palette = BuildDIBPalette ( (PBITMAPINFO)bmi, (PINT)&DIB_Palette_Type );
// Clean up
EngDeleteXlate(XlateObj);
- EngDeletePalette(DIB_Palette);
+ PALETTE_FreePalette(DIB_Palette);
EngDeleteSurface(SourceBitmap);
EngDeleteSurface(DestBitmap);
BITMAPOBJ_UnlockBitmap(hBitmap);
return 0;
}
- PalGdi = (PPALGDI) AccessInternalObject((ULONG) DCObj->w.hPalette);
+ PalGdi = PALETTE_LockPalette(DCObj->w.hPalette);
BitField = (DWORD *) ((char *) &InfoWithBitFields + InfoWithBitFields.Info.bmiHeader.biSize);
BitField[0] = PalGdi->RedMask;
BitField[1] = PalGdi->GreenMask;
BitField[2] = PalGdi->BlueMask;
+ PALETTE_UnlockPalette(DCObj->w.hPalette);
InfoSize = InfoWithBitFields.Info.bmiHeader.biSize + 3 * sizeof(DWORD);
DC_UnlockDc(hDC);
}
DWORD *lpIndex;
PPALOBJ palObj;
- palObj = AccessUserObject ( (ULONG)dc->DevInfo->hpalDefault );
+ palObj = (PPALOBJ) PALETTE_LockPalette(dc->DevInfo->hpalDefault);
- if (palObj == NULL)
- {
+ if (NULL == palObj)
+ {
// RELEASEDCINFO(hDC);
- return NULL;
- }
+ return NULL;
+ }
nNumColors = 1 << lpbmi->bmiHeader.biBitCount;
if (lpbmi->bmiHeader.biClrUsed)
- nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
+ {
+ nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
+ }
lpRGB = (RGBQUAD *)ExAllocatePool(NonPagedPool, sizeof(RGBQUAD) * nNumColors);
lpIndex = (DWORD *)&lpbmi->bmiColors[0];
- for (i=0; i<nNumColors; i++)
- {
- lpRGB[i].rgbRed = palObj->logpalette->palPalEntry[*lpIndex].peRed;
- lpRGB[i].rgbGreen = palObj->logpalette->palPalEntry[*lpIndex].peGreen;
- lpRGB[i].rgbBlue = palObj->logpalette->palPalEntry[*lpIndex].peBlue;
- lpIndex++;
- }
+ for (i = 0; i < nNumColors; i++)
+ {
+ lpRGB[i].rgbRed = palObj->logpalette->palPalEntry[*lpIndex].peRed;
+ lpRGB[i].rgbGreen = palObj->logpalette->palPalEntry[*lpIndex].peGreen;
+ lpRGB[i].rgbBlue = palObj->logpalette->palPalEntry[*lpIndex].peBlue;
+ lpIndex++;
+ }
// RELEASEDCINFO(hDC);
-// RELEASEPALETTEINFO(hPalette);
+ PALETTE_UnlockPalette(dc->DevInfo->hpalDefault);
+
return lpRGB;
}
{
ULONG i;
- for(i=0; i<ColorCount; i++)
- {
- palEntries->peRed = DIBColorTable->rgbRed;
- palEntries->peGreen = DIBColorTable->rgbGreen;
- palEntries->peBlue = DIBColorTable->rgbBlue;
- palEntries++;
- DIBColorTable++;
- }
+ for (i = 0; i < ColorCount; i++)
+ {
+ palEntries->peRed = DIBColorTable->rgbRed;
+ palEntries->peGreen = DIBColorTable->rgbGreen;
+ palEntries->peBlue = DIBColorTable->rgbBlue;
+ palEntries++;
+ DIBColorTable++;
+ }
return palEntries;
}
bits = bmi->bmiHeader.biBitCount;
// Determine paletteType from Bits Per Pixel
- if(bits <= 8)
- {
- *paletteType = PAL_INDEXED;
- } else
- if(bits < 24)
- {
- *paletteType = PAL_BITFIELDS;
- } else {
- *paletteType = PAL_RGB; // Would it be BGR, considering the BGR nature of the DIB color table?
- }
+ if (bits <= 8)
+ {
+ *paletteType = PAL_INDEXED;
+ }
+ else if(bits < 24)
+ {
+ *paletteType = PAL_BITFIELDS;
+ }
+ else
+ {
+ *paletteType = PAL_RGB; // Would it be BGR, considering the BGR nature of the DIB color table?
+ }
+#ifdef TODO
if (bmi->bmiHeader.biClrUsed == 0)
+#else
+ if (bmi->bmiHeader.biClrUsed == 0 && bmi->bmiHeader.biBitCount <= 8)
+#endif
{
ColorCount = 1 << bmi->bmiHeader.biBitCount;
}
palEntries = ExAllocatePool(NonPagedPool, sizeof(PALETTEENTRY)*ColorCount);
DIBColorTableToPaletteEntries(palEntries, bmi->bmiColors, ColorCount);
- hPal = EngCreatePalette ( *paletteType, ColorCount, (ULONG*)palEntries, 0, 0, 0 );
+ hPal = PALETTE_AllocPalette( *paletteType, ColorCount, (ULONG*)palEntries, 0, 0, 0 );
ExFreePool(palEntries);
return hPal;
}
+
/* EOF */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: palette.c,v 1.10 2003/08/19 11:48:50 weiden Exp $ */
+/* $Id: palette.c,v 1.11 2003/08/28 12:35:59 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <win32k/debug.h>
+#include <win32k/debug1.h>
#include <win32k/bitmaps.h>
#include <win32k/color.h>
+#include <win32k/gdiobj.h>
#include <debug.h>
#include <include/palette.h>
#include <include/object.h>
static int PALETTE_firstFree = 0;
static unsigned char PALETTE_freeList[256];
+#ifdef TODO
static ColorShifts PALETTE_PRed = {0,0,0};
//static ColorShifts PALETTE_LRed = {0,0,0};
static ColorShifts PALETTE_PGreen = {0,0,0};
//static ColorShifts PALETTE_LBlue = {0,0,0};
static int PALETTE_Graymax = 0;
static int palette_size;
+#endif
int PALETTE_PaletteFlags = 0;
PALETTEENTRY *COLOR_sysPal = NULL;
return COLOR_sysPal;
}
+static BOOL FASTCALL
+PALETTE_InternalDelete(PPALGDI Palette)
+{
+ if (NULL != Palette->IndexedColors)
+ {
+ ExFreePool(Palette->IndexedColors);
+ }
+
+ return TRUE;
+}
+
+HPALETTE FASTCALL
+PALETTE_AllocPalette(ULONG Mode,
+ ULONG NumColors,
+ ULONG *Colors,
+ ULONG Red,
+ ULONG Green,
+ ULONG Blue)
+{
+ HPALETTE NewPalette;
+ PPALGDI PalGDI;
+
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
+ if (NULL == NewPalette)
+ {
+ return NULL;
+ }
+
+ PalGDI = PALETTE_LockPalette(NewPalette);
+ ASSERT( PalGDI );
+
+ PalGDI->Self = NewPalette;
+ PalGDI->Mode = Mode;
+
+ if (NULL != Colors)
+ {
+ PalGDI->IndexedColors = ExAllocatePool(NonPagedPool, sizeof(PALETTEENTRY) * NumColors);
+ if (NULL == PalGDI->IndexedColors)
+ {
+ PALETTE_UnlockPalette(NewPalette);
+ PALETTE_FreePalette(NewPalette);
+ return NULL;
+ }
+ RtlCopyMemory(PalGDI->IndexedColors, Colors, sizeof(PALETTEENTRY) * NumColors);
+ }
+
+ if (PAL_INDEXED == Mode)
+ {
+ PalGDI->NumColors = NumColors;
+ }
+ else if (PAL_BITFIELDS == Mode)
+ {
+ PalGDI->RedMask = Red;
+ PalGDI->GreenMask = Green;
+ PalGDI->BlueMask = Blue;
+ }
+
+ PALETTE_UnlockPalette(NewPalette);
+
+ return NewPalette;
+}
+
// Create the system palette
HPALETTE FASTCALL PALETTE_Init(VOID)
{
hpalette = NtGdiCreatePalette(palPtr);
ExFreePool(palPtr);
- palObj = (PPALOBJ)AccessUserObject((ULONG)hpalette);
+ palObj = (PPALOBJ)PALETTE_LockPalette(hpalette);
if (palObj)
{
if (!(palObj->mapping = ExAllocatePool(NonPagedPool, sizeof(int) * 20)))
DbgPrint("Win32k: Can not create palette mapping -- out of memory!");
return FALSE;
}
-// GDI_ReleaseObj( hpalette );
+ PALETTE_UnlockPalette(hpalette);
}
/* palette_size = visual->map_entries; */
PALETTE_freeList[j] = 0;
}
+#ifdef TODO
/* Ported from WINE 20020804 (graphics\x11drv\palette.c) */
static int FASTCALL SysPaletteLookupPixel( COLORREF col, BOOL skipReserved )
{
DPRINT("(%04x,%06lx): returning %d\n", hpalette, color, index );
return index;
}
+#endif
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, INT size)
{
return iRemapped;
}
+#ifdef TODO
/* Return the physical color closest to 'color'. */
/* Ported from WINE 20020804 (graphics\x11drv\palette.c) */
INT FASTCALL PALETTE_ToPhysical (PDC dc, COLORREF color)
// GDI_ReleaseObj( hPal );
return index;
}
+#endif
+
/* EOF */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: text.c,v 1.44 2003/08/20 07:45:02 gvg Exp $ */
+/* $Id: text.c,v 1.45 2003/08/28 12:35:59 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <include/inteng.h>
#include <include/text.h>
#include <include/eng.h>
+#include <include/palette.h>
#define NDEBUG
#include <win32k/debug1.h>
PTEXTOBJ TextObj;
PPALGDI PalDestGDI;
PXLATEOBJ XlateObj;
+ ULONG Mode;
if( !dc )
return FALSE;
}
// Create the brush
- PalDestGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
- XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
+ PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
+ Mode = PalDestGDI->Mode;
+ PALETTE_UnlockPalette(dc->w.hPalette);
+ XlateObj = (PXLATEOBJ)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
hBrush = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
Brush = BRUSHOBJ_LockBrush(hBrush);
EngDeleteXlate(XlateObj);