Ignore:
Timestamp:
Nov 12, 2003, 3:13:26 PM (22 years ago)
Author:
sandervl
Message:

Visible & Clip region changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/dc.cpp

    r10093 r10316  
    1 /* $Id: dc.cpp,v 1.121 2003-05-15 13:12:52 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.122 2003-11-12 14:10:18 sandervl Exp $ */
    22
    33/*
     
    594594   HDC   hdc;
    595595   HPS   hps;
    596    HRGN  hrgnUpdate, hrgnOld, hrgnClip, hrgnCombined;
     596   HRGN  hrgnUpdate;
    597597   RECTL rectl = { 1, 1, 2, 2 };
     598   pDCData pHps = NULLHANDLE;
    598599
    599600   hwnd = wnd->getOS2WindowHandle();
     
    602603   hrgnUpdate = GpiCreateRegion (hps, 1, &rectl);
    603604   WinQueryUpdateRegion (hwnd, hrgnUpdate);
    604    hrgnClip = GpiQueryClipRegion (hps);
    605 
    606    if (hrgnClip == NULLHANDLE)
    607    {
    608       GpiSetClipRegion (hps, hrgnUpdate, &hrgnOld);
    609    }
    610    else
    611    {
    612       hrgnCombined = GpiCreateRegion (hps, 1, &rectl);
    613       GpiCombineRegion (hps, hrgnCombined, hrgnClip, hrgnUpdate, CRGN_AND);
    614       GpiSetClipRegion (hps, hrgnCombined, &hrgnOld);
    615       GpiDestroyRegion (hps, hrgnUpdate);
    616       GpiDestroyRegion (hps, hrgnClip);
    617    }
    618    if (hrgnOld != NULLHANDLE)
    619       GpiDestroyRegion (hps, hrgnOld);
    620605
    621606   hdc = HPSToHDC (hwnd, hps, NULL, NULL);
     607
     608   pHps = (pDCData)GpiQueryDCData(hps);
     609   GdiSetVisRgn(pHps, hrgnUpdate);
    622610
    623611   erased = wnd->MsgEraseBackGround (hdc);
     
    676664        return (HDC)0;
    677665    }
    678 //    bIcon = (IsIconic(hwnd) && GetClassLongA(hWnd, GCL_HICON_W));
    679666    bIcon = IsIconic(hwnd);
    680667
     
    725712        }
    726713
    727         HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectl);
    728         GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
     714        //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
     715        dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
     716        wnd->SaveClipRegion(pHps->hrgnWin32Clip);
     717        wnd->SaveVisRegion(pHps->hrgnWinVis);
     718
     719        //clear visible and clip regions
     720        pHps->hrgnWin32Clip = NULLHANDLE;
     721        pHps->hrgnWinVis    = NULLHANDLE;
     722
     723        HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectl);
     724        GdiSetVisRgn(pHps, hrgnVis);
    729725
    730726        selectClientArea(wnd, pHps);
    731727
    732         //save old clip region (restored for CS_OWNDC windows in EndPaint)
    733         wnd->SetClipRegion(hrgnOldClip);
    734728        if(bIcon) {
    735729              lComplexity = RGN_RECT;
     
    742736
    743737        //Query update region
    744         HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectlClip);
    745         WinQueryUpdateRegion(hwndClient, hrgnClip);
    746         WinValidateRegion(hwndClient, hrgnClip, FALSE);
    747 
    748         dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnClip);
     738        HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectlClip);
     739        WinQueryUpdateRegion(hwndClient, hrgnVis);
     740        WinValidateRegion(hwndClient, hrgnVis, FALSE);
     741
     742        dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnVis);
    749743
    750744#ifdef DEBUG
     
    754748#endif
    755749
     750        //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
     751        dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
     752        wnd->SaveClipRegion(pHps->hrgnWin32Clip);
     753        wnd->SaveVisRegion(pHps->hrgnWinVis);
     754
     755        //clear visible and clip regions
     756        pHps->hrgnWin32Clip = NULLHANDLE;
     757        pHps->hrgnWinVis    = NULLHANDLE;
     758
    756759        //set clip region
    757         lComplexity = GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
    758 
    759         if(lComplexity == RGN_NULL) {
     760        lComplexity = GdiSetVisRgn(pHps, hrgnVis);
     761
     762        if(lComplexity == NULLREGION_W) {
    760763            dprintf (("BeginPaint %x: EMPTY update rectangle (vis=%d/%d show=%d/%d", hWnd,  WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()),  WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
    761764        }
     
    769772        dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
    770773#endif
    771         //save old clip region (restored for CS_OWNDC windows in EndPaint)
    772         wnd->SetClipRegion(hrgnOldClip);
    773774    }
    774775
     
    783784    WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
    784785
    785     if((wnd->needsEraseBkgnd() || wnd->IsVisibleRegionChanged()) && lComplexity != RGN_NULL) {
    786         wnd->setEraseBkgnd(FALSE);
    787         wnd->SetVisibleRegionChanged(FALSE);
    788         lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
     786    if((wnd->needsEraseBkgnd() || wnd->hasPMUpdateRegionChanged()) && lComplexity != RGN_NULL) {
     787         wnd->setEraseBkgnd(FALSE);
     788         wnd->SetPMUpdateRegionChanged(FALSE);
     789         lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
    789790    }
    790791    else lpps->fErase = TRUE;
     
    817818{
    818819  HWND    hwnd = hWnd ? hWnd : HWND_DESKTOP;
    819   HRGN    hrgnOld;
    820820  pDCData pHps;
    821821
     
    832832    if (pHps && (pHps->hdcType == TYPE_3))
    833833    {
    834         GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
    835         wnd->SetClipRegion(0);
    836         if(hrgnOld) {
    837             GpiDestroyRegion(pHps->hps, hrgnOld);
    838         }
     834        //restore previous visible and clip regions
     835        pHps->hrgnWin32Clip = NULLHANDLE;
     836        pHps->hrgnWinVis    = NULLHANDLE;
     837
     838        GdiSetVisRgn(pHps, wnd->GetVisRegion());
     839        GdiCombineVisRgnClipRgn(pHps, wnd->GetClipRegion(), RGN_AND_W);
     840
     841        wnd->SaveClipRegion(0);
     842        wnd->SaveVisRegion(0);
     843
    839844        pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
    840845        ReleaseDC(hwnd, pPaint->hdc);
     
    879884            if(pHps && pHps->psType == MICRO_CACHED) {
    880885                removeClientArea(wnd, pHps);
    881                 if(pHps->hrgnVis) {
    882                     GreDestroyRegion(pHps->hps, pHps->hrgnVis);
    883                     pHps->hrgnVis = 0;
     886                if(pHps->hrgnWinVis) {
     887                    GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
     888                    pHps->hrgnWinVis = 0;
     889                }
     890                if(pHps->hrgnWin32Clip) {
     891                    GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
     892                    pHps->hrgnWin32Clip = 0;
    884893                }
    885894            }
     
    912921}
    913922//******************************************************************************
    914 // This implementation of GetDCEx supports
     923// This implementation of GetDCEx supports:
     924//
    915925// DCX_WINDOW
    916926// DCX_CACHE
     
    922932// DCX_PARENTCLIP
    923933//
     934// Not supported:
     935//
     936// DCX_NORESETATTRS_W
     937// DCX_INTERSECTUPDATE_W
     938// DCX_LOCKWINDOWUPDATE_W
     939// DCX_VALIDATE_W
     940// DCX_EXCLUDEUPDATE_W
     941//
    924942//TODO: WM_SETREDRAW affects drawingAllowed flag!!
    925943//******************************************************************************
     
    935953   BOOL     creatingOwnDC = FALSE;
    936954   PS_Type  psType;
     955
     956    if(flags & (DCX_NORESETATTRS_W | DCX_INTERSECTUPDATE_W | DCX_LOCKWINDOWUPDATE_W | DCX_VALIDATE_W | DCX_EXCLUDEUPDATE_W)) {
     957        dprintf(("ERROR: GetDCEx: unsupported flags %x!!", flags));
     958        DebugInt3();
     959    }
    937960
    938961    if(hwnd == 0) {
     
    10661089        success = TRUE;
    10671090        if (flags & DCX_EXCLUDERGN_W)
    1068         {
    1069 #if 0 //CB: todo
    1070          long height;
    1071 
    1072          BytesNeeded = GetRegionData (hrgn, 0, NULL);
    1073          RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
    1074          if (RgnData == NULL)
    1075                 goto error;
    1076          GetRegionData (hrgn, BytesNeeded, RgnData);
    1077 
    1078          i = RgnData->rdh.nCount;
    1079          pr = (PRECT)(RgnData->Buffer);
    1080 
    1081          if (flags & DCX_WINDOW_W)
    1082                 height = wnd->getWindowHeight();
    1083          else   height = wnd->getClientHeight();
    1084 
    1085          for (; (i > 0) && success; i--, pr++) {
    1086             LONG y = pr->yBottom;
    1087 
    1088             pr->yBottom = height - pr->yTop;
    1089             pr->yTop    = height - y;
    1090             success &= GpiExcludeClipRectangle (pHps->hps, pr);
    1091          }
    1092 #endif
     1091        {//exclude specified region from visible region
     1092            success = (GdiCombineVisRgn(pHps, hrgn, RGN_DIFF_W) != ERROR_W);
    10931093        }
    10941094        else //DCX_INTERSECTRGN_W
    1095         {
    1096             //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
    1097             //     with a region that covers the entire window (RealPlayer 7 Update 1)
    1098             //     Using SelectClipRgn here doesn't make any difference.
    1099             if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
    1100                 dprintf(("ExtSelectClipRgn failed!!"));
    1101             }
     1095        {//intersect visible region with specified region
     1096            success = (GdiCombineVisRgn(pHps, hrgn, RGN_AND_W) != ERROR_W);
    11021097        }
    11031098        if (!success)
     
    12921287        //already (partly) invalidated
    12931288        if (!WinQueryUpdateRect (hwnd, NULL)) {
     1289            dprintf(("RDW_INVALIDATE: no update rectangle, disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
    12941290            wnd->setEraseBkgnd(FALSE);
    12951291        }
     
    13321328    else if (redraw & RDW_VALIDATE_W)
    13331329    {
    1334         if (redraw & RDW_NOERASE_W)
     1330        if (redraw & RDW_NOERASE_W) {
     1331            dprintf(("RDW_NOERASE: disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
    13351332            wnd->setEraseBkgnd(FALSE);
    1336 
     1333        }
    13371334        if (WinQueryUpdateRect (hwnd, NULL))
    13381335        {
Note: See TracChangeset for help on using the changeset viewer.