ReactOS  0.4.14-dev-999-g61c8d34
palette.c File Reference
#include "driver.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Functions

BOOL NTAPI bInitDefaultPalette (PPDEV ppdev, DEVINFO *pDevInfo)
 
BOOL NTAPI bInitPaletteInfo (PPDEV ppdev, DEVINFO *pDevInfo)
 
VOID NTAPI vDisablePalette (PPDEV ppdev)
 
BOOL NTAPI bInit256ColorPalette (PPDEV ppdev)
 
BOOL NTAPI DrvSetPalette (DHPDEV dhpdev, PALOBJ *ppalo, FLONG fl, ULONG iStart, ULONG cColors)
 

Variables

const PALETTEENTRY BASEPALETTE [20]
 

Function Documentation

◆ bInit256ColorPalette()

BOOL NTAPI bInit256ColorPalette ( PPDEV  ppdev)

Definition at line 193 of file palette.c.

194 {
195  BYTE ajClutSpace[MAX_CLUT_SIZE];
196  PVIDEO_CLUT pScreenClut;
197  ULONG ulReturnedDataLength;
198  ULONG cColors;
199  PVIDEO_CLUTDATA pScreenClutData;
200 
201  if (ppdev->ulBitCount == 8)
202  {
203  //
204  // Fill in pScreenClut header info:
205  //
206 
207  pScreenClut = (PVIDEO_CLUT) ajClutSpace;
208  pScreenClut->NumEntries = 256;
209  pScreenClut->FirstEntry = 0;
210 
211  //
212  // Copy colours in:
213  //
214 
215  cColors = 256;
216  pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
217 
218  while(cColors--)
219  {
220  pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >>
221  ppdev->cPaletteShift;
222  pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >>
223  ppdev->cPaletteShift;
224  pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >>
225  ppdev->cPaletteShift;
226  pScreenClutData[cColors].Unused = 0;
227  }
228 
229  //
230  // Set palette registers:
231  //
232 
233  if (EngDeviceIoControl(ppdev->hDriver,
235  pScreenClut,
237  NULL,
238  0,
239  &ulReturnedDataLength))
240  {
241  DISPDBG((0, "Failed bEnablePalette"));
242  return(FALSE);
243  }
244  }
245 
246  DISPDBG((5, "Passed bEnablePalette"));
247 
248  return(TRUE);
249 }
#define TRUE
Definition: types.h:120
USHORT FirstEntry
Definition: ntddvdeo.h:520
struct VIDEO_CLUT * PVIDEO_CLUT
PALETTEENTRY * pPal
Definition: driver.h:48
HANDLE hDriver
Definition: framebuf.h:35
smooth NULL
Definition: ftsmooth.c:416
ULONG ulBitCount
Definition: driver.h:42
USHORT NumEntries
Definition: ntddvdeo.h:519
#define DISPDBG(arg)
Definition: debug.h:23
unsigned char BYTE
Definition: mem.h:68
ULONG cPaletteShift
Definition: driver.h:39
#define MAX_CLUT_SIZE
Definition: driver.h:64
unsigned int ULONG
Definition: retypes.h:1
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
union VIDEO_CLUT::@3062 LookupTable[1]

◆ bInitDefaultPalette()

BOOL bInitDefaultPalette ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 86 of file palette.c.

87 {
88  if (ppdev->ulBitCount == 8)
89  {
90  ULONG ulLoop;
91  BYTE jRed,jGre,jBlu;
92 
93  //
94  // Allocate our palette
95  //
96 
97  ppdev->pPal = (PPALETTEENTRY)EngAllocMem(0, sizeof(PALETTEENTRY) * 256,
98  ALLOC_TAG);
99 
100  if ((ppdev->pPal) == NULL) {
101  RIP("DISP bInitDefaultPalette() failed EngAllocMem\n");
102  return(FALSE);
103  }
104 
105  //
106  // Generate 256 (8*4*4) RGB combinations to fill the palette
107  //
108 
109  jRed = jGre = jBlu = 0;
110 
111  for (ulLoop = 0; ulLoop < 256; ulLoop++)
112  {
113  ppdev->pPal[ulLoop].peRed = jRed;
114  ppdev->pPal[ulLoop].peGreen = jGre;
115  ppdev->pPal[ulLoop].peBlue = jBlu;
116  ppdev->pPal[ulLoop].peFlags = (BYTE)0;
117 
118  if (!(jRed += 32))
119  if (!(jGre += 32))
120  jBlu += 64;
121  }
122 
123  //
124  // Fill in Windows Reserved Colors from the WIN 3.0 DDK
125  // The Window Manager reserved the first and last 10 colors for
126  // painting windows borders and for non-palette managed applications.
127  //
128 
129  for (ulLoop = 0; ulLoop < 10; ulLoop++)
130  {
131  //
132  // First 10
133  //
134 
135  ppdev->pPal[ulLoop] = BASEPALETTE[ulLoop];
136 
137  //
138  // Last 10
139  //
140 
141  ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10];
142  }
143 
144  //
145  // Create handle for palette.
146  //
147 
148  ppdev->hpalDefault =
150  256,
151  (PULONG) ppdev->pPal,
152  0,0,0);
153 
154  if (ppdev->hpalDefault == (HPALETTE) 0)
155  {
156  RIP("DISP bInitDefaultPalette failed EngCreatePalette\n");
157  EngFreeMem(ppdev->pPal);
158  return(FALSE);
159  }
160 
161  //
162  // Initialize the hardware with the initial palette.
163  //
164 
165  return(TRUE);
166 
167  } else {
168 
169  ppdev->hpalDefault =
171  0,(PULONG) NULL,
172  ppdev->flRed,
173  ppdev->flGreen,
174  ppdev->flBlue);
175 
176  if (ppdev->hpalDefault == (HPALETTE) 0)
177  {
178  RIP("DISP bInitDefaultPalette failed EngCreatePalette\n");
179  return(FALSE);
180  }
181  }
182 
183  return(TRUE);
184 }
#define TRUE
Definition: types.h:120
#define EngFreeMem
Definition: polytest.cpp:56
#define RIP(x)
Definition: debug.h:24
HPALETTE hpalDefault
Definition: driver.h:27
#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
PALETTEENTRY * pPal
Definition: driver.h:48
FLONG flGreen
Definition: driver.h:37
const PALETTEENTRY BASEPALETTE[20]
Definition: palette.c:28
HPALETTE hpalDefault
Definition: winddi.h:398
smooth NULL
Definition: ftsmooth.c:416
FLONG flRed
Definition: driver.h:36
ULONG ulBitCount
Definition: driver.h:42
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
unsigned char BYTE
Definition: mem.h:68
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
FLONG flBlue
Definition: driver.h:38
struct tagPALETTEENTRY * PPALETTEENTRY

Referenced by bInitPaletteInfo().

◆ bInitPaletteInfo()

BOOL NTAPI bInitPaletteInfo ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 50 of file palette.c.

51 {
52  if (!bInitDefaultPalette(ppdev, pDevInfo))
53  return(FALSE);
54 
55  return(TRUE);
56 }
#define TRUE
Definition: types.h:120
BOOL NTAPI bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo)
Definition: palette.c:86

◆ DrvSetPalette()

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

Definition at line 258 of file palette.c.

264 {
265  BYTE ajClutSpace[MAX_CLUT_SIZE];
266  PVIDEO_CLUT pScreenClut;
267  PVIDEO_CLUTDATA pScreenClutData;
268  PDEV* ppdev;
269 
271 
272  ppdev = (PDEV*) dhpdev;
273 
274  //
275  // Fill in pScreenClut header info:
276  //
277 
278  pScreenClut = (PVIDEO_CLUT) ajClutSpace;
279  pScreenClut->NumEntries = (USHORT) cColors;
280  pScreenClut->FirstEntry = (USHORT) iStart;
281 
282  pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
283 
284  if (cColors != PALOBJ_cGetColors(ppalo, iStart, cColors,
285  (ULONG*) pScreenClutData))
286  {
287  DISPDBG((0, "DrvSetPalette failed PALOBJ_cGetColors\n"));
288  return (FALSE);
289  }
290 
291  //
292  // Set the high reserved byte in each palette entry to 0.
293  // Do the appropriate palette shifting to fit in the DAC.
294  //
295 
296  if (ppdev->cPaletteShift)
297  {
298  while(cColors--)
299  {
300  pScreenClutData[cColors].Red >>= ppdev->cPaletteShift;
301  pScreenClutData[cColors].Green >>= ppdev->cPaletteShift;
302  pScreenClutData[cColors].Blue >>= ppdev->cPaletteShift;
303  pScreenClutData[cColors].Unused = 0;
304  }
305  }
306  else
307  {
308  while(cColors--)
309  {
310  pScreenClutData[cColors].Unused = 0;
311  }
312  }
313 
314  //
315  // Set palette registers
316  //
317 
318  if (EngDeviceIoControl(ppdev->hDriver,
320  pScreenClut,
322  NULL,
323  0,
324  &cColors))
325  {
326  DISPDBG((0, "DrvSetPalette failed EngDeviceIoControl\n"));
327  return (FALSE);
328  }
329 
330  return(TRUE);
331 
332 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
USHORT FirstEntry
Definition: ntddvdeo.h:520
_In_ UINT iStart
Definition: wingdi.h:3619
struct VIDEO_CLUT * PVIDEO_CLUT
ULONG APIENTRY PALOBJ_cGetColors(PALOBJ *PalObj, ULONG Start, ULONG Colors, ULONG *PaletteEntry)
Definition: palette.c:423
_In_ FLONG fl
Definition: winddi.h:1279
HANDLE hDriver
Definition: framebuf.h:35
smooth NULL
Definition: ftsmooth.c:416
USHORT NumEntries
Definition: ntddvdeo.h:519
#define DISPDBG(arg)
Definition: debug.h:23
_In_ PALOBJ * ppalo
Definition: winddi.h:4012
Definition: framebuf.h:33
unsigned char BYTE
Definition: mem.h:68
ULONG cPaletteShift
Definition: driver.h:39
#define MAX_CLUT_SIZE
Definition: driver.h:64
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
union VIDEO_CLUT::@3062 LookupTable[1]

◆ vDisablePalette()

VOID NTAPI vDisablePalette ( PPDEV  ppdev)

Definition at line 65 of file palette.c.

66 {
67 // Delete the default palette if we created one.
68 
69  if (ppdev->hpalDefault)
70  {
72  ppdev->hpalDefault = (HPALETTE) 0;
73  }
74 
75  if (ppdev->pPal != (PPALETTEENTRY)NULL)
76  EngFreeMem((PVOID)ppdev->pPal);
77 }
#define EngFreeMem
Definition: polytest.cpp:56
HPALETTE hpalDefault
Definition: driver.h:27
PALETTEENTRY * pPal
Definition: driver.h:48
smooth NULL
Definition: ftsmooth.c:416
BOOL APIENTRY EngDeletePalette(IN HPALETTE hpal)
Definition: palette.c:406

Variable Documentation

◆ BASEPALETTE

const PALETTEENTRY BASEPALETTE[20]
Initial value:
=
{
{ 0, 0, 0, 0 },
{ 0x80,0, 0, 0 },
{ 0, 0x80,0, 0 },
{ 0x80,0x80,0, 0 },
{ 0, 0, 0x80,0 },
{ 0x80,0, 0x80,0 },
{ 0, 0x80,0x80,0 },
{ 0xC0,0xC0,0xC0,0 },
{ 192, 220, 192, 0 },
{ 166, 202, 240, 0 },
{ 255, 251, 240, 0 },
{ 160, 160, 164, 0 },
{ 0x80,0x80,0x80,0 },
{ 0xFF,0, 0 ,0 },
{ 0, 0xFF,0 ,0 },
{ 0xFF,0xFF,0 ,0 },
{ 0 ,0, 0xFF,0 },
{ 0xFF,0, 0xFF,0 },
{ 0, 0xFF,0xFF,0 },
{ 0xFF,0xFF,0xFF,0 },
}

Definition at line 15 of file palette.c.