ReactOS  0.4.14-dev-57-g333b8f1
palette.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for palette.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define PAL_SETPOWNER   0x8000
 
#define MAX_PALCOLORS   65536
 

Functions

unsigned short GetNumberOfBits (unsigned int dwMask)
 
INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl (VOID)
 
VOID FASTCALL PALETTE_ValidateFlags (PALETTEENTRY *lpPalE, INT size)
 
PPALETTE NTAPI PALETTE_AllocPalette (_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
 
PPALETTE NTAPI PALETTE_AllocPalWithHandle (_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
 
VOID NTAPI PALETTE_vCleanup (PVOID ObjectBody)
 
INT FASTCALL PALETTE_GetObject (PPALETTE ppal, INT cbCount, LPLOGBRUSH lpBuffer)
 
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex (PALETTE *ppal, ULONG iColor)
 
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex (PALETTE *ppal, ULONG ulColor)
 
ULONG NTAPI PALETTE_ulGetNearestIndex (PALETTE *ppal, ULONG ulColor)
 
VOID NTAPI PALETTE_vGetBitMasks (PPALETTE ppal, PULONG pulColors)
 
VOID FASTCALL ColorCorrection (PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors)
 
HPALETTE APIENTRY EngCreatePalette (ULONG iMode, ULONG cColors, ULONG *pulColors, ULONG flRed, ULONG flGreen, ULONG flBlue)
 
BOOL APIENTRY EngDeletePalette (IN HPALETTE hpal)
 
ULONG APIENTRY PALOBJ_cGetColors (PALOBJ *PalObj, ULONG Start, ULONG Colors, ULONG *PaletteEntry)
 
HPALETTE NTAPI GreCreatePaletteInternal (IN LPLOGPALETTE pLogPal, IN UINT cEntries)
 
HPALETTE APIENTRY NtGdiCreatePaletteInternal (IN LPLOGPALETTE plogpalUser, IN UINT cEntries)
 
HPALETTE APIENTRY NtGdiCreateHalftonePalette (HDC hDC)
 
BOOL APIENTRY NtGdiResizePalette (HPALETTE hpal, UINT Entries)
 
BOOL APIENTRY NtGdiGetColorAdjustment (HDC hdc, LPCOLORADJUSTMENT pca)
 
BOOL APIENTRY NtGdiSetColorAdjustment (HDC hdc, LPCOLORADJUSTMENT pca)
 
COLORREF APIENTRY NtGdiGetNearestColor (_In_ HDC hDC, _In_ COLORREF Color)
 
UINT APIENTRY NtGdiGetNearestPaletteIndex (HPALETTE hpal, COLORREF crColor)
 
UINT FASTCALL IntGdiRealizePalette (HDC hDC)
 
UINT APIENTRY IntAnimatePalette (HPALETTE hPal, UINT StartIndex, UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
 
UINT APIENTRY IntGetPaletteEntries (HPALETTE hpal, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
 
UINT APIENTRY IntGetSystemPaletteEntries (HDC hDC, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
 
UINT APIENTRY IntSetPaletteEntries (HPALETTE hpal, UINT Start, UINT Entries, CONST LPPALETTEENTRY pe)
 
ULONG APIENTRY GreGetSetColorTable (HDC hdc, ULONG iStartIndex, ULONG cEntries, RGBQUAD *prgbColors, BOOL bSet)
 
__kernel_entry LONG APIENTRY NtGdiDoPalette (_In_ HGDIOBJ hObj, _In_ WORD iStart, _In_ WORD cEntries, _When_(bInbound!=0, _In_reads_bytes_(cEntries *sizeof(PALETTEENTRY))) _When_(bInbound==0, _Out_writes_bytes_(cEntries *sizeof(PALETTEENTRY))) LPVOID pUnsafeEntries, _In_ DWORD iFunc, _In_ BOOL bInbound)
 
UINT APIENTRY NtGdiSetSystemPaletteUse (HDC hDC, UINT Usage)
 
UINT APIENTRY NtGdiGetSystemPaletteUse (HDC hDC)
 
BOOL APIENTRY NtGdiUpdateColors (HDC hDC)
 
BOOL APIENTRY NtGdiUnrealizeObject (HGDIOBJ hgdiobj)
 
__kernel_entry HPALETTE APIENTRY NtGdiEngCreatePalette (_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
 
__kernel_entry BOOL APIENTRY NtGdiEngDeletePalette (_In_ HPALETTE hPal)
 

Variables

static UINT SystemPaletteUse = SYSPAL_NOSTATIC
 
PALETTE gpalRGB
 
PALETTE gpalBGR
 
PALETTE gpalRGB555
 
PALETTE gpalRGB565
 
PALETTEgppalMono
 
PALETTEgppalDefault
 
PPALETTE appalSurfaceDefault [11]
 
const PALETTEENTRY g_sysPalTemplate [NB_RESERVED_COLORS]
 

Macro Definition Documentation

◆ MAX_PALCOLORS

#define MAX_PALCOLORS   65536

Definition at line 16 of file palette.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file palette.c.

◆ PAL_SETPOWNER

#define PAL_SETPOWNER   0x8000

Definition at line 15 of file palette.c.

Function Documentation

◆ ColorCorrection()

VOID FASTCALL ColorCorrection ( PPALETTE  PalGDI,
PPALETTEENTRY  PaletteEntry,
ULONG  Colors 
)

Definition at line 348 of file palette.c.

349 {
350  PPDEVOBJ ppdev = (PPDEVOBJ)PalGDI->hPDev;
351 
352  if (!ppdev) return;
353 
354  if (ppdev->flFlags & PDEV_GAMMARAMP_TABLE)
355  {
356  ULONG i;
357  PGAMMARAMP GammaRamp = (PGAMMARAMP)ppdev->pvGammaRamp;
358  for ( i = 0; i < Colors; i++)
359  {
360  PaletteEntry[i].peRed += GammaRamp->Red[i];
361  PaletteEntry[i].peGreen += GammaRamp->Green[i];
362  PaletteEntry[i].peBlue += GammaRamp->Blue[i];
363  }
364  }
365  return;
366 }
struct _GAMMARAMP * PGAMMARAMP
WORD Green[256]
Definition: winddi.h:776
WORD Red[256]
Definition: winddi.h:775
PVOID pvGammaRamp
Definition: pdevobj.h:108
struct _PDEVOBJ * PPDEVOBJ
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FLONG flFlags
Definition: pdevobj.h:89
if(!(yy_init))
Definition: macro.lex.yy.c:714
Colors
Definition: ansiprsr.h:4
#define for
Definition: utility.h:88
HDEV hPDev
Definition: palette.h:49
WORD Blue[256]
Definition: winddi.h:777
unsigned int ULONG
Definition: retypes.h:1

Referenced by PALOBJ_cGetColors().

◆ EngCreatePalette()

HPALETTE APIENTRY EngCreatePalette ( ULONG  iMode,
ULONG  cColors,
ULONG pulColors,
ULONG  flRed,
ULONG  flGreen,
ULONG  flBlue 
)

Display Driver Interface

Definition at line 375 of file palette.c.

382 {
383  PPALETTE ppal;
384  HPALETTE hpal;
385 
386  ppal = PALETTE_AllocPalette(iMode, cColors, (PPALETTEENTRY)pulColors, flRed, flGreen, flBlue);
387  if (!ppal) return NULL;
388 
390  if (!hpal)
391  {
392  DPRINT1("Could not insert palette into handle table.\n");
394  return NULL;
395  }
396 
397  PALETTE_UnlockPalette(ppal);
398  return hpal;
399 }
_In_ ULONG iMode
Definition: winddi.h:3520
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
smooth NULL
Definition: ftsmooth.c:416
BASEOBJECT BaseObject
Definition: palette.h:36
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
Definition: gdiobj.c:593
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
Definition: gdiobj.c:909

Referenced by bInitDefaultPalette(), IntInitDefaultPalette(), and NtGdiEngCreatePalette().

◆ EngDeletePalette()

BOOL APIENTRY EngDeletePalette ( IN HPALETTE  hpal)

Definition at line 406 of file palette.c.

407 {
408  PPALETTE ppal;
409 
410  ppal = PALETTE_ShareLockPalette(hpal);
411  if (!ppal) return FALSE;
412 
414 
415  return TRUE;
416 }
#define TRUE
Definition: types.h:120
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1108
BASEOBJECT BaseObject
Definition: palette.h:36

Referenced by NtGdiEngDeletePalette(), and vDisablePalette().

◆ GetNumberOfBits()

unsigned short GetNumberOfBits ( unsigned int  dwMask)

Definition at line 54 of file palette.c.

55 {
56  unsigned short wBits;
57  for (wBits = 0; dwMask; dwMask = dwMask & (dwMask - 1))
58  wBits++;
59  return wBits;
60 }

◆ GreCreatePaletteInternal()

HPALETTE NTAPI GreCreatePaletteInternal ( IN LPLOGPALETTE  pLogPal,
IN UINT  cEntries 
)

Systemcall Interface

Definition at line 448 of file palette.c.

451 {
452  HPALETTE hpal = NULL;
453  PPALETTE ppal;
454 
455  pLogPal->palNumEntries = cEntries;
457  cEntries,
458  pLogPal->palPalEntry,
459  0, 0, 0);
460 
461  if (ppal != NULL)
462  {
464 
465  hpal = ppal->BaseObject.hHmgr;
466  PALETTE_UnlockPalette(ppal);
467  }
468 
469  return hpal;
470 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:125
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3615
BASEOBJECT BaseObject
Definition: palette.h:36
ULONG NumColors
Definition: palette.h:41

◆ GreGetSetColorTable()

ULONG APIENTRY GreGetSetColorTable ( HDC  hdc,
ULONG  iStartIndex,
ULONG  cEntries,
RGBQUAD prgbColors,
BOOL  bSet 
)

Definition at line 995 of file palette.c.

1001 {
1002  PDC pdc;
1003  PSURFACE psurf;
1004  PPALETTE ppal = NULL;
1005  ULONG i, iEndIndex, iResult = 0;
1006 
1007  /* Lock the DC */
1008  pdc = DC_LockDc(hdc);
1009  if (!pdc)
1010  {
1011  return 0;
1012  }
1013 
1014  /* Get the surface from the DC */
1015  psurf = pdc->dclevel.pSurface;
1016 
1017  /* Check if we have the default surface */
1018  if (psurf == NULL)
1019  {
1020  /* Use a mono palette */
1021  if (!bSet)
1022  ppal = gppalMono;
1023  }
1024  else if (psurf->SurfObj.iType == STYPE_BITMAP)
1025  {
1026  /* Get the palette of the surface */
1027  ppal = psurf->ppal;
1028  }
1029 
1030  /* Check if this is an indexed palette and the range is ok */
1031  if (ppal && (ppal->flFlags & PAL_INDEXED) &&
1032  (iStartIndex < ppal->NumColors))
1033  {
1034  /* Calculate the end of the operation */
1035  iEndIndex = min(iStartIndex + cEntries, ppal->NumColors);
1036 
1037  /* Check what operation to perform */
1038  if (bSet)
1039  {
1040  /* Loop all colors and set the palette entries */
1041  for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
1042  {
1043  ppal->IndexedColors[i].peRed = prgbColors->rgbRed;
1044  ppal->IndexedColors[i].peGreen = prgbColors->rgbGreen;
1045  ppal->IndexedColors[i].peBlue = prgbColors->rgbBlue;
1046  }
1047 
1048  /* Mark the dc brushes invalid */
1049  pdc->pdcattr->ulDirty_ |= DIRTY_FILL|DIRTY_LINE|
1051  }
1052  else
1053  {
1054  /* Loop all colors and get the palette entries */
1055  for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
1056  {
1057  prgbColors->rgbRed = ppal->IndexedColors[i].peRed;
1058  prgbColors->rgbGreen = ppal->IndexedColors[i].peGreen;
1059  prgbColors->rgbBlue = ppal->IndexedColors[i].peBlue;
1060  prgbColors->rgbReserved = 0;
1061  }
1062  }
1063 
1064  /* Calculate how many entries were modified */
1065  iResult = iEndIndex - iStartIndex;
1066  }
1067 
1068  /* Unlock the DC */
1069  DC_UnlockDc(pdc);
1070 
1071  return iResult;
1072 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
PALETTE * gppalMono
Definition: palette.c:20
#define STYPE_BITMAP
Definition: winddi.h:1175
USHORT iType
Definition: winddi.h:1216
PALETTEENTRY * IndexedColors
Definition: palette.h:42
struct _PALETTE *const ppal
Definition: surface.h:11
UCHAR rgbBlue
Definition: inbv.c:170
#define DIRTY_BACKGROUND
Definition: ntgdihdl.h:148
UCHAR rgbGreen
Definition: inbv.c:171
UCHAR rgbRed
Definition: inbv.c:172
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
SURFOBJ SurfObj
Definition: surface.h:8
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3615
#define DIRTY_TEXT
Definition: ntgdihdl.h:147
#define DIRTY_FILL
Definition: ntgdihdl.h:145
HDC hdc
Definition: main.c:9
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
#define DIRTY_LINE
Definition: ntgdihdl.h:146
UCHAR rgbReserved
Definition: inbv.c:173

Referenced by NtGdiDoPalette().

◆ InitPaletteImpl()

INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl ( VOID  )

Definition at line 66 of file palette.c.

67 {
68  // Create default palette (20 system colors)
70  20,
72  0, 0, 0);
75 
76  /* palette_size = visual->map_entries; */
77 
79  gpalRGB.RedMask = RGB(0xFF, 0x00, 0x00);
80  gpalRGB.GreenMask = RGB(0x00, 0xFF, 0x00);
81  gpalRGB.BlueMask = RGB(0x00, 0x00, 0xFF);
84 
86  gpalBGR.RedMask = RGB(0x00, 0x00, 0xFF);
87  gpalBGR.GreenMask = RGB(0x00, 0xFF, 0x00);
88  gpalBGR.BlueMask = RGB(0xFF, 0x00, 0x00);
91 
93  gpalRGB555.RedMask = 0x7C00;
94  gpalRGB555.GreenMask = 0x3E0;
95  gpalRGB555.BlueMask = 0x1F;
98 
100  gpalRGB565.RedMask = 0xF800;
101  gpalRGB565.GreenMask = 0x7E0;
102  gpalRGB565.BlueMask = 0x1F;
105 
109 
110  /* Initialize default surface palettes */
121 
122  return STATUS_SUCCESS;
123 }
#define BMF_24BPP
Definition: winddi.h:359
PALETTE gpalRGB565
Definition: palette.c:20
PALETTE gpalBGR
Definition: palette.c:20
ULONG ulShareCount
Definition: gdiobj.h:42
#define BMF_32BPP
Definition: winddi.h:360
PALETTE * gppalMono
Definition: palette.c:20
#define BMF_8RLE
Definition: winddi.h:362
PALETTE * gppalDefault
Definition: palette.c:20
USHORT BaseFlags
Definition: gdiobj.h:46
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
Definition: palette.h:152
Definition: xlate.c:10
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
#define BMF_PNG
Definition: winddi.h:364
ULONG RedMask
Definition: palette.h:43
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
#define BMF_4RLE
Definition: winddi.h:361
smooth NULL
Definition: ftsmooth.c:416
#define BMF_16BPP
Definition: winddi.h:358
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
#define RGB(r, g, b)
Definition: wingdi.h:2935
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
BASEOBJECT BaseObject
Definition: palette.h:36
FLONG flFlags
Definition: palette.h:40
Definition: xlate.c:8
Definition: xlate.c:9
VOID NTAPI GDIOBJ_vReferenceObjectByPointer(POBJ pobj)
Definition: gdiobj.c:731
PPALETTE appalSurfaceDefault[11]
Definition: palette.c:21
PALETTE gpalRGB
Definition: palette.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966
PALETTE gpalRGB555
Definition: palette.c:20
#define BMF_JPEG
Definition: winddi.h:363
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS]
Definition: palette.c:23

Referenced by DriverEntry().

◆ IntAnimatePalette()

UINT APIENTRY IntAnimatePalette ( HPALETTE  hPal,
UINT  StartIndex,
UINT  NumEntries,
CONST PPALETTEENTRY  PaletteColors 
)

Definition at line 786 of file palette.c.

790 {
791  UINT ret = 0;
792 
793  if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
794  {
795  PPALETTE palPtr;
797  const PALETTEENTRY *pptr = PaletteColors;
798 
799  palPtr = PALETTE_ShareLockPalette(hPal);
800  if (!palPtr) return FALSE;
801 
802  pal_entries = palPtr->NumColors;
803  if (StartIndex >= pal_entries)
804  {
806  return FALSE;
807  }
808  if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;
809 
810  for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++)
811  {
812  /* According to MSDN, only animate PC_RESERVED colours */
813  if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED)
814  {
815  memcpy( &palPtr->IndexedColors[StartIndex], pptr,
816  sizeof(PALETTEENTRY) );
817  ret++;
818  PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1);
819  }
820  }
821 
823 
824 #if 0
825 /* FIXME: This is completely broken! We cannot call UserGetDesktopWindow
826  without first acquiring the USER lock. But the whole process here is
827  screwed anyway. Instead of messing with the desktop DC, we need to
828  check, whether the palette is associated with a PDEV and whether that
829  PDEV supports palette operations. Then we need to call pfnDrvSetPalette.
830  But since IntGdiRealizePalette() is not even implemented for direct DCs,
831  we can as well just do nothing, that will at least not ASSERT!
832  I leave the whole thing here, to scare people away, who want to "fix" it. */
833 
834  /* Immediately apply the new palette if current window uses it */
835  Wnd = UserGetDesktopWindow();
836  hDC = UserGetWindowDC(Wnd);
837  dc = DC_LockDc(hDC);
838  if (NULL != dc)
839  {
840  if (dc->dclevel.hpal == hPal)
841  {
842  DC_UnlockDc(dc);
844  }
845  else
846  DC_UnlockDc(dc);
847  }
848  UserReleaseDC(Wnd,hDC, FALSE);
849 #endif // 0
850  }
851  return ret;
852 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
PALETTEENTRY * IndexedColors
Definition: palette.h:42
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:125
HDC FASTCALL UserGetWindowDC(PWND Wnd)
Definition: windc.c:946
HDC dc
Definition: cylfrac.c:34
smooth NULL
Definition: ftsmooth.c:416
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define DEFAULT_PALETTE
Definition: wingdi.h:912
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define PC_RESERVED
Definition: wingdi.h:881
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
unsigned int UINT
Definition: ndis.h:50
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:917
int pal_entries[256]
Definition: uimain.c:52
UINT FASTCALL IntGdiRealizePalette(HDC hDC)
Definition: palette.c:731

Referenced by NtGdiDoPalette().

◆ IntGdiRealizePalette()

UINT FASTCALL IntGdiRealizePalette ( HDC  hDC)

FIXME: shouldn't dereference pSurface while the PDEV is not locked

Definition at line 731 of file palette.c.

732 {
733  UINT i, realize = 0;
734  PDC pdc;
735  PALETTE *ppalSurf, *ppalDC;
736 
737  pdc = DC_LockDc(hDC);
738  if (!pdc)
739  {
741  return 0;
742  }
743 
744  if (!pdc->dclevel.pSurface)
745  {
746  goto cleanup;
747  }
748 
749  if (pdc->dctype == DCTYPE_DIRECT)
750  {
751  static BOOL g_WarnedOnce = FALSE;
752  if (!g_WarnedOnce)
753  {
754  g_WarnedOnce = TRUE;
756  }
757  goto cleanup;
758  }
759 
761  ppalSurf = pdc->dclevel.pSurface->ppal;
762  ppalDC = pdc->dclevel.ppal;
763 
764  if (!(ppalSurf->flFlags & PAL_INDEXED))
765  {
766  // FIXME: Set error?
767  goto cleanup;
768  }
769 
770  ASSERT(ppalDC->flFlags & PAL_INDEXED);
771 
772  // FIXME: Should we resize ppalSurf if it's too small?
773  realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : ppalSurf->NumColors;
774 
775  for (i=0; i<realize; i++)
776  {
777  InterlockedExchange((LONG*)&ppalSurf->IndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]);
778  }
779 
780 cleanup:
781  DC_UnlockDc(pdc);
782  return realize;
783 }
#define TRUE
Definition: types.h:120
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
PALETTEENTRY * IndexedColors
Definition: palette.h:42
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: polytest.cpp:40
#define for
Definition: utility.h:88
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
#define InterlockedExchange
Definition: armddk.h:54
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
unsigned int UINT
Definition: ndis.h:50
#define UNIMPLEMENTED
Definition: debug.h:114
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by IntAnimatePalette(), and UserRealizePalette().

◆ IntGetPaletteEntries()

UINT APIENTRY IntGetPaletteEntries ( HPALETTE  hpal,
UINT  StartIndex,
UINT  Entries,
LPPALETTEENTRY  pe 
)

Definition at line 855 of file palette.c.

860 {
861  PPALETTE palGDI;
862  UINT numEntries;
863 
864  palGDI = (PPALETTE) PALETTE_ShareLockPalette(hpal);
865  if (NULL == palGDI)
866  {
867  return 0;
868  }
869 
870  numEntries = palGDI->NumColors;
871  if (NULL != pe)
872  {
873  if (numEntries < StartIndex + Entries)
874  {
875  Entries = numEntries - StartIndex;
876  }
877  if (numEntries <= StartIndex)
878  {
880  return 0;
881  }
882  memcpy(pe, palGDI->IndexedColors + StartIndex, Entries * sizeof(PALETTEENTRY));
883  }
884  else
885  {
886  Entries = numEntries;
887  }
888 
890  return Entries;
891 }
struct _PALETTE * PPALETTE
PALETTEENTRY * IndexedColors
Definition: palette.h:42
smooth NULL
Definition: ftsmooth.c:416
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
unsigned int UINT
Definition: ndis.h:50

Referenced by NtGdiDoPalette().

◆ IntGetSystemPaletteEntries()

UINT APIENTRY IntGetSystemPaletteEntries ( HDC  hDC,
UINT  StartIndex,
UINT  Entries,
LPPALETTEENTRY  pe 
)

Definition at line 894 of file palette.c.

898 {
899  PPALETTE palGDI = NULL;
900  PDC dc = NULL;
901  UINT EntriesSize = 0;
902  UINT Ret = 0;
903 
904  if (Entries == 0)
905  {
907  return 0;
908  }
909 
910  if (pe != NULL)
911  {
912  EntriesSize = Entries * sizeof(pe[0]);
913  if (Entries != EntriesSize / sizeof(pe[0]))
914  {
915  /* Integer overflow! */
917  return 0;
918  }
919  }
920 
921  if (!(dc = DC_LockDc(hDC)))
922  {
924  return 0;
925  }
926 
927  palGDI = PALETTE_ShareLockPalette(dc->dclevel.hpal);
928  if (palGDI != NULL)
929  {
930  if (pe != NULL)
931  {
932  if (StartIndex >= palGDI->NumColors)
933  Entries = 0;
934  else if (Entries > palGDI->NumColors - StartIndex)
935  Entries = palGDI->NumColors - StartIndex;
936 
937  memcpy(pe,
938  palGDI->IndexedColors + StartIndex,
939  Entries * sizeof(pe[0]));
940 
941  Ret = Entries;
942  }
943  else
944  {
945  Ret = dc->ppdev->gdiinfo.ulNumPalReg;
946  }
947  }
948 
949  if (palGDI != NULL)
951 
952  if (dc != NULL)
953  DC_UnlockDc(dc);
954 
955  return Ret;
956 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
PALETTEENTRY * IndexedColors
Definition: palette.h:42
HDC dc
Definition: cylfrac.c:34
smooth NULL
Definition: ftsmooth.c:416
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
Definition: polytest.cpp:40
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
unsigned int UINT
Definition: ndis.h:50
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtGdiDoPalette().

◆ IntSetPaletteEntries()

UINT APIENTRY IntSetPaletteEntries ( HPALETTE  hpal,
UINT  Start,
UINT  Entries,
CONST LPPALETTEENTRY  pe 
)

Definition at line 960 of file palette.c.

965 {
966  PPALETTE palGDI;
967  ULONG numEntries;
968 
969  if ((UINT_PTR)hpal & GDI_HANDLE_STOCK_MASK)
970  {
971  return 0;
972  }
973 
974  palGDI = PALETTE_ShareLockPalette(hpal);
975  if (!palGDI) return 0;
976 
977  numEntries = palGDI->NumColors;
978  if (Start >= numEntries)
979  {
981  return 0;
982  }
983  if (numEntries < Start + Entries)
984  {
985  Entries = numEntries - Start;
986  }
987  memcpy(palGDI->IndexedColors + Start, pe, Entries * sizeof(PALETTEENTRY));
989 
990  return Entries;
991 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
Definition: partlist.h:33
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
unsigned int ULONG
Definition: retypes.h:1
#define GDI_HANDLE_STOCK_MASK
Definition: gdi.h:19

Referenced by NtGdiDoPalette().

◆ NtGdiCreateHalftonePalette()

HPALETTE APIENTRY NtGdiCreateHalftonePalette ( HDC  hDC)

Definition at line 518 of file palette.c.

519 {
520  int i, r, g, b;
521  PALETTEENTRY PalEntries[256];
522  PPALETTE ppal;
523  PDC pdc;
524  HPALETTE hpal = NULL;
525 
526  pdc = DC_LockDc(hDC);
527  if (!pdc)
528  {
530  return NULL;
531  }
532 
533  RtlZeroMemory(PalEntries, sizeof(PalEntries));
534 
535  /* First and last ten entries are default ones */
536  for (i = 0; i < 10; i++)
537  {
538  PalEntries[i].peRed = g_sysPalTemplate[i].peRed;
539  PalEntries[i].peGreen = g_sysPalTemplate[i].peGreen;
540  PalEntries[i].peBlue = g_sysPalTemplate[i].peBlue;
541 
542  PalEntries[246 + i].peRed = g_sysPalTemplate[10 + i].peRed;
543  PalEntries[246 + i].peGreen = g_sysPalTemplate[10 + i].peGreen;
544  PalEntries[246 + i].peBlue = g_sysPalTemplate[10 + i].peBlue;
545  }
546 
547  ppal = PALETTE_ShareLockPalette(pdc->dclevel.hpal);
548  if (ppal && (ppal->flFlags & PAL_INDEXED))
549  {
550  /* FIXME: optimize the palette for the current palette */
552  }
553  else
554  {
555  for (r = 0; r < 6; r++)
556  {
557  for (g = 0; g < 6; g++)
558  {
559  for (b = 0; b < 6; b++)
560  {
561  i = r + g*6 + b*36 + 10;
562  PalEntries[i].peRed = r * 51;
563  PalEntries[i].peGreen = g * 51;
564  PalEntries[i].peBlue = b * 51;
565  }
566  }
567  }
568 
569  for (i = 216; i < 246; i++)
570  {
571  int v = (i - 216) << 3;
572  PalEntries[i].peRed = v;
573  PalEntries[i].peGreen = v;
574  PalEntries[i].peBlue = v;
575  }
576  }
577 
578  if (ppal)
580 
581  DC_UnlockDc(pdc);
582 
583  ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED, 256, PalEntries, 0, 0, 0);
584  if (ppal)
585  {
586  hpal = ppal->BaseObject.hHmgr;
587  PALETTE_UnlockPalette(ppal);
588  }
589 
590  return hpal;
591 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
#define b
Definition: ke_i.h:79
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
Definition: polytest.cpp:40
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
BASEOBJECT BaseObject
Definition: palette.h:36
FLONG flFlags
Definition: palette.h:40
static HDC hDC
Definition: 3dtext.c:33
const GLdouble * v
Definition: gl.h:2040
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS]
Definition: palette.c:23

◆ NtGdiCreatePaletteInternal()

HPALETTE APIENTRY NtGdiCreatePaletteInternal ( IN LPLOGPALETTE  plogpalUser,
IN UINT  cEntries 
)

Definition at line 477 of file palette.c.

480 {
481  HPALETTE hpal = NULL;
482  PPALETTE ppal;
483  ULONG i, cjSize;
484 
486  if (ppal == NULL)
487  {
488  return NULL;
489  }
490 
491  cjSize = FIELD_OFFSET(LOGPALETTE, palPalEntry[cEntries]);
492 
493  _SEH2_TRY
494  {
495  ProbeForRead(plogpalUser, cjSize, 1);
496 
497  for (i = 0; i < cEntries; i++)
498  {
499  ppal->IndexedColors[i] = plogpalUser->palPalEntry[i];
500  }
501  }
503  {
505  _SEH2_YIELD(return NULL);
506  }
507  _SEH2_END;
508 
510  hpal = ppal->BaseObject.hHmgr;
511  PALETTE_UnlockPalette(ppal);
512 
513  return hpal;
514 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:125
_SEH2_TRY
Definition: create.c:4250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1108
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3615
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
BASEOBJECT BaseObject
Definition: palette.h:36
_SEH2_END
Definition: create.c:4424
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by CreatePalette().

◆ NtGdiDoPalette()

__kernel_entry LONG APIENTRY NtGdiDoPalette ( _In_ HGDIOBJ  hObj,
_In_ WORD  iStart,
_In_ WORD  cEntries,
_When_(bInbound!=0, _In_reads_bytes_(cEntries *sizeof(PALETTEENTRY))) _When_(bInbound==0, _Out_writes_bytes_(cEntries *sizeof(PALETTEENTRY))) LPVOID  pUnsafeEntries,
_In_ DWORD  iFunc,
_In_ BOOL  bInbound 
)

Definition at line 1077 of file palette.c.

1085 {
1086  LONG ret;
1087  LPVOID pEntries = NULL;
1088  SIZE_T cjSize;
1089 
1090  if (pUnsafeEntries)
1091  {
1092  if (cEntries == 0)
1093  return 0;
1094 
1095  cjSize = cEntries * sizeof(PALETTEENTRY);
1097  if (!pEntries)
1098  return 0;
1099 
1100  if (bInbound)
1101  {
1102  _SEH2_TRY
1103  {
1104  ProbeForRead(pUnsafeEntries, cjSize, 1);
1105  memcpy(pEntries, pUnsafeEntries, cjSize);
1106  }
1108  {
1109  ExFreePoolWithTag(pEntries, TAG_PALETTE);
1110  _SEH2_YIELD(return 0);
1111  }
1112  _SEH2_END
1113  }
1114  else
1115  {
1116  /* Zero it out, so we don't accidentally leak kernel data */
1117  RtlZeroMemory(pEntries, cjSize);
1118  }
1119  }
1120 
1121  ret = 0;
1122  switch(iFunc)
1123  {
1124  case GdiPalAnimate:
1125  if (pEntries)
1126  ret = IntAnimatePalette((HPALETTE)hObj, iStart, cEntries, (CONST PPALETTEENTRY)pEntries);
1127  break;
1128 
1129  case GdiPalSetEntries:
1130  if (pEntries)
1131  ret = IntSetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (CONST LPPALETTEENTRY)pEntries);
1132  break;
1133 
1134  case GdiPalGetEntries:
1135  ret = IntGetPaletteEntries((HPALETTE)hObj, iStart, cEntries, (LPPALETTEENTRY)pEntries);
1136  break;
1137 
1140  break;
1141 
1142  case GdiPalSetColorTable:
1143  if (pEntries)
1144  ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, TRUE);
1145  break;
1146 
1147  case GdiPalGetColorTable:
1148  if (pEntries)
1149  ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, FALSE);
1150  break;
1151  }
1152 
1153  if (pEntries)
1154  {
1155  if (!bInbound && (ret > 0))
1156  {
1157  cjSize = min(cEntries, ret) * sizeof(PALETTEENTRY);
1158  _SEH2_TRY
1159  {
1160  ProbeForWrite(pUnsafeEntries, cjSize, 1);
1161  memcpy(pUnsafeEntries, pEntries, cjSize);
1162  }
1164  {
1165  ret = 0;
1166  }
1167  _SEH2_END
1168  }
1169  ExFreePoolWithTag(pEntries, TAG_PALETTE);
1170  }
1171 
1172  return ret;
1173 }
#define TRUE
Definition: types.h:120
UINT APIENTRY IntGetSystemPaletteEntries(HDC hDC, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
Definition: palette.c:894
static HDC
Definition: imagelist.c:92
ULONG APIENTRY GreGetSetColorTable(HDC hdc, ULONG iStartIndex, ULONG cEntries, RGBQUAD *prgbColors, BOOL bSet)
Definition: palette.c:995
_In_ UINT iStart
Definition: wingdi.h:3615
UINT APIENTRY IntAnimatePalette(HPALETTE hPal, UINT StartIndex, UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
Definition: palette.c:786
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
long LONG
Definition: pedump.c:60
UINT APIENTRY IntGetPaletteEntries(HPALETTE hpal, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
Definition: palette.c:855
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
UINT APIENTRY IntSetPaletteEntries(HPALETTE hpal, UINT Start, UINT Entries, CONST LPPALETTEENTRY pe)
Definition: palette.c:960
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3615
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
int ret
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TAG_PALETTE
Definition: tags.h:26
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_SEH2_END
Definition: create.c:4424
#define min(a, b)
Definition: monoChain.cc:55
_In_ ULONG cjSize
Definition: winddi.h:3634
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct tagPALETTEENTRY PALETTEENTRY
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define CONST
Definition: pedump.c:81

Referenced by AnimatePalette(), GetDIBColorTable(), GetPaletteEntries(), GetSystemPaletteEntries(), SetDIBColorTable(), SetPaletteEntries(), Test_NtGdiDoPalette_GdiPalAnimate(), Test_NtGdiDoPalette_GdiPalGetEntries(), Test_NtGdiDoPalette_GdiPalSetEntries(), and Test_NtGdiDoPalette_SetDIBColorTable().

◆ NtGdiEngCreatePalette()

__kernel_entry HPALETTE APIENTRY NtGdiEngCreatePalette ( _In_ ULONG  iMode,
_In_ ULONG  cColors,
_In_ ULONG pulColors,
_In_ FLONG  flRed,
_In_ FLONG  flGreen,
_In_ FLONG  flBlue 
)

Definition at line 1272 of file palette.c.

1279 {
1280  HPALETTE hPal = NULL;
1281  ULONG *pulcSafe, ulColors[WINDDI_MAXSETPALETTECOLORS];
1282 
1283  if ( cColors > MAX_PALCOLORS ) return NULL;
1284 
1285  if ( cColors <= WINDDI_MAXSETPALETTECOLORS )
1286  {
1287  pulcSafe = ulColors;
1288  }
1289  else
1290  {
1291  pulcSafe = ExAllocatePoolWithTag(PagedPool, cColors * sizeof(ULONG), GDITAG_UMPD );
1292  }
1293 
1294  _SEH2_TRY
1295  {
1296  ProbeForRead( pulColors, cColors * sizeof(ULONG), 1);
1297  RtlCopyMemory( pulcSafe, pulColors, cColors * sizeof(ULONG) );
1298  }
1300  {
1302  if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD );
1303  _SEH2_YIELD(return hPal);
1304  }
1305  _SEH2_END;
1306 
1307  hPal = EngCreatePalette( iMode/*|PAL_SETPOWNER*/, cColors, pulcSafe, flRed, flGreen, flBlue );
1308 
1309  if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD );
1310 
1311  return hPal;
1312 }
#define GDITAG_UMPD
Definition: tags.h:174
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG iMode
Definition: winddi.h:3520
#define MAX_PALCOLORS
Definition: palette.c:16
_SEH2_TRY
Definition: create.c:4250
HPALETTE APIENTRY EngCreatePalette(ULONG iMode, ULONG cColors, ULONG *pulColors, ULONG flRed, ULONG flGreen, ULONG flBlue)
Definition: palette.c:375
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define WINDDI_MAXSETPALETTECOLORS
Definition: winddi.h:4006
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by START_TEST().

◆ NtGdiEngDeletePalette()

__kernel_entry BOOL APIENTRY NtGdiEngDeletePalette ( _In_ HPALETTE  hPal)

Definition at line 1317 of file palette.c.

1319 {
1320  return EngDeletePalette(hPal);
1321 }
BOOL APIENTRY EngDeletePalette(IN HPALETTE hpal)
Definition: palette.c:406

◆ NtGdiGetColorAdjustment()

BOOL APIENTRY NtGdiGetColorAdjustment ( HDC  hdc,
LPCOLORADJUSTMENT  pca 
)

Definition at line 642 of file palette.c.

645 {
647  return FALSE;
648 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ NtGdiGetNearestColor()

COLORREF APIENTRY NtGdiGetNearestColor ( _In_ HDC  hDC,
_In_ COLORREF  Color 
)

FIXME: shouldn't dereference pSurface while the PDEV is not locked

Definition at line 662 of file palette.c.

665 {
666  COLORREF nearest = CLR_INVALID;
667  PDC dc;
668  EXLATEOBJ exlo;
669  PPALETTE ppal;
670 
671  dc = DC_LockDc(hDC);
672 
673  if(dc == NULL)
674  {
676  return CLR_INVALID;
677  }
678 
680  if(dc->dclevel.pSurface == NULL)
681  ppal = gppalMono;
682  else
683  ppal = dc->dclevel.pSurface->ppal;
684 
685  /* Translate the color to the DC format */
687 
688  /* XLATE it back to RGB color space */
689  EXLATEOBJ_vInitialize(&exlo,
690  ppal,
691  &gpalRGB,
692  0,
693  RGB(0xff, 0xff, 0xff),
694  RGB(0, 0, 0));
695 
696  nearest = XLATEOBJ_iXlate(&exlo.xlo, Color);
697 
698  EXLATEOBJ_vCleanup(&exlo);
699 
700  /* We're done */
701  DC_UnlockDc(dc);
702 
703  return nearest;
704 }
ULONG TranslateCOLORREF(PDC pdc, COLORREF crColor)
Definition: dcutil.c:864
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
PALETTE * gppalMono
Definition: palette.c:20
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define CLR_INVALID
Definition: wingdi.h:882
HDC dc
Definition: cylfrac.c:34
XLATEOBJ xlo
Definition: xlateobj.h:21
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
Definition: polytest.cpp:40
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2935
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PALETTE gpalRGB
Definition: palette.c:20
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiGetNearestPaletteIndex()

UINT APIENTRY NtGdiGetNearestPaletteIndex ( HPALETTE  hpal,
COLORREF  crColor 
)

Definition at line 708 of file palette.c.

711 {
712  PPALETTE ppal = PALETTE_ShareLockPalette(hpal);
713  UINT index = 0;
714 
715  if (ppal)
716  {
717  if (ppal->flFlags & PAL_INDEXED)
718  {
719  /* Return closest match for the given RGB color */
720  index = PALETTE_ulGetNearestPaletteIndex(ppal, crColor);
721  }
722  // else SetLastError ?
724  }
725 
726  return index;
727 }
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex(PALETTE *ppal, ULONG iColor)
Definition: palette.c:261
GLuint index
Definition: glext.h:6031
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define index(s, c)
Definition: various.h:29
FLONG flFlags
Definition: palette.h:40
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
unsigned int UINT
Definition: ndis.h:50

◆ NtGdiGetSystemPaletteUse()

UINT APIENTRY NtGdiGetSystemPaletteUse ( HDC  hDC)

Definition at line 1203 of file palette.c.

1204 {
1205  return SystemPaletteUse;
1206 }
static UINT SystemPaletteUse
Definition: palette.c:18

◆ NtGdiResizePalette()

BOOL APIENTRY NtGdiResizePalette ( HPALETTE  hpal,
UINT  Entries 
)

Definition at line 595 of file palette.c.

598 {
599 /* PALOBJ *palPtr = (PALOBJ*)AccessUserObject(hPal);
600  UINT cPrevEnt, prevVer;
601  INT prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
602  XLATEOBJ *XlateObj = NULL;
603 
604  if(!palPtr) return FALSE;
605  cPrevEnt = palPtr->logpalette->palNumEntries;
606  prevVer = palPtr->logpalette->palVersion;
607  prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) + sizeof(int*) + sizeof(GDIOBJHDR);
608  size += sizeof(int*) + sizeof(GDIOBJHDR);
609  XlateObj = palPtr->logicalToSystem;
610 
611  if (!(palPtr = GDI_ReallocObject(size, hPal, palPtr))) return FALSE;
612 
613  if(XlateObj)
614  {
615  XLATEOBJ *NewXlateObj = (int*) HeapReAlloc(GetProcessHeap(), 0, XlateObj, cEntries * sizeof(int));
616  if(NewXlateObj == NULL)
617  {
618  ERR("Can not resize logicalToSystem -- out of memory!");
619  GDI_ReleaseObj( hPal );
620  return FALSE;
621  }
622  palPtr->logicalToSystem = NewXlateObj;
623  }
624 
625  if(cEntries > cPrevEnt)
626  {
627  if(XlateObj) memset(palPtr->logicalToSystem + cPrevEnt, 0, (cEntries - cPrevEnt)*sizeof(int));
628  memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
629  PALETTE_ValidateFlags((PALETTEENTRY*)((BYTE*)palPtr + prevsize), cEntries - cPrevEnt );
630  }
631  palPtr->logpalette->palNumEntries = cEntries;
632  palPtr->logpalette->palVersion = prevVer;
633 // GDI_ReleaseObj( hPal );
634  return TRUE; */
635 
637  return FALSE;
638 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by ResizePalette().

◆ NtGdiSetColorAdjustment()

BOOL APIENTRY NtGdiSetColorAdjustment ( HDC  hdc,
LPCOLORADJUSTMENT  pca 
)

Definition at line 652 of file palette.c.

655 {
657  return FALSE;
658 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ NtGdiSetSystemPaletteUse()

UINT APIENTRY NtGdiSetSystemPaletteUse ( HDC  hDC,
UINT  Usage 
)

Definition at line 1176 of file palette.c.

1177 {
1178  UINT old = SystemPaletteUse;
1179 
1180  /* Device doesn't support colour palettes */
1182  return SYSPAL_ERROR;
1183  }
1184 
1185  switch (Usage)
1186  {
1187  case SYSPAL_NOSTATIC:
1188  case SYSPAL_NOSTATIC256:
1189  case SYSPAL_STATIC:
1191  break;
1192 
1193  default:
1194  old=SYSPAL_ERROR;
1195  break;
1196  }
1197 
1198  return old;
1199 }
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
static UINT SystemPaletteUse
Definition: palette.c:18
#define SYSPAL_ERROR
Definition: wingdi.h:926
#define RASTERCAPS
Definition: wingdi.h:744
#define SYSPAL_NOSTATIC256
Definition: wingdi.h:21
#define RC_PALETTE
Definition: wingdi.h:789
#define SYSPAL_STATIC
Definition: wingdi.h:925
#define SYSPAL_NOSTATIC
Definition: wingdi.h:924
static HDC hDC
Definition: 3dtext.c:33
unsigned int UINT
Definition: ndis.h:50
__kernel_entry W32KAPI INT APIENTRY NtGdiGetDeviceCaps(_In_ HDC hdc, _In_ INT i)

◆ NtGdiUnrealizeObject()

BOOL APIENTRY NtGdiUnrealizeObject ( HGDIOBJ  hgdiobj)

Definition at line 1247 of file palette.c.

1248 {
1249  BOOL Ret = FALSE;
1250  PPALETTE palGDI;
1251 
1252  if ( !hgdiobj ||
1253  ((UINT_PTR)hgdiobj & GDI_HANDLE_STOCK_MASK) ||
1255  return Ret;
1256 
1257  palGDI = PALETTE_ShareLockPalette(hgdiobj);
1258  if (!palGDI) return FALSE;
1259 
1260  // FIXME!!
1261  // Need to do something!!!
1262  // Zero out Current and Old Translated pointers?
1263  //
1264  Ret = TRUE;
1266  return Ret;
1267 }
#define GDI_HANDLE_IS_TYPE(h, t)
Definition: gdi.h:34
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GDI_OBJECT_TYPE_PALETTE
Definition: gdi.h:49
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define GDI_HANDLE_STOCK_MASK
Definition: gdi.h:19

◆ NtGdiUpdateColors()

BOOL APIENTRY NtGdiUpdateColors ( HDC  hDC)

Definition at line 1210 of file palette.c.

1211 {
1212  PWND Wnd;
1213  BOOL calledFromUser, ret;
1215 
1216  calledFromUser = UserIsEntered();
1217 
1218  if (!calledFromUser){
1220  }
1221 
1223  if (Wnd == NULL)
1224  {
1226 
1227  if (!calledFromUser){
1228  UserLeave();
1229  }
1230 
1231  return FALSE;
1232  }
1233 
1234  UserRefObjectCo(Wnd, &Ref);
1236  UserDerefObjectCo(Wnd);
1237 
1238  if (!calledFromUser){
1239  UserLeave();
1240  }
1241 
1242  return ret;
1243 }
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:225
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
unsigned int BOOL
Definition: ntddk_ex.h:94
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
Definition: object.h:3
smooth NULL
Definition: ftsmooth.c:416
HWND FASTCALL IntWindowFromDC(HDC hDc)
Definition: windc.c:893
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
int ret
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static HDC hDC
Definition: 3dtext.c:33
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:876
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define RDW_INVALIDATE
Definition: winuser.h:1200

Referenced by UpdateColors().

◆ PALETTE_AllocPalette()

PPALETTE NTAPI PALETTE_AllocPalette ( _In_ ULONG  iMode,
_In_ ULONG  cColors,
_In_opt_ const PALETTEENTRY pEntries,
_In_ FLONG  flRed,
_In_ FLONG  flGreen,
_In_ FLONG  flBlue 
)

Definition at line 135 of file palette.c.

142 {
143  PPALETTE ppal;
144  ULONG fl = 0, cjSize = sizeof(PALETTE);
145 
146  /* Check if the palette has entries */
147  if (iMode & PAL_INDEXED)
148  {
149  /* Check color count */
150  if ((cColors == 0) || (cColors > 1024)) return NULL;
151 
152  /* Allocate enough space for the palete entries */
153  cjSize += cColors * sizeof(PALETTEENTRY);
154  }
155  else
156  {
157  /* There are no palette entries */
158  cColors = 0;
159 
160  /* We can use the lookaside list */
162  }
163 
164  /* Allocate the object (without a handle!) */
166  if (!ppal)
167  {
168  return NULL;
169  }
170 
171  /* Set mode, color count and entry pointer */
172  ppal->flFlags = iMode;
173  ppal->NumColors = cColors;
174  ppal->IndexedColors = ppal->apalColors;
175 
176  /* Check what kind of palette this is */
177  if (iMode & PAL_INDEXED)
178  {
179  /* Check if we got a color array */
180  if (pEntries)
181  {
182  /* Copy the entries */
183  RtlCopyMemory(ppal->IndexedColors, pEntries, cColors * sizeof(pEntries[0]));
184  }
185  }
186  else if (iMode & PAL_BITFIELDS)
187  {
188  /* Copy the color masks */
189  ppal->RedMask = flRed;
190  ppal->GreenMask = flGreen;
191  ppal->BlueMask = flBlue;
192 
193  /* Check what masks we have and set optimization flags */
194  if ((flRed == 0x7c00) && (flGreen == 0x3E0) && (flBlue == 0x1F))
195  ppal->flFlags |= PAL_RGB16_555;
196  else if ((flRed == 0xF800) && (flGreen == 0x7E0) && (flBlue == 0x1F))
197  ppal->flFlags |= PAL_RGB16_565;
198  else if ((flRed == 0xFF0000) && (flGreen == 0xFF00) && (flBlue == 0xFF))
199  ppal->flFlags |= PAL_BGR;
200  else if ((flRed == 0xFF) && (flGreen == 0xFF00) && (flBlue == 0xFF0000))
201  ppal->flFlags |= PAL_RGB;
202  }
203 
204  return ppal;
205 }
struct _PALETTE * PPALETTE
PALETTEENTRY apalColors[0]
Definition: palette.h:50
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _PALETTE PALETTE
_In_ ULONG iMode
Definition: winddi.h:3520
PALETTEENTRY * IndexedColors
Definition: palette.h:42
_In_ FLONG fl
Definition: winddi.h:1279
ULONG RedMask
Definition: palette.h:43
smooth NULL
Definition: ftsmooth.c:416
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634
struct tagPALETTEENTRY PALETTEENTRY
POBJ NTAPI GDIOBJ_AllocateObject(UCHAR objt, ULONG cjSize, FLONG fl)
Definition: gdiobj.c:559

Referenced by CreateDIBPalette(), EngCreatePalette(), FixupDIBBrushPalette(), InitPaletteImpl(), NtGdiDdDDICreateDCFromMemory(), and PALETTE_AllocPalWithHandle().

◆ PALETTE_AllocPalWithHandle()

PPALETTE NTAPI PALETTE_AllocPalWithHandle ( _In_ ULONG  iMode,
_In_ ULONG  cColors,
_In_opt_ const PALETTEENTRY pEntries,
_In_ FLONG  flRed,
_In_ FLONG  flGreen,
_In_ FLONG  flBlue 
)

Definition at line 209 of file palette.c.

216 {
217  PPALETTE ppal;
218 
219  /* Allocate the palette without a handle */
220  ppal = PALETTE_AllocPalette(iMode, cColors, pEntries, flRed, flGreen, flBlue);
221  if (!ppal) return NULL;
222 
223  /* Insert the palette into the handle table */
225  {
226  DPRINT1("Could not insert palette into handle table.\n");
228  return NULL;
229  }
230 
231  return ppal;
232 }
_In_ ULONG iMode
Definition: winddi.h:3520
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
smooth NULL
Definition: ftsmooth.c:416
BASEOBJECT BaseObject
Definition: palette.h:36
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
Definition: gdiobj.c:593
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
Definition: gdiobj.c:909

Referenced by DIB_MapPaletteColors(), GreCreatePaletteInternal(), InitPaletteImpl(), NtGdiCreateHalftonePalette(), and NtGdiCreatePaletteInternal().

◆ PALETTE_GetObject()

INT FASTCALL PALETTE_GetObject ( PPALETTE  ppal,
INT  cbCount,
LPLOGBRUSH  lpBuffer 
)

Definition at line 247 of file palette.c.

248 {
249  if (!lpBuffer)
250  {
251  return sizeof(WORD);
252  }
253 
254  if ((UINT)cbCount < sizeof(WORD)) return 0;
255  *((WORD*)lpBuffer) = (WORD)ppal->NumColors;
256  return sizeof(WORD);
257 }
static int cbCount
Definition: fiber.c:42
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
unsigned short WORD
Definition: ntddk_ex.h:93
ULONG NumColors
Definition: palette.h:41
unsigned int UINT
Definition: ndis.h:50

Referenced by GreGetObject().

◆ PALETTE_ulGetNearestBitFieldsIndex()

ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex ( PALETTE ppal,
ULONG  ulColor 
)

Definition at line 294 of file palette.c.

295 {
296  ULONG ulNewColor;
297 
298  // FIXME: HACK, should be stored already
299  ppal->ulRedShift = CalculateShift(RGB(0xff,0,0), ppal->RedMask);
300  ppal->ulGreenShift = CalculateShift(RGB(0,0xff,0), ppal->GreenMask);
301  ppal->ulBlueShift = CalculateShift(RGB(0,0,0xff), ppal->BlueMask);
302 
303  ulNewColor = _rotl(ulColor, ppal->ulRedShift) & ppal->RedMask;
304  ulNewColor |= _rotl(ulColor, ppal->ulGreenShift) & ppal->GreenMask;
305  ulNewColor |= _rotl(ulColor, ppal->ulBlueShift) & ppal->BlueMask;
306 
307  return ulNewColor;
308 }
ULONG ulBlueShift
Definition: palette.h:48
ULONG ulGreenShift
Definition: palette.h:47
ULONG ulRedShift
Definition: palette.h:46
ULONG RedMask
Definition: palette.h:43
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
#define RGB(r, g, b)
Definition: wingdi.h:2935
_Check_return_ unsigned int __cdecl _rotl(_In_ unsigned int _Value, _In_ int _Shift)
FORCEINLINE ULONG CalculateShift(ULONG ulMask1, ULONG ulMask2)
Definition: palette.h:130
unsigned int ULONG
Definition: retypes.h:1

Referenced by EXLATEOBJ_vInitialize(), and PALETTE_ulGetNearestIndex().

◆ PALETTE_ulGetNearestIndex()

ULONG NTAPI PALETTE_ulGetNearestIndex ( PALETTE ppal,
ULONG  ulColor 
)

Definition at line 312 of file palette.c.

313 {
314  if (ppal->flFlags & PAL_INDEXED) // Use fl & PALINDEXED
315  return PALETTE_ulGetNearestPaletteIndex(ppal, ulColor);
316  else
317  return PALETTE_ulGetNearestBitFieldsIndex(ppal, ulColor);
318 }
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex(PALETTE *ppal, ULONG iColor)
Definition: palette.c:261
FLONG flFlags
Definition: palette.h:40
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex(PALETTE *ppal, ULONG ulColor)
Definition: palette.c:294

Referenced by EXLATEOBJ_vInitialize(), and TranslateCOLORREF().

◆ PALETTE_ulGetNearestPaletteIndex()

ULONG NTAPI PALETTE_ulGetNearestPaletteIndex ( PALETTE ppal,
ULONG  iColor 
)

Definition at line 261 of file palette.c.

262 {
263  ULONG ulDiff, ulColorDiff, ulMinimalDiff = 0xFFFFFF;
264  ULONG i, ulBestIndex = 0;
265  PALETTEENTRY peColor = *(PPALETTEENTRY)&iColor;
266 
267  /* Loop all palette entries */
268  for (i = 0; i < ppal->NumColors; i++)
269  {
270  /* Calculate distance in the color cube */
271  ulDiff = peColor.peRed - ppal->IndexedColors[i].peRed;
272  ulColorDiff = ulDiff * ulDiff;
273  ulDiff = peColor.peGreen - ppal->IndexedColors[i].peGreen;
274  ulColorDiff += ulDiff * ulDiff;
275  ulDiff = peColor.peBlue - ppal->IndexedColors[i].peBlue;
276  ulColorDiff += ulDiff * ulDiff;
277 
278  /* Check for a better match */
279  if (ulColorDiff < ulMinimalDiff)
280  {
281  ulBestIndex = i;
282  ulMinimalDiff = ulColorDiff;
283 
284  /* Break on exact match */
285  if (ulMinimalDiff == 0) break;
286  }
287  }
288 
289  return ulBestIndex;
290 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG NumColors
Definition: palette.h:41
unsigned int ULONG
Definition: retypes.h:1
struct tagPALETTEENTRY * PPALETTEENTRY
_In_ ULONG iColor
Definition: xlateobj.h:17

Referenced by EXLATEOBJ_vInitialize(), NtGdiGetNearestPaletteIndex(), and PALETTE_ulGetNearestIndex().

◆ PALETTE_ValidateFlags()

VOID FASTCALL PALETTE_ValidateFlags ( PALETTEENTRY lpPalE,
INT  size 
)

Definition at line 125 of file palette.c.

126 {
127  int i = 0;
128  for (; i<size ; i++)
129  lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07);
130 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizeiptr size
Definition: glext.h:5919
#define PC_SYS_USED
Definition: color.h:3

Referenced by GreCreatePaletteInternal(), IntAnimatePalette(), and NtGdiCreatePaletteInternal().

◆ PALETTE_vCleanup()

VOID NTAPI PALETTE_vCleanup ( PVOID  ObjectBody)

Definition at line 236 of file palette.c.

237 {
238  PPALETTE pPal = (PPALETTE)ObjectBody;
239  if (pPal->IndexedColors && pPal->IndexedColors != pPal->apalColors)
240  {
242  }
243 }
struct _PALETTE * PPALETTE
PALETTEENTRY apalColors[0]
Definition: palette.h:50
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define TAG_PALETTE
Definition: tags.h:26
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ PALETTE_vGetBitMasks()

VOID NTAPI PALETTE_vGetBitMasks ( PPALETTE  ppal,
PULONG  pulColors 
)

Definition at line 322 of file palette.c.

323 {
324  ASSERT(pulColors);
325 
326  if (ppal->flFlags & PAL_INDEXED || ppal->flFlags & PAL_RGB)
327  {
328  pulColors[0] = RGB(0xFF, 0x00, 0x00);
329  pulColors[1] = RGB(0x00, 0xFF, 0x00);
330  pulColors[2] = RGB(0x00, 0x00, 0xFF);
331  }
332  else if (ppal->flFlags & PAL_BGR)
333  {
334  pulColors[0] = RGB(0x00, 0x00, 0xFF);
335  pulColors[1] = RGB(0x00, 0xFF, 0x00);
336  pulColors[2] = RGB(0xFF, 0x00, 0x00);
337  }
338  else if (ppal->flFlags & PAL_BITFIELDS)
339  {
340  pulColors[0] = ppal->RedMask;
341  pulColors[1] = ppal->GreenMask;
342  pulColors[2] = ppal->BlueMask;
343  }
344 }
ULONG RedMask
Definition: palette.h:43
ULONG BlueMask
Definition: palette.h:45
ULONG GreenMask
Definition: palette.h:44
#define RGB(r, g, b)
Definition: wingdi.h:2935
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
FLONG flFlags
Definition: palette.h:40

Referenced by EXLATEOBJ_vInitialize().

◆ PALOBJ_cGetColors()

ULONG APIENTRY PALOBJ_cGetColors ( PALOBJ PalObj,
ULONG  Start,
ULONG  Colors,
ULONG PaletteEntry 
)

Definition at line 423 of file palette.c.

424 {
425  PALETTE *PalGDI;
426 
427  PalGDI = (PALETTE*)PalObj;
428 
429  if (Start >= PalGDI->NumColors)
430  return 0;
431 
432  Colors = min(Colors, PalGDI->NumColors - Start);
433 
434  /* NOTE: PaletteEntry ULONGs are in the same order as PALETTEENTRY. */
435  RtlCopyMemory(PaletteEntry, PalGDI->IndexedColors + Start, sizeof(ULONG) * Colors);
436 
437  if (PalGDI->flFlags & PAL_GAMMACORRECTION)
438  ColorCorrection(PalGDI, (PPALETTEENTRY)PaletteEntry, Colors);
439 
440  return Colors;
441 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PALETTEENTRY * IndexedColors
Definition: palette.h:42
Colors
Definition: ansiprsr.h:4
Definition: partlist.h:33
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL ColorCorrection(PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors)
Definition: palette.c:348

Referenced by DrvSetPalette().

Variable Documentation

◆ appalSurfaceDefault

PPALETTE appalSurfaceDefault[11]

Definition at line 21 of file palette.c.

Referenced by InitPaletteImpl(), and SURFACE_AllocSurface().

◆ g_sysPalTemplate

Initial value:
=
{
{ 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 },
{ 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 }
}
#define PC_SYS_USED
Definition: color.h:3

Definition at line 23 of file palette.c.

Referenced by InitPaletteImpl(), and NtGdiCreateHalftonePalette().

◆ gpalBGR

PALETTE gpalBGR

Definition at line 20 of file palette.c.

Referenced by InitPaletteImpl().

◆ gpalRGB

◆ gpalRGB555

PALETTE gpalRGB555

Definition at line 20 of file palette.c.

Referenced by InitPaletteImpl().

◆ gpalRGB565

PALETTE gpalRGB565

Definition at line 20 of file palette.c.

Referenced by InitPaletteImpl().

◆ gppalDefault

PALETTE * gppalDefault

Definition at line 20 of file palette.c.

Referenced by CreateDIBPalette(), CreateStockObjects(), EBRUSHOBJ_vInit(), and InitPaletteImpl().

◆ gppalMono

◆ SystemPaletteUse

UINT SystemPaletteUse = SYSPAL_NOSTATIC
static

Definition at line 18 of file palette.c.

Referenced by NtGdiGetSystemPaletteUse(), and NtGdiSetSystemPaletteUse().