[ros-diffs] [jgardou] 48007: [WIN32K] - Get rid of rosdc::hVisRgn, as in yarotows (r46372)

jgardou at svn.reactos.org jgardou at svn.reactos.org
Mon Jul 12 16:52:12 UTC 2010


Author: jgardou
Date: Mon Jul 12 16:52:10 2010
New Revision: 48007

URL: http://svn.reactos.org/svn/reactos?rev=48007&view=rev
Log:
[WIN32K]
  - Get rid of rosdc::hVisRgn, as in yarotows (r46372)

Modified:
    trunk/reactos/subsystems/win32/win32k/include/dc.h
    trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c
    trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
    trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c
    trunk/reactos/subsystems/win32/win32k/objects/dclife.c
    trunk/reactos/subsystems/win32/win32k/objects/region.c

Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/dc.h?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -7,6 +7,7 @@
 #include "bitmaps.h"
 #include "pdevobj.h"
 #include "palette.h"
+#include "region.h"
 
 /* Constants ******************************************************************/
 
@@ -26,7 +27,6 @@
 typedef struct _ROS_DC_INFO
 {
   HRGN     hClipRgn;     /* Clip region (may be 0) */
-  HRGN     hVisRgn;      /* Visible region (must never be 0) */
   HRGN     hGCClipRgn;   /* GC clip region (ClipRgn AND VisRgn) */
 
   CLIPOBJ     *CombinedClip; /* Use XCLIPOBJ in DC. */
@@ -101,9 +101,9 @@
   RECTL       erclWindow;
   RECTL       erclBounds;
   RECTL       erclBoundsApp;
-  PVOID       prgnAPI; /* PROSRGNDATA */
-  PVOID       prgnVis;
-  PVOID       prgnRao;
+  PROSRGNDATA prgnAPI; /* PROSRGNDATA */
+  PROSRGNDATA prgnVis; /* Visible region (must never be 0) */
+  PROSRGNDATA prgnRao;
   POINTL      ptlFillOrigin;
   EBRUSHOBJ   eboFill;
   EBRUSHOBJ   eboLine;

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -184,8 +184,8 @@
 
    Monitor->GdiDevice = pGdiDevice;
    Monitor->rcMonitor.left  = 0;
-   Monitor->rcMonitor.top   = 0;   
-   Monitor->rcMonitor.right  = Monitor->rcMonitor.left + pGdiDevice->gdiinfo.ulHorzRes; 
+   Monitor->rcMonitor.top   = 0;
+   Monitor->rcMonitor.right  = Monitor->rcMonitor.left + pGdiDevice->gdiinfo.ulHorzRes;
    Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + pGdiDevice->gdiinfo.ulVertRes;
    Monitor->rcWork = Monitor->rcMonitor;
    Monitor->cWndStack = 0;
@@ -492,7 +492,6 @@
    if (hDC != NULL)
    {
       PDC dc;
-      HRGN dcVisRgn;
       INT regionType;
 
       /* get visible region bounding rect */
@@ -503,10 +502,9 @@
          /* FIXME: setlasterror? */
          return -1;
       }
-      dcVisRgn = dc->rosdc.hVisRgn;
+      regionType = REGION_GetRgnBox(dc->prgnVis, &dcRect);
       DC_UnlockDc(dc);
 
-      regionType = NtGdiGetRgnBox(dcVisRgn, &dcRect);
       if (regionType == 0)
       {
          DPRINT("NtGdiGetRgnBox() failed!\n");

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/painting.c?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -1206,8 +1206,7 @@
       {
          return FALSE;
       }
-      hrgnVisible = pDC->rosdc.hVisRgn;  // pDC->prgnRao?
-      DC_UnlockDc(pDC);
+      hrgnVisible = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr;  // pDC->prgnRao?
 
       /* Begin with the shifted and then clipped scroll rect */
       rcDst = rcScroll;
@@ -1234,6 +1233,9 @@
       NtGdiCombineRgn(hrgnTmp, hrgnTmp, hrgnVisible, RGN_AND);
       NtGdiOffsetRgn(hrgnTmp, dx, dy);
       Result = NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF);
+
+	  /* DO NOT Unlock DC while messing with prgnVis! */
+	  DC_UnlockDc(pDC);
 
       REGION_FreeRgnByHandle(hrgnTmp);
 

Modified: trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -26,6 +26,7 @@
 CLIPPING_UpdateGCRegion(DC* Dc)
 {
    PROSRGNDATA CombinedRegion;
+   HRGN hRgnVis = NULL;
 
    /* Experiment with API region based on wine.. */
    if (Dc->rosdc.hClipRgn && Dc->dclevel.prgnMeta)
@@ -50,13 +51,14 @@
       Dc->prgnAPI = NULL;
    }
 
+
    if (Dc->rosdc.hGCClipRgn == NULL)
       Dc->rosdc.hGCClipRgn = IntSysCreateRectRgn(0, 0, 0, 0);
 
    if (Dc->rosdc.hClipRgn == NULL)
-      NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hVisRgn, 0, RGN_COPY);
+      NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, ((PROSRGNDATA)Dc->prgnVis)->BaseObject.hHmgr, 0, RGN_COPY);
    else
-      NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, Dc->rosdc.hVisRgn, RGN_AND);
+      NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, hRgnVis, RGN_AND);
 
    NtGdiOffsetRgn(Dc->rosdc.hGCClipRgn, Dc->ptlDCOrig.x, Dc->ptlDCOrig.y);
 
@@ -104,17 +106,17 @@
   }
 
   dc->fs &= ~DC_FLAG_DIRTY_RAO;
-  
-  if (dc->rosdc.hVisRgn == NULL)
-  {
-    dc->rosdc.hVisRgn = IntSysCreateRectRgn(0, 0, 0, 0);
-    GDIOBJ_CopyOwnership(hdc, dc->rosdc.hVisRgn);
-  }
-
-  retval = NtGdiCombineRgn(dc->rosdc.hVisRgn, hrgn, 0, RGN_COPY);
+
+  if (dc->prgnVis == NULL)
+  {
+    dc->prgnVis = IntSysCreateRectpRgn(0, 0, 0, 0);
+    GDIOBJ_CopyOwnership(hdc, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr);
+  }
+
+  retval = NtGdiCombineRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, hrgn, 0, RGN_COPY);
   if ( retval != ERROR )
   {
-    NtGdiOffsetRgn(dc->rosdc.hVisRgn, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
+    NtGdiOffsetRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
     CLIPPING_UpdateGCRegion(dc);
   }
 
@@ -150,12 +152,10 @@
   {
     if (!dc->rosdc.hClipRgn)
     {
-      PROSRGNDATA Rgn;
       RECTL rect;
-      if((Rgn = RGNOBJAPI_Lock(dc->rosdc.hVisRgn, NULL)))
-      {
-        REGION_GetRgnBox(Rgn, &rect);
-        RGNOBJAPI_Unlock(Rgn);
+      if(dc->prgnVis)
+      {
+		REGION_GetRgnBox(dc->prgnVis, &rect);
         dc->rosdc.hClipRgn = IntSysCreateRectRgnIndirect(&rect);
       }
       else
@@ -196,10 +196,10 @@
 INT FASTCALL
 GdiGetClipBox(HDC hDC, PRECTL rc)
 {
-   PROSRGNDATA Rgn;
    INT retval;
    PDC dc;
-   HRGN hRgnNew, hRgn = NULL;
+   PROSRGNDATA pRgnNew, pRgn = NULL;
+   BOOL Unlock = FALSE; //Small hack
 
    if (!(dc = DC_LockDc(hDC)))
    {
@@ -209,44 +209,40 @@
    /* FIXME! Rao and Vis only! */
    if (dc->prgnAPI) // APIRGN
    {
-      hRgn = ((PROSRGNDATA)dc->prgnAPI)->BaseObject.hHmgr;
+      pRgn = dc->prgnAPI;
    }
    else if (dc->dclevel.prgnMeta) // METARGN
    {
-      hRgn = ((PROSRGNDATA)dc->dclevel.prgnMeta)->BaseObject.hHmgr;
+      pRgn = dc->dclevel.prgnMeta;
    }
    else
    {
-      hRgn = dc->rosdc.hClipRgn; // CLIPRGN
-   }
-
-   if (hRgn)
-   {
-      hRgnNew = IntSysCreateRectRgn( 0, 0, 0, 0 );
-
-      NtGdiCombineRgn(hRgnNew, dc->rosdc.hVisRgn, hRgn, RGN_AND);
-
-      if (!(Rgn = RGNOBJAPI_Lock(hRgnNew, NULL)))
+	   Unlock = TRUE ;
+       pRgn = REGION_LockRgn(dc->rosdc.hClipRgn); // CLIPRGN
+   }
+
+   if (pRgn)
+   {
+      pRgnNew = IntSysCreateRectpRgn( 0, 0, 0, 0 );
+
+	  if (!pRgnNew)
       {
          DC_UnlockDc(dc);
+		 if(Unlock) REGION_UnlockRgn(pRgn);
          return ERROR;
       }
 
-      retval = REGION_GetRgnBox(Rgn, rc);
-
-      REGION_FreeRgnByHandle(hRgnNew);
-      RGNOBJAPI_Unlock(Rgn);
+      IntGdiCombineRgn(pRgnNew, dc->prgnVis, pRgn, RGN_AND);
+
+      retval = REGION_GetRgnBox(pRgnNew, rc);
+
+	  REGION_FreeRgnByHandle(pRgnNew->BaseObject.hHmgr);
       DC_UnlockDc(dc);
+	  if(Unlock) REGION_UnlockRgn(pRgn);
       return retval;
    }
 
-   if (!(Rgn = RGNOBJAPI_Lock(dc->rosdc.hVisRgn, NULL)))
-   {
-      DC_UnlockDc(dc);
-      return ERROR;
-   }
-   retval = REGION_GetRgnBox(Rgn, rc);
-   RGNOBJAPI_Unlock(Rgn);
+   retval = REGION_GetRgnBox(dc->prgnVis, rc);
    IntDPtoLP(dc, (LPPOINT)rc, 2);
    DC_UnlockDc(dc);
 
@@ -318,7 +314,7 @@
       if (!dc->rosdc.hClipRgn)
       {
          dc->rosdc.hClipRgn = IntSysCreateRectRgn(0, 0, 0, 0);
-         NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hVisRgn, NewRgn, RGN_DIFF);
+         NtGdiCombineRgn(dc->rosdc.hClipRgn, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, NewRgn, RGN_DIFF);
          Result = SIMPLEREGION;
       }
       else
@@ -483,7 +479,7 @@
 }
 
 int
-FASTCALL 
+FASTCALL
 IntGdiSetMetaRgn(PDC pDC)
 {
   INT Ret = ERROR;
@@ -495,7 +491,7 @@
      {
         TempRgn = IntSysCreateRectpRgn(0,0,0,0);
         if (TempRgn)
-        {        
+        {
            Ret = IntGdiCombineRgn( TempRgn,
                      pDC->dclevel.prgnMeta,
                      pDC->dclevel.prgnClip,
@@ -531,7 +527,7 @@
         pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip;
         pDC->dclevel.prgnClip = NULL;
      }
-     else 
+     else
        Ret = SIMPLEREGION;
   }
   return Ret;
@@ -572,7 +568,7 @@
      REGION_Delete(pDC->prgnRao);
      pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0);
   }
-  
+
   if (pDC->dclevel.prgnMeta && pDC->dclevel.prgnClip)
   {
      IntGdiCombineRgn( pDC->prgnAPI,

Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dclife.c?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -191,14 +191,14 @@
             //
             if (!GDIOBJ_SetOwnership(pDC->rosdc.hClipRgn, Owner)) return FALSE;
         }
-        if (pDC->rosdc.hVisRgn)
+        if (pDC->prgnVis)
         {   // FIXME! HAX!!!
-            Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hVisRgn);
+            Index = GDI_HANDLE_GET_INDEX(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr);
             Entry = &GdiHandleTable->Entries[Index];
             if (Entry->UserData) FreeObjectAttr(Entry->UserData);
             Entry->UserData = NULL;
             //
-            if (!GDIOBJ_SetOwnership(pDC->rosdc.hVisRgn, Owner)) return FALSE;
+            if (!GDIOBJ_SetOwnership(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr, Owner)) return FALSE;
         }
         if (pDC->rosdc.hGCClipRgn)
         {   // FIXME! HAX!!!
@@ -525,9 +525,9 @@
     {
         GreDeleteObject(DCToDelete->rosdc.hClipRgn);
     }
-    if (DCToDelete->rosdc.hVisRgn)
-    {
-        GreDeleteObject(DCToDelete->rosdc.hVisRgn);
+    if (DCToDelete->prgnVis)
+    {
+        GreDeleteObject(DCToDelete->prgnVis->BaseObject.hHmgr);
     }
     if (NULL != DCToDelete->rosdc.CombinedClip)
     {

Modified: trunk/reactos/subsystems/win32/win32k/objects/region.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/region.c?rev=48007&r1=48006&r2=48007&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] Mon Jul 12 16:52:10 2010
@@ -607,42 +607,38 @@
         else
         {
             xrect = ExAllocatePoolWithTag(PagedPool, rgnSrc->rdh.nCount * sizeof(RECT), TAG_REGION);
+			if(!xrect)
+				return FALSE;
             if (rgnDst->Buffer && rgnDst->Buffer != &rgnDst->rdh.rcBound)
                 ExFreePoolWithTag(rgnDst->Buffer, TAG_REGION); //free the old buffer. will be assigned to xrect below.
         }
 
-        if (xrect)
-        {
-            ULONG i;
-
-            if (rgnDst != rgnSrc)
+        if (rgnDst != rgnSrc)
+        {
+            *rgnDst = *rgnSrc;
+        }
+
+        if (off->x || off->y)
+        {
+			ULONG i;
+            for (i = 0; i < rgnDst->rdh.nCount; i++)
             {
-                *rgnDst = *rgnSrc;
+                xrect[i].left = (rgnSrc->Buffer + i)->left + off->x;
+                xrect[i].right = (rgnSrc->Buffer + i)->right + off->x;
+                xrect[i].top = (rgnSrc->Buffer + i)->top + off->y;
+                xrect[i].bottom = (rgnSrc->Buffer + i)->bottom + off->y;
             }
-
-            if (off->x || off->y)
-            {
-                for (i = 0; i < rgnDst->rdh.nCount; i++)
-                {
-                    xrect[i].left = (rgnSrc->Buffer + i)->left + off->x;
-                    xrect[i].right = (rgnSrc->Buffer + i)->right + off->x;
-                    xrect[i].top = (rgnSrc->Buffer + i)->top + off->y;
-                    xrect[i].bottom = (rgnSrc->Buffer + i)->bottom + off->y;
-                }
-                rgnDst->rdh.rcBound.left   += off->x;
-                rgnDst->rdh.rcBound.right  += off->x;
-                rgnDst->rdh.rcBound.top    += off->y;
-                rgnDst->rdh.rcBound.bottom += off->y;
-            }
-            else
-            {
-                COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount);
-            }
-
-            rgnDst->Buffer = xrect;
+            rgnDst->rdh.rcBound.left   += off->x;
+            rgnDst->rdh.rcBound.right  += off->x;
+            rgnDst->rdh.rcBound.top    += off->y;
+            rgnDst->rdh.rcBound.bottom += off->y;
         }
         else
-            return FALSE;
+        {
+            COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount);
+        }
+
+        rgnDst->Buffer = xrect;
     }
     else if ((rect->left >= rect->right) ||
              (rect->top >= rect->bottom) ||
@@ -2035,13 +2031,13 @@
 {
     HRGN hReg;
     PROSRGNDATA pReg;
-    
+
     pReg = (PROSRGNDATA)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_REGION);
     if(!pReg)
     {
         return NULL;
     }
-    
+
     hReg = pReg->BaseObject.hHmgr;
 
     if (nReg == 0 || nReg == 1)
@@ -2228,7 +2224,7 @@
 {
     PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody;
     if (pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound)
-        ExFreePool(pRgn->Buffer);
+        ExFreePoolWithTag(pRgn->Buffer, TAG_REGION);
     return TRUE;
 }
 
@@ -2419,7 +2415,7 @@
     if (!(tmpVisRgn = IntSysCreateRectRgn(0, 0, 0, 0))) return FALSE;
 
     // Transform region into device co-ords
-    if (!REGION_LPTODP(dc, tmpVisRgn, hRgn) || 
+    if (!REGION_LPTODP(dc, tmpVisRgn, hRgn) ||
          NtGdiOffsetRgn(tmpVisRgn, dc->ptlDCOrig.x, dc->ptlDCOrig.y) == ERROR)
     {
         REGION_FreeRgnByHandle(tmpVisRgn);
@@ -2552,13 +2548,13 @@
     }
 }
 
-INT  
+INT
 FASTCALL
 IntGdiOffsetRgn(
     PROSRGNDATA rgn,
     INT XOffset,
     INT YOffset )
-{            
+{
     if (XOffset || YOffset)
     {
         int nbox = rgn->rdh.nCount;
@@ -3444,7 +3440,7 @@
     if ( rgn1->rdh.nCount == 0 )
     {
        bRet = TRUE;
-       goto exit;  
+       goto exit;
     }
 
     if ( rgn1->rdh.rcBound.left   != rgn2->rdh.rcBound.left  ||
@@ -3691,8 +3687,7 @@
         else if (pDC->dclevel.prgnMeta) hSrc = ((PROSRGNDATA)pDC->dclevel.prgnMeta)->BaseObject.hHmgr;
         break;
     case SYSRGN:
-        hSrc = pDC->rosdc.hVisRgn;
-//        if (pDC->prgnVis) hSrc = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr;
+        if (pDC->prgnVis) hSrc = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr;
         break;
     default:
         hSrc = 0;




More information about the Ros-diffs mailing list