[ros-diffs] [jimtabor] 31523: Implement gdi ScaleViewport/WindowExtEx and mirror region support. Mirroring is not finished and is unplugged.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Mon Dec 31 18:26:57 CET 2007


Author: jimtabor
Date: Mon Dec 31 20:26:57 2007
New Revision: 31523

URL: http://svn.reactos.org/svn/reactos?rev=31523&view=rev
Log:
Implement gdi ScaleViewport/WindowExtEx and mirror region support. Mirroring is not finished and is unplugged.

Modified:
    trunk/reactos/dll/win32/gdi32/misc/stubs.c
    trunk/reactos/dll/win32/gdi32/objects/coord.c
    trunk/reactos/dll/win32/gdi32/objects/region.c

Modified: trunk/reactos/dll/win32/gdi32/misc/stubs.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs.c?rev=31523&r1=31522&r2=31523&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubs.c (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubs.c Mon Dec 31 20:26:57 2007
@@ -674,47 +674,6 @@
 	return 0;
 }
 
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-ScaleViewportExtEx(
-	HDC	a0,
-	int	a1,
-	int	a2,
-	int	a3,
-	int	a4,
-	LPSIZE	a5
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-ScaleWindowExtEx(
-	HDC	a0,
-	int	a1,
-	int	a2,
-	int	a3,
-	int	a4,
-	LPSIZE	a5
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return FALSE;
-}
-
-
 /*
  * @implemented
  */
@@ -1463,22 +1422,6 @@
     }
     return retValue;
 }
-
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-MirrorRgn(HWND hwnd,HRGN hrgn)
-{
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
-}
-
-
 
 /*
  * @unimplemented

Modified: trunk/reactos/dll/win32/gdi32/objects/coord.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/coord.c?rev=31523&r1=31522&r2=31523&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/coord.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/coord.c Mon Dec 31 20:26:57 2007
@@ -565,6 +565,86 @@
 /*
  * @implemented
  */
+BOOL
+STDCALL
+ScaleViewportExtEx(
+	HDC	a0,
+	int	a1,
+	int	a2,
+	int	a3,
+	int	a4,
+	LPSIZE	a5
+	)
+{
+#if 0
+  if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)
+  {
+    if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC)
+      return MFDRV_;
+    else
+    {
+      PLDC pLDC = GdiGetLDC(a0);
+      if ( !pLDC )
+      {
+         SetLastError(ERROR_INVALID_HANDLE);
+         return FALSE;
+      }
+      if (pLDC->iType == LDC_EMFLDC)
+      {
+        return EMFDRV_;
+      }
+    }
+  }
+#endif
+  if (!GdiIsHandleValid((HGDIOBJ) a0) ||
+      (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE;
+
+  return NtGdiScaleViewportExtEx(a0, a1, a2, a3, a4, a5);
+}
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+ScaleWindowExtEx(
+	HDC	a0,
+	int	a1,
+	int	a2,
+	int	a3,
+	int	a4,
+	LPSIZE	a5
+	)
+{
+#if 0
+  if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)
+  {
+    if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC)
+      return MFDRV_;
+    else
+    {
+      PLDC pLDC = GdiGetLDC(a0);
+      if ( !pLDC )
+      {
+         SetLastError(ERROR_INVALID_HANDLE);
+         return FALSE;
+      }
+      if (pLDC->iType == LDC_EMFLDC)
+      {
+        return EMFDRV_;
+      }
+    }
+  }
+#endif
+  if (!GdiIsHandleValid((HGDIOBJ) a0) ||
+      (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE;
+
+  return NtGdiScaleWindowExtEx(a0, a1, a2, a3, a4, a5);
+}
+
+/*
+ * @implemented
+ */
 DWORD
 STDCALL
 GetLayout(HDC hdc

Modified: trunk/reactos/dll/win32/gdi32/objects/region.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/region.c?rev=31523&r1=31522&r2=31523&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/region.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/region.c Mon Dec 31 20:26:57 2007
@@ -1,80 +1,30 @@
 #include "precomp.h"
 
 
-/*
- * @implemented
- */
-int STDCALL
-SelectClipRgn(
-        HDC     hdc,
-        HRGN    hrgn
-)
-{
-    return ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
-}
-
-
-/*
- * @implemented
- */
-int
-STDCALL
-GetClipRgn(
-        HDC     hdc,
-        HRGN    hrgn
-        )
-{
-    return NtGdiGetRandomRgn(hdc, hrgn, 1);
-}
-
-
-HRGN
-WINAPI
-CreatePolygonRgn( const POINT * lppt, int cPoints, int fnPolyFillMode)
-{
-    return (HRGN) NtGdiPolyPolyDraw( (HDC) fnPolyFillMode, (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
-}
-
-
-HRGN
-WINAPI
-CreatePolyPolygonRgn( const POINT* lppt,
-                      const INT* lpPolyCounts,
-                      int nCount,
-                      int fnPolyFillMode)
-{
-    return (HRGN) NtGdiPolyPolyDraw(  (HDC) fnPolyFillMode, (PPOINT) lppt, (PULONG) lpPolyCounts, (ULONG) nCount, GdiPolyPolyRgn );
-}
-
-HRGN
-WINAPI
-CreateEllipticRgnIndirect(
-   const RECT *prc
-)
-{
-    /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
-    return NtGdiCreateEllipticRgn(prc->left, prc->top, prc->right, prc->bottom);
-
-}
-
-HRGN
-WINAPI
-CreateRectRgn(int x1, int y1, int x2,int y2)
-{
-    /* FIXME Some part need be done in user mode */
-    return NtGdiCreateRectRgn(x1,y1,x2,y2);
-}
-
-
-HRGN
-WINAPI
-CreateRectRgnIndirect(
-    const RECT *prc
-)
-{
-    /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
-    return CreateRectRgn(prc->left, prc->top, prc->right, prc->bottom);
-
+static
+VOID
+FASTCALL
+SortRects(PRECT pRect, INT nCount)
+{
+  INT i = 0, a = 0, b = 0;
+  RECT sRect;
+
+  if (nCount > 0)
+  {
+      for(;;)
+      {
+         do
+         {
+            if(pRect[b].top != pRect[i].bottom) break;
+            if(pRect[b].left < pRect[a].left)
+            {
+               sRect = pRect[a];
+               pRect[a] = pRect[b];
+               pRect[b] = sRect;
+            }
+         } while(0);
+      }
+  }
 }
 
 /*
@@ -85,7 +35,7 @@
 DeleteRegion( HRGN hRgn )
 {
 #if 0
-  PREGION_ATTR Rgn_Attr;
+  PRGN_ATTR Rgn_Attr;
 
   if ((GdiGetHandleUserData((HGDIOBJ) hRgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) &&
       ( Rgn_Attr != NULL ))
@@ -110,6 +60,131 @@
   }
 #endif
   return NtGdiDeleteObjectApp((HGDIOBJ) hRgn);
+}
+
+INT
+FASTCALL
+MirrorRgnByWidth(HRGN hRgn, INT Width, HRGN *phRgn)
+{
+  INT cRgnDSize, Ret = 0;
+  PRGNDATA pRgnData;
+  
+  cRgnDSize = NtGdiGetRegionData(hRgn, 0, NULL);
+
+  if (cRgnDSize)
+  {
+     pRgnData = LocalAlloc(LMEM_FIXED, cRgnDSize * sizeof(LONG));
+     if (pRgnData)
+     {
+        if ( GetRegionData(hRgn, cRgnDSize, pRgnData) )
+        {
+           HRGN hRgnex;
+           INT i, SaveL = pRgnData->rdh.rcBound.left;
+           pRgnData->rdh.rcBound.left = Width - pRgnData->rdh.rcBound.right;
+           pRgnData->rdh.rcBound.right = Width - SaveL;
+           if (pRgnData->rdh.nCount > 0)
+           {
+              PRECT pRect = (PRECT)&pRgnData->Buffer;
+              for (i = 0; i < pRgnData->rdh.nCount; i++)
+              {
+                  SaveL = pRect[i].left;
+                  pRect[i].left = Width - pRect[i].right;
+                  pRect[i].right = Width - SaveL;
+              }
+           }
+           SortRects((PRECT)&pRgnData->Buffer, pRgnData->rdh.nCount);
+           hRgnex = ExtCreateRegion(NULL, cRgnDSize , pRgnData);
+           if (hRgnex)
+           {
+              if (phRgn) phRgn = (HRGN *)hRgnex;
+              else
+              {
+                 CombineRgn(hRgn, hRgnex, *phRgn, RGN_COPY); 
+                 DeleteObject(hRgnex);
+              }
+              Ret = 1;
+           }
+        }
+        LocalFree(pRgnData);
+     }
+  }
+  return Ret;
+}
+
+INT
+STDCALL
+MirrorRgnDC(HDC hdc, HRGN hRgn, HRGN *phRgn)
+{
+  if (!GdiIsHandleValid((HGDIOBJ) hdc) ||
+      (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return 0;
+
+  return MirrorRgnByWidth(hRgn, NtGdiGetDeviceWidth(hdc), phRgn);
+}
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+HRGN
+WINAPI
+CreatePolygonRgn( const POINT * lppt, int cPoints, int fnPolyFillMode)
+{
+    return (HRGN) NtGdiPolyPolyDraw( (HDC) fnPolyFillMode, (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
+}
+
+
+/*
+ * @implemented
+ */
+HRGN
+WINAPI
+CreatePolyPolygonRgn( const POINT* lppt,
+                      const INT* lpPolyCounts,
+                      int nCount,
+                      int fnPolyFillMode)
+{
+    return (HRGN) NtGdiPolyPolyDraw(  (HDC) fnPolyFillMode, (PPOINT) lppt, (PULONG) lpPolyCounts, (ULONG) nCount, GdiPolyPolyRgn );
+}
+
+
+/*
+ * @implemented
+ */
+HRGN
+WINAPI
+CreateEllipticRgnIndirect(
+   const RECT *prc
+)
+{
+    /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
+    return NtGdiCreateEllipticRgn(prc->left, prc->top, prc->right, prc->bottom);
+
+}
+
+/*
+ * @implemented
+ */
+HRGN
+WINAPI
+CreateRectRgn(int x1, int y1, int x2,int y2)
+{
+    /* FIXME Some part need be done in user mode */
+    return NtGdiCreateRectRgn(x1,y1,x2,y2);
+}
+
+/*
+ * @implemented
+ */
+HRGN
+WINAPI
+CreateRectRgnIndirect(
+    const RECT *prc
+)
+{
+    /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
+    return CreateRectRgn(prc->left, prc->top, prc->right, prc->bottom);
+
 }
 
 /*
@@ -136,6 +211,47 @@
    return NULL;
 }
 
+/*
+ * @implemented
+ */
+int
+STDCALL
+GetClipRgn(
+        HDC     hdc,
+        HRGN    hrgn
+        )
+{
+  INT Ret = NtGdiGetRandomRgn(hdc, hrgn, 1);
+//  if (Ret)
+ // {
+ //    if(GetLayout(hdc) & LAYOUT_RTL) MirrorRgnDC(hdc,(HRGN)Ret, NULL);
+ // }
+  return Ret;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+MirrorRgn(HWND hwnd, HRGN hrgn)
+{
+  RECT Rect;
+  GetWindowRect(hwnd, &Rect);
+  return MirrorRgnByWidth(hrgn, Rect.right - Rect.left, NULL);
+}
+
+/*
+ * @implemented
+ */
+int STDCALL
+SelectClipRgn(
+        HDC     hdc,
+        HRGN    hrgn
+)
+{
+    return ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
+}
 
 /*
  * @implemented
@@ -149,7 +265,7 @@
            int nBottomRect)
 {
 #if 0
-  PREGION_ATTR Rgn_Attr;
+  PRGN_ATTR Rgn_Attr;
 
   if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) 
 #endif




More information about the Ros-diffs mailing list