7150134: JCK api/java_awt/Graphics/index.html#DrawLine fails with OOM for jdk8 with XRender pipeline
authorceisserer
Mon, 09 Apr 2012 15:49:33 -0700
changeset 12393 c88c137e54fc
parent 12392 af6c2083c5d7
child 12394 7ded3320efee
7150134: JCK api/java_awt/Graphics/index.html#DrawLine fails with OOM for jdk8 with XRender pipeline Reviewed-by: prr
jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	Thu Apr 05 15:17:19 2012 -0700
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	Mon Apr 09 15:49:33 2012 -0700
@@ -69,20 +69,26 @@
     }
 
     public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
-        try {
-            SunToolkit.awtLock();
-
-            validateSurface(sg2d);
-            int transx = sg2d.transX;
-            int transy = sg2d.transY;
+        Region compClip = sg2d.getCompClip();
+        int transX1 = x1 + sg2d.transX;
+        int transY1 = y1 + sg2d.transY;
+        int transX2 = x2 + sg2d.transX;
+        int transY2 = y2 + sg2d.transY;
 
-            XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
+        // Non clipped fast path
+        if (compClip.contains(transX1, transY1)
+                && compClip.contains(transX2, transY2)) {
+            try {
+                SunToolkit.awtLock();
 
-            tileManager.addLine(x1 + transx, y1 + transy,
-                                x2 + transx, y2 + transy);
-            tileManager.fillMask(xrsd);
-        } finally {
-            SunToolkit.awtUnlock();
+                validateSurface(sg2d);
+                tileManager.addLine(transX1, transY1, transX2, transY2);
+                tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
+            } finally {
+                SunToolkit.awtUnlock();
+            }
+        } else {
+            draw(sg2d, new Line2D.Float(x1, y1, x2, y2));
         }
     }