changeset 12486:9f149a2bfe1a

8130400: Test java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java fails with ClassCastException Reviewed-by: prr, serb
author azvegint
date Tue, 04 Aug 2015 12:34:08 +0300
parents e2853ff537da
children 3a879c43ebfe
files src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java
diffstat 2 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java	Mon Aug 03 15:48:33 2015 -0500
+++ b/src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java	Tue Aug 04 12:34:08 2015 +0300
@@ -46,24 +46,28 @@
         SurfaceData dstData = sg.surfaceData;
         SurfaceData srcData = dstData.getSourceSurfaceData(img,
                 SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor);
-        int compRule = ((AlphaComposite) sg.composite).getRule();
-        float extraAlpha = ((AlphaComposite) sg.composite).getAlpha();
 
-        if (srcData != null && !isBgOperation(srcData, bgColor)
+        if (sg.composite instanceof AlphaComposite) {
+            int compRule = ((AlphaComposite) sg.composite).getRule();
+            float extraAlpha = ((AlphaComposite) sg.composite).getAlpha();
+
+            if (srcData != null && !isBgOperation(srcData, bgColor)
                 && interpType <= AffineTransformOp.TYPE_BILINEAR
                 && (XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
-                        || (XRUtils.isTransformQuadrantRotated(tx)) && extraAlpha == 1.0f))
-                         {
-            SurfaceType srcType = srcData.getSurfaceType();
-            SurfaceType dstType = dstData.getSurfaceType();
+                    || (XRUtils.isTransformQuadrantRotated(tx))
+                    && extraAlpha == 1.0f))
+            {
+                SurfaceType srcType = srcData.getSurfaceType();
+                SurfaceType dstType = dstData.getSurfaceType();
 
-            TransformBlit blit = TransformBlit.getFromCache(srcType,
-                    sg.imageComp, dstType);
-            if (blit != null) {
-                blit.Transform(srcData, dstData, sg.composite,
-                        sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2
+                TransformBlit blit = TransformBlit.getFromCache(srcType,
+                        sg.imageComp, dstType);
+                if (blit != null) {
+                    blit.Transform(srcData, dstData, sg.composite,
+                          sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2
                                 - sx1, sy2 - sy1);
                     return;
+                }
             }
         }
 
--- a/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java	Mon Aug 03 15:48:33 2015 -0500
+++ b/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java	Tue Aug 04 12:34:08 2015 +0300
@@ -40,7 +40,7 @@
 
 /**
  * @test
- * @bug 8061831
+ * @bug 8061831 8130400
  * @summary Tests drawing volatile image to volatile image using different
  *          clips + xor mode. Results of the blit compatibleImage to
  *          compatibleImage is used for comparison.