Author: jimtabor
Date: Thu Dec 22 17:34:58 2016
New Revision: 73476
URL: 
http://svn.reactos.org/svn/reactos?rev=73476&view=rev
Log:
[Win32SS]
- Implement DC Bounds support. It's close to what wine does and passes thousands of
tests. Still WIP. See CORE-11582.
Modified:
    trunk/reactos/win32ss/gdi/gdi32/objects/dc.c
    trunk/reactos/win32ss/gdi/ntgdi/bitblt.c
    trunk/reactos/win32ss/gdi/ntgdi/coord.h
    trunk/reactos/win32ss/gdi/ntgdi/dc.h
    trunk/reactos/win32ss/gdi/ntgdi/dcutil.c
    trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
    trunk/reactos/win32ss/gdi/ntgdi/fillshap.c
    trunk/reactos/win32ss/gdi/ntgdi/freetype.c
    trunk/reactos/win32ss/gdi/ntgdi/line.c
    trunk/reactos/win32ss/gdi/ntgdi/pen.h
    trunk/reactos/win32ss/include/ntgdityp.h
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/dc.c        [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/dc.c        [iso-8859-1] Thu Dec 22 17:34:58
2016
@@ -800,7 +800,7 @@
     UINT       flags
 )
 {
-    return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET);
+    return NtGdiGetBoundsRect(hdc,lprcBounds,flags & ~DCB_WINDOWMGR);
 }
@@ -814,7 +814,7 @@
               UINT flags)
 {
     /* FIXME add check for validate the flags */
-    return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags);
+    return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags & ~DCB_WINDOWMGR);
 }
Modified: trunk/reactos/win32ss/gdi/ntgdi/bitblt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitblt.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/bitblt.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/bitblt.c    [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -77,6 +77,11 @@
     DestRect.top    += DCDest->ptlDCOrig.y;
     DestRect.right  += DCDest->ptlDCOrig.x;
     DestRect.bottom += DCDest->ptlDCOrig.y;
+
+    if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(DCDest, &DestRect);
+    }
     SourceRect.left   = XOriginSrc;
     SourceRect.top    = YOriginSrc;
@@ -262,6 +267,11 @@
     rcSrc.right  += DCSrc->ptlDCOrig.x;
     rcSrc.bottom += DCSrc->ptlDCOrig.y;
+    if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(DCDest, &rcDest);
+    }
+
     /* Prepare for blit */
     DC_vPrepareDCsForBlit(DCDest, &rcDest, DCSrc, &rcSrc);
@@ -419,6 +429,11 @@
     DestRect.top    += DCDest->ptlDCOrig.y;
     DestRect.right  += DCDest->ptlDCOrig.x;
     DestRect.bottom += DCDest->ptlDCOrig.y;
+
+    if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(DCDest, &DestRect);
+    }
     SourcePoint.x = nXSrc;
     SourcePoint.y = nYSrc;
@@ -619,6 +634,11 @@
     DestRect.right  += DCDest->ptlDCOrig.x;
     DestRect.bottom += DCDest->ptlDCOrig.y;
+    if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(DCDest, &DestRect);
+    }
+
     SourceRect.left   = XOriginSrc;
     SourceRect.top    = YOriginSrc;
     SourceRect.right  = XOriginSrc+WidthSrc;
@@ -807,6 +827,12 @@
     DestRect.top    += pdc->ptlDCOrig.y;
     DestRect.right  += pdc->ptlDCOrig.x;
     DestRect.bottom += pdc->ptlDCOrig.y;
+
+    if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(pdc, &DestRect);
+    }
+
 #ifdef _USE_DIBLIB_
     BrushOrigin.x = pbrush->ptOrigin.x + pdc->ptlDCOrig.x + XLeft;
     BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y + YLeft;
@@ -1058,6 +1084,13 @@
         return FALSE;
     }
+    if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+        RECTL rcrgn;
+        REGION_GetRgnBox(prgnClip, &rcrgn);
+        IntUpdateBoundsRect(pdc, &rcrgn);
+    }
+
     /* Prepare the DC */
     DC_vPrepareDCsForBlit(pdc, &prgnClip->rdh.rcBound, NULL, NULL);
@@ -1137,6 +1170,13 @@
         return FALSE;
     }
+    if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+        RECTL rcrgn;
+        REGION_GetRgnBox(prgnClip, &rcrgn);
+        IntUpdateBoundsRect(pdc, &rcrgn);
+    }
+
     IntEngInitClipObj(&xcoClip);
     IntEngUpdateClipRegion(&xcoClip,
                            prgnClip->rdh.nCount,
@@ -1349,6 +1389,22 @@
         /* Fail! */
         DC_UnlockDc(pdc);
         return -1;
+    }
+
+    if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       RECTL rcDst;
+
+       RECTL_vSetRect(&rcDst, x, y, x+1, y+1);
+
+       IntLPtoDP(pdc, (LPPOINT)&rcDst, 2);
+
+       rcDst.left   += pdc->ptlDCOrig.x;
+       rcDst.top    += pdc->ptlDCOrig.y;
+       rcDst.right  += pdc->ptlDCOrig.x;
+       rcDst.bottom += pdc->ptlDCOrig.y;
+
+       IntUpdateBoundsRect(pdc, &rcDst);
     }
     /* Translate the color to the target format */
Modified: trunk/reactos/win32ss/gdi/ntgdi/coord.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/coord.h?…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/coord.h     [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/coord.h     [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -4,10 +4,16 @@
 #define MIN_COORD (INT_MIN / 16)
 #define MAX_COORD (INT_MAX / 16)
-#define IntLPtoDP(pdc, ppt, count) DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt),
(PPOINTL)(ppt));
-#define CoordLPtoDP(pdc, ppt) DC_vXformWorldToDevice(pdc, 1,  (PPOINTL)(ppt),
(PPOINTL)(ppt));
-#define IntDPtoLP(pdc, ppt, count) DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt),
(PPOINTL)(ppt));
-#define CoordDPtoLP(pdc, ppt) DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt),
(PPOINTL)(ppt));
+#define IntLPtoDP(pdc, ppt, count) \
+        DC_vUpdateWorldToDevice(pdc); \
+        DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
+#define CoordLPtoDP(pdc, ppt) \
+        DC_vXformWorldToDevice(pdc, 1,  (PPOINTL)(ppt), (PPOINTL)(ppt));
+#define IntDPtoLP(pdc, ppt, count) \
+        DC_vUpdateDeviceToWorld(pdc); \
+        DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
+#define CoordDPtoLP(pdc, ppt) \
+        DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
 #define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x)
 #define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m)
Modified: trunk/reactos/win32ss/gdi/ntgdi/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dc.h?rev…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dc.h        [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dc.h        [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -2,9 +2,6 @@
 #define __WIN32K_DC_H
 /* Constants ******************************************************************/
-
-/* Get/SetBounds/Rect support. */
-#define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the
application's */
 /* flFontState */
 enum _FONT_STATE
@@ -207,6 +204,7 @@
 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
 BOOL FASTCALL IntGdiCleanDC(HDC hDC);
 VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
+VOID FASTCALL IntUpdateBoundsRect(PDC,PRECTL);
 BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner);
 HDC APIENTRY GreCreateCompatibleDC(HDC hdc, BOOL bAltDc);
Modified: trunk/reactos/win32ss/gdi/ntgdi/dcutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcutil.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dcutil.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dcutil.c    [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -189,8 +189,8 @@
     }
     DC_vUpdateTextBrush(pdc);
-//    DC_vUpdateLineBrush(pdc);
-//    DC_vUpdateFillBrush(pdc);
+    DC_vUpdateLineBrush(pdc);
+    DC_vUpdateFillBrush(pdc);
     DC_UnlockDc(pdc);
@@ -652,6 +652,20 @@
     return Ret;
 }
+VOID
+FASTCALL
+IntUpdateBoundsRect(PDC pdc, PRECTL pRect)
+{
+   if (pdc->fs & DC_ACCUM_APP)
+   {
+      RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, pRect);
+   }
+   if (pdc->fs & DC_ACCUM_WMGR)
+   {
+      RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, pRect);
+   }
+}
+
 DWORD
 APIENTRY
 NtGdiGetBoundsRect(
@@ -661,19 +675,49 @@
 {
     DWORD ret;
     PDC pdc;
+    RECT rc;
     /* Lock the DC */
     if (!(pdc = DC_LockDc(hdc))) return 0;
-    /* Get the return value */
-    ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
-    ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
+    if (!(flags & DCB_WINDOWMGR))
+    {
+       rc = pdc->erclBoundsApp;
+
+       if (RECTL_bIsEmptyRect(&rc))
+       {
+          rc.left = rc.top = rc.right = rc.bottom = 0;
+          ret = DCB_RESET;
+       }
+       else
+       {
+          RECTL rcRgn;
+          if (pdc->fs & DC_FLAG_DIRTY_RAO) CLIPPING_UpdateGCRegion(pdc);
+          if(!REGION_GetRgnBox(pdc->prgnRao, &rcRgn))
+          {
+             REGION_GetRgnBox(pdc->prgnVis, &rcRgn);
+          }
+          rc.left   = max( rc.left, 0 );
+          rc.top    = max( rc.top, 0 );
+          rc.right  = min( rc.right,  rcRgn.right - rcRgn.left );
+          rc.bottom = min( rc.bottom, rcRgn.bottom - rcRgn.top );
+          DPRINT1("Rao dc %p r %d b %d\n",pdc,rcRgn.right - rcRgn.left,
rcRgn.bottom - rcRgn.top);
+          DPRINT1("rc  l %d t %d\n",rc.left,rc.top);
+          DPRINT1("    r %d b %d\n",rc.right,rc.bottom);
+          ret = DCB_SET;
+       }
+       IntDPtoLP( pdc, &rc, 2 );
+       DPRINT1("rc1 l %d t %d\n",rc.left,rc.top);
+       DPRINT1("    r %d b %d\n",rc.right,rc.bottom);
+    }
+    else
+       rc = pdc->erclBounds;
     /* Copy the rect to the caller */
     _SEH2_TRY
     {
         ProbeForWrite(prc, sizeof(RECT), 1);
-        *prc = pdc->erclBoundsApp;
+        *prc = rc;
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
@@ -683,13 +727,21 @@
     if (flags & DCB_RESET)
     {
-        RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
+        if (!(flags & DCB_WINDOWMGR))
+        {
+           pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
+           pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
+        }
+        else
+        {
+           pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
+           pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
+        }
     }
     DC_UnlockDc(pdc);
     return ret;
 }
-
 DWORD
 APIENTRY
@@ -709,12 +761,23 @@
     if (!(pdc = DC_LockDc(hdc))) return 0;
     /* Get the return value */
-    ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
-    ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
+    ret = DCB_RESET; /* we don't have device-specific bounds */
+    ret = (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR) ? DCB_ENABLE : DCB_DISABLE) |
+          (RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? ret & DCB_SET : DCB_SET
);
+    ret |= (flags & DCB_WINDOWMGR);
     if (flags & DCB_RESET)
     {
-        RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
+        if (!(flags & DCB_WINDOWMGR))
+        {
+           pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
+           pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
+        }
+        else
+        {
+           pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
+           pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
+        }
     }
     if (flags & DCB_ACCUMULATE && prc != NULL)
@@ -733,11 +796,30 @@
         _SEH2_END;
         RECTL_vMakeWellOrdered(&rcl);
-        RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp,
&rcl);
-    }
-
-    if (flags & DCB_ENABLE) pdc->fs |= DC_ACCUM_APP;
-    if (flags & DCB_DISABLE) pdc->fs &= ~DC_ACCUM_APP;
+
+        if (!(flags & DCB_WINDOWMGR))
+        {
+           IntLPtoDP( pdc, (POINT *)&rcl, 2 );
+           RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp,
&rcl);
+        }
+        else
+           RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, &rcl);
+    }
+
+    if (flags & DCB_ENABLE)
+    {
+       if (!(flags & DCB_WINDOWMGR))
+          pdc->fs |= DC_ACCUM_APP;
+       else
+          pdc->fs |= DC_ACCUM_WMGR;
+    }
+    if (flags & DCB_DISABLE)
+    {
+       if (!(flags & DCB_WINDOWMGR))
+          pdc->fs &= ~DC_ACCUM_APP;
+       else
+          pdc->fs &= ~DC_ACCUM_WMGR;
+    }
     DC_UnlockDc(pdc);
     return ret;
 }
Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dibobj.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dibobj.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dibobj.c    [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -558,6 +558,11 @@
     rcDest.right = rcDest.left + Width;
     rcDest.bottom = rcDest.top + Height;
     rcDest.top += StartScan;
+
+    if (pDC->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(pDC, &rcDest);
+    }
     ptSource.x = XSrc;
     ptSource.y = YSrc;
@@ -1256,6 +1261,11 @@
     IntLPtoDP(pdc, (POINTL*)&rcDst, 2);
     RECTL_vOffsetRect(&rcDst, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
+    if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(pdc, &rcDst);
+    }
+
     hbmTmp = GreCreateBitmapEx(pbmi->bmiHeader.biWidth,
                                abs(pbmi->bmiHeader.biHeight),
                                0,
Modified: trunk/reactos/win32ss/gdi/ntgdi/fillshap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/fillshap…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/fillshap.c  [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/fillshap.c  [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -580,6 +580,11 @@
     DestRect.top    += dc->ptlDCOrig.y;
     DestRect.bottom += dc->ptlDCOrig.y;
+    if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(dc, &DestRect);
+    }
+
     /* In GM_COMPATIBLE, don't include bottom and right edges */
     if (pdcattr->iGraphicsMode == GM_COMPATIBLE)
     {
@@ -978,6 +983,11 @@
     ptlDitherOrg.x += pdc->ptlDCOrig.x;
     ptlDitherOrg.y += pdc->ptlDCOrig.y;
+
+   if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+   {
+      IntUpdateBoundsRect(pdc, &rclExtent);
+   }
     DC_vPrepareDCsForBlit(pdc, &rclExtent, NULL, NULL);
@@ -1146,6 +1156,11 @@
         RECTL_vSetRect(&DestRect, 0, 0, psurf->SurfObj.sizlBitmap.cx,
psurf->SurfObj.sizlBitmap.cy);
     }
+    if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+    {
+       IntUpdateBoundsRect(dc, &DestRect);
+    }
+
     EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurf->ppal, 0, 0xffffff, 0);
     /* Only solid fills supported for now
Modified: trunk/reactos/win32ss/gdi/ntgdi/freetype.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/freetype…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/freetype.c  [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/freetype.c  [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -3446,6 +3446,11 @@
         DestRect.right  += dc->ptlDCOrig.x;
         DestRect.bottom += dc->ptlDCOrig.y;
+        if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+        {
+           IntUpdateBoundsRect(dc, &DestRect);
+        }
+
         DC_vPrepareDCsForBlit(dc, &DestRect, NULL, NULL);
         if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
@@ -3722,6 +3727,10 @@
             DestRect.top = TextTop + yoff - ((fixAscender + 32) >> 6);
             DestRect.bottom = TextTop + yoff + ((32 - fixDescender) >> 6);
             MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top,
DestRect.right, DestRect.bottom);
+            if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+            {
+               IntUpdateBoundsRect(dc, &DestRect);
+            }
             IntEngBitBlt(
                 &psurf->SurfObj,
                 NULL,
Modified: trunk/reactos/win32ss/gdi/ntgdi/line.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/line.c?r…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/line.c      [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/line.c      [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -12,6 +12,67 @@
 #include <debug.h>
 // Some code from the WINE project source (
www.winehq.com)
+
+VOID FASTCALL
+AddPenLinesBounds(PDC dc, int count, POINT *points)
+{
+    DWORD join, endcap;
+    RECTL bounds, rect;
+    LONG lWidth;
+    PBRUSH pbrLine;
+
+    /* Get BRUSH from current pen. */
+    pbrLine = dc->dclevel.pbrLine;
+    ASSERT(pbrLine);
+
+    lWidth = pbrLine->lWidth;
+
+    // Setup bounds
+    bounds.left = bounds.top = INT_MAX;
+    bounds.right = bounds.bottom = INT_MIN;
+
+    if (((pbrLine->ulPenStyle & PS_TYPE_MASK) & PS_GEOMETRIC) || lWidth >
1)
+    {
+        /* Windows uses some heuristics to estimate the distance from the point that will
be painted */
+        lWidth = lWidth + 2;
+        endcap = (PS_ENDCAP_MASK & pbrLine->ulPenStyle);
+        join   = (PS_JOIN_MASK   & pbrLine->ulPenStyle);
+        if (join == PS_JOIN_MITER)
+        {
+           lWidth *= 5;
+           if (endcap == PS_ENDCAP_SQUARE) lWidth = (lWidth * 3 + 1) / 2;
+        }
+        else
+        {
+           if (endcap == PS_ENDCAP_SQUARE) lWidth -= lWidth / 4;
+           else lWidth = (lWidth + 1) / 2;
+        }
+    }
+
+    while (count-- > 0)
+    {
+        rect.left   = points->x - lWidth;
+        rect.top    = points->y - lWidth;
+        rect.right  = points->x + lWidth + 1;
+        rect.bottom = points->y + lWidth + 1;
+        RECTL_bUnionRect(&bounds, &bounds, &rect);
+        points++;
+    }
+
+    DPRINT1("APLB dc %p l %d t %d\n",dc,rect.left,rect.top);
+    DPRINT1("                 r %d b %d\n",rect.right,rect.bottom);
+
+    {
+       RECTL rcRgn;
+       if (dc->fs & DC_FLAG_DIRTY_RAO) CLIPPING_UpdateGCRegion(dc);
+       if (REGION_GetRgnBox(dc->prgnRao, &rcRgn))
+       {
+          if (RECTL_bIntersectRect( &rcRgn, &rcRgn, &bounds ))
IntUpdateBoundsRect(dc, &rcRgn);
+       }
+       else
+          IntUpdateBoundsRect(dc, &bounds);
+    }
+}
 // Should use Fx in Point
 //
@@ -131,6 +192,13 @@
         pbrLine = dc->dclevel.pbrLine;
         ASSERT(pbrLine);
+        if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+        {
+           DPRINT1("Bounds dc %p l %d t %d\n",dc,Bounds.left,Bounds.top);
+           DPRINT1("                   r %d b
%d\n",Bounds.right,Bounds.bottom);
+           AddPenLinesBounds(dc, 2, Points);
+        }
+
         if (!(pbrLine->flAttrs & BR_IS_NULL))
         {
             Ret = IntEngLineTo(&psurf->SurfObj,
@@ -258,6 +326,11 @@
             {
                 Points[i].x += dc->ptlDCOrig.x;
                 Points[i].y += dc->ptlDCOrig.y;
+            }
+
+            if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+            {
+               AddPenLinesBounds(dc, Count, Points);
             }
             Ret = IntEngPolyline(&psurf->SurfObj,
Modified: trunk/reactos/win32ss/gdi/ntgdi/pen.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/pen.h?re…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/pen.h       [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/pen.h       [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -27,3 +27,5 @@
     _In_ PPEN pPen,
     _In_ INT Count,
     _Out_ PLOGPEN Buffer);
+
+VOID FASTCALL AddPenLinesBounds(PDC,int,POINT *);
Modified: trunk/reactos/win32ss/include/ntgdityp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/include/ntgdityp.h…
==============================================================================
--- trunk/reactos/win32ss/include/ntgdityp.h    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/include/ntgdityp.h    [iso-8859-1] Thu Dec 22 17:34:58 2016
@@ -231,6 +231,8 @@
 /* New color use parameter. See 
support.microsoft.com/kb/kbview/108497 */
 #define DIB_PAL_INDICES 2
+/* Get/SetBounds/Rect support. */
+#define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the
application's */
 /* TYPES *********************************************************************/