ReactOS  0.4.14-dev-583-g2a1ba2c
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 }
PALETTEENTRY * PaletteEntries
Definition: framebuf.h:49
#define TRUE
Definition: types.h:120
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
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
HANDLE hDriver
Definition: framebuf.h:35
BYTE BitsPerPixel
Definition: framebuf.h:42
smooth NULL
Definition: ftsmooth.c:416
ULONG ModeIndex
Definition: framebuf.h:38
struct _PDEV * PPDEV
Definition: framebuf.h:33
_In_ BOOL bEnable
Definition: winddi.h:3426
unsigned int ULONG
Definition: retypes.h:1

◆ 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 
140  EngDeleteSurface(ppdev->hSurfEng);
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 }
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
smooth NULL
Definition: ftsmooth.c:416
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _PDEV * PPDEV
Definition: framebuf.h:33
HSURF hSurfEng
Definition: framebuf.h:37
BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:564
FN_DrvSetPointerShape DrvSetPointerShape

◆ 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 FALSE;
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 FALSE;
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 FALSE;
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 FALSE;
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 FALSE;
115  }
116 
117  ppdev->hSurfEng = hSurface;
118 
119  return hSurface;
120 }
#define BMF_24BPP
Definition: winddi.h:359
PALETTEENTRY * PaletteEntries
Definition: framebuf.h:49
ULONG ScreenHeight
Definition: framebuf.h:40
#define BMF_32BPP
Definition: winddi.h:360
DWORD iDitherFormat
Definition: framebuf.h:61
#define BMF_TOPDOWN
Definition: winddi.h:1180
HDEV hDevEng
Definition: framebuf.h:36
BOOL APIENTRY IntSetPalette(IN DHPDEV dhpdev, IN PPALETTEENTRY ppalent, IN ULONG iStart, IN ULONG cColors)
Definition: palette.c:110
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
BOOL APIENTRY EngAssociateSurface(_In_ HSURF hsurf, _In_ HDEV hdev, _In_ FLONG flHooks)
Definition: surface.c:428
HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ ULONG fl, _In_opt_ PVOID pvBits)
Definition: surface.c:306
HANDLE hDriver
Definition: framebuf.h:35
BYTE BitsPerPixel
Definition: framebuf.h:42
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
#define BMF_16BPP
Definition: winddi.h:358
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
ULONG ModeIndex
Definition: framebuf.h:38
struct _PDEV * PPDEV
Definition: framebuf.h:33
PVOID ScreenPtr
Definition: framebuf.h:47
HSURF hSurfEng
Definition: framebuf.h:37
BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:564
unsigned int ULONG
Definition: retypes.h:1
Definition: xlate.c:10
LONG cy
Definition: windef.h:335
ULONG ScreenDelta
Definition: framebuf.h:41
ULONG ScreenWidth
Definition: framebuf.h:39