Author: tkreuzer Date: Sat Jul 4 04:18:32 2009 New Revision: 41762
URL: http://svn.reactos.org/svn/reactos?rev=41762&view=rev Log: Merge eng/palette.c, objects/palobj.c and objects/color.c into objects/palette.c, dropping some useless bitrotting code. The rest of the code needs some love and cleanup. Btw, Arch, how's the weather?
Added: trunk/reactos/subsystems/win32/win32k/objects/palette.c - copied, changed from r41760, trunk/reactos/subsystems/win32/win32k/eng/palette.c Removed: trunk/reactos/subsystems/win32/win32k/eng/palette.c trunk/reactos/subsystems/win32/win32k/objects/color.c trunk/reactos/subsystems/win32/win32k/objects/palobj.c Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild
Removed: trunk/reactos/subsystems/win32/win32k/eng/palette.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/palette.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/palette.c (removed) @@ -1,101 +1,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: GDI Palette Functions - * FILE: subsys/win32k/eng/palette.c - * PROGRAMER: Jason Filby - */ - -#include <w32k.h> - -#define NDEBUG -#include <debug.h> - -// -// -// -VOID -FASTCALL -ColorCorrection(PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors) -{ - PPDEVOBJ ppdev = (PPDEVOBJ)PalGDI->hPDev; - - if (!ppdev) return; - - if (ppdev->flFlags & PDEV_GAMMARAMP_TABLE) - { - INT i; - PGAMMARAMP GammaRamp = (PGAMMARAMP)ppdev->pvGammaRamp; - for ( i = 0; i < Colors; i++) - { - PaletteEntry[i].peRed += GammaRamp->Red[i]; - PaletteEntry[i].peGreen += GammaRamp->Green[i]; - PaletteEntry[i].peBlue += GammaRamp->Blue[i]; - } - } - return; -} - -/* - * @implemented - */ -HPALETTE -APIENTRY -EngCreatePalette( - ULONG Mode, - ULONG NumColors, - ULONG *Colors, - ULONG Red, - ULONG Green, - ULONG Blue) -{ - HPALETTE Palette; - - Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue); - if (Palette != NULL) - { - GDIOBJ_SetOwnership(Palette, NULL); - } - - return Palette; -} - -/* - * @implemented - */ -BOOL -APIENTRY -EngDeletePalette(IN HPALETTE Palette) -{ - GDIOBJ_SetOwnership(Palette, PsGetCurrentProcess()); - - return PALETTE_FreePaletteByHandle(Palette); -} - -/* - * @implemented - */ -ULONG -APIENTRY -PALOBJ_cGetColors(PALOBJ *PalObj, ULONG Start, ULONG Colors, ULONG *PaletteEntry) -{ - PALETTE *PalGDI; - - PalGDI = (PALETTE*)PalObj; - /* PalGDI = (PALETTE*)AccessInternalObjectFromUserObject(PalObj); */ - - if (Start >= PalGDI->NumColors) - return 0; - - Colors = min(Colors, PalGDI->NumColors - Start); - - /* NOTE: PaletteEntry ULONGs are in the same order as PALETTEENTRY. */ - RtlCopyMemory(PaletteEntry, PalGDI->IndexedColors + Start, sizeof(ULONG) * Colors); - - if (PalGDI->Mode & PAL_GAMMACORRECTION) - ColorCorrection(PalGDI, (PPALETTEENTRY)PaletteEntry, Colors); - - return Colors; -} - -/* EOF */
Removed: trunk/reactos/subsystems/win32/win32k/objects/color.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/color.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/color.c (removed) @@ -1,877 +1,0 @@ -/* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -/* $Id$ */ - -#include <w32k.h> - -#define NDEBUG -#include <debug.h> - -// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping - -int COLOR_gapStart = 256; -int COLOR_gapEnd = -1; -int COLOR_gapFilled = 0; -int COLOR_max = 256; - -#ifndef NO_MAPPING -static HPALETTE hPrimaryPalette = 0; // used for WM_PALETTECHANGED -#endif -//static HPALETTE hLastRealizedPalette = 0; // UnrealizeObject() needs it - - -static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* the program need save the pallete and restore it */ - -const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] = -{ - // first 10 entries in the system palette - // red green blue flags - { 0x00, 0x00, 0x00, PC_SYS_USED }, - { 0x80, 0x00, 0x00, PC_SYS_USED }, - { 0x00, 0x80, 0x00, PC_SYS_USED }, - { 0x80, 0x80, 0x00, PC_SYS_USED }, - { 0x00, 0x00, 0x80, PC_SYS_USED }, - { 0x80, 0x00, 0x80, PC_SYS_USED }, - { 0x00, 0x80, 0x80, PC_SYS_USED }, - { 0xc0, 0xc0, 0xc0, PC_SYS_USED }, - { 0xc0, 0xdc, 0xc0, PC_SYS_USED }, - { 0xa6, 0xca, 0xf0, PC_SYS_USED }, - - // ... c_min/2 dynamic colorcells - // ... gap (for sparse palettes) - // ... c_min/2 dynamic colorcells - - { 0xff, 0xfb, 0xf0, PC_SYS_USED }, - { 0xa0, 0xa0, 0xa4, PC_SYS_USED }, - { 0x80, 0x80, 0x80, PC_SYS_USED }, - { 0xff, 0x00, 0x00, PC_SYS_USED }, - { 0x00, 0xff, 0x00, PC_SYS_USED }, - { 0xff, 0xff, 0x00, PC_SYS_USED }, - { 0x00, 0x00, 0xff, PC_SYS_USED }, - { 0xff, 0x00, 0xff, PC_SYS_USED }, - { 0x00, 0xff, 0xff, PC_SYS_USED }, - { 0xff, 0xff, 0xff, PC_SYS_USED } // last 10 -}; - -const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void) -{ - return (const PALETTEENTRY*)&COLOR_sysPalTemplate; -} - -UINT APIENTRY -IntAnimatePalette(HPALETTE hPal, - UINT StartIndex, - UINT NumEntries, - CONST PPALETTEENTRY PaletteColors) -{ - UINT ret = 0; - - if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) ) - { - PPALETTE palPtr; - UINT pal_entries; - HDC hDC; - PDC dc; - PWINDOW_OBJECT Wnd; - const PALETTEENTRY *pptr = PaletteColors; - - palPtr = (PPALETTE)PALETTE_LockPalette(hPal); - if (!palPtr) return FALSE; - - pal_entries = palPtr->NumColors; - if (StartIndex >= pal_entries) - { - PALETTE_UnlockPalette(palPtr); - return FALSE; - } - if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex; - - for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) - { - /* According to MSDN, only animate PC_RESERVED colours */ - if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED) - { - memcpy( &palPtr->IndexedColors[StartIndex], pptr, - sizeof(PALETTEENTRY) ); - ret++; - PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1); - } - } - - PALETTE_UnlockPalette(palPtr); - - /* Immediately apply the new palette if current window uses it */ - Wnd = UserGetDesktopWindow(); - hDC = UserGetWindowDC(Wnd); - dc = DC_LockDc(hDC); - if (NULL != dc) - { - if (dc->dclevel.hpal == hPal) - { - DC_UnlockDc(dc); - IntGdiRealizePalette(hDC); - } - else - DC_UnlockDc(dc); - } - UserReleaseDC(Wnd,hDC, FALSE); - } - return ret; -} - -HPALETTE APIENTRY NtGdiCreateHalftonePalette(HDC hDC) -{ - int i, r, g, b; - struct { - WORD Version; - WORD NumberOfEntries; - PALETTEENTRY aEntries[256]; - } Palette; - - Palette.Version = 0x300; - Palette.NumberOfEntries = 256; - if (IntGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries) == 0) - { - /* from wine, more that 256 color math */ - Palette.NumberOfEntries = 20; - for (i = 0; i < Palette.NumberOfEntries; i++) - { - Palette.aEntries[i].peRed=0xff; - Palette.aEntries[i].peGreen=0xff; - Palette.aEntries[i].peBlue=0xff; - Palette.aEntries[i].peFlags=0x00; - } - - Palette.aEntries[0].peRed=0x00; - Palette.aEntries[0].peBlue=0x00; - Palette.aEntries[0].peGreen=0x00; - - /* the first 6 */ - for (i=1; i <= 6; i++) - { - Palette.aEntries[i].peRed=(i%2)?0x80:0; - Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0; - Palette.aEntries[i].peBlue=(i>3)?0x80:0; - } - - for (i=7; i <= 12; i++) - { - switch(i) - { - case 7: - Palette.aEntries[i].peRed=0xc0; - Palette.aEntries[i].peBlue=0xc0; - Palette.aEntries[i].peGreen=0xc0; - break; - case 8: - Palette.aEntries[i].peRed=0xc0; - Palette.aEntries[i].peGreen=0xdc; - Palette.aEntries[i].peBlue=0xc0; - break; - case 9: - Palette.aEntries[i].peRed=0xa6; - Palette.aEntries[i].peGreen=0xca; - Palette.aEntries[i].peBlue=0xf0; - break; - case 10: - Palette.aEntries[i].peRed=0xff; - Palette.aEntries[i].peGreen=0xfb; - Palette.aEntries[i].peBlue=0xf0; - break; - case 11: - Palette.aEntries[i].peRed=0xa0; - Palette.aEntries[i].peGreen=0xa0; - Palette.aEntries[i].peBlue=0xa4; - break; - case 12: - Palette.aEntries[i].peRed=0x80; - Palette.aEntries[i].peGreen=0x80; - Palette.aEntries[i].peBlue=0x80; - } - } - - for (i=13; i <= 18; i++) - { - Palette.aEntries[i].peRed=(i%2)?0xff:0; - Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0; - Palette.aEntries[i].peBlue=(i>15)?0xff:0x00; - } - } - else - { - /* 256 color table */ - for (r = 0; r < 6; r++) - for (g = 0; g < 6; g++) - for (b = 0; b < 6; b++) - { - i = r + g*6 + b*36 + 10; - Palette.aEntries[i].peRed = r * 51; - Palette.aEntries[i].peGreen = g * 51; - Palette.aEntries[i].peBlue = b * 51; - } - - for (i = 216; i < 246; i++) - { - int v = (i - 216) << 3; - Palette.aEntries[i].peRed = v; - Palette.aEntries[i].peGreen = v; - Palette.aEntries[i].peBlue = v; - } - } - - return NtGdiCreatePaletteInternal((LOGPALETTE *)&Palette, Palette.NumberOfEntries); -} - - - -/* - * @implemented - */ -HPALETTE APIENTRY -NtGdiCreatePaletteInternal ( IN LPLOGPALETTE pLogPal, IN UINT cEntries ) -{ - PPALETTE PalGDI; - HPALETTE NewPalette; - - pLogPal->palNumEntries = cEntries; - NewPalette = PALETTE_AllocPalette( PAL_INDEXED, - cEntries, - (PULONG)pLogPal->palPalEntry, - 0, 0, 0); - - if (NewPalette == NULL) - { - return NULL; - } - - PalGDI = (PPALETTE) PALETTE_LockPalette(NewPalette); - if (PalGDI != NULL) - { - PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors); - PalGDI->logicalToSystem = NULL; - PALETTE_UnlockPalette(PalGDI); - } - else - { - /* FIXME - Handle PalGDI == NULL!!!! */ - DPRINT1("waring PalGDI is NULL \n"); - } - return NewPalette; -} - - -BOOL APIENTRY NtGdiGetColorAdjustment(HDC hDC, - LPCOLORADJUSTMENT ca) -{ - UNIMPLEMENTED; - return FALSE; -} - -unsigned short GetNumberOfBits(unsigned int dwMask) -{ - unsigned short wBits; - for (wBits = 0; dwMask; dwMask = dwMask & (dwMask - 1)) - wBits++; - return wBits; -} - -COLORREF APIENTRY NtGdiGetNearestColor(HDC hDC, COLORREF Color) -{ - COLORREF nearest = CLR_INVALID; - PDC dc; - PPALETTE palGDI; - LONG RBits, GBits, BBits; - - dc = DC_LockDc(hDC); - if (NULL != dc) - { - HPALETTE hpal = dc->dclevel.hpal; - palGDI = (PPALETTE) PALETTE_LockPalette(hpal); - if (!palGDI) - { - DC_UnlockDc(dc); - return nearest; - } - - switch (palGDI->Mode) - { - case PAL_INDEXED: - nearest = COLOR_LookupNearestColor(palGDI->IndexedColors, - palGDI->NumColors, Color); - break; - case PAL_BGR: - case PAL_RGB: - nearest = Color; - break; - case PAL_BITFIELDS: - RBits = 8 - GetNumberOfBits(palGDI->RedMask); - GBits = 8 - GetNumberOfBits(palGDI->GreenMask); - BBits = 8 - GetNumberOfBits(palGDI->BlueMask); - nearest = RGB( - (GetRValue(Color) >> RBits) << RBits, - (GetGValue(Color) >> GBits) << GBits, - (GetBValue(Color) >> BBits) << BBits); - break; - } - PALETTE_UnlockPalette(palGDI); - DC_UnlockDc(dc); - } - - return nearest; -} - -UINT APIENTRY NtGdiGetNearestPaletteIndex(HPALETTE hpal, - COLORREF Color) -{ - PPALETTE palGDI = (PPALETTE) PALETTE_LockPalette(hpal); - UINT index = 0; - - if (NULL != palGDI) - { - /* Return closest match for the given RGB color */ - index = COLOR_PaletteLookupPixel(palGDI->IndexedColors, palGDI->NumColors, NULL, Color, FALSE); - PALETTE_UnlockPalette(palGDI); - } - - return index; -} - -UINT APIENTRY -IntGetPaletteEntries(HPALETTE hpal, - UINT StartIndex, - UINT Entries, - LPPALETTEENTRY pe) -{ - PPALETTE palGDI; - UINT numEntries; - - palGDI = (PPALETTE) PALETTE_LockPalette(hpal); - if (NULL == palGDI) - { - return 0; - } - - numEntries = palGDI->NumColors; - if (NULL != pe) - { - if (numEntries < StartIndex + Entries) - { - Entries = numEntries - StartIndex; - } - if (numEntries <= StartIndex) - { - PALETTE_UnlockPalette(palGDI); - return 0; - } - memcpy(pe, palGDI->IndexedColors + StartIndex, Entries * sizeof(PALETTEENTRY)); - for (numEntries = 0; numEntries < Entries; numEntries++) - { - if (pe[numEntries].peFlags & 0xF0) - { - pe[numEntries].peFlags = 0; - } - } - } - else - { - Entries = numEntries; - } - - PALETTE_UnlockPalette(palGDI); - return Entries; -} - -UINT APIENTRY -IntGetSystemPaletteEntries(HDC hDC, - UINT StartIndex, - UINT Entries, - LPPALETTEENTRY pe) -{ - PPALETTE palGDI = NULL; - PDC dc = NULL; - UINT EntriesSize = 0; - UINT Ret = 0; - - if (Entries == 0) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - - if (pe != NULL) - { - EntriesSize = Entries * sizeof(pe[0]); - if (Entries != EntriesSize / sizeof(pe[0])) - { - /* Integer overflow! */ - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - } - - if (!(dc = DC_LockDc(hDC))) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return 0; - } - - palGDI = PALETTE_LockPalette(dc->dclevel.hpal); - if (palGDI != NULL) - { - if (pe != NULL) - { - if (StartIndex >= palGDI->NumColors) - Entries = 0; - else if (Entries > palGDI->NumColors - StartIndex) - Entries = palGDI->NumColors - StartIndex; - - memcpy(pe, - palGDI->IndexedColors + StartIndex, - Entries * sizeof(pe[0])); - - Ret = Entries; - } - else - { - Ret = dc->ppdev->GDIInfo.ulNumPalReg; - } - } - - if (palGDI != NULL) - PALETTE_UnlockPalette(palGDI); - - if (dc != NULL) - DC_UnlockDc(dc); - - return Ret; -} - -UINT APIENTRY NtGdiGetSystemPaletteUse(HDC hDC) -{ - return SystemPaletteUse; -} - -/*! -The RealizePalette function modifies the palette for the device associated with the specified device context. If the device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device context is a display DC, the physical palette for that device is modified. - -A logical palette is a buffer between color-intensive applications and the system, allowing these applications to use as many colors as needed without interfering with colors displayed by other windows. - -1= IF DRAWING TO A DEVICE --- If it is a paletted bitmap, and is not an identity palette, then an XLATEOBJ is created between the logical palette and - the system palette. --- If it is an RGB palette, then an XLATEOBJ is created between the RGB values and the system palette. - -2= IF DRAWING TO A MEMORY DC\BITMAP --- If it is a paletted bitmap, and is not an identity palette, then an XLATEOBJ is created between the logical palette and - the dc palette. --- If it is an RGB palette, then an XLATEOBJ is created between the RGB values and the dc palette. -*/ -UINT FASTCALL IntGdiRealizePalette(HDC hDC) -{ - /* - * This function doesn't do any real work now and there's plenty - * of bugs in it. - */ - - PPALETTE palGDI, sysGDI; - int realized = 0; - PDC dc; - HPALETTE systemPalette; - USHORT sysMode, palMode; - - dc = DC_LockDc(hDC); - if (!dc) return 0; - - systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE); - palGDI = PALETTE_LockPalette(dc->dclevel.hpal); - - if (palGDI == NULL) - { - DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n"); - DC_UnlockDc(dc); - return 0; - } - - sysGDI = PALETTE_LockPalette(systemPalette); - - if (sysGDI == NULL) - { - DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n"); - PALETTE_UnlockPalette(palGDI); - DC_UnlockDc(dc); - return 0; - } - - // The RealizePalette function modifies the palette for the device associated with the specified device context. If the - // device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device - // context is a display DC, the physical palette for that device is modified. - if(dc->dctype == DC_TYPE_MEMORY) - { - // Memory managed DC - DPRINT1("RealizePalette unimplemented for memory managed DCs\n"); - } else - { - DPRINT1("RealizePalette unimplemented for device DCs\n"); - } - - // need to pass this to IntEngCreateXlate with palettes unlocked - sysMode = sysGDI->Mode; - palMode = palGDI->Mode; - PALETTE_UnlockPalette(sysGDI); - PALETTE_UnlockPalette(palGDI); - - // Create the XLATEOBJ for device managed DCs - if(dc->dctype != DC_TYPE_MEMORY) - { - if (palGDI->logicalToSystem != NULL) - { - EngDeleteXlate(palGDI->logicalToSystem); - } - palGDI->logicalToSystem = IntEngCreateXlate(sysMode, palMode, systemPalette, dc->dclevel.hpal); - } - - DC_UnlockDc(dc); - - return realized; -} - -BOOL APIENTRY NtGdiResizePalette(HPALETTE hpal, - UINT Entries) -{ -/* PALOBJ *palPtr = (PALOBJ*)AccessUserObject(hPal); - UINT cPrevEnt, prevVer; - INT prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY); - XLATEOBJ *XlateObj = NULL; - - if(!palPtr) return FALSE; - 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; - - if (!(palPtr = GDI_ReallocObject(size, hPal, palPtr))) return FALSE; - - if(XlateObj) - { - XLATEOBJ *NewXlateObj = (int*) HeapReAlloc(GetProcessHeap(), 0, XlateObj, cEntries * sizeof(int)); - if(NewXlateObj == NULL) - { - ERR("Can not resize logicalToSystem -- out of memory!"); - GDI_ReleaseObj( hPal ); - return FALSE; - } - palPtr->logicalToSystem = NewXlateObj; - } - - if(cEntries > cPrevEnt) - { - if(XlateObj) memset(palPtr->logicalToSystem + cPrevEnt, 0, (cEntries - cPrevEnt)*sizeof(int)); - memset( (BYTE*)palPtr + prevsize, 0, size - prevsize ); - PALETTE_ValidateFlags((PALETTEENTRY*)((BYTE*)palPtr + prevsize), cEntries - cPrevEnt ); - } - palPtr->logpalette->palNumEntries = cEntries; - palPtr->logpalette->palVersion = prevVer; -// GDI_ReleaseObj( hPal ); - return TRUE; */ - - UNIMPLEMENTED; - return FALSE; -} - -BOOL APIENTRY NtGdiSetColorAdjustment(HDC hDC, - LPCOLORADJUSTMENT ca) -{ - UNIMPLEMENTED; - return FALSE; -} - -UINT APIENTRY -IntSetPaletteEntries(HPALETTE hpal, - UINT Start, - UINT Entries, - CONST LPPALETTEENTRY pe) -{ - PPALETTE palGDI; - WORD numEntries; - - if ((UINT)hpal & GDI_HANDLE_STOCK_MASK) - { - return 0; - } - - palGDI = PALETTE_LockPalette(hpal); - if (!palGDI) return 0; - - numEntries = palGDI->NumColors; - if (Start >= numEntries) - { - PALETTE_UnlockPalette(palGDI); - return 0; - } - if (numEntries < Start + Entries) - { - Entries = numEntries - Start; - } - memcpy(palGDI->IndexedColors + Start, pe, Entries * sizeof(PALETTEENTRY)); - PALETTE_ValidateFlags(palGDI->IndexedColors, palGDI->NumColors); - if (palGDI->logicalToSystem) - ExFreePool(palGDI->logicalToSystem); - palGDI->logicalToSystem = NULL; - PALETTE_UnlockPalette(palGDI); - - return Entries; -} - -UINT APIENTRY -NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage) -{ - UINT old = SystemPaletteUse; - - /* Device doesn't support colour palettes */ - if (!(NtGdiGetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)) { - return SYSPAL_ERROR; - } - - switch (Usage) - { - case SYSPAL_NOSTATIC: - case SYSPAL_NOSTATIC256: - case SYSPAL_STATIC: - SystemPaletteUse = Usage; - break; - - default: - old=SYSPAL_ERROR; - break; - } - - return old; -} - -BOOL -APIENTRY -NtGdiUnrealizeObject(HGDIOBJ hgdiobj) -{ - BOOL Ret = FALSE; - PPALETTE palGDI; - - if ( !hgdiobj || - ((UINT)hgdiobj & GDI_HANDLE_STOCK_MASK) || - !GDI_HANDLE_IS_TYPE(hgdiobj, GDI_OBJECT_TYPE_PALETTE) ) - return Ret; - - palGDI = PALETTE_LockPalette(hgdiobj); - if (!palGDI) return FALSE; - - // FIXME!! - // Need to do something!!! - // Zero out Current and Old Translated pointers? - // - Ret = TRUE; - PALETTE_UnlockPalette(palGDI); - return Ret; -} - -BOOL APIENTRY -NtGdiUpdateColors(HDC hDC) -{ - PWINDOW_OBJECT Wnd; - BOOL calledFromUser, ret; - USER_REFERENCE_ENTRY Ref; - - calledFromUser = UserIsEntered(); - - if (!calledFromUser){ - UserEnterExclusive(); - } - - Wnd = UserGetWindowObject(IntWindowFromDC(hDC)); - if (Wnd == NULL) - { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - - if (!calledFromUser){ - UserLeave(); - } - - return FALSE; - } - - UserRefObjectCo(Wnd, &Ref); - ret = co_UserRedrawWindow(Wnd, NULL, 0, RDW_INVALIDATE); - UserDerefObjectCo(Wnd); - - if (!calledFromUser){ - UserLeave(); - } - - return ret; -} - -INT APIENTRY COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, - XLATEOBJ *XlateObj, COLORREF col, BOOL skipReserved) -{ - int i, best = 0, diff = 0x7fffffff; - int r, g, b; - - for( i = 0; i < size && diff ; i++ ) - { -#if 0 - if(!(palPalEntry[i].peFlags & PC_SYS_USED) || (skipReserved && palPalEntry[i].peFlags & PC_SYS_RESERVED)) - continue; -#endif - - r = abs((SHORT)palPalEntry[i].peRed - GetRValue(col)); - g = abs((SHORT)palPalEntry[i].peGreen - GetGValue(col)); - b = abs((SHORT)palPalEntry[i].peBlue - GetBValue(col)); - - r = r*r + g*g + b*b; - - if( r < diff ) { best = i; diff = r; } - } - - if (XlateObj == NULL) - return best; - else - return (XlateObj->pulXlate) ? (INT)XlateObj->pulXlate[best] : best; -} - -COLORREF APIENTRY COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF color ) -{ - INT index; - - index = COLOR_PaletteLookupPixel(palPalEntry, size, NULL, color, FALSE); - return RGB( - palPalEntry[index].peRed, - palPalEntry[index].peGreen, - palPalEntry[index].peBlue); -} - -int APIENTRY COLOR_PaletteLookupExactIndex( PALETTEENTRY* palPalEntry, int size, - COLORREF col ) -{ - int i; - BYTE r = GetRValue(col), g = GetGValue(col), b = GetBValue(col); - for( i = 0; i < size; i++ ) - { - if( palPalEntry[i].peFlags & PC_SYS_USED ) /* skips gap */ - if(palPalEntry[i].peRed == r && palPalEntry[i].peGreen == g && palPalEntry[i].peBlue == b) return i; - } - return -1; -} - - -W32KAPI -LONG -APIENTRY -NtGdiDoPalette( - IN HGDIOBJ hObj, - IN WORD iStart, - IN WORD cEntries, - IN LPVOID pUnsafeEntries, - IN DWORD iFunc, - IN BOOL bInbound) -{ - LONG ret; - LPVOID pEntries = NULL; - - /* FIXME: Handle bInbound correctly */ - - if (bInbound && - (pUnsafeEntries == NULL || cEntries == 0)) - { - return 0; - } - - if (pUnsafeEntries) - { - pEntries = ExAllocatePool(PagedPool, cEntries * sizeof(PALETTEENTRY)); - if (!pEntries) - return 0; - if (bInbound) - { - _SEH2_TRY - { - ProbeForRead(pUnsafeEntries, cEntries * sizeof(PALETTEENTRY), 1); - memcpy(pEntries, pUnsafeEntries, cEntries * sizeof(PALETTEENTRY)); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - ExFreePool(pEntries); - _SEH2_YIELD(return 0); - } - _SEH2_END - } - } - - ret = 0; - switch(iFunc) - { - case GdiPalAnimate: - if (pEntries) - ret = IntAnimatePalette((HPALETTE)hObj, iStart, cEntries, (CONST PPALETTEENTRY)pEntries); - break; - - case GdiPalSetEntries: - if (pEntries) - ret = IntSetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (CONST LPPALETTEENTRY)pEntries); - break; - - case GdiPalGetEntries: - ret = IntGetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries); - break; - - case GdiPalGetSystemEntries: - ret = IntGetSystemPaletteEntries((HDC)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries); - break; - - case GdiPalSetColorTable: - if (pEntries) - ret = IntSetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries); - break; - - case GdiPalGetColorTable: - if (pEntries) - ret = IntGetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries); - break; - } - - if (pEntries) - { - if (!bInbound) - { - _SEH2_TRY - { - ProbeForWrite(pUnsafeEntries, cEntries * sizeof(PALETTEENTRY), 1); - memcpy(pUnsafeEntries, pEntries, cEntries * sizeof(PALETTEENTRY)); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - ret = 0; - } - _SEH2_END - } - ExFreePool(pEntries); - } - - return ret; -} - -/* EOF */
Copied: trunk/reactos/subsystems/win32/win32k/objects/palette.c (from r41760, trunk/reactos/subsystems/win32/win32k/eng/palette.c) URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/palette.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] Sat Jul 4 04:18:32 2009 @@ -3,7 +3,8 @@ * PROJECT: ReactOS kernel * PURPOSE: GDI Palette Functions * FILE: subsys/win32k/eng/palette.c - * PROGRAMER: Jason Filby + * PROGRAMERS: Jason Filby + * Timo Kreuzer */
#include <w32k.h> @@ -11,9 +12,270 @@ #define NDEBUG #include <debug.h>
-// -// -// +static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* the program need save the pallete and restore it */ + +const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] = +{ + // first 10 entries in the system palette + // red green blue flags + { 0x00, 0x00, 0x00, PC_SYS_USED }, + { 0x80, 0x00, 0x00, PC_SYS_USED }, + { 0x00, 0x80, 0x00, PC_SYS_USED }, + { 0x80, 0x80, 0x00, PC_SYS_USED }, + { 0x00, 0x00, 0x80, PC_SYS_USED }, + { 0x80, 0x00, 0x80, PC_SYS_USED }, + { 0x00, 0x80, 0x80, PC_SYS_USED }, + { 0xc0, 0xc0, 0xc0, PC_SYS_USED }, + { 0xc0, 0xdc, 0xc0, PC_SYS_USED }, + { 0xa6, 0xca, 0xf0, PC_SYS_USED }, + + // ... c_min/2 dynamic colorcells + // ... gap (for sparse palettes) + // ... c_min/2 dynamic colorcells + + { 0xff, 0xfb, 0xf0, PC_SYS_USED }, + { 0xa0, 0xa0, 0xa4, PC_SYS_USED }, + { 0x80, 0x80, 0x80, PC_SYS_USED }, + { 0xff, 0x00, 0x00, PC_SYS_USED }, + { 0x00, 0xff, 0x00, PC_SYS_USED }, + { 0xff, 0xff, 0x00, PC_SYS_USED }, + { 0x00, 0x00, 0xff, PC_SYS_USED }, + { 0xff, 0x00, 0xff, PC_SYS_USED }, + { 0x00, 0xff, 0xff, PC_SYS_USED }, + { 0xff, 0xff, 0xff, PC_SYS_USED } // last 10 +}; + +const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void) +{ + return (const PALETTEENTRY*)&COLOR_sysPalTemplate; +} + +INT APIENTRY COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, + XLATEOBJ *XlateObj, COLORREF col, BOOL skipReserved) +{ + int i, best = 0, diff = 0x7fffffff; + int r, g, b; + + for( i = 0; i < size && diff ; i++ ) + { +#if 0 + if(!(palPalEntry[i].peFlags & PC_SYS_USED) || (skipReserved && palPalEntry[i].peFlags & PC_SYS_RESERVED)) + continue; +#endif + + r = abs((SHORT)palPalEntry[i].peRed - GetRValue(col)); + g = abs((SHORT)palPalEntry[i].peGreen - GetGValue(col)); + b = abs((SHORT)palPalEntry[i].peBlue - GetBValue(col)); + + r = r*r + g*g + b*b; + + if( r < diff ) { best = i; diff = r; } + } + + if (XlateObj == NULL) + return best; + else + return (XlateObj->pulXlate) ? (INT)XlateObj->pulXlate[best] : best; +} + +COLORREF APIENTRY COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF color ) +{ + INT index; + + index = COLOR_PaletteLookupPixel(palPalEntry, size, NULL, color, FALSE); + return RGB( + palPalEntry[index].peRed, + palPalEntry[index].peGreen, + palPalEntry[index].peBlue); +} + +unsigned short GetNumberOfBits(unsigned int dwMask) +{ + unsigned short wBits; + for (wBits = 0; dwMask; dwMask = dwMask & (dwMask - 1)) + wBits++; + return wBits; +} + +// Create the system palette +HPALETTE FASTCALL PALETTE_Init(VOID) +{ + int i; + HPALETTE hpalette; + PLOGPALETTE palPtr; +#ifndef NO_MAPPING + PALOBJ *palObj; +#endif + const PALETTEENTRY* __sysPalTemplate = (const PALETTEENTRY*)COLOR_GetSystemPaletteTemplate(); + + // create default palette (20 system colors) + palPtr = ExAllocatePoolWithTag(PagedPool, + sizeof(LOGPALETTE) + + (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)), + TAG_PALETTE); + if (!palPtr) return FALSE; + + palPtr->palVersion = 0x300; + palPtr->palNumEntries = NB_RESERVED_COLORS; + for (i=0; i<NB_RESERVED_COLORS; i++) + { + palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed; + palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen; + palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue; + palPtr->palPalEntry[i].peFlags = 0; + } + + hpalette = NtGdiCreatePaletteInternal(palPtr,NB_RESERVED_COLORS); + ExFreePoolWithTag(palPtr, TAG_PALETTE); + +#ifndef NO_MAPPING + palObj = (PALOBJ*)PALETTE_LockPalette(hpalette); + if (palObj) + { + if (!(palObj->mapping = ExAllocatePool(PagedPool, sizeof(int) * 20))) + { + DbgPrint("Win32k: Can not create palette mapping -- out of memory!"); + return FALSE; + } + PALETTE_UnlockPalette(palObj); + } +#endif + + /* palette_size = visual->map_entries; */ + + return hpalette; +} + +VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, INT size) +{ + int i = 0; + for (; i<size ; i++) + lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07); +} + +HPALETTE +FASTCALL +PALETTE_AllocPalette(ULONG Mode, + ULONG NumColors, + ULONG *Colors, + ULONG Red, + ULONG Green, + ULONG Blue) +{ + HPALETTE NewPalette; + PPALETTE PalGDI; + + PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE); + if (!PalGDI) + { + return NULL; + } + + NewPalette = PalGDI->BaseObject.hHmgr; + + PalGDI->Self = NewPalette; + PalGDI->Mode = Mode; + + if (NULL != Colors) + { + PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, + sizeof(PALETTEENTRY) * NumColors, + TAG_PALETTE); + if (NULL == PalGDI->IndexedColors) + { + PALETTE_UnlockPalette(PalGDI); + PALETTE_FreePaletteByHandle(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(PalGDI); + + return NewPalette; +} + +HPALETTE +FASTCALL +PALETTE_AllocPaletteIndexedRGB(ULONG NumColors, + CONST RGBQUAD *Colors) +{ + HPALETTE NewPalette; + PPALETTE PalGDI; + UINT i; + + PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE); + if (!PalGDI) + { + return NULL; + } + + NewPalette = PalGDI->BaseObject.hHmgr; + + PalGDI->Self = NewPalette; + PalGDI->Mode = PAL_INDEXED; + + PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, + sizeof(PALETTEENTRY) * NumColors, + TAG_PALETTE); + if (NULL == PalGDI->IndexedColors) + { + PALETTE_UnlockPalette(PalGDI); + PALETTE_FreePaletteByHandle(NewPalette); + return NULL; + } + + for (i = 0; i < NumColors; i++) + { + PalGDI->IndexedColors[i].peRed = Colors[i].rgbRed; + PalGDI->IndexedColors[i].peGreen = Colors[i].rgbGreen; + PalGDI->IndexedColors[i].peBlue = Colors[i].rgbBlue; + PalGDI->IndexedColors[i].peFlags = 0; + } + + PalGDI->NumColors = NumColors; + + PALETTE_UnlockPalette(PalGDI); + + return NewPalette; +} + +BOOL INTERNAL_CALL +PALETTE_Cleanup(PVOID ObjectBody) +{ + PPALETTE pPal = (PPALETTE)ObjectBody; + if (NULL != pPal->IndexedColors) + { + ExFreePool(pPal->IndexedColors); + } + + return TRUE; +} + +INT FASTCALL +PALETTE_GetObject(PPALETTE pGdiObject, INT cbCount, LPLOGBRUSH lpBuffer) +{ + if (!lpBuffer) + { + return sizeof(WORD); + } + + if ((UINT)cbCount < sizeof(WORD)) return 0; + *((WORD*)lpBuffer) = (WORD)pGdiObject->NumColors; + return sizeof(WORD); +} + VOID FASTCALL ColorCorrection(PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors) @@ -35,6 +297,8 @@ } return; } + +/** Display Driver Interface **************************************************/
/* * @implemented @@ -98,4 +362,753 @@ return Colors; }
+ +/** Systemcall Interface ******************************************************/ + +/* + * @implemented + */ +HPALETTE APIENTRY +NtGdiCreatePaletteInternal ( IN LPLOGPALETTE pLogPal, IN UINT cEntries ) +{ + PPALETTE PalGDI; + HPALETTE NewPalette; + + pLogPal->palNumEntries = cEntries; + NewPalette = PALETTE_AllocPalette( PAL_INDEXED, + cEntries, + (PULONG)pLogPal->palPalEntry, + 0, 0, 0); + + if (NewPalette == NULL) + { + return NULL; + } + + PalGDI = (PPALETTE) PALETTE_LockPalette(NewPalette); + if (PalGDI != NULL) + { + PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors); + PalGDI->logicalToSystem = NULL; + PALETTE_UnlockPalette(PalGDI); + } + else + { + /* FIXME - Handle PalGDI == NULL!!!! */ + DPRINT1("waring PalGDI is NULL \n"); + } + return NewPalette; +} + +HPALETTE APIENTRY NtGdiCreateHalftonePalette(HDC hDC) +{ + int i, r, g, b; + struct { + WORD Version; + WORD NumberOfEntries; + PALETTEENTRY aEntries[256]; + } Palette; + + Palette.Version = 0x300; + Palette.NumberOfEntries = 256; + if (IntGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries) == 0) + { + /* from wine, more that 256 color math */ + Palette.NumberOfEntries = 20; + for (i = 0; i < Palette.NumberOfEntries; i++) + { + Palette.aEntries[i].peRed=0xff; + Palette.aEntries[i].peGreen=0xff; + Palette.aEntries[i].peBlue=0xff; + Palette.aEntries[i].peFlags=0x00; + } + + Palette.aEntries[0].peRed=0x00; + Palette.aEntries[0].peBlue=0x00; + Palette.aEntries[0].peGreen=0x00; + + /* the first 6 */ + for (i=1; i <= 6; i++) + { + Palette.aEntries[i].peRed=(i%2)?0x80:0; + Palette.aEntries[i].peGreen=(i==2)?0x80:(i==3)?0x80:(i==6)?0x80:0; + Palette.aEntries[i].peBlue=(i>3)?0x80:0; + } + + for (i=7; i <= 12; i++) + { + switch(i) + { + case 7: + Palette.aEntries[i].peRed=0xc0; + Palette.aEntries[i].peBlue=0xc0; + Palette.aEntries[i].peGreen=0xc0; + break; + case 8: + Palette.aEntries[i].peRed=0xc0; + Palette.aEntries[i].peGreen=0xdc; + Palette.aEntries[i].peBlue=0xc0; + break; + case 9: + Palette.aEntries[i].peRed=0xa6; + Palette.aEntries[i].peGreen=0xca; + Palette.aEntries[i].peBlue=0xf0; + break; + case 10: + Palette.aEntries[i].peRed=0xff; + Palette.aEntries[i].peGreen=0xfb; + Palette.aEntries[i].peBlue=0xf0; + break; + case 11: + Palette.aEntries[i].peRed=0xa0; + Palette.aEntries[i].peGreen=0xa0; + Palette.aEntries[i].peBlue=0xa4; + break; + case 12: + Palette.aEntries[i].peRed=0x80; + Palette.aEntries[i].peGreen=0x80; + Palette.aEntries[i].peBlue=0x80; + } + } + + for (i=13; i <= 18; i++) + { + Palette.aEntries[i].peRed=(i%2)?0xff:0; + Palette.aEntries[i].peGreen=(i==14)?0xff:(i==15)?0xff:(i==18)?0xff:0; + Palette.aEntries[i].peBlue=(i>15)?0xff:0x00; + } + } + else + { + /* 256 color table */ + for (r = 0; r < 6; r++) + for (g = 0; g < 6; g++) + for (b = 0; b < 6; b++) + { + i = r + g*6 + b*36 + 10; + Palette.aEntries[i].peRed = r * 51; + Palette.aEntries[i].peGreen = g * 51; + Palette.aEntries[i].peBlue = b * 51; + } + + for (i = 216; i < 246; i++) + { + int v = (i - 216) << 3; + Palette.aEntries[i].peRed = v; + Palette.aEntries[i].peGreen = v; + Palette.aEntries[i].peBlue = v; + } + } + + return NtGdiCreatePaletteInternal((LOGPALETTE *)&Palette, Palette.NumberOfEntries); +} + +BOOL +APIENTRY +NtGdiResizePalette( + HPALETTE hpal, + UINT Entries) +{ +/* PALOBJ *palPtr = (PALOBJ*)AccessUserObject(hPal); + UINT cPrevEnt, prevVer; + INT prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY); + XLATEOBJ *XlateObj = NULL; + + if(!palPtr) return FALSE; + 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; + + if (!(palPtr = GDI_ReallocObject(size, hPal, palPtr))) return FALSE; + + if(XlateObj) + { + XLATEOBJ *NewXlateObj = (int*) HeapReAlloc(GetProcessHeap(), 0, XlateObj, cEntries * sizeof(int)); + if(NewXlateObj == NULL) + { + ERR("Can not resize logicalToSystem -- out of memory!"); + GDI_ReleaseObj( hPal ); + return FALSE; + } + palPtr->logicalToSystem = NewXlateObj; + } + + if(cEntries > cPrevEnt) + { + if(XlateObj) memset(palPtr->logicalToSystem + cPrevEnt, 0, (cEntries - cPrevEnt)*sizeof(int)); + memset( (BYTE*)palPtr + prevsize, 0, size - prevsize ); + PALETTE_ValidateFlags((PALETTEENTRY*)((BYTE*)palPtr + prevsize), cEntries - cPrevEnt ); + } + palPtr->logpalette->palNumEntries = cEntries; + palPtr->logpalette->palVersion = prevVer; +// GDI_ReleaseObj( hPal ); + return TRUE; */ + + UNIMPLEMENTED; + return FALSE; +} + +BOOL +APIENTRY +NtGdiGetColorAdjustment( + HDC hdc, + LPCOLORADJUSTMENT pca) +{ + UNIMPLEMENTED; + return FALSE; +} + +BOOL +APIENTRY +NtGdiSetColorAdjustment( + HDC hdc, + LPCOLORADJUSTMENT pca) +{ + UNIMPLEMENTED; + return FALSE; +} + +COLORREF APIENTRY NtGdiGetNearestColor(HDC hDC, COLORREF Color) +{ + COLORREF nearest = CLR_INVALID; + PDC dc; + PPALETTE palGDI; + LONG RBits, GBits, BBits; + + dc = DC_LockDc(hDC); + if (NULL != dc) + { + HPALETTE hpal = dc->dclevel.hpal; + palGDI = (PPALETTE) PALETTE_LockPalette(hpal); + if (!palGDI) + { + DC_UnlockDc(dc); + return nearest; + } + + switch (palGDI->Mode) + { + case PAL_INDEXED: + nearest = COLOR_LookupNearestColor(palGDI->IndexedColors, + palGDI->NumColors, Color); + break; + case PAL_BGR: + case PAL_RGB: + nearest = Color; + break; + case PAL_BITFIELDS: + RBits = 8 - GetNumberOfBits(palGDI->RedMask); + GBits = 8 - GetNumberOfBits(palGDI->GreenMask); + BBits = 8 - GetNumberOfBits(palGDI->BlueMask); + nearest = RGB( + (GetRValue(Color) >> RBits) << RBits, + (GetGValue(Color) >> GBits) << GBits, + (GetBValue(Color) >> BBits) << BBits); + break; + } + PALETTE_UnlockPalette(palGDI); + DC_UnlockDc(dc); + } + + return nearest; +} + +UINT +APIENTRY +NtGdiGetNearestPaletteIndex( + HPALETTE hpal, + COLORREF crColor) +{ + PPALETTE ppal = (PPALETTE) PALETTE_LockPalette(hpal); + UINT index = 0; + + if (ppal) + { + /* Return closest match for the given RGB color */ + index = COLOR_PaletteLookupPixel(ppal->IndexedColors, + ppal->NumColors, + NULL, + crColor, + FALSE); + PALETTE_UnlockPalette(ppal); + } + + return index; +} + +UINT +FASTCALL +IntGdiRealizePalette(HDC hDC) +{ + /* + * This function doesn't do any real work now and there's plenty + * of bugs in it. + */ + + PPALETTE palGDI, sysGDI; + int realized = 0; + PDC dc; + HPALETTE systemPalette; + USHORT sysMode, palMode; + + dc = DC_LockDc(hDC); + if (!dc) return 0; + + systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE); + palGDI = PALETTE_LockPalette(dc->dclevel.hpal); + + if (palGDI == NULL) + { + DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n"); + DC_UnlockDc(dc); + return 0; + } + + sysGDI = PALETTE_LockPalette(systemPalette); + + if (sysGDI == NULL) + { + DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n"); + PALETTE_UnlockPalette(palGDI); + DC_UnlockDc(dc); + return 0; + } + + // The RealizePalette function modifies the palette for the device associated with the specified device context. If the + // device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device + // context is a display DC, the physical palette for that device is modified. + if(dc->dctype == DC_TYPE_MEMORY) + { + // Memory managed DC + DPRINT1("RealizePalette unimplemented for memory managed DCs\n"); + } else + { + DPRINT1("RealizePalette unimplemented for device DCs\n"); + } + + // need to pass this to IntEngCreateXlate with palettes unlocked + sysMode = sysGDI->Mode; + palMode = palGDI->Mode; + PALETTE_UnlockPalette(sysGDI); + PALETTE_UnlockPalette(palGDI); + + // Create the XLATEOBJ for device managed DCs + if(dc->dctype != DC_TYPE_MEMORY) + { + if (palGDI->logicalToSystem != NULL) + { + EngDeleteXlate(palGDI->logicalToSystem); + } + palGDI->logicalToSystem = IntEngCreateXlate(sysMode, palMode, systemPalette, dc->dclevel.hpal); + } + + DC_UnlockDc(dc); + + return realized; +} + +UINT APIENTRY +IntAnimatePalette(HPALETTE hPal, + UINT StartIndex, + UINT NumEntries, + CONST PPALETTEENTRY PaletteColors) +{ + UINT ret = 0; + + if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) ) + { + PPALETTE palPtr; + UINT pal_entries; + HDC hDC; + PDC dc; + PWINDOW_OBJECT Wnd; + const PALETTEENTRY *pptr = PaletteColors; + + palPtr = (PPALETTE)PALETTE_LockPalette(hPal); + if (!palPtr) return FALSE; + + pal_entries = palPtr->NumColors; + if (StartIndex >= pal_entries) + { + PALETTE_UnlockPalette(palPtr); + return FALSE; + } + if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex; + + for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++) + { + /* According to MSDN, only animate PC_RESERVED colours */ + if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED) + { + memcpy( &palPtr->IndexedColors[StartIndex], pptr, + sizeof(PALETTEENTRY) ); + ret++; + PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1); + } + } + + PALETTE_UnlockPalette(palPtr); + + /* Immediately apply the new palette if current window uses it */ + Wnd = UserGetDesktopWindow(); + hDC = UserGetWindowDC(Wnd); + dc = DC_LockDc(hDC); + if (NULL != dc) + { + if (dc->dclevel.hpal == hPal) + { + DC_UnlockDc(dc); + IntGdiRealizePalette(hDC); + } + else + DC_UnlockDc(dc); + } + UserReleaseDC(Wnd,hDC, FALSE); + } + return ret; +} + +UINT APIENTRY +IntGetPaletteEntries( + HPALETTE hpal, + UINT StartIndex, + UINT Entries, + LPPALETTEENTRY pe) +{ + PPALETTE palGDI; + UINT numEntries; + + palGDI = (PPALETTE) PALETTE_LockPalette(hpal); + if (NULL == palGDI) + { + return 0; + } + + numEntries = palGDI->NumColors; + if (NULL != pe) + { + if (numEntries < StartIndex + Entries) + { + Entries = numEntries - StartIndex; + } + if (numEntries <= StartIndex) + { + PALETTE_UnlockPalette(palGDI); + return 0; + } + memcpy(pe, palGDI->IndexedColors + StartIndex, Entries * sizeof(PALETTEENTRY)); + for (numEntries = 0; numEntries < Entries; numEntries++) + { + if (pe[numEntries].peFlags & 0xF0) + { + pe[numEntries].peFlags = 0; + } + } + } + else + { + Entries = numEntries; + } + + PALETTE_UnlockPalette(palGDI); + return Entries; +} + +UINT APIENTRY +IntGetSystemPaletteEntries(HDC hDC, + UINT StartIndex, + UINT Entries, + LPPALETTEENTRY pe) +{ + PPALETTE palGDI = NULL; + PDC dc = NULL; + UINT EntriesSize = 0; + UINT Ret = 0; + + if (Entries == 0) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return 0; + } + + if (pe != NULL) + { + EntriesSize = Entries * sizeof(pe[0]); + if (Entries != EntriesSize / sizeof(pe[0])) + { + /* Integer overflow! */ + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return 0; + } + } + + if (!(dc = DC_LockDc(hDC))) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return 0; + } + + palGDI = PALETTE_LockPalette(dc->dclevel.hpal); + if (palGDI != NULL) + { + if (pe != NULL) + { + if (StartIndex >= palGDI->NumColors) + Entries = 0; + else if (Entries > palGDI->NumColors - StartIndex) + Entries = palGDI->NumColors - StartIndex; + + memcpy(pe, + palGDI->IndexedColors + StartIndex, + Entries * sizeof(pe[0])); + + Ret = Entries; + } + else + { + Ret = dc->ppdev->GDIInfo.ulNumPalReg; + } + } + + if (palGDI != NULL) + PALETTE_UnlockPalette(palGDI); + + if (dc != NULL) + DC_UnlockDc(dc); + + return Ret; +} + +UINT +APIENTRY +IntSetPaletteEntries( + HPALETTE hpal, + UINT Start, + UINT Entries, + CONST LPPALETTEENTRY pe) +{ + PPALETTE palGDI; + WORD numEntries; + + if ((UINT)hpal & GDI_HANDLE_STOCK_MASK) + { + return 0; + } + + palGDI = PALETTE_LockPalette(hpal); + if (!palGDI) return 0; + + numEntries = palGDI->NumColors; + if (Start >= numEntries) + { + PALETTE_UnlockPalette(palGDI); + return 0; + } + if (numEntries < Start + Entries) + { + Entries = numEntries - Start; + } + memcpy(palGDI->IndexedColors + Start, pe, Entries * sizeof(PALETTEENTRY)); + PALETTE_ValidateFlags(palGDI->IndexedColors, palGDI->NumColors); + if (palGDI->logicalToSystem) + ExFreePool(palGDI->logicalToSystem); + palGDI->logicalToSystem = NULL; + PALETTE_UnlockPalette(palGDI); + + return Entries; +} + +W32KAPI +LONG +APIENTRY +NtGdiDoPalette( + IN HGDIOBJ hObj, + IN WORD iStart, + IN WORD cEntries, + IN LPVOID pUnsafeEntries, + IN DWORD iFunc, + IN BOOL bInbound) +{ + LONG ret; + LPVOID pEntries = NULL; + + /* FIXME: Handle bInbound correctly */ + + if (bInbound && + (pUnsafeEntries == NULL || cEntries == 0)) + { + return 0; + } + + if (pUnsafeEntries) + { + pEntries = ExAllocatePool(PagedPool, cEntries * sizeof(PALETTEENTRY)); + if (!pEntries) + return 0; + if (bInbound) + { + _SEH2_TRY + { + ProbeForRead(pUnsafeEntries, cEntries * sizeof(PALETTEENTRY), 1); + memcpy(pEntries, pUnsafeEntries, cEntries * sizeof(PALETTEENTRY)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ExFreePool(pEntries); + _SEH2_YIELD(return 0); + } + _SEH2_END + } + } + + ret = 0; + switch(iFunc) + { + case GdiPalAnimate: + if (pEntries) + ret = IntAnimatePalette((HPALETTE)hObj, iStart, cEntries, (CONST PPALETTEENTRY)pEntries); + break; + + case GdiPalSetEntries: + if (pEntries) + ret = IntSetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (CONST LPPALETTEENTRY)pEntries); + break; + + case GdiPalGetEntries: + ret = IntGetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries); + break; + + case GdiPalGetSystemEntries: + ret = IntGetSystemPaletteEntries((HDC)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries); + break; + + case GdiPalSetColorTable: + if (pEntries) + ret = IntSetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries); + break; + + case GdiPalGetColorTable: + if (pEntries) + ret = IntGetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries); + break; + } + + if (pEntries) + { + if (!bInbound) + { + _SEH2_TRY + { + ProbeForWrite(pUnsafeEntries, cEntries * sizeof(PALETTEENTRY), 1); + memcpy(pUnsafeEntries, pEntries, cEntries * sizeof(PALETTEENTRY)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ret = 0; + } + _SEH2_END + } + ExFreePool(pEntries); + } + + return ret; +} + +UINT APIENTRY +NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage) +{ + UINT old = SystemPaletteUse; + + /* Device doesn't support colour palettes */ + if (!(NtGdiGetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)) { + return SYSPAL_ERROR; + } + + switch (Usage) + { + case SYSPAL_NOSTATIC: + case SYSPAL_NOSTATIC256: + case SYSPAL_STATIC: + SystemPaletteUse = Usage; + break; + + default: + old=SYSPAL_ERROR; + break; + } + + return old; +} + +UINT +APIENTRY +NtGdiGetSystemPaletteUse(HDC hDC) +{ + return SystemPaletteUse; +} + +BOOL +APIENTRY +NtGdiUpdateColors(HDC hDC) +{ + PWINDOW_OBJECT Wnd; + BOOL calledFromUser, ret; + USER_REFERENCE_ENTRY Ref; + + calledFromUser = UserIsEntered(); + + if (!calledFromUser){ + UserEnterExclusive(); + } + + Wnd = UserGetWindowObject(IntWindowFromDC(hDC)); + if (Wnd == NULL) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + + if (!calledFromUser){ + UserLeave(); + } + + return FALSE; + } + + UserRefObjectCo(Wnd, &Ref); + ret = co_UserRedrawWindow(Wnd, NULL, 0, RDW_INVALIDATE); + UserDerefObjectCo(Wnd); + + if (!calledFromUser){ + UserLeave(); + } + + return ret; +} + +BOOL +APIENTRY +NtGdiUnrealizeObject(HGDIOBJ hgdiobj) +{ + BOOL Ret = FALSE; + PPALETTE palGDI; + + if ( !hgdiobj || + ((UINT)hgdiobj & GDI_HANDLE_STOCK_MASK) || + !GDI_HANDLE_IS_TYPE(hgdiobj, GDI_OBJECT_TYPE_PALETTE) ) + return Ret; + + palGDI = PALETTE_LockPalette(hgdiobj); + if (!palGDI) return FALSE; + + // FIXME!! + // Need to do something!!! + // Zero out Current and Old Translated pointers? + // + Ret = TRUE; + PALETTE_UnlockPalette(palGDI); + return Ret; +} + + /* EOF */
Removed: trunk/reactos/subsystems/win32/win32k/objects/palobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/palobj.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/palobj.c (removed) @@ -1,362 +1,0 @@ -/* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <w32k.h> - -#define NDEBUG -#include <debug.h> - -#ifndef NO_MAPPING -static int PALETTE_firstFree = 0; -static unsigned char PALETTE_freeList[256]; -#endif - -int PALETTE_PaletteFlags = 0; -PALETTEENTRY *COLOR_sysPal = NULL; -int COLOR_gapStart; -int COLOR_gapEnd; -int COLOR_gapFilled; -int COLOR_max; - -PPALETTEENTRY FASTCALL ReturnSystemPalette(VOID) -{ - return COLOR_sysPal; -} - -BOOL INTERNAL_CALL -PALETTE_Cleanup(PVOID ObjectBody) -{ - PPALETTE pPal = (PPALETTE)ObjectBody; - if (NULL != pPal->IndexedColors) - { - ExFreePool(pPal->IndexedColors); - } - - return TRUE; -} - -HPALETTE -FASTCALL -PALETTE_AllocPalette(ULONG Mode, - ULONG NumColors, - ULONG *Colors, - ULONG Red, - ULONG Green, - ULONG Blue) -{ - HPALETTE NewPalette; - PPALETTE PalGDI; - - PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE); - if (!PalGDI) - { - return NULL; - } - - NewPalette = PalGDI->BaseObject.hHmgr; - - PalGDI->Self = NewPalette; - PalGDI->Mode = Mode; - - if (NULL != Colors) - { - PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, - sizeof(PALETTEENTRY) * NumColors, - TAG_PALETTE); - if (NULL == PalGDI->IndexedColors) - { - PALETTE_UnlockPalette(PalGDI); - PALETTE_FreePaletteByHandle(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(PalGDI); - - return NewPalette; -} - -HPALETTE -FASTCALL -PALETTE_AllocPaletteIndexedRGB(ULONG NumColors, - CONST RGBQUAD *Colors) -{ - HPALETTE NewPalette; - PPALETTE PalGDI; - UINT i; - - PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE); - if (!PalGDI) - { - return NULL; - } - - NewPalette = PalGDI->BaseObject.hHmgr; - - PalGDI->Self = NewPalette; - PalGDI->Mode = PAL_INDEXED; - - PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, - sizeof(PALETTEENTRY) * NumColors, - TAG_PALETTE); - if (NULL == PalGDI->IndexedColors) - { - PALETTE_UnlockPalette(PalGDI); - PALETTE_FreePaletteByHandle(NewPalette); - return NULL; - } - - for (i = 0; i < NumColors; i++) - { - PalGDI->IndexedColors[i].peRed = Colors[i].rgbRed; - PalGDI->IndexedColors[i].peGreen = Colors[i].rgbGreen; - PalGDI->IndexedColors[i].peBlue = Colors[i].rgbBlue; - PalGDI->IndexedColors[i].peFlags = 0; - } - - PalGDI->NumColors = NumColors; - - PALETTE_UnlockPalette(PalGDI); - - return NewPalette; -} - -// Create the system palette -HPALETTE FASTCALL PALETTE_Init(VOID) -{ - int i; - HPALETTE hpalette; - PLOGPALETTE palPtr; -#ifndef NO_MAPPING - PALOBJ *palObj; -#endif - const PALETTEENTRY* __sysPalTemplate = (const PALETTEENTRY*)COLOR_GetSystemPaletteTemplate(); - - // create default palette (20 system colors) - palPtr = ExAllocatePoolWithTag(PagedPool, - sizeof(LOGPALETTE) + - (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)), - TAG_PALETTE); - if (!palPtr) return FALSE; - - palPtr->palVersion = 0x300; - palPtr->palNumEntries = NB_RESERVED_COLORS; - for (i=0; i<NB_RESERVED_COLORS; i++) - { - palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed; - palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen; - palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue; - palPtr->palPalEntry[i].peFlags = 0; - } - - hpalette = NtGdiCreatePaletteInternal(palPtr,NB_RESERVED_COLORS); - ExFreePoolWithTag(palPtr, TAG_PALETTE); - -#ifndef NO_MAPPING - palObj = (PALOBJ*)PALETTE_LockPalette(hpalette); - if (palObj) - { - if (!(palObj->mapping = ExAllocatePool(PagedPool, sizeof(int) * 20))) - { - DbgPrint("Win32k: Can not create palette mapping -- out of memory!"); - return FALSE; - } - PALETTE_UnlockPalette(palObj); - } -#endif - - /* palette_size = visual->map_entries; */ - - return hpalette; -} - -#ifndef NO_MAPPING -static void FASTCALL PALETTE_FormatSystemPalette(void) -{ - // Build free list so we'd have an easy way to find - // out if there are any available colorcells. - - int i, j = PALETTE_firstFree = NB_RESERVED_COLORS/2; - - COLOR_sysPal[j].peFlags = 0; - for (i = (NB_RESERVED_COLORS>>1) + 1 ; i < 256 - (NB_RESERVED_COLORS>>1) ; i++) - { - if (i < COLOR_gapStart || i > COLOR_gapEnd) - { - COLOR_sysPal[i].peFlags = 0; // unused tag - PALETTE_freeList[j] = i; // next - j = i; - } - } - PALETTE_freeList[j] = 0; -} -#endif - -VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, INT size) -{ - int i = 0; - for (; i<size ; i++) - lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07); -} - -#ifndef NO_MAPPING -// Set the color-mapping table for selected palette. -// Return number of entries which mapping has changed. -INT APIENTRY PALETTE_SetMapping(PALOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly) -{ - char flag; - int prevMapping = (palPtr->mapping) ? 1 : 0; - int index, iRemapped = 0; - int *mapping; - HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE); - PPALETTE pSysPal = PALETTE_LockPalette(hSysPal); - PPALETTE palGDI = CONTAINING_RECORD(palPtr,PALETTE,PalObj); - /* FIXME - handle pSysPal == NULL!!!!!!! */ - - COLOR_sysPal = pSysPal->IndexedColors; - PALETTE_UnlockPalette(pSysPal); // FIXME: Is this a right way to obtain pointer to the system palette? - - - // reset dynamic system palette entries - - if (!mapOnly && PALETTE_firstFree != -1) PALETTE_FormatSystemPalette(); - - // initialize palette mapping table - - //mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping, - // sizeof(int)*palPtr->logpalette->palNumEntries); - ExFreePool(palPtr->mapping); - mapping = ExAllocatePoolWithTag(PagedPool, sizeof(int)*palGDI->NumColors, TAG_PALETTEMAP); - - if (!mapping) - { - DPRINT1("Failed allocating memory for palette mapping!\n"); - return 0; - } - - palPtr->mapping = mapping; - - for (uNum += uStart; uStart < uNum; uStart++) - { - index = -1; - flag = PC_SYS_USED; - - switch (palGDI->IndexedColors[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*)(palGDI->IndexedColors + uStart); - if (index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd)) - { - DbgPrint("Win32k: PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index); - index = 0; - } - break; - - case PC_RESERVED: // forbid future mappings to this entry - // For palette animation, the entries in the logical palette need the PC_RESERVED flag - flag |= PC_SYS_RESERVED; - - // fall through - default: // try to collapse identical colors - index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256, - *(COLORREF*)(palGDI->IndexedColors + uStart)); - // fall through - - case PC_NOCOLLAPSE: - // If an entry in the logical palette is marked with the PC_NOCOLLAPSE flag, the palette - // manager allocates a free entry in the system palette if one is available and only uses the - // closest colour match if there are no (more) free entries in the system palette - - DbgPrint("Win32k: WARNING: PC_NOCOLLAPSE is not yet working properly\n"); - - if (index < 0) - { - if (PALETTE_firstFree > 0 /* && !(PALETTE_PaletteFlags & PALETTE_FIXED) FIXME */) - { - DbgPrint("Win32k: Unimplemented Palette Operation: PC_NOCOLLAPSE [objects/palette.c]\n"); - /* XColor color; - index = PALETTE_firstFree; // ought to be available - 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.flags = DoRed | DoGreen | DoBlue; - TSXStoreColor(display, PALETTE_PaletteXColormap, &color); - - COLOR_sysPal[index] = palPtr->logpalette->palPalEntry[uStart]; - COLOR_sysPal[index].peFlags = flag; - PALETTE_freeList[index] = 0; - - if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; */ - break; - } - /* else if (PALETTE_PaletteFlags & PALETTE_VIRTUAL) - { - index = PALETTE_ToPhysical(NULL, 0x00ffffff & - *(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*)(palGDI->IndexedColors + uStart), TRUE); - } - palGDI->IndexedColors[uStart].peFlags |= PC_SYS_USED; - - /* if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; FIXME */ - break; - } - - if (!prevMapping || palPtr->mapping[uStart] != index) iRemapped++; - palPtr->mapping[uStart] = index; - } - return iRemapped; -} -#endif - -INT FASTCALL -PALETTE_GetObject(PPALETTE pGdiObject, INT cbCount, LPLOGBRUSH lpBuffer) -{ - if (!lpBuffer) - { - return sizeof(WORD); - } - - if ((UINT)cbCount < sizeof(WORD)) return 0; - *((WORD*)lpBuffer) = (WORD)pGdiObject->NumColors; - return sizeof(WORD); -} - -/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/win... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] Sat Jul 4 04:18:32 2009 @@ -67,7 +67,6 @@ <file>engmisc.c</file> <file>mouse.c</file> <file>paint.c</file> - <file>palette.c</file> <file>perfcnt.c</file> <file>semaphor.c</file> <file>sort.c</file> @@ -163,7 +162,6 @@ <file>bitmaps.c</file> <file>brush.c</file> <file>cliprgn.c</file> - <file>color.c</file> <file>coord.c</file> <file>dcattr.c</file> <file>dclife.c</file> @@ -181,7 +179,7 @@ <file>icm.c</file> <file>line.c</file> <file>metafile.c</file> - <file>palobj.c</file> + <file>palette.c</file> <file>path.c</file> <file>pen.c</file> <file>polyfill.c</file>