ReactOS 0.4.16-dev-297-gc569aee
framebuf.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <wingdi.h>
#include <winddi.h>
#include <winioctl.h>
#include <ntddvdeo.h>
Include dependency graph for framebuf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PDEV
 

Macros

#define DEVICE_NAME   L"framebuf"
 
#define ALLOC_TAG   'FUBF'
 

Typedefs

typedef struct _PDEV PDEV
 
typedef struct _PDEVPPDEV
 

Functions

BOOL APIENTRY DrvEnableDirectDraw (DHPDEV dhpdev, DD_CALLBACKS *pCallbacks, DD_SURFACECALLBACKS *pSurfaceCallbacks, DD_PALETTECALLBACKS *pPaletteCallbacks)
 
VOID APIENTRY DrvDisableDirectDraw (DHPDEV dhpdev)
 
DHPDEV APIENTRY DrvEnablePDEV (IN DEVMODEW *pdm, IN LPWSTR pwszLogAddress, IN ULONG cPat, OUT HSURF *phsurfPatterns, IN ULONG cjCaps, OUT ULONG *pdevcaps, IN ULONG cjDevInfo, OUT DEVINFO *pdi, IN HDEV hdev, IN LPWSTR pwszDeviceName, IN HANDLE hDriver)
 
VOID APIENTRY DrvCompletePDEV (IN DHPDEV dhpdev, IN HDEV hdev)
 
VOID APIENTRY DrvDisablePDEV (IN DHPDEV dhpdev)
 
HSURF APIENTRY DrvEnableSurface (IN DHPDEV dhpdev)
 
VOID APIENTRY DrvDisableSurface (IN DHPDEV dhpdev)
 
BOOL APIENTRY DrvAssertMode (IN DHPDEV dhpdev, IN BOOL bEnable)
 
ULONG APIENTRY DrvGetModes (IN HANDLE hDriver, IN ULONG cjSize, OUT DEVMODEW *pdm)
 
BOOL APIENTRY DrvSetPalette (IN DHPDEV dhpdev, IN PALOBJ *ppalo, IN FLONG fl, IN ULONG iStart, IN ULONG cColors)
 
ULONG APIENTRY DrvSetPointerShape (IN SURFOBJ *pso, IN SURFOBJ *psoMask, IN SURFOBJ *psoColor, IN XLATEOBJ *pxlo, IN LONG xHot, IN LONG yHot, IN LONG x, IN LONG y, IN RECTL *prcl, IN FLONG fl)
 
VOID APIENTRY DrvMovePointer (IN SURFOBJ *pso, IN LONG x, IN LONG y, IN RECTL *prcl)
 
BOOL IntInitScreenInfo (PPDEV ppdev, LPDEVMODEW pDevMode, PGDIINFO pGdiInfo, PDEVINFO pDevInfo)
 
BOOL IntInitDefaultPalette (PPDEV ppdev, PDEVINFO pDevInfo)
 
BOOL APIENTRY IntSetPalette (IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
 

Macro Definition Documentation

◆ ALLOC_TAG

#define ALLOC_TAG   'FUBF'

Definition at line 71 of file framebuf.h.

◆ DEVICE_NAME

#define DEVICE_NAME   L"framebuf"

Definition at line 70 of file framebuf.h.

Typedef Documentation

◆ PDEV

typedef struct _PDEV PDEV

◆ PPDEV

typedef struct _PDEV * PPDEV

Function Documentation

◆ DrvAssertMode()

BOOL APIENTRY DrvAssertMode ( IN DHPDEV  dhpdev,
IN BOOL  bEnable 
)

Definition at line 168 of file surface.c.

171{
172 PPDEV ppdev = (PPDEV)dhpdev;
173 ULONG ulTemp;
174
175 if (bEnable)
176 {
177 /*
178 * Reinitialize the device to a clean state.
179 */
180 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_SET_CURRENT_MODE,
181 &(ppdev->ModeIndex), sizeof(ULONG), NULL, 0,
182 &ulTemp))
183 {
184 /* We failed, bail out */
185 return FALSE;
186 }
187 if (ppdev->BitsPerPixel == 8)
188 {
189 IntSetPalette(dhpdev, ppdev->PaletteEntries, 0, 256);
190 }
191
192 return TRUE;
193 }
194 else
195 {
196 /*
197 * Call the miniport driver to reset the device to a known state.
198 */
199 return !EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_RESET_DEVICE,
200 NULL, 0, NULL, 0, &ulTemp);
201 }
202}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _PDEV * PPDEV
BOOL APIENTRY IntSetPalette(IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
Definition: palette.c:110
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:206
Definition: framebuf.h:34
ULONG ModeIndex
Definition: framebuf.h:38
PALETTEENTRY * PaletteEntries
Definition: framebuf.h:49
HANDLE hDriver
Definition: framebuf.h:35
BYTE BitsPerPixel
Definition: framebuf.h:42
uint32_t ULONG
Definition: typedefs.h:59
_In_ BOOL bEnable
Definition: winddi.h:3426

◆ DrvCompletePDEV()

VOID APIENTRY DrvCompletePDEV ( IN DHPDEV  dhpdev,
IN HDEV  hdev 
)

Definition at line 168 of file enable.c.

171{
172 ((PPDEV)dhpdev)->hDevEng = hdev;
173}
_In_ HDEV hdev
Definition: winddi.h:3449

◆ DrvDisableDirectDraw()

VOID APIENTRY DrvDisableDirectDraw ( DHPDEV  dhpdev)

Definition at line 69 of file enable.c.

71{
72}

◆ DrvDisablePDEV()

VOID APIENTRY DrvDisablePDEV ( IN DHPDEV  dhpdev)

Definition at line 186 of file enable.c.

188{
189 if (((PPDEV)dhpdev)->DefaultPalette)
190 {
192 }
193
194 if (((PPDEV)dhpdev)->PaletteEntries != NULL)
195 {
196 EngFreeMem(((PPDEV)dhpdev)->PaletteEntries);
197 }
198
199 EngFreeMem(dhpdev);
200}
static const UCHAR DefaultPalette[]
Definition: blue.c:69
#define EngFreeMem
Definition: polytest.cpp:56
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)

◆ DrvDisableSurface()

VOID APIENTRY DrvDisableSurface ( IN DHPDEV  dhpdev)

Definition at line 133 of file surface.c.

135{
136 DWORD ulTemp;
137 VIDEO_MEMORY VideoMemory;
138 PPDEV ppdev = (PPDEV)dhpdev;
139
141 ppdev->hSurfEng = NULL;
142
143#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
144 /* Clear all mouse pointer surfaces. */
145 DrvSetPointerShape(NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0);
146#endif
147
148 /*
149 * Unmap the framebuffer.
150 */
151
152 VideoMemory.RequestedVirtualAddress = ((PPDEV)dhpdev)->ScreenPtr;
153 EngDeviceIoControl(((PPDEV)dhpdev)->hDriver, IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
154 &VideoMemory, sizeof(VIDEO_MEMORY), NULL, 0, &ulTemp);
155}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
HSURF hSurfEng
Definition: framebuf.h:37
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:344
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:567
FN_DrvSetPointerShape DrvSetPointerShape
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557

◆ DrvEnableDirectDraw()

BOOL APIENTRY DrvEnableDirectDraw ( DHPDEV  dhpdev,
DD_CALLBACKS pCallbacks,
DD_SURFACECALLBACKS pSurfaceCallbacks,
DD_PALETTECALLBACKS pPaletteCallbacks 
)

Definition at line 45 of file enable.c.

50{
51 RtlZeroMemory(pCallbacks, sizeof(*pCallbacks));
52 RtlZeroMemory(pSurfaceCallbacks, sizeof(*pSurfaceCallbacks));
53 RtlZeroMemory(pPaletteCallbacks, sizeof(*pPaletteCallbacks));
54
55 pCallbacks->dwSize = sizeof(*pCallbacks);
56 pSurfaceCallbacks->dwSize = sizeof(*pSurfaceCallbacks);
57 pPaletteCallbacks->dwSize = sizeof(*pPaletteCallbacks);
58
59 /* We don't support any optional callback */
60
61 return TRUE;
62}
DWORD dwSize
Definition: ddrawint.h:498
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ DrvEnablePDEV()

DHPDEV APIENTRY DrvEnablePDEV ( IN DEVMODEW pdm,
IN LPWSTR  pwszLogAddress,
IN ULONG  cPat,
OUT HSURF phsurfPatterns,
IN ULONG  cjCaps,
OUT ULONG pdevcaps,
IN ULONG  cjDevInfo,
OUT DEVINFO pdi,
IN HDEV  hdev,
IN LPWSTR  pwszDeviceName,
IN HANDLE  hDriver 
)

Definition at line 114 of file enable.c.

126{
127 PPDEV ppdev;
128 GDIINFO GdiInfo;
129 DEVINFO DevInfo;
130
131 ppdev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
132 if (ppdev == NULL)
133 {
134 return NULL;
135 }
136
137 ppdev->hDriver = hDriver;
138
139 if (!IntInitScreenInfo(ppdev, pdm, &GdiInfo, &DevInfo))
140 {
141 EngFreeMem(ppdev);
142 return NULL;
143 }
144
145 if (!IntInitDefaultPalette(ppdev, &DevInfo))
146 {
147 EngFreeMem(ppdev);
148 return NULL;
149 }
150
151 memcpy(pdi, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
152 memcpy(pdevcaps, &GdiInfo, min(sizeof(GDIINFO), cjCaps));
153
154 return (DHPDEV)ppdev;
155}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
BOOL IntInitScreenInfo(PPDEV ppdev, LPDEVMODEW pDevMode, PGDIINFO pGdiInfo, PDEVINFO pDevInfo)
Definition: screen.c:120
BOOL IntInitDefaultPalette(PPDEV ppdev, PDEVINFO pDevInfo)
Definition: palette.c:60
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG cjDevInfo
Definition: winddi.h:3553
typedef DHPDEV(APIENTRY FN_DrvEnablePDEV)(_In_ DEVMODEW *pdm
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554
_In_ LPWSTR _In_ ULONG _In_ ULONG cjCaps
Definition: winddi.h:3551

◆ DrvEnableSurface()

HSURF APIENTRY DrvEnableSurface ( IN DHPDEV  dhpdev)

Definition at line 34 of file surface.c.

36{
37 PPDEV ppdev = (PPDEV)dhpdev;
38 HSURF hSurface;
39 ULONG BitmapType;
40 SIZEL ScreenSize;
41 VIDEO_MEMORY VideoMemory;
42 VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
43 ULONG ulTemp;
44
45 /*
46 * Set video mode of our adapter.
47 */
48
49 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_SET_CURRENT_MODE,
50 &(ppdev->ModeIndex), sizeof(ULONG), NULL, 0,
51 &ulTemp))
52 {
53 return NULL;
54 }
55
56 /*
57 * Map the framebuffer into our memory.
58 */
59
60 VideoMemory.RequestedVirtualAddress = NULL;
61 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_MAP_VIDEO_MEMORY,
62 &VideoMemory, sizeof(VIDEO_MEMORY),
63 &VideoMemoryInfo, sizeof(VIDEO_MEMORY_INFORMATION),
64 &ulTemp))
65 {
66 return NULL;
67 }
68
69 ppdev->ScreenPtr = VideoMemoryInfo.FrameBufferBase;
70
71 switch (ppdev->BitsPerPixel)
72 {
73 case 8:
74 IntSetPalette(dhpdev, ppdev->PaletteEntries, 0, 256);
75 BitmapType = BMF_8BPP;
76 break;
77
78 case 16:
79 BitmapType = BMF_16BPP;
80 break;
81
82 case 24:
83 BitmapType = BMF_24BPP;
84 break;
85
86 case 32:
87 BitmapType = BMF_32BPP;
88 break;
89
90 default:
91 return NULL;
92 }
93
94 ppdev->iDitherFormat = BitmapType;
95
96 ScreenSize.cx = ppdev->ScreenWidth;
97 ScreenSize.cy = ppdev->ScreenHeight;
98
99 hSurface = (HSURF)EngCreateBitmap(ScreenSize, ppdev->ScreenDelta, BitmapType,
100 (ppdev->ScreenDelta > 0) ? BMF_TOPDOWN : 0,
101 ppdev->ScreenPtr);
102 if (hSurface == NULL)
103 {
104 return NULL;
105 }
106
107 /*
108 * Associate the surface with our device.
109 */
110
111 if (!EngAssociateSurface(hSurface, ppdev->hDevEng, 0))
112 {
113 EngDeleteSurface(hSurface);
114 return NULL;
115 }
116
117 ppdev->hSurfEng = hSurface;
118
119 return hSurface;
120}
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
HDEV hDevEng
Definition: framebuf.h:36
ULONG ScreenDelta
Definition: framebuf.h:41
ULONG ScreenWidth
Definition: framebuf.h:39
DWORD iDitherFormat
Definition: framebuf.h:61
ULONG ScreenHeight
Definition: framebuf.h:40
PVOID ScreenPtr
Definition: framebuf.h:47
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
ENGAPI HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ FLONG fl, _In_opt_ PVOID pvBits)
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_TOPDOWN
Definition: winddi.h:1180
#define BMF_32BPP
Definition: winddi.h:360
ENGAPI BOOL APIENTRY EngAssociateSurface(_In_ HSURF hsurf, _In_ HDEV hdev, _In_ FLONG flHooks)
Definition: surface.c:431
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)

◆ DrvGetModes()

ULONG APIENTRY DrvGetModes ( IN HANDLE  hDriver,
IN ULONG  cjSize,
OUT DEVMODEW pdm 
)

Definition at line 362 of file screen.c.

366{
367 ULONG ModeCount;
368 ULONG ModeInfoSize;
369 PVIDEO_MODE_INFORMATION ModeInfo, ModeInfoPtr;
370 ULONG OutputSize;
371
372 ModeCount = GetAvailableModes(hDriver, &ModeInfo, &ModeInfoSize);
373 if (ModeCount == 0)
374 {
375 return 0;
376 }
377
378 if (pdm == NULL)
379 {
380 EngFreeMem(ModeInfo);
381 return ModeCount * sizeof(DEVMODEW);
382 }
383
384 /*
385 * Copy the information about supported modes into the output buffer.
386 */
387
388 OutputSize = 0;
389 ModeInfoPtr = ModeInfo;
390
391 while (ModeCount-- > 0)
392 {
393 if (ModeInfoPtr->Length == 0)
394 {
395 ModeInfoPtr = (PVIDEO_MODE_INFORMATION)(((ULONG_PTR)ModeInfoPtr) + ModeInfoSize);
396 continue;
397 }
398
399 memset(pdm, 0, sizeof(DEVMODEW));
400 memcpy(pdm->dmDeviceName, DEVICE_NAME, sizeof(DEVICE_NAME));
401 pdm->dmSpecVersion =
402 pdm->dmDriverVersion = DM_SPECVERSION;
403 pdm->dmSize = sizeof(DEVMODEW);
404 pdm->dmDriverExtra = 0;
405 pdm->dmBitsPerPel = ModeInfoPtr->NumberOfPlanes * ModeInfoPtr->BitsPerPlane;
406 pdm->dmPelsWidth = ModeInfoPtr->VisScreenWidth;
407 pdm->dmPelsHeight = ModeInfoPtr->VisScreenHeight;
408 pdm->dmDisplayFrequency = ModeInfoPtr->Frequency;
409 pdm->dmDisplayFlags = 0;
410 pdm->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT |
412
413 ModeInfoPtr = (PVIDEO_MODE_INFORMATION)(((ULONG_PTR)ModeInfoPtr) + ModeInfoSize);
414 pdm = (LPDEVMODEW)(((ULONG_PTR)pdm) + sizeof(DEVMODEW));
415 OutputSize += sizeof(DEVMODEW);
416 }
417
418 EngFreeMem(ModeInfo);
419 return OutputSize;
420}
#define DEVICE_NAME
Definition: ext2fs.h:137
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD GetAvailableModes(HANDLE hDriver, PVIDEO_MODE_INFORMATION *ModeInfo, DWORD *ModeInfoSize)
Definition: screen.c:35
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
struct _devicemodeW * LPDEVMODEW
struct _devicemodeW DEVMODEW
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_SPECVERSION
Definition: wingdi.h:1243
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define DM_DISPLAYFLAGS
Definition: wingdi.h:1271

◆ DrvMovePointer()

VOID APIENTRY DrvMovePointer ( IN SURFOBJ pso,
IN LONG  x,
IN LONG  y,
IN RECTL prcl 
)

Definition at line 62 of file pointer.c.

67{
69}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3665
ENGAPI VOID APIENTRY EngMovePointer(_In_ SURFOBJ *pso, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl)
Definition: mouse.c:575
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3531

◆ 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}
unsigned int BOOL
Definition: ntddk_ex.h:94
uint32_t * PULONG
Definition: typedefs.h:59
BOOL APIENTRY IntSetPalette(IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
Definition: palette.c:110
_In_ PALOBJ * ppalo
Definition: winddi.h:4012
ENGAPI ULONG APIENTRY PALOBJ_cGetColors(_In_ PALOBJ *ppalo, _In_ ULONG iStart, _In_ ULONG cColors, _Out_writes_(cColors) ULONG *pulColors)
_In_ UINT iStart
Definition: wingdi.h:3620

◆ DrvSetPointerShape()

ULONG APIENTRY DrvSetPointerShape ( IN SURFOBJ pso,
IN SURFOBJ psoMask,
IN SURFOBJ psoColor,
IN XLATEOBJ pxlo,
IN LONG  xHot,
IN LONG  yHot,
IN LONG  x,
IN LONG  y,
IN RECTL prcl,
IN FLONG  fl 
)

Definition at line 35 of file pointer.c.

46{
47/* return SPS_DECLINE;*/
49}
_In_ FLONG fl
Definition: winddi.h:1279
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ XLATEOBJ _In_ LONG xHot
Definition: winddi.h:4052
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ XLATEOBJ _In_ LONG _In_ LONG yHot
Definition: winddi.h:4053
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ * pxlo
Definition: winddi.h:3416
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoMask
Definition: winddi.h:3434
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoColor
Definition: winddi.h:4050
ENGAPI ULONG APIENTRY EngSetPointerShape(_In_ SURFOBJ *pso, _In_opt_ SURFOBJ *psoMask, _In_opt_ SURFOBJ *psoColor, _In_opt_ XLATEOBJ *pxlo, _In_ LONG xHot, _In_ LONG yHot, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl, _In_ FLONG fl)
Definition: mouse.c:330

◆ 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}
HPALETTE hpalDefault
Definition: winddi.h:398
ULONG GreenMask
Definition: framebuf.h:44
ULONG BlueMask
Definition: framebuf.h:45
ULONG RedMask
Definition: framebuf.h:43
HPALETTE DefaultPalette
Definition: framebuf.h:48
const PALETTEENTRY BASEPALETTE[20]
Definition: palette.c:28
#define PAL_BITFIELDS
Definition: winddi.h:1562
#define PAL_INDEXED
Definition: winddi.h:1561
_Must_inspect_result_ ENGAPI HPALETTE APIENTRY EngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)

Referenced by DrvEnablePDEV().

◆ IntInitScreenInfo()

BOOL IntInitScreenInfo ( PPDEV  ppdev,
LPDEVMODEW  pDevMode,
PGDIINFO  pGdiInfo,
PDEVINFO  pDevInfo 
)

Definition at line 120 of file screen.c.

125{
126 ULONG ModeCount;
127 ULONG ModeInfoSize;
128 PVIDEO_MODE_INFORMATION ModeInfo, ModeInfoPtr, SelectedMode = NULL;
129 VIDEO_COLOR_CAPABILITIES ColorCapabilities;
130 ULONG Temp;
131
132 /*
133 * Call miniport to get information about video modes.
134 */
135
136 ModeCount = GetAvailableModes(ppdev->hDriver, &ModeInfo, &ModeInfoSize);
137 if (ModeCount == 0)
138 {
139 return FALSE;
140 }
141
142 /*
143 * Select the video mode depending on the info passed in pDevMode.
144 */
145
146 if (pDevMode->dmPelsWidth == 0 && pDevMode->dmPelsHeight == 0 &&
147 pDevMode->dmBitsPerPel == 0 && pDevMode->dmDisplayFrequency == 0)
148 {
149 ModeInfoPtr = ModeInfo;
150 while (ModeCount-- > 0)
151 {
152 if (ModeInfoPtr->Length == 0)
153 {
154 ModeInfoPtr = (PVIDEO_MODE_INFORMATION)
155 (((PUCHAR)ModeInfoPtr) + ModeInfoSize);
156 continue;
157 }
158 SelectedMode = ModeInfoPtr;
159 break;
160 }
161 }
162 else
163 {
164 ModeInfoPtr = ModeInfo;
165 while (ModeCount-- > 0)
166 {
167 if (ModeInfoPtr->Length > 0 &&
168 pDevMode->dmPelsWidth == ModeInfoPtr->VisScreenWidth &&
169 pDevMode->dmPelsHeight == ModeInfoPtr->VisScreenHeight &&
170 pDevMode->dmBitsPerPel == (ModeInfoPtr->BitsPerPlane *
171 ModeInfoPtr->NumberOfPlanes) &&
172 pDevMode->dmDisplayFrequency == ModeInfoPtr->Frequency)
173 {
174 SelectedMode = ModeInfoPtr;
175 break;
176 }
177
178 ModeInfoPtr = (PVIDEO_MODE_INFORMATION)
179 (((PUCHAR)ModeInfoPtr) + ModeInfoSize);
180 }
181 }
182
183 if (SelectedMode == NULL)
184 {
185 EngFreeMem(ModeInfo);
186 return FALSE;
187 }
188
189 /*
190 * Fill in the GDIINFO data structure with the information returned from
191 * the kernel driver.
192 */
193
194 ppdev->ModeIndex = SelectedMode->ModeIndex;
195 ppdev->ScreenWidth = SelectedMode->VisScreenWidth;
196 ppdev->ScreenHeight = SelectedMode->VisScreenHeight;
197 ppdev->ScreenDelta = SelectedMode->ScreenStride;
198 ppdev->BitsPerPixel = (UCHAR)(SelectedMode->BitsPerPlane * SelectedMode->NumberOfPlanes);
199
200 ppdev->MemWidth = SelectedMode->VideoMemoryBitmapWidth;
201 ppdev->MemHeight = SelectedMode->VideoMemoryBitmapHeight;
202
203 ppdev->RedMask = SelectedMode->RedMask;
204 ppdev->GreenMask = SelectedMode->GreenMask;
205 ppdev->BlueMask = SelectedMode->BlueMask;
206
207 pGdiInfo->ulVersion = GDI_DRIVER_VERSION;
208 pGdiInfo->ulTechnology = DT_RASDISPLAY;
209 pGdiInfo->ulHorzSize = SelectedMode->XMillimeter;
210 pGdiInfo->ulVertSize = SelectedMode->YMillimeter;
211 pGdiInfo->ulHorzRes = SelectedMode->VisScreenWidth;
212 pGdiInfo->ulVertRes = SelectedMode->VisScreenHeight;
213 pGdiInfo->ulPanningHorzRes = SelectedMode->VisScreenWidth;
214 pGdiInfo->ulPanningVertRes = SelectedMode->VisScreenHeight;
215 pGdiInfo->cBitsPixel = SelectedMode->BitsPerPlane;
216 pGdiInfo->cPlanes = SelectedMode->NumberOfPlanes;
217 pGdiInfo->ulVRefresh = SelectedMode->Frequency;
218 pGdiInfo->ulBltAlignment = 1;
219 pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels;
220 pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels;
221 pGdiInfo->flTextCaps = TC_RA_ABLE;
222 pGdiInfo->flRaster = 0;
223 pGdiInfo->ulDACRed = SelectedMode->NumberRedBits;
224 pGdiInfo->ulDACGreen = SelectedMode->NumberGreenBits;
225 pGdiInfo->ulDACBlue = SelectedMode->NumberBlueBits;
226 pGdiInfo->ulAspectX = 0x24;
227 pGdiInfo->ulAspectY = 0x24;
228 pGdiInfo->ulAspectXY = 0x33;
229 pGdiInfo->xStyleStep = 1;
230 pGdiInfo->yStyleStep = 1;
231 pGdiInfo->denStyleStep = 3;
232 pGdiInfo->ptlPhysOffset.x = 0;
233 pGdiInfo->ptlPhysOffset.y = 0;
234 pGdiInfo->szlPhysSize.cx = 0;
235 pGdiInfo->szlPhysSize.cy = 0;
236
237 /*
238 * Try to get the color info from the miniport.
239 */
240
241 if (!EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES,
242 NULL, 0, &ColorCapabilities,
243 sizeof(VIDEO_COLOR_CAPABILITIES), &Temp))
244 {
245 pGdiInfo->ciDevice.Red.x = ColorCapabilities.RedChromaticity_x;
246 pGdiInfo->ciDevice.Red.y = ColorCapabilities.RedChromaticity_y;
247 pGdiInfo->ciDevice.Green.x = ColorCapabilities.GreenChromaticity_x;
248 pGdiInfo->ciDevice.Green.y = ColorCapabilities.GreenChromaticity_y;
249 pGdiInfo->ciDevice.Blue.x = ColorCapabilities.BlueChromaticity_x;
250 pGdiInfo->ciDevice.Blue.y = ColorCapabilities.BlueChromaticity_y;
251 pGdiInfo->ciDevice.AlignmentWhite.x = ColorCapabilities.WhiteChromaticity_x;
252 pGdiInfo->ciDevice.AlignmentWhite.y = ColorCapabilities.WhiteChromaticity_y;
253 pGdiInfo->ciDevice.AlignmentWhite.Y = ColorCapabilities.WhiteChromaticity_Y;
254 if (ColorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR)
255 {
256 pGdiInfo->ciDevice.RedGamma = ColorCapabilities.RedGamma;
257 pGdiInfo->ciDevice.GreenGamma = ColorCapabilities.GreenGamma;
258 pGdiInfo->ciDevice.BlueGamma = ColorCapabilities.BlueGamma;
259 }
260 else
261 {
262 pGdiInfo->ciDevice.RedGamma = ColorCapabilities.WhiteGamma;
263 pGdiInfo->ciDevice.GreenGamma = ColorCapabilities.WhiteGamma;
264 pGdiInfo->ciDevice.BlueGamma = ColorCapabilities.WhiteGamma;
265 }
266 }
267 else
268 {
269 pGdiInfo->ciDevice.Red.x = 6700;
270 pGdiInfo->ciDevice.Red.y = 3300;
271 pGdiInfo->ciDevice.Green.x = 2100;
272 pGdiInfo->ciDevice.Green.y = 7100;
273 pGdiInfo->ciDevice.Blue.x = 1400;
274 pGdiInfo->ciDevice.Blue.y = 800;
275 pGdiInfo->ciDevice.AlignmentWhite.x = 3127;
276 pGdiInfo->ciDevice.AlignmentWhite.y = 3290;
277 pGdiInfo->ciDevice.AlignmentWhite.Y = 0;
278 pGdiInfo->ciDevice.RedGamma = 20000;
279 pGdiInfo->ciDevice.GreenGamma = 20000;
280 pGdiInfo->ciDevice.BlueGamma = 20000;
281 }
282
283 pGdiInfo->ciDevice.Red.Y = 0;
284 pGdiInfo->ciDevice.Green.Y = 0;
285 pGdiInfo->ciDevice.Blue.Y = 0;
286 pGdiInfo->ciDevice.Cyan.x = 0;
287 pGdiInfo->ciDevice.Cyan.y = 0;
288 pGdiInfo->ciDevice.Cyan.Y = 0;
289 pGdiInfo->ciDevice.Magenta.x = 0;
290 pGdiInfo->ciDevice.Magenta.y = 0;
291 pGdiInfo->ciDevice.Magenta.Y = 0;
292 pGdiInfo->ciDevice.Yellow.x = 0;
293 pGdiInfo->ciDevice.Yellow.y = 0;
294 pGdiInfo->ciDevice.Yellow.Y = 0;
295 pGdiInfo->ciDevice.MagentaInCyanDye = 0;
296 pGdiInfo->ciDevice.YellowInCyanDye = 0;
297 pGdiInfo->ciDevice.CyanInMagentaDye = 0;
298 pGdiInfo->ciDevice.YellowInMagentaDye = 0;
299 pGdiInfo->ciDevice.CyanInYellowDye = 0;
300 pGdiInfo->ciDevice.MagentaInYellowDye = 0;
301 pGdiInfo->ulDevicePelsDPI = 0;
305
306 pDevInfo->flGraphicsCaps = 0;
307 pDevInfo->lfDefaultFont = SystemFont;
309 pDevInfo->lfAnsiFixFont = AnsiFixedFont;
310 pDevInfo->cFonts = 0;
311 pDevInfo->cxDither = 0;
312 pDevInfo->cyDither = 0;
313 pDevInfo->hpalDefault = 0;
314 pDevInfo->flGraphicsCaps2 = 0;
315
316 if (ppdev->BitsPerPixel == 8)
317 {
318 pGdiInfo->ulNumColors = 20;
319 pGdiInfo->ulNumPalReg = 1 << ppdev->BitsPerPixel;
321 pDevInfo->flGraphicsCaps |= GCAPS_PALMANAGED;
322 pDevInfo->iDitherFormat = BMF_8BPP;
323 /* Assuming palette is orthogonal - all colors are same size. */
324 ppdev->PaletteShift = (UCHAR)(8 - pGdiInfo->ulDACRed);
325 }
326 else
327 {
328 pGdiInfo->ulNumColors = (ULONG)(-1);
329 pGdiInfo->ulNumPalReg = 0;
330 switch (ppdev->BitsPerPixel)
331 {
332 case 16:
334 pDevInfo->iDitherFormat = BMF_16BPP;
335 break;
336
337 case 24:
339 pDevInfo->iDitherFormat = BMF_24BPP;
340 break;
341
342 default:
344 pDevInfo->iDitherFormat = BMF_32BPP;
345 }
346 }
347
348 EngFreeMem(ModeInfo);
349 return TRUE;
350}
#define VIDEO_DEVICE_COLOR
Definition: ntddvdeo.h:473
#define IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES
Definition: ntddvdeo.h:179
LDECI4 x
Definition: winddi.h:240
LDECI4 Y
Definition: winddi.h:242
LDECI4 y
Definition: winddi.h:241
CIECHROMA Cyan
Definition: winddi.h:288
LDECI4 GreenGamma
Definition: winddi.h:293
LDECI4 MagentaInCyanDye
Definition: winddi.h:295
CIECHROMA Magenta
Definition: winddi.h:289
LDECI4 YellowInCyanDye
Definition: winddi.h:296
LDECI4 CyanInMagentaDye
Definition: winddi.h:297
LDECI4 CyanInYellowDye
Definition: winddi.h:299
LDECI4 YellowInMagentaDye
Definition: winddi.h:298
LDECI4 MagentaInYellowDye
Definition: winddi.h:300
CIECHROMA Red
Definition: winddi.h:285
CIECHROMA Green
Definition: winddi.h:286
CIECHROMA Blue
Definition: winddi.h:287
CIECHROMA Yellow
Definition: winddi.h:290
LDECI4 BlueGamma
Definition: winddi.h:294
LDECI4 RedGamma
Definition: winddi.h:292
CIECHROMA AlignmentWhite
Definition: winddi.h:291
USHORT cyDither
Definition: winddi.h:397
LOGFONTW lfAnsiVarFont
Definition: winddi.h:392
FLONG flGraphicsCaps
Definition: winddi.h:390
ULONG cFonts
Definition: winddi.h:394
ULONG iDitherFormat
Definition: winddi.h:395
LOGFONTW lfAnsiFixFont
Definition: winddi.h:393
USHORT cxDither
Definition: winddi.h:396
LOGFONTW lfDefaultFont
Definition: winddi.h:391
FLONG flGraphicsCaps2
Definition: winddi.h:399
ULONG ulVertSize
Definition: winddi.h:881
ULONG ulLogPixelsY
Definition: winddi.h:889
ULONG ulDACGreen
Definition: winddi.h:892
ULONG ulPanningHorzRes
Definition: winddi.h:911
ULONG ulPanningVertRes
Definition: winddi.h:912
ULONG ulHTPatternSize
Definition: winddi.h:906
ULONG ulLogPixelsX
Definition: winddi.h:888
ULONG ulAspectY
Definition: winddi.h:895
ULONG ulTechnology
Definition: winddi.h:879
ULONG ulNumColors
Definition: winddi.h:886
ULONG ulAspectX
Definition: winddi.h:894
ULONG ulPrimaryOrder
Definition: winddi.h:905
ULONG cBitsPixel
Definition: winddi.h:884
ULONG ulDevicePelsDPI
Definition: winddi.h:904
ULONG ulVertRes
Definition: winddi.h:883
POINTL ptlPhysOffset
Definition: winddi.h:900
ULONG ulBltAlignment
Definition: winddi.h:910
ULONG ulHTOutputFormat
Definition: winddi.h:907
SIZEL szlPhysSize
Definition: winddi.h:901
ULONG ulHorzSize
Definition: winddi.h:880
COLORINFO ciDevice
Definition: winddi.h:903
ULONG ulHorzRes
Definition: winddi.h:882
LONG xStyleStep
Definition: winddi.h:897
ULONG flRaster
Definition: winddi.h:887
ULONG ulDACBlue
Definition: winddi.h:893
ULONG ulVersion
Definition: winddi.h:878
ULONG ulAspectXY
Definition: winddi.h:896
LONG denStyleStep
Definition: winddi.h:899
ULONG ulNumPalReg
Definition: winddi.h:902
ULONG flHTFlags
Definition: winddi.h:908
ULONG flTextCaps
Definition: winddi.h:890
ULONG cPlanes
Definition: winddi.h:885
ULONG ulDACRed
Definition: winddi.h:891
LONG yStyleStep
Definition: winddi.h:898
ULONG ulVRefresh
Definition: winddi.h:909
BYTE PaletteShift
Definition: framebuf.h:46
ULONG MemWidth
Definition: framebuf.h:63
ULONG MemHeight
Definition: framebuf.h:62
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD dmPelsWidth
Definition: wingdi.h:1648
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
WORD dmLogPixels
Definition: wingdi.h:1646
unsigned char * PUCHAR
Definition: typedefs.h:53
static LOGFONTW SystemFont
Definition: screen.c:23
static LOGFONTW AnsiVariableFont
Definition: screen.c:24
static LOGFONTW AnsiFixedFont
Definition: screen.c:25
#define HT_FORMAT_8BPP
Definition: winddi.h:819
#define HT_FORMAT_16BPP
Definition: winddi.h:820
#define HT_PATSIZE_4x4_M
Definition: winddi.h:792
#define HT_FLAG_ADDITIVE_PRIMS
Definition: winddi.h:827
#define HT_FORMAT_24BPP
Definition: winddi.h:821
#define GDI_DRIVER_VERSION
Definition: winddi.h:109
#define HT_FORMAT_32BPP
Definition: winddi.h:822
#define PRIMARY_ORDER_CBA
Definition: winddi.h:785
#define GCAPS_PALMANAGED
Definition: winddi.h:341
#define TC_RA_ABLE
Definition: wingdi.h:820
#define DT_RASDISPLAY
Definition: wingdi.h:708
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvEnablePDEV().

◆ 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 IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
union VIDEO_CLUT::@3174 LookupTable[1]
USHORT FirstEntry
Definition: ntddvdeo.h:590
ULONG RgbLong
Definition: ntddvdeo.h:593
VIDEO_CLUTDATA RgbArray
Definition: ntddvdeo.h:592
USHORT NumEntries
Definition: ntddvdeo.h:589

Referenced by DrvAssertMode(), DrvEnableSurface(), and DrvSetPalette().