Question about XRender specification

Helge Bahmann hcb at
Tue Apr 8 13:28:23 PDT 2008

> Testcase:
> 			XTrapezoid trap[2];
> 				trap[0].top=10<<16;
> 				trap[0].bottom=80<<16;
> 				trap[0].left.p1.x=30<<16; trap[0].left.p1.y=0<<16;
> 				trap[0].left.p2.x=20<<16; trap[0].left.p2.y=90<<16;
> 				trap[0].right.p1.x=XDoubleToFixed(100); trap[0].right.p1.y=0<<16;
> 				trap[0].right.p2.x=XDoubleToFixed(90); trap[0].right.p2.y=90<<16;
> 				trap[1].top=XDoubleToFixed(10);
> 				trap[1].bottom=80<<16;
> 				trap[1].left.p1.x=XDoubleToFixed(100); trap[1].left.p1.y=0<<16;
> 				trap[1].left.p2.x=XDoubleToFixed(90); trap[1].left.p2.y=90<<16;
> 				trap[1].right.p1.x=160<<16; trap[1].right.p1.y=0<<16;
> 				trap[1].right.p2.x=150<<16; trap[1].right.p2.y=90<<16;
> 				XRenderCompositeTrapezoids(display,
> 					PictOpOver, red_transp, picture, 0,
> 					0, 0, &trap, 2);

The problem is actually quite easy to explain -- let's assume one pixel is 
covered by 1/2 by each of the trapezoids, then alpha for that pixel=0.5 for 
each of the trapezoids

the way you are calling, they are drawn independently, this means the first 
trapezoid covers the pixel by 1/2, the second gets drawn over and now the 
pixel is covered by 3/4 and NOT 1 !

The solution is to use PictOpDisjointOver; possibly to have to composite your 
figure into a temporary mask and then use this pre-composited shape in a 
second rendering step

hope that helps

More information about the xorg mailing list