ReactOS  0.4.14-dev-114-gc8cbd56
wingl.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS win32 kernel mode subsystem
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: win32ss/gdi/ntgdi/wingl.c
5  * PURPOSE: WinGL API
6  * PROGRAMMER:
7  */
8 
9 #include <win32k.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 static
15 INT
18 {
19  INT Ret = 0;
20  PPDEVOBJ ppdev = pdc->ppdev;
21 
22  if (ppdev->flFlags & PDEV_META_DEVICE)
23  {
24  return 0;
25  }
26 
28  {
30  ppdev->dhpdev,
31  1,
32  0,
33  NULL);
34  }
35 
36  if (Ret) pdc->ipfdDevMax = Ret;
37 
38  return Ret;
39 }
40 
41 _Success_(return != 0)
43 INT
45 NtGdiDescribePixelFormat(
46  _In_ HDC hdc,
47  _In_ INT ipfd,
48  _In_ UINT cjpfd,
50 {
51  PDC pdc;
52  PPDEVOBJ ppdev;
53  INT Ret = 0;
54  PIXELFORMATDESCRIPTOR pfdSafe;
55 
56  if ((ppfd == NULL) && (cjpfd != 0)) return 0;
57 
58  pdc = DC_LockDc(hdc);
59  if (!pdc)
60  {
62  return 0;
63  }
64 
65  if (!pdc->ipfdDevMax)
66  {
67  if (!IntGetipfdDevMax(pdc))
68  {
69  /* EngSetLastError ? */
70  goto Exit;
71  }
72  }
73 
74  if (!ppfd)
75  {
76  Ret = pdc->ipfdDevMax;
77  goto Exit;
78  }
79 
80  if ((ipfd < 1) || (ipfd > pdc->ipfdDevMax))
81  {
83  goto Exit;
84  }
85 
86  ppdev = pdc->ppdev;
87 
88  if (ppdev->flFlags & PDEV_META_DEVICE)
89  {
91  goto Exit;
92  }
93 
95  {
97  ppdev->dhpdev,
98  ipfd,
99  sizeof(pfdSafe),
100  &pfdSafe);
101  }
102 
103  if (Ret && cjpfd)
104  {
105  _SEH2_TRY
106  {
107  cjpfd = min(cjpfd, sizeof(PIXELFORMATDESCRIPTOR));
108  ProbeForWrite(ppfd, cjpfd, 1);
109  RtlCopyMemory(ppfd, &pfdSafe, cjpfd);
110  }
112  {
114  }
115  _SEH2_END;
116  }
117 
118 Exit:
119  DC_UnlockDc(pdc);
120  return Ret;
121 }
122 
123 
124 BOOL
125 APIENTRY
127  _In_ HDC hdc,
128  _In_ INT ipfd)
129 {
130  PDC pdc;
131  PPDEVOBJ ppdev;
132  HWND hWnd;
133  PWNDOBJ pWndObj;
134  SURFOBJ *pso = NULL;
135  BOOL Ret = FALSE;
136 
137  DPRINT1("Setting pixel format from win32k!\n");
138 
139  pdc = DC_LockDc(hdc);
140  if (!pdc)
141  {
143  return FALSE;
144  }
145 
146  if (!pdc->ipfdDevMax)
147  IntGetipfdDevMax(pdc);
148 
149  if ( ipfd < 1 ||
150  ipfd > pdc->ipfdDevMax )
151  {
153  goto Exit;
154  }
155 
157  hWnd = UserGethWnd(hdc, &pWndObj);
158  UserLeave();
159 
160  if (!hWnd)
161  {
163  goto Exit;
164  }
165 
166  ppdev = pdc->ppdev;
167 
168  /*
169  WndObj is needed so exit on NULL pointer.
170  */
171  if (pWndObj)
172  pso = pWndObj->psoOwner;
173  else
174  {
176  goto Exit;
177  }
178 
179  if (ppdev->flFlags & PDEV_META_DEVICE)
180  {
182  goto Exit;
183  }
184 
185  if (ppdev->DriverFunctions.SetPixelFormat)
186  {
187  Ret = ppdev->DriverFunctions.SetPixelFormat(
188  pso,
189  ipfd,
190  hWnd);
191  }
192 
193 Exit:
194  DC_UnlockDc(pdc);
195  return Ret;
196 }
197 
198 BOOL
199 APIENTRY
201  _In_ HDC hdc)
202 {
203  PDC pdc;
204  PPDEVOBJ ppdev;
205  HWND hWnd;
206  PWNDOBJ pWndObj;
207  SURFOBJ *pso = NULL;
208  BOOL Ret = FALSE;
209 
210  pdc = DC_LockDc(hdc);
211  if (!pdc)
212  {
214  return FALSE;
215  }
216 
218  hWnd = UserGethWnd(hdc, &pWndObj);
219  UserLeave();
220 
221  if (!hWnd)
222  {
224  goto Exit;
225  }
226 
227  ppdev = pdc->ppdev;
228 
229  /*
230  WndObj is needed so exit on NULL pointer.
231  */
232  if (pWndObj)
233  pso = pWndObj->psoOwner;
234  else
235  {
237  goto Exit;
238  }
239 
240  if (ppdev->flFlags & PDEV_META_DEVICE)
241  {
243  goto Exit;
244  }
245 
246  if (ppdev->DriverFunctions.SwapBuffers)
247  {
248  Ret = ppdev->DriverFunctions.SwapBuffers(pso, pWndObj);
249  }
250 
251 Exit:
252  DC_UnlockDc(pdc);
253  return Ret;
254 }
255 
256 /* EOF */
DHPDEV dhpdev
Definition: pdevobj.h:121
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PFN_DrvSwapBuffers SwapBuffers
Definition: ntgdityp.h:624
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
SURFOBJ * psoOwner
Definition: winddi.h:1230
_In_ INT ipfd
Definition: ntgdi.h:474
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
#define FASTCALL
Definition: nt_native.h:50
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
PFN_DrvDescribePixelFormat DescribePixelFormat
Definition: ntgdityp.h:623
_SEH2_TRY
Definition: create.c:4250
PFN_DrvSetPixelFormat SetPixelFormat
Definition: ntgdityp.h:622
BOOL APIENTRY NtGdiSetPixelFormat(_In_ HDC hdc, _In_ INT ipfd)
Definition: wingl.c:126
_In_ LONG _In_ ULONG cjpfd
Definition: winddi.h:3488
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:138
FLONG flFlags
Definition: pdevobj.h:89
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define _Out_writes_bytes_(size)
Definition: no_sal2.h:370
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3664
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
_Success_(return !=0)
Definition: wingl.c:41
static INT FASTCALL IntGetipfdDevMax(PDC pdc)
Definition: wingl.c:17
Definition: polytest.cpp:40
#define __kernel_entry
Definition: specstrings.h:50
static void Exit(void)
Definition: sock.c:1331
#define ERROR_INVALID_WINDOW_STYLE
Definition: winerror.h:1181
HDC hdc
Definition: main.c:9
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
HWND FASTCALL UserGethWnd(HDC, PWNDOBJ *)
Definition: windc.c:952
#define _In_
Definition: no_sal2.h:204
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
#define UNIMPLEMENTED
Definition: debug.h:114
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
BOOL APIENTRY NtGdiSwapBuffers(_In_ HDC hdc)
Definition: wingl.c:200
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define APIENTRY
Definition: api.h:79