makeNativeRgn

Robert Collins robert.collins@itdomain.com.au
Tue Apr 9 22:35:00 GMT 2002



> -----Original Message-----
> From: Robert Collins 
> Sent: Wednesday, April 10, 2002 12:42 PM
> To: Cygwin-Xfree
> Subject: makeNativeRgn
> 
> 
> Alan,
>   this may be of use to you: It's the region optimisation I 
> mentioned before. It seems a little faster to me, which 
> indicates that some
> (most?) of the calls have mulitple clip regions. 

There's more that can be done, like moving the clipboard selection
before the spans iteration, but the biggest improvement I've achieved so
far is making native Rgn's for the FILLTILED routine. I'll make a patch
for this once I clean a little other code in winfillsp.c up. The
background rendering is instantaneous with this for me.

Rob

in winclip.c (perhaps we need a winrgn.c? )
HRGN
makeNativeRgnFromSpans (int iSpans, DDXPointPtr pPoints, int *piWidths)
{
  HRGN rv;
  if (!iSpans)
    return NULL;
  rv = CreateRectRgn (pPoints->x, pPoints->y, pPoints->x + *piWidths,
pPoints->y
+1);
  ++pPoints;
  ++piWidths;
  while (iSpans--)
    {
      HRGN tempRgn;
      int combinerv;
      tempRgn = CreateRectRgn (pPoints->x, pPoints->y, pPoints->x +
*piWidths, p
Points->y+1);
      combinerv = CombineRgn (rv, rv, tempRgn, RGN_OR);
      if (combinerv == ERROR)
        {
          ErrorF ("makeNativeRgn: Failed to create native region %u\n",
GetLastE
rror());
          DeleteObject (rv);
          return NULL;
        }
      DeleteObject (tempRgn);
      ++pPoints;
      ++piWidths;
    }
  return rv;
}


and in winfillsp.c

        case FillTiled:
          hrgn = makeNativeRgn (pClip);
          if (hrgn)
            {
              HBRUSH aBrush,oldBrush;

              /* TODO: should we intersect the clip region? */
              SelectClipRgn (pGCPriv->hdcMem, hrgn);
              DeleteObject (hrgn);
              hrgn = NULL;

          /* Get a pixmap pointer from the tile pointer, and fetch
privates  */
          pTile = (PixmapPtr) pGC->tile.pixmap;
          pTilePriv = winGetPixmapPriv (pTile);

          /* create a brush */

          aBrush = CreatePatternBrush(pTilePriv->hBitmap);
          oldBrush = SelectObject (hdc, aBrush);

          hrgn = makeNativeRgnFromSpans (iSpans, pPoints,piWidths);
          if (hrgn)
            {
              PaintRgn (hdc, hrgn);
              DeleteObject (hrgn);
            }

          /* Cleanup */
          SelectObject (hdc, oldBrush);
          DeleteObject (aBrush);

            }
          break;



More information about the Cygwin-xfree mailing list