--- old/src/share/classes/sun/java2d/SunGraphics2D.java 2013-01-14 23:22:28.368048100 +0400 +++ new/src/share/classes/sun/java2d/SunGraphics2D.java 2013-01-14 23:22:28.212047800 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,14 +82,12 @@ import sun.java2d.loops.SurfaceType; import sun.java2d.loops.Blit; import sun.java2d.loops.MaskFill; -import sun.font.FontManager; import java.awt.font.FontRenderContext; import sun.java2d.loops.XORComposite; import sun.awt.ConstrainableGraphics; import sun.awt.SunHints; import java.util.Map; import java.util.Iterator; -import sun.java2d.DestSurfaceProvider; import sun.misc.PerformanceLogger; import javax.tools.annotation.GenerateNativeHeader; @@ -1749,11 +1747,13 @@ if (usrClip instanceof Rectangle) { r = new Rectangle((Rectangle) usrClip); } else { - r = usrClip.getBounds(); + r = new Rectangle(); + r.setFrame(usrClip.getBounds2D()); } r.translate(-transX, -transY); } else { - r = getClip().getBounds(); + r = new Rectangle(); + r.setFrame(getClip().getBounds2D()); } return r; } @@ -1764,11 +1764,11 @@ if (usrClip instanceof Rectangle) { r.setBounds((Rectangle) usrClip); } else { - r.setBounds(usrClip.getBounds()); + r.setFrame(usrClip.getBounds2D()); } r.translate(-transX, -transY); } else { - r.setBounds(getClip().getBounds()); + r.setFrame(getClip().getBounds2D()); } } else if (r == null) { throw new NullPointerException("null rectangle parameter"); @@ -1943,10 +1943,10 @@ matrix[2] = matrix[0] + rect.getWidth(); matrix[3] = matrix[1] + rect.getHeight(); tx.transform(matrix, 0, matrix, 0, 2); - rect = new Rectangle2D.Float(); - rect.setFrameFromDiagonal(matrix[0], matrix[1], - matrix[2], matrix[3]); - return rect; + fixRectangleOrientation(matrix, rect); + return new Rectangle2D.Double(matrix[0], matrix[1], + matrix[2] - matrix[0], + matrix[3] - matrix[1]); } if (tx.isIdentity()) { @@ -1956,6 +1956,22 @@ return tx.createTransformedShape(clip); } + /** + * Sets orientation of the rectangle according to the clip. + */ + private static void fixRectangleOrientation(double[] m, Rectangle2D clip) { + if (clip.getWidth() > 0 != (m[2] - m[0] > 0)) { + double t = m[0]; + m[0] = m[2]; + m[2] = t; + } + if (clip.getHeight() > 0 != (m[3] - m[1] > 0)) { + double t = m[1]; + m[1] = m[3]; + m[3] = t; + } + } + public void clipRect(int x, int y, int w, int h) { clip(new Rectangle(x, y, w, h)); }