[libavg-devel] Div Node Rotations Patch

Ulrich von Zadow uzadow at libavg.de
Sun Aug 19 22:05:03 CEST 2007


Nick Hebner schrieb:
> 
> On 8/18/07, *Nick Hebner* <hebnern at gmail.com <mailto:hebnern at gmail.com>> 
> wrote:
> 
>     Attached is a patch moving rotations into Node. This fixed the clip
>     lanes problem clipping members of the div, but somehow introduced a
>     bug where items outside of the div are being clipped (the 'Click
>     Here to Rotate' text in my script for instance). I am nos sure why
>     this is occurring, and will continue to look into it. If you have
>     any ideas, let me know. 
> 
> 
> Ok, I think I figured out the problem. The way that pushClipRect was 
> written, it only applied the clip rect in ogl if it was for a div node. 
> This was leaving the old clip planes around, and clipping the next 
> element that was rendered. I removed the bClip bool from pushClipRect, 
> so they are always applied. Let me know if there are any other issues 
> with this patch.

Looking at the code again, I think the bool parameter worked and was 
there for a reason... but there's other things. If you run make check, 
you'll see several failing tests :-(. The test code is in 
src/test/Test.py. The images that changed are in src/test/resultimages. 
It seems that rotations are applied twice now.

Also, now that I look at it more closely, I see something else: The 
current clip rectangles are calculated as intersections of clip 
rectangles up the node hierarchy and then the resulting rectangle is 
used for the opengl clipping planes - have a look at 
Node::getVisibleRect(). This will break if there are rotations in between.

I am not sure how to solve this cleanly. Without rotations, there is 
always just a clipping rectangle. With rotations, there is an arbitrary 
convex clipping polygon - the intersection of several, possibly rotated 
rectangles. And opengl allows only 6 clipping planes to be set :-(. (If 
I'm not being clear, draw a few <divs> rotated differently on paper - if 
the clipping rectangles intersect, the resulting region isn't a 
rectangle anymore.)

One possible way would be to make <div> nodes non-clipping and add a 
<clip> node that adds a clipping rectangle. Only one <clip> node could 
be active at a time...

Or draw the clipping region into the stencil buffer and use that to clip 
- actually, I'm beginning to like that the best.

Any better ideas?

Regards,

   Uli

-- 

Ulrich von Zadow | +49-172-7872715 | cocacoder at jabber.berlin.ccc.de




More information about the libavg-devel mailing list