[OpenJDK 2D-Dev] clip with negative width or height in Graphics2D

Jim Graham james.graham at oracle.com
Wed Dec 12 18:48:33 UTC 2012

It sounds like the code that transforms the clip does not detect if the 
rectangle is empty first.  The clip should be set to a no-area clip if 
the incoming width or height are negative (or 0)...


On 12/12/2012 7:32 AM, Sergey Bylokhov wrote:
> Hello 2d team,
> I have a question about clipping in our implementation of SunGraphics2D.
> Currently if I set usrClip to Rectangle(100,100,-100,-100) the real clip
> will be clipRegion = 100,100,100,100;
> But if I set clip to Rectangle2D with the same coordinates the real clip
> will be clipRegion = 0,0,100,100;(This is because we normalizes usrClip
> before use).
> We automatically convert usrClip from Rectangle to Rectangle2D, if our
> graphics is scaled. So we get different clipRegion depending from scale.
> What behavior is correct? Should we always normalize usrClip before use
> or should we treat it as empty/nonexistent rectangle?

More information about the 2d-dev mailing list