[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 28 Apr 2011 14:29:47 +0000 (14:29 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 28 Apr 2011 14:29:47 +0000 (14:29 +0000)
- Don't use exclusive locks for pens
- Don't try to delete the window update region
- Don't ignore pid in GreIsHandleValid
- Check if handle is valid before deleting it in DC_Cleanup
- Silence a DPRINT

svn path=/trunk/; revision=51475

reactos/subsystems/win32/win32k/include/pen.h
reactos/subsystems/win32/win32k/ntuser/painting.c
reactos/subsystems/win32/win32k/objects/arc.c
reactos/subsystems/win32/win32k/objects/dclife.c
reactos/subsystems/win32/win32k/objects/fillshap.c
reactos/subsystems/win32/win32k/objects/gdiobj.c
reactos/subsystems/win32/win32k/objects/pen.c

index a7e96ad..29f0742 100644 (file)
@@ -11,8 +11,6 @@
 #define PEN_FreePen(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDIObjType_BRUSH_TYPE)
 #define PEN_FreePenByHandle(hBMObj) GDIOBJ_FreeObjByHandle((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
 
-//#define PEN_LockPen(hBMObj) ((PBRUSH)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
-
 #define PEN_AllocExtPen() ((PBRUSH)GDIOBJ_AllocObj(GDIObjType_BRUSH_TYPE))
 #define PEN_AllocExtPenWithHandle() ((PBRUSH)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_EXTPEN, sizeof(BRUSH)))
 
@@ -25,8 +23,6 @@
 
 #define  PEN_ShareUnlockPen(ppen) GDIOBJ_vDereferenceObject((POBJ)ppen)
 
-
-PBRUSH FASTCALL PEN_LockPen(HGDIOBJ);
 PBRUSH FASTCALL PEN_ShareLockPen(HGDIOBJ);
 
 INT APIENTRY PEN_GetObject(PBRUSH pPen, INT Count, PLOGPEN Buffer);
index 636e271..fc7eba1 100644 (file)
@@ -242,12 +242,6 @@ co_IntPaintWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
             MsqDecPaintCountQueue(Wnd->head.pti->MessageQueue);
             co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
 
-            if ( (HANDLE) 1 != TempRegion &&
-                 NULL != TempRegion)
-            {
-               /* NOTE: The region can already be deleted! */
-               GreDeleteObject(TempRegion);
-            }
          }
 
          if (Wnd->state & WNDS_ERASEBACKGROUND)
index 17d7f26..eefccce 100644 (file)
@@ -46,7 +46,7 @@ IntArc( DC *dc,
 {
     PDC_ATTR pdcattr;
     RECTL RectBounds, RectSEpts;
-    PBRUSH pbrushPen;
+    PBRUSH pbrPen;
     SURFACE *psurf;
     BOOL ret = TRUE;
     LONG PenWidth, PenOrigWidth;
@@ -71,18 +71,18 @@ IntArc( DC *dc,
 
     pdcattr = dc->pdcattr;
 
-    pbrushPen = PEN_LockPen(pdcattr->hpen);
-    if (!pbrushPen)
+    pbrPen = PEN_ShareLockPen(pdcattr->hpen);
+    if (!pbrPen)
     {
         DPRINT1("Arc Fail 1\n");
         EngSetLastError(ERROR_INTERNAL_ERROR);
         return FALSE;
     }
 
-    PenOrigWidth = PenWidth = pbrushPen->ptPenWidth.x;
-    if (pbrushPen->ulPenStyle == PS_NULL) PenWidth = 0;
+    PenOrigWidth = PenWidth = pbrPen->ptPenWidth.x;
+    if (pbrPen->ulPenStyle == PS_NULL) PenWidth = 0;
 
-    if (pbrushPen->ulPenStyle == PS_INSIDEFRAME)
+    if (pbrPen->ulPenStyle == PS_INSIDEFRAME)
     {
        if (2*PenWidth > (Right - Left)) PenWidth = (Right -Left + 1)/2;
        if (2*PenWidth > (Bottom - Top)) PenWidth = (Bottom -Top + 1)/2;
@@ -93,7 +93,7 @@ IntArc( DC *dc,
     }
 
     if (!PenWidth) PenWidth = 1;
-    pbrushPen->ptPenWidth.x = PenWidth;
+    pbrPen->ptPenWidth.x = PenWidth;
 
     RectBounds.left   = Left;
     RectBounds.right  = Right;
@@ -156,13 +156,13 @@ IntArc( DC *dc,
               AngleStart,
               AngleEnd,
               arctype,
-              pbrushPen);
+              pbrPen);
 
     psurf = dc->dclevel.pSurface;
     if (NULL == psurf)
     {
         DPRINT1("Arc Fail 2\n");
-        PEN_UnlockPen(pbrushPen);
+        PEN_ShareUnlockPen(pbrPen);
         EngSetLastError(ERROR_INTERNAL_ERROR);
         return FALSE;
     }
@@ -175,8 +175,8 @@ IntArc( DC *dc,
     if (arctype == GdiTypeChord)
         PUTLINE(EfCx + CenterX, EfCy + CenterY, SfCx + CenterX, SfCy + CenterY, dc->eboLine);
 
-    pbrushPen->ptPenWidth.x = PenOrigWidth;
-    PEN_UnlockPen(pbrushPen);
+    pbrPen->ptPenWidth.x = PenOrigWidth;
+    PEN_ShareUnlockPen(pbrPen);
     DPRINT("IntArc Exit.\n");
     return ret;
 }
index 83cd245..6b66f8c 100644 (file)
@@ -368,13 +368,13 @@ DC_Cleanup(PVOID ObjectBody)
     EBRUSHOBJ_vCleanup(&pdc->eboBackground);
 
     /*  Free regions */
-    if (pdc->rosdc.hClipRgn)
+    if (pdc->rosdc.hClipRgn && GreIsHandleValid(pdc->rosdc.hClipRgn))
         GreDeleteObject(pdc->rosdc.hClipRgn);
     if (pdc->prgnVis)
     {
         REGION_Delete(pdc->prgnVis);
     }
-    if (pdc->rosdc.hGCClipRgn)
+    if (pdc->rosdc.hGCClipRgn && GreIsHandleValid(pdc->rosdc.hGCClipRgn))
     {
         GreDeleteObject(pdc->rosdc.hGCClipRgn);
     }
index bdb98e2..c1ff201 100644 (file)
@@ -248,7 +248,7 @@ NtGdiEllipse(
     if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
         DC_vUpdateLineBrush(dc);
 
-    pbrush = PEN_LockPen(pdcattr->hpen);
+    pbrush = PEN_ShareLockPen(pdcattr->hpen);
     if (!pbrush)
     {
         DPRINT1("Ellipse Fail 1\n");
@@ -329,7 +329,7 @@ NtGdiEllipse(
                              pbrush);
 
     pbrush->ptPenWidth.x = PenOrigWidth;
-    PEN_UnlockPen(pbrush);
+    PEN_ShareUnlockPen(pbrush);
     DC_UnlockDc(dc);
     DPRINT("Ellipse Exit.\n");
     return ret;
@@ -714,7 +714,7 @@ IntRoundRect(
     int  yCurveDiameter)
 {
     PDC_ATTR pdcattr;
-    PBRUSH   pbrushLine, pbrushFill;
+    PBRUSH   pbrLine, pbrFill;
     RECTL RectBounds;
     LONG PenWidth, PenOrigWidth;
     BOOL ret = TRUE; // default to success
@@ -748,18 +748,18 @@ IntRoundRect(
     if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
         DC_vUpdateLineBrush(dc);
 
-    pbrushLine = PEN_LockPen(pdcattr->hpen);
-    if (!pbrushLine)
+    pbrLine = PEN_ShareLockPen(pdcattr->hpen);
+    if (!pbrLine)
     {
         /* Nothing to do, as we don't have a bitmap */
         EngSetLastError(ERROR_INTERNAL_ERROR);
         return FALSE;
     }
 
-    PenOrigWidth = PenWidth = pbrushLine->ptPenWidth.x;
-    if (pbrushLine->ulPenStyle == PS_NULL) PenWidth = 0;
+    PenOrigWidth = PenWidth = pbrLine->ptPenWidth.x;
+    if (pbrLine->ulPenStyle == PS_NULL) PenWidth = 0;
 
-    if (pbrushLine->ulPenStyle == PS_INSIDEFRAME)
+    if (pbrLine->ulPenStyle == PS_INSIDEFRAME)
     {
        if (2*PenWidth > (Right - Left)) PenWidth = (Right -Left + 1)/2;
        if (2*PenWidth > (Bottom - Top)) PenWidth = (Bottom -Top + 1)/2;
@@ -770,7 +770,7 @@ IntRoundRect(
     }
 
     if (!PenWidth) PenWidth = 1;
-    pbrushLine->ptPenWidth.x = PenWidth;
+    pbrLine->ptPenWidth.x = PenWidth;
 
     RectBounds.left = Left;
     RectBounds.top = Top;
@@ -784,8 +784,8 @@ IntRoundRect(
     RectBounds.right  += dc->ptlDCOrig.x;
     RectBounds.bottom += dc->ptlDCOrig.y;
 
-    pbrushFill = BRUSH_ShareLockBrush(pdcattr->hbrush);
-    if (NULL == pbrushFill)
+    pbrFill = BRUSH_ShareLockBrush(pdcattr->hbrush);
+    if (!pbrFill)
     {
         DPRINT1("FillRound Fail\n");
         EngSetLastError(ERROR_INTERNAL_ERROR);
@@ -793,7 +793,7 @@ IntRoundRect(
     }
     else
     {
-        RtlCopyMemory(&brushTemp, pbrushFill, sizeof(brushTemp));
+        RtlCopyMemory(&brushTemp, pbrFill, sizeof(brushTemp));
         brushTemp.ptOrigin.x += RectBounds.left - Left;
         brushTemp.ptOrigin.y += RectBounds.top - Top;
         ret = IntFillRoundRect( dc,
@@ -804,7 +804,7 @@ IntRoundRect(
                                 xCurveDiameter,
                                 yCurveDiameter,
                                 &brushTemp);
-        BRUSH_ShareUnlockBrush(pbrushFill);
+        BRUSH_ShareUnlockBrush(pbrFill);
     }
 
     if (ret)
@@ -815,10 +815,10 @@ IntRoundRect(
                 RectBounds.bottom,
                    xCurveDiameter,
                    yCurveDiameter,
-                   pbrushLine);
+                   pbrLine);
 
-    pbrushLine->ptPenWidth.x = PenOrigWidth;
-    PEN_UnlockPen(pbrushLine);
+    pbrLine->ptPenWidth.x = PenOrigWidth;
+    PEN_ShareUnlockPen(pbrLine);
     return ret;
 }
 
index 1050de6..2a5597e 100644 (file)
@@ -368,9 +368,8 @@ ENTRY_ReferenceEntryByHandle(HGDIOBJ hobj, FLONG fl)
             pentry->ObjectOwner.ulObj != GDI_OBJ_HMGR_PUBLIC &&
             pentry->ObjectOwner.ulObj != PtrToUlong(PsGetCurrentProcessId()))
         {
-            DPRINT1("GDIOBJ: Cannot reference foreign handle %p, pentry=%p:%lx.\n",
+            DPRINT("GDIOBJ: Cannot reference foreign handle %p, pentry=%p:%lx.\n",
                     hobj, pentry, pentry->ObjectOwner.ulObj);
-            //ASSERT(FALSE);
             return NULL;
         }
 
@@ -892,7 +891,7 @@ GreIsHandleValid(HGDIOBJ hobj)
 {
     PENTRY pentry;
 
-    pentry = ENTRY_ReferenceEntryByHandle(hobj, GDIOBJFLAG_IGNOREPID);
+    pentry = ENTRY_ReferenceEntryByHandle(hobj, 0);
     if (!pentry) return FALSE;
     GDIOBJ_vDereferenceObject(pentry->einfo.pobj);
     return TRUE;
index 4c9a2d0..9c246b8 100644 (file)
 
 PBRUSH
 FASTCALL
-PEN_LockPen(HGDIOBJ hobj)
+PEN_ShareLockPen(HGDIOBJ hobj)
 {
     if (GDI_HANDLE_GET_TYPE(hobj) != GDILoObjType_LO_PEN_TYPE &&
-        GDI_HANDLE_GET_TYPE(hobj) != GDILoObjType_LO_EXTPEN_TYPE) return NULL;
-
-    return GDIOBJ_LockObject(hobj, GDIObjType_BRUSH_TYPE);
-}
+        GDI_HANDLE_GET_TYPE(hobj) != GDILoObjType_LO_EXTPEN_TYPE)
+    {
+        return NULL;
+    }
 
-PBRUSH
-FASTCALL
-PEN_ShareLockPen(HGDIOBJ hBMObj)
-{
-   if (GDI_HANDLE_GET_TYPE(hBMObj) == GDI_OBJECT_TYPE_EXTPEN)
-      return GDIOBJ_ShareLockObj( hBMObj, GDI_OBJECT_TYPE_EXTPEN);
-   else
-      return GDIOBJ_ShareLockObj( hBMObj, GDI_OBJECT_TYPE_PEN);
+    return (PBRUSH)GDIOBJ_ReferenceObjectByHandle(hobj, GDIObjType_BRUSH_TYPE);
 }
 
 HPEN APIENTRY
@@ -196,16 +189,16 @@ ExitCleanup:
 VOID FASTCALL
 IntGdiSetSolidPenColor(HPEN hPen, COLORREF Color)
 {
-  PBRUSH pbrushPen;
+  PBRUSH pbrPen;
 
-  pbrushPen = PEN_LockPen(hPen);
-  if (pbrushPen)
+  pbrPen = PEN_ShareLockPen(hPen);
+  if (pbrPen)
   {
-    if (pbrushPen->flAttrs & GDIBRUSH_IS_SOLID)
+    if (pbrPen->flAttrs & GDIBRUSH_IS_SOLID)
     {
-      pbrushPen->BrushAttr.lbColor = Color & 0xFFFFFF;
+      pbrPen->BrushAttr.lbColor = Color & 0xFFFFFF;
     }
-    PEN_UnlockPen(pbrushPen);
+    PEN_ShareUnlockPen(pbrPen);
   }
 }