ReactOS 0.4.15-dev-5669-g09dde2c
surface.c File Reference
#include "framebuf.h"
Include dependency graph for surface.c:

Go to the source code of this file.

Functions

HSURF APIENTRY DrvEnableSurface (IN DHPDEV dhpdev)
 
VOID APIENTRY DrvDisableSurface (IN DHPDEV dhpdev)
 
BOOL APIENTRY DrvAssertMode (IN DHPDEV dhpdev, IN BOOL bEnable)
 

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:152
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
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

◆ 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:179
HSURF hSurfEng
Definition: framebuf.h:37
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:275
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

◆ 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:104
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: windef.h:334
LONG cy
Definition: windef.h:335
#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)