🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11597

Re:ClipRect help wanted

#11597
From: David Gay
Date: Sun, 26 Feb 1989 16:01
64 lines
2581 bytes
In article <911@applix.UUCP> scott@applix.uucp (Scott Evernden) writes:
>
>In article <5379@abo.fi> rosenbergr@abo.fi (Robin Rosenberg, Computer Science,
> ]bo Akademi) writes:
>>A simple question: What is the best way of doing clipping. I.e
>>I would like to render some text and images into a part of a window. If
>>the object goes outside the required borders (a rectangle) I want that part
>>chopped of. I know the ROMS have a InstallClipRect() function but how do
>>I use it?
>>Could anyone give me an example of how to do this the right way?
>
>Sure.  It's really not too hard...

Well, if this worked it wouldn't be too hard, but ... it doesn't (at least
not with simple refresh windows). I found this out the hard way, as this was
my initial approach, and then I had to fool around to find a way that worked.

[...]

>Then, when you want clipping within (xmin,ymin)-(xmax,ymax):
[...]
>    InstallClipRegion(window->RPort->Layer, region);
[...]
>Finally, at cleanup time:
>
>    DisposeRegion(region);
>    InstallClipRegion(window->RPort->Layer, (struct Region *) NULL);
>
>-scott
>

This creates problems as soon as your window gets a damage list (eg if you
display a requester in the window, or if your window is behind another).
I had to do the following to get everything working:

Setup clipping region:

    /* Save old damage list */
    oldRegion = win->WLayer->DamageList;
    /* New clip region is old region AND my clipping region */
    if (oldRegion == NULL || oldRegion->RegionRectangle == NULL)
        success = TRUE;
    else
        /* Argh ! */
        success = AndRegionRegion(win->WLayer->DamageList, region);
    if (success) InstallClipRegion(win->WLayer, region);


And the following to clean up:

    InstallClipRegion(win->WLayer, oldRegion);
    DisposeRegion(region);

This works, but I have grave doubts about it working in future releases ...
(if the xxRegion routines are changed for instance).

Anybody have a better method ?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Gay                                  6 x 9 = 42

GAY@ELDE.EPFL.CH, or GAY%ELDE.EPFL.CH@CLSEPF51.bitnet

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Technical Details
Message-ID: <890226170104.21a012c5@elcc.epfl.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!elde.epfl.ch!gay

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!elde.epfl.ch!gay
From: gay@elde.epfl.ch (David Gay)
Newsgroups: comp.sys.amiga.tech
Subject: Re:ClipRect help wanted
Message-ID: <890226170104.21a012c5@elcc.epfl.ch>
Date: 26 Feb 89 16:01:04 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 64