Bug fixes

svn path=/trunk/; revision=1944
This commit is contained in:
Jason Filby 2001-06-04 14:54:40 +00:00
parent f105303a7b
commit 49e30c043c
5 changed files with 40 additions and 37 deletions

View file

@ -31,8 +31,8 @@ HPALETTE EngCreatePalette(ULONG Mode,
if(Colors != NULL)
{
PalGDI->IndexedColors = ExAllocatePool(NonPagedPool, sizeof(ULONG)*NumColors);
RtlCopyMemory(PalGDI->IndexedColors, Colors, sizeof(ULONG)*NumColors);
PalGDI->IndexedColors = ExAllocatePool(NonPagedPool, sizeof(PALETTEENTRY) * NumColors);
RtlCopyMemory(PalGDI->IndexedColors, Colors, sizeof(PALETTEENTRY) * NumColors);
}
if(Mode==PAL_INDEXED)

View file

@ -52,7 +52,7 @@ const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
const PALETTEENTRY* COLOR_GetSystemPaletteTemplate(void)
{
return COLOR_sysPalTemplate;
return &COLOR_sysPalTemplate;
}
BOOL STDCALL W32kAnimatePalette(HPALETTE hpal,
@ -125,9 +125,10 @@ HPALETTE STDCALL W32kCreatePalette(CONST PLOGPALETTE palette)
PalObj = AccessUserObject(NewPalette);
size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
memcpy(&PalObj->logpalette, palette, size);
PALETTE_ValidateFlags(PalObj->logpalette.palPalEntry, PalObj->logpalette.palNumEntries);
size = sizeof(LOGPALETTE) + (palette->palNumEntries * sizeof(PALETTEENTRY));
PalObj->logpalette = ExAllocatePool(NonPagedPool, size);
memcpy(PalObj->logpalette, palette, size);
PALETTE_ValidateFlags(PalObj->logpalette->palPalEntry, PalObj->logpalette->palNumEntries);
PalObj->logicalToSystem = NULL;
return NewPalette;
@ -155,8 +156,8 @@ COLORREF STDCALL W32kGetNearestColor(HDC hDC,
return nearest;
}
nearest = COLOR_LookupNearestColor(palObj->logpalette.palPalEntry,
palObj->logpalette.palNumEntries, Color);
nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry,
palObj->logpalette->palNumEntries, Color);
// GDI_ReleaseObj( hpal );
// GDI_ReleaseObj( hdc );
@ -174,7 +175,7 @@ UINT STDCALL W32kGetNearestPaletteIndex(HPALETTE hpal,
if( palObj )
{
// Return closest match for the given RGB color
index = COLOR_PaletteLookupPixel(palObj->logpalette.palPalEntry, palObj->logpalette.palNumEntries, NULL, Color, FALSE);
index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE);
// GDI_ReleaseObj( hpalette );
}
@ -192,7 +193,7 @@ UINT STDCALL W32kGetPaletteEntries(HPALETTE hpal,
palPtr = AccessUserObject(hpal);
if (!palPtr) return 0;
numEntries = palPtr->logpalette.palNumEntries;
numEntries = palPtr->logpalette->palNumEntries;
if (StartIndex + Entries > numEntries) Entries = numEntries - StartIndex;
if (pe)
{
@ -201,7 +202,7 @@ UINT STDCALL W32kGetPaletteEntries(HPALETTE hpal,
// GDI_ReleaseObj( hpalette );
return 0;
}
memcpy(pe, &palPtr->logpalette.palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY));
memcpy(pe, &palPtr->logpalette->palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY));
for(numEntries = 0; numEntries < Entries ; numEntries++)
if (pe[numEntries].peFlags & 0xF0)
pe[numEntries].peFlags = 0;
@ -285,7 +286,7 @@ A logical palette is a buffer between color-intensive applications and the syste
sysGDI = AccessInternalObject(systemPalette);
// Step 1: Create mapping of system palette\DC palette
realized = PALETTE_SetMapping(palPtr, 0, palPtr->logpalette.palNumEntries,
realized = PALETTE_SetMapping(palPtr, 0, palPtr->logpalette->palNumEntries,
(dc->w.hPalette != hPrimaryPalette) ||
(dc->w.hPalette == W32kGetStockObject(DEFAULT_PALETTE)));
@ -300,7 +301,7 @@ A logical palette is a buffer between color-intensive applications and the syste
} else {
if(SurfGDI->SetPalette)
{
success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysPtr->logpalette.palNumEntries);
success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysPtr->logpalette->palNumEntries);
}
}
@ -326,8 +327,8 @@ BOOL STDCALL W32kResizePalette(HPALETTE hpal,
PXLATEOBJ XlateObj = NULL;
if(!palPtr) return FALSE;
cPrevEnt = palPtr->logpalette.palNumEntries;
prevVer = palPtr->logpalette.palVersion;
cPrevEnt = palPtr->logpalette->palNumEntries;
prevVer = palPtr->logpalette->palVersion;
prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) + sizeof(int*) + sizeof(GDIOBJHDR);
size += sizeof(int*) + sizeof(GDIOBJHDR);
XlateObj = palPtr->logicalToSystem;
@ -352,8 +353,8 @@ BOOL STDCALL W32kResizePalette(HPALETTE hpal,
memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
PALETTE_ValidateFlags((PALETTEENTRY*)((BYTE*)palPtr + prevsize), cEntries - cPrevEnt );
}
palPtr->logpalette.palNumEntries = cEntries;
palPtr->logpalette.palVersion = prevVer;
palPtr->logpalette->palNumEntries = cEntries;
palPtr->logpalette->palVersion = prevVer;
// GDI_ReleaseObj( hPal );
return TRUE; */
@ -392,15 +393,15 @@ UINT STDCALL W32kSetPaletteEntries(HPALETTE hpal,
palPtr = AccessUserObject(hpal);
if (!palPtr) return 0;
numEntries = palPtr->logpalette.palNumEntries;
numEntries = palPtr->logpalette->palNumEntries;
if (Start >= numEntries)
{
// GDI_ReleaseObj( hpalette );
return 0;
}
if (Start + Entries > numEntries) Entries = numEntries - Start;
memcpy(&palPtr->logpalette.palPalEntry[Start], pe, Entries * sizeof(PALETTEENTRY));
PALETTE_ValidateFlags(palPtr->logpalette.palPalEntry, palPtr->logpalette.palNumEntries);
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 );

View file

@ -1,7 +1,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.7 2001/03/31 15:35:08 jfilby Exp $
* $Id: gdiobj.c,v 1.8 2001/06/04 14:54:40 jfilby Exp $
*
*/
@ -208,6 +208,7 @@ HGDIOBJ GDIOBJ_SetNextObject (HGDIOBJ Obj, WORD Magic, HGDIOBJ NextObj)
VOID CreateStockObjects(void)
{
// Create GDI Stock Objects from the logical structures we've defined
StockObjects[WHITE_BRUSH] = W32kCreateBrushIndirect(&WhiteBrush);
StockObjects[LTGRAY_BRUSH] = W32kCreateBrushIndirect(&LtGrayBrush);
StockObjects[GRAY_BRUSH] = W32kCreateBrushIndirect(&GrayBrush);

View file

@ -30,7 +30,7 @@ HPALETTE PALETTE_Init(void)
const PALETTEENTRY* __sysPalTemplate = COLOR_GetSystemPaletteTemplate();
// create default palette (20 system colors)
palPtr = ExAllocatePool(NonPagedPool, sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1) * sizeof(PALETTEENTRY));
palPtr = ExAllocatePool(NonPagedPool, sizeof(LOGPALETTE) + (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)));
if (!palPtr) return FALSE;
palPtr->palVersion = 0x300;
@ -42,6 +42,7 @@ HPALETTE PALETTE_Init(void)
palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
palPtr->palPalEntry[i].peFlags = 0;
}
hpalette = W32kCreatePalette(palPtr);
ExFreePool(palPtr);
@ -102,9 +103,9 @@ int PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
// initialize palette mapping table
//mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping,
// sizeof(int)*palPtr->logpalette.palNumEntries);
// sizeof(int)*palPtr->logpalette->palNumEntries);
ExFreePool(palPtr->mapping);
mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palPtr->logpalette.palNumEntries);
mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palPtr->logpalette->palNumEntries);
palPtr->mapping = mapping;
@ -113,11 +114,11 @@ int PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
index = -1;
flag = PC_SYS_USED;
switch( palPtr->logpalette.palPalEntry[uStart].peFlags & 0x07 )
switch( palPtr->logpalette->palPalEntry[uStart].peFlags & 0x07 )
{
case PC_EXPLICIT: // palette entries are indices into system palette
// The PC_EXPLICIT flag is used to copy an entry from the system palette into the logical palette
index = *(WORD*)(palPtr->logpalette.palPalEntry + uStart);
index = *(WORD*)(palPtr->logpalette->palPalEntry + uStart);
if(index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd))
{
DbgPrint("Win32k: PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index);
@ -132,7 +133,7 @@ int PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
// fall through
default: // try to collapse identical colors
index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256,
*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart));
*(COLORREF*)(palPtr->logpalette->palPalEntry + uStart));
// fall through
case PC_NOCOLLAPSE:
@ -152,13 +153,13 @@ int PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
PALETTE_firstFree = PALETTE_freeList[index];
color.pixel = (PALETTE_PaletteToXPixel) ? PALETTE_PaletteToXPixel[index] : index;
color.red = palPtr->logpalette.palPalEntry[uStart].peRed << 8;
color.green = palPtr->logpalette.palPalEntry[uStart].peGreen << 8;
color.blue = palPtr->logpalette.palPalEntry[uStart].peBlue << 8;
color.red = palPtr->logpalette->palPalEntry[uStart].peRed << 8;
color.green = palPtr->logpalette->palPalEntry[uStart].peGreen << 8;
color.blue = palPtr->logpalette->palPalEntry[uStart].peBlue << 8;
color.flags = DoRed | DoGreen | DoBlue;
TSXStoreColor(display, PALETTE_PaletteXColormap, &color);
COLOR_sysPal[index] = palPtr->logpalette.palPalEntry[uStart];
COLOR_sysPal[index] = palPtr->logpalette->palPalEntry[uStart];
COLOR_sysPal[index].peFlags = flag;
PALETTE_freeList[index] = 0;
@ -168,16 +169,16 @@ int PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
/* else if (PALETTE_PaletteFlags & PALETTE_VIRTUAL)
{
index = PALETTE_ToPhysical(NULL, 0x00ffffff &
*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart));
*(COLORREF*)(palPtr->logpalette->palPalEntry + uStart));
break;
} FIXME */
// we have to map to existing entry in the system palette
index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL,
*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart), TRUE);
*(COLORREF*)(palPtr->logpalette->palPalEntry + uStart), TRUE);
}
palPtr->logpalette.palPalEntry[uStart].peFlags |= PC_SYS_USED;
palPtr->logpalette->palPalEntry[uStart].peFlags |= PC_SYS_USED;
/* if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; FIXME */
break;

View file

@ -60,8 +60,8 @@ W32kAddFontResource(LPCWSTR Filename)
ANSI_STRING StringA;
UNICODE_STRING StringU;
FontObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(XLATEOBJ), NULL);
FontGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(XLATEGDI), NULL);
FontObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTOBJ), NULL);
FontGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTGDI), NULL);
NewFont = CreateGDIHandle(FontGDI, FontObj);
RtlCreateUnicodeString(&uFileName, Filename);
@ -132,10 +132,10 @@ W32kAddFontResource(LPCWSTR Filename)
// Add this font resource to the font table
FontTable[FontsLoaded].hFont = NewFont;
FontTable[FontsLoaded].FaceName = ExAllocatePool(NonPagedPool, (StringU.Length + 1) * 2);
RtlInitAnsiString(&StringA, (LPSTR)face->family_name);
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
FontTable[FontsLoaded].FaceName = ExAllocatePool(NonPagedPool, (StringU.Length + 1) * 2);
wcscpy(FontTable[FontsLoaded].FaceName, StringU.Buffer);
RtlFreeUnicodeString(&StringU);