[ros-diffs] [jimtabor] 41245: - Implement NtGdiDescribePixelFormat, needs testing.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Tue Jun 2 01:24:21 CEST 2009


Author: jimtabor
Date: Tue Jun  2 03:24:20 2009
New Revision: 41245

URL: http://svn.reactos.org/svn/reactos?rev=41245&view=rev
Log:
- Implement NtGdiDescribePixelFormat, needs testing.

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/wingl.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/wingl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/wingl.c?rev=41245&r1=41244&r2=41245&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/wingl.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/wingl.c [iso-8859-1] Tue Jun  2 03:24:20 2009
@@ -23,13 +23,32 @@
 #define NDEBUG
 #include <debug.h>
 
+static
 INT
-APIENTRY
-NtGdiChoosePixelFormat(HDC  hDC,
-                           CONST PPIXELFORMATDESCRIPTOR  pfd)
+FASTCALL
+IntGetipfdDevMax(PDC pdc)
 {
-  UNIMPLEMENTED;
-  return 0;
+  INT Ret = 0;
+  PPDEVOBJ ppdev = pdc->ppdev;
+
+  if (ppdev->flFlags & PDEV_META_DEVICE)
+  {
+     return 0;
+  }
+
+  if (ppdev->DriverFunctions.DescribePixelFormat)
+  {
+
+     Ret = ppdev->DriverFunctions.DescribePixelFormat(
+                                                ppdev->hPDev,
+                                                1,
+                                                0,
+                                                NULL);
+  }
+
+  if (Ret) pdc->ipfdDevMax = Ret;
+
+  return Ret;
 }
 
 
@@ -40,8 +59,67 @@
                              UINT  BufSize,
                              LPPIXELFORMATDESCRIPTOR  pfd)
 {
-  UNIMPLEMENTED;
-  return 0;
+  PDC pdc;
+  PPDEVOBJ ppdev;
+  INT Ret = 0;
+  PIXELFORMATDESCRIPTOR pfdSafe;
+  NTSTATUS Status = STATUS_SUCCESS;
+
+  if (!BufSize) return 0;
+
+  pdc = DC_LockDc(hDC);
+  if (!pdc)
+  {
+     SetLastWin32Error(ERROR_INVALID_HANDLE);
+     return 0;
+  }
+
+  if (!pdc->ipfdDevMax) IntGetipfdDevMax(pdc);
+
+  if ( BufSize < sizeof(PIXELFORMATDESCRIPTOR) ||
+       PixelFormat < 1 ||
+       PixelFormat > pdc->ipfdDevMax )
+  {  
+     SetLastWin32Error(ERROR_INVALID_PARAMETER);
+     goto Exit;
+  }
+
+  ppdev = pdc->ppdev;
+
+  if (ppdev->flFlags & PDEV_META_DEVICE)
+  {
+     UNIMPLEMENTED;
+     goto Exit;
+  }
+
+  if (ppdev->DriverFunctions.DescribePixelFormat)
+  {
+
+     Ret = ppdev->DriverFunctions.DescribePixelFormat(
+                                                ppdev->hPDev,
+                                                PixelFormat,
+                                                sizeof(PIXELFORMATDESCRIPTOR),
+                                                &pfdSafe);
+  }
+
+  _SEH2_TRY
+  {
+     ProbeForWrite( pfd,
+                    sizeof(PIXELFORMATDESCRIPTOR),
+                    1);
+     RtlCopyMemory(&pfdSafe, pfd, sizeof(PIXELFORMATDESCRIPTOR));
+  }
+  _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+  {
+     Status = _SEH2_GetExceptionCode();
+  }
+  _SEH2_END;
+
+  if (!NT_SUCCESS(Status)) SetLastNtError(Status);
+
+Exit:
+  DC_UnlockDc(pdc);
+  return Ret;
 }
 
 



More information about the Ros-diffs mailing list