[OpenJDK 2D-Dev] [8] Request for review: 8004859 Graphics.getClipBounds/getClip return difference nonequivalent bounds, depending from transform.

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Thu Apr 18 13:24:52 UTC 2013

Hello Jim.

On 1/17/13 4:56 AM, Jim Graham wrote:
> The original code in getClipBounds would end up returning a "new 
> Rectangle()" if the clip was an empty rectangle due to the way that 
> "Rectangle2D/Path2D.getBounds()" works.  You now use 
> setFrame(getBounds2D()) which will attempt to preserve the dimensions 
> of empty clips.  So, the "preserve the size of an empty clip" support 
> is new.
> I then mentioned that we don't need to go out of our way to preserve 
> the dimensions of an empty clip, but you seem to be saying that we 
> don't want to change this behavior - but your new code represents the 
> break with existing behaviors, no?
I returned to this problem and studied it a little more deeply.
Assume we set clip=Rectangle[100, 100,-100,-100] for sg2d with a 
different transform.
  1 identity/translate (default mode for non-retina): getClip () will 
return Rectangle[100, 100,-100,-100].
  2 scale (default mode for retina): getClip() will return 
Rectangle[0,0,100,100] <- bug and it should be fixed.
  3 generic: getClip will return Rectangle[0,0,0,0], because we convert 
Rectangle to the Shape through RectIterator, which ignores the negative 
width and height. Note that x and y were not preserved only if w and 
h<0, but if w = h =0, then x and y will be preserved.

In an original fix I made case 2 like case 1, so from the point of view 
of users there was no difference in case of retina display.
But now I have doubts and I think that all cases shall work equally like 
in case 3.
What do you think?

>             ...jim

Best regards, Sergey.

More information about the 2d-dev mailing list