ReactOS  0.4.14-dev-552-g2fad488
palette.c File Reference
#include "framebuf.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Functions

BOOL IntInitDefaultPalette (PPDEV ppdev, PDEVINFO pDevInfo)
 
BOOL APIENTRY IntSetPalette (IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
 
BOOL APIENTRY DrvSetPalette (IN DHPDEV dhpdev, IN PALOBJ *ppalo, IN FLONG fl, IN ULONG iStart, IN ULONG cColors)
 

Variables

const PALETTEENTRY BASEPALETTE [20]
 

Function Documentation

◆ DrvSetPalette()

BOOL APIENTRY DrvSetPalette ( IN DHPDEV  dhpdev,
IN PALOBJ ppalo,
IN FLONG  fl,
IN ULONG  iStart,
IN ULONG  cColors 
)

Definition at line 170 of file palette.c.

176 {
177  PPALETTEENTRY PaletteEntries;
178  BOOL bRet;
179 
180  if (cColors == 0)
181  return FALSE;
182 
183  PaletteEntries = EngAllocMem(0, cColors * sizeof(ULONG), ALLOC_TAG);
184  if (PaletteEntries == NULL)
185  {
186  return FALSE;
187  }
188 
189  if (PALOBJ_cGetColors(ppalo, iStart, cColors, (PULONG)PaletteEntries) !=
190  cColors)
191  {
192  EngFreeMem(PaletteEntries);
193  return FALSE;
194  }
195 
196  bRet = IntSetPalette(dhpdev, PaletteEntries, iStart, cColors);
197  EngFreeMem(PaletteEntries);
198  return bRet;
199 }
#define EngFreeMem
Definition: polytest.cpp:56
_In_ UINT iStart
Definition: wingdi.h:3619
ULONG APIENTRY PALOBJ_cGetColors(PALOBJ *PalObj, ULONG Start, ULONG Colors, ULONG *PaletteEntry)
Definition: palette.c:423
#define ALLOC_TAG
Definition: btrfs_drv.h:91
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_In_ PALOBJ * ppalo
Definition: winddi.h:4012
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
BOOL APIENTRY IntSetPalette(IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
Definition: palette.c:110
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

◆ IntInitDefaultPalette()

BOOL IntInitDefaultPalette ( PPDEV  ppdev,
PDEVINFO  pDevInfo 
)

Definition at line 60 of file palette.c.

63 {
64  ULONG ColorLoop;
65  PPALETTEENTRY PaletteEntryPtr;
66 
67  if (ppdev->BitsPerPixel > 8)
68  {
69  ppdev->DefaultPalette = pDevInfo->hpalDefault =
71  ppdev->RedMask, ppdev->GreenMask, ppdev->BlueMask);
72  }
73  else
74  {
75  ppdev->PaletteEntries = EngAllocMem(0, sizeof(PALETTEENTRY) << 8, ALLOC_TAG);
76  if (ppdev->PaletteEntries == NULL)
77  {
78  return FALSE;
79  }
80 
81  for (ColorLoop = 256, PaletteEntryPtr = ppdev->PaletteEntries;
82  ColorLoop != 0;
83  ColorLoop--, PaletteEntryPtr++)
84  {
85  PaletteEntryPtr->peRed = ((ColorLoop >> 5) & 7) * 255 / 7;
86  PaletteEntryPtr->peGreen = ((ColorLoop >> 3) & 3) * 255 / 3;
87  PaletteEntryPtr->peBlue = (ColorLoop & 7) * 255 / 7;
88  PaletteEntryPtr->peFlags = 0;
89  }
90 
91  memcpy(ppdev->PaletteEntries, BASEPALETTE, 10 * sizeof(PALETTEENTRY));
92  memcpy(ppdev->PaletteEntries + 246, BASEPALETTE + 10, 10 * sizeof(PALETTEENTRY));
93 
94  ppdev->DefaultPalette = pDevInfo->hpalDefault =
95  EngCreatePalette(PAL_INDEXED, 256, (PULONG)ppdev->PaletteEntries, 0, 0, 0);
96  }
97 
98  return ppdev->DefaultPalette != NULL;
99 }
PALETTEENTRY * PaletteEntries
Definition: framebuf.h:49
ULONG GreenMask
Definition: framebuf.h:44
#define ALLOC_TAG
Definition: btrfs_drv.h:91
HPALETTE APIENTRY EngCreatePalette(ULONG iMode, ULONG cColors, ULONG *pulColors, ULONG flRed, ULONG flGreen, ULONG flBlue)
Definition: palette.c:375
ULONG BlueMask
Definition: framebuf.h:45
const PALETTEENTRY BASEPALETTE[20]
Definition: palette.c:28
BYTE BitsPerPixel
Definition: framebuf.h:42
HPALETTE hpalDefault
Definition: winddi.h:398
smooth NULL
Definition: ftsmooth.c:416
ULONG RedMask
Definition: framebuf.h:43
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HPALETTE DefaultPalette
Definition: framebuf.h:48
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

◆ IntSetPalette()

BOOL APIENTRY IntSetPalette ( IN DHPDEV  dhpdev,
IN PPALETTEENTRY  ppalent,
IN ULONG  iStart,
IN ULONG  cColors 
)

Definition at line 110 of file palette.c.

115 {
116  PVIDEO_CLUT pClut;
117  ULONG ClutSize;
118 
119  ClutSize = sizeof(VIDEO_CLUT) + (cColors * sizeof(ULONG));
120  pClut = EngAllocMem(0, ClutSize, ALLOC_TAG);
121  pClut->FirstEntry = iStart;
122  pClut->NumEntries = cColors;
123  memcpy(&pClut->LookupTable[0].RgbLong, ppalent, sizeof(ULONG) * cColors);
124 
125  if (((PPDEV)dhpdev)->PaletteShift)
126  {
127  while (cColors--)
128  {
129  pClut->LookupTable[cColors].RgbArray.Red >>= ((PPDEV)dhpdev)->PaletteShift;
130  pClut->LookupTable[cColors].RgbArray.Green >>= ((PPDEV)dhpdev)->PaletteShift;
131  pClut->LookupTable[cColors].RgbArray.Blue >>= ((PPDEV)dhpdev)->PaletteShift;
132  pClut->LookupTable[cColors].RgbArray.Unused = 0;
133  }
134  }
135  else
136  {
137  while (cColors--)
138  {
139  pClut->LookupTable[cColors].RgbArray.Unused = 0;
140  }
141  }
142 
143  /*
144  * Set the palette registers.
145  */
146 
147  if (EngDeviceIoControl(((PPDEV)dhpdev)->hDriver, IOCTL_VIDEO_SET_COLOR_REGISTERS,
148  pClut, ClutSize, NULL, 0, &cColors))
149  {
150  EngFreeMem(pClut);
151  return FALSE;
152  }
153 
154  EngFreeMem(pClut);
155  return TRUE;
156 }
#define TRUE
Definition: types.h:120
ULONG RgbLong
Definition: ntddvdeo.h:523
#define EngFreeMem
Definition: polytest.cpp:56
USHORT FirstEntry
Definition: ntddvdeo.h:520
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
_In_ UINT iStart
Definition: wingdi.h:3619
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:522
#define ALLOC_TAG
Definition: btrfs_drv.h:91
smooth NULL
Definition: ftsmooth.c:416
USHORT NumEntries
Definition: ntddvdeo.h:519
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
struct _PDEV * PPDEV
Definition: framebuf.h:33
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int ULONG
Definition: retypes.h:1
union VIDEO_CLUT::@3066 LookupTable[1]
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149

Referenced by DrvSetPalette().

Variable Documentation

◆ BASEPALETTE

const PALETTEENTRY BASEPALETTE[20]
Initial value:
=
{
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x80, 0x00, 0x00, 0x00 },
{ 0x00, 0x80, 0x00, 0x00 },
{ 0x80, 0x80, 0x00, 0x00 },
{ 0x00, 0x00, 0x80, 0x00 },
{ 0x80, 0x00, 0x80, 0x00 },
{ 0x00, 0x80, 0x80, 0x00 },
{ 0xC0, 0xC0, 0xC0, 0x00 },
{ 0xC0, 0xDC, 0xC0, 0x00 },
{ 0xD4, 0xD0, 0xC8, 0x00 },
{ 0xFF, 0xFB, 0xF0, 0x00 },
{ 0x3A, 0x6E, 0xA5, 0x00 },
{ 0x80, 0x80, 0x80, 0x00 },
{ 0xFF, 0x00, 0x00, 0x00 },
{ 0x00, 0xFF, 0x00, 0x00 },
{ 0xFF, 0xFF, 0x00, 0x00 },
{ 0x00, 0x00, 0xFF, 0x00 },
{ 0xFF, 0x00, 0xFF, 0x00 },
{ 0x00, 0xFF, 0xFF, 0x00 },
{ 0xFF, 0xFF, 0xFF, 0x00 },
}

Definition at line 28 of file palette.c.

Referenced by bInitDefaultPalette(), and IntInitDefaultPalette().