ReactOS 0.4.15-dev-7942-gd23573b
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
14static
15INT
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)
43INT
45NtGdiDescribePixelFormat(
46 _In_ HDC hdc,
50{
51 PDC pdc;
52 PPDEVOBJ ppdev;
53 INT Ret = 0;
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 {
106 {
109 RtlCopyMemory(ppfd, &pfdSafe, cjpfd);
110 }
112 {
114 }
115 _SEH2_END;
116 }
117
118Exit:
119 DC_UnlockDc(pdc);
120 return Ret;
121}
122
123
124BOOL
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
186 {
187 Ret = ppdev->DriverFunctions.SetPixelFormat(
188 pso,
189 ipfd,
190 hWnd);
191 }
192
193Exit:
194 DC_UnlockDc(pdc);
195 return Ret;
196}
197
198BOOL
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
251Exit:
252 DC_UnlockDc(pdc);
253 return Ret;
254}
255
256/* EOF */
HWND hWnd
Definition: settings.c:17
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:115
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
HWND FASTCALL UserGethWnd(HDC, PWNDOBJ *)
Definition: windc.c:953
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define min(a, b)
Definition: monoChain.cc:55
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Out_writes_bytes_(size)
Definition: ms_sal.h:350
#define _In_
Definition: ms_sal.h:308
unsigned int UINT
Definition: ndis.h:50
#define FASTCALL
Definition: nt_native.h:50
static INT FASTCALL IntGetipfdDevMax(PDC pdc)
Definition: wingl.c:17
BOOL APIENTRY NtGdiSetPixelFormat(_In_ HDC hdc, _In_ INT ipfd)
Definition: wingl.c:126
BOOL APIENTRY NtGdiSwapBuffers(_In_ HDC hdc)
Definition: wingl.c:200
_In_ INT ipfd
Definition: ntgdi.h:474
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:242
@ PDEV_META_DEVICE
Definition: pdevobj.h:20
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
static void Exit(void)
Definition: sock.c:1330
#define __kernel_entry
Definition: specstrings.h:355
Definition: polytest.cpp:41
PFN_DrvSetPixelFormat SetPixelFormat
Definition: ntgdityp.h:623
PFN_DrvDescribePixelFormat DescribePixelFormat
Definition: ntgdityp.h:624
PFN_DrvSwapBuffers SwapBuffers
Definition: ntgdityp.h:625
FLONG flFlags
Definition: pdevobj.h:87
DHPDEV dhpdev
Definition: pdevobj.h:120
DRIVER_FUNCTIONS DriverFunctions
Definition: pdevobj.h:137
SURFOBJ * psoOwner
Definition: winddi.h:1230
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3665
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
_In_ LONG _In_ ULONG cjpfd
Definition: winddi.h:3489
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3490
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
#define ERROR_INVALID_WINDOW_STYLE
Definition: winerror.h:1181