8198613: Test cases result in failure or timeout when run with OpenGL backend
Reviewed-by: serb, jdv
--- a/test/jdk/ProblemList.txt Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/ProblemList.txt Fri Mar 02 14:39:29 2018 +0530
@@ -247,13 +247,9 @@
sun/java2d/SunGraphics2D/SimplePrimQuality.java 7992007 generic-all
sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java 8196191 windows-all,macosx-all
sun/java2d/pipe/InterpolationQualityTest.java 8171303 windows-all,linux-all,macosx-all
-java/awt/FullScreen/BufferStrategyExceptionTest/BufferStrategyExceptionTest.java 8196186 windows-all
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469 windows-all
-java/awt/FullScreen/NonExistentDisplayModeTest/NonExistentDisplayModeTest.java 8196187 windows-all
java/awt/Graphics/ClippedCopyAreaTest/ClippedCopyAreaTest.java 8196436 linux-all
-java/awt/Graphics/CopyScaledArea/CopyScaledAreaTest.java 8196189 windows-all
java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8197796 generic-all
-java/awt/GraphicsDevice/CloneConfigsTest.java 8196190 windows-all
java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java 8196300 windows-all
java/awt/print/PrinterJob/Margins.java 8196301 windows-all
java/awt/print/PrinterJob/PSQuestionMark.java 7003378 windows-all
@@ -638,7 +634,6 @@
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all
javax/swing/JTree/8003400/Test8003400.java 8011259 macosx-all
javax/swing/JFileChooser/8041694/bug8041694.java 8196302 windows-all
-javax/swing/JInternalFrame/8069348/bug8069348.java 8196303 windows-all
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all
javax/swing/Action/8133039/bug8133039.java 8196089 windows-all,macosx-all
javax/swing/JComboBox/6559152/bug6559152.java 8196090 windows-all,macosx-all
--- a/test/jdk/java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -24,14 +24,13 @@
/*
@test
@key headful
- @bug 6275887 6429971 6459792
+ @bug 6275887 6429971 6459792 8198613
@summary Test that we don't crash when alt+tabbing in and out of
fullscreen app
@author Dmitri.Trembovetski@sun.com: area=FullScreen
@run main/othervm/timeout=100 AltTabCrashTest -auto -changedm
@run main/othervm/timeout=100 -Dsun.java2d.d3d=True AltTabCrashTest -auto -changedm
@run main/othervm/timeout=100 -Dsun.java2d.d3d=True AltTabCrashTest -auto -usebs -changedm
- @run main/othervm/timeout=100 -Dsun.java2d.opengl=True AltTabCrashTest -auto
*/
import java.awt.AWTException;
--- a/test/jdk/java/awt/FullScreen/BufferStrategyExceptionTest/BufferStrategyExceptionTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/BufferStrategyExceptionTest/BufferStrategyExceptionTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -24,11 +24,10 @@
/**
* @test
* @key headful
- * @bug 6366813 6459844
+ * @bug 6366813 6459844 8198613
* @summary Tests that no exception is thrown if a frame is resized just
* before we create a bufferStrategy
* @author Dmitri.Trembovetski area=FullScreen/BufferStrategy
- * @run main/othervm -Dsun.java2d.opengl=true BufferStrategyExceptionTest
* @run main/othervm BufferStrategyExceptionTest
*/
--- a/test/jdk/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -24,12 +24,11 @@
/**
* @test
* @key headful
- * @bug 6366359
+ * @bug 6366359 8198613
* @summary Test that we don't crash when changing from 8 to 16/32 bit modes
* @author Dmitri.Trembovetski@Sun.COM area=FullScreen
* @run main/othervm/timeout=200 DisplayChangeVITest
* @run main/othervm/timeout=200 -Dsun.java2d.d3d=false DisplayChangeVITest
- * @run main/othervm/timeout=200 -Dsun.java2d.opengl=true DisplayChangeVITest
*/
import java.awt.Color;
--- a/test/jdk/java/awt/FullScreen/MultimonFullscreenTest/MultimonFullscreenTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/MultimonFullscreenTest/MultimonFullscreenTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -23,12 +23,7 @@
/**
* @test
- * @bug 5041219
- * @bug 5101561
- * @bug 5035272
- * @bug 5096011
- * @bug 5101712
- * @bug 5098624
+ * @bug 5041219 5101561 5035272 5096011 5101712 5098624 8198613
* @summary Here are a few assertions worth verification:
* - the fullscreen window is positioned at 0,0
* - the fs window appears on the correct screen
@@ -49,7 +44,7 @@
* @run main/manual/othervm -Dsun.java2d.pmoffscreen=false MultimonFullscreenTest
* @run main/manual/othervm -Dsun.java2d.d3d=True MultimonFullscreenTest
* @run main/manual/othervm -Dsun.java2d.noddraw=true MultimonFullscreenTest
- * @run main/manual/othervm -Dsun.java2d.opengl=True MultimonFullscreenTest
+ * @run main/manual/othervm MultimonFullscreenTest
*/
import java.awt.Button;
--- a/test/jdk/java/awt/FullScreen/NonExistentDisplayModeTest/NonExistentDisplayModeTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/NonExistentDisplayModeTest/NonExistentDisplayModeTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -32,12 +32,11 @@
/**
* @test
* @key headful
- * @bug 6430607
+ * @bug 6430607 8198613
* @summary Test that we throw an exception for incorrect display modes
* @author Dmitri.Trembovetski@Sun.COM area=FullScreen
* @run main/othervm NonExistentDisplayModeTest
* @run main/othervm -Dsun.java2d.noddraw=true NonExistentDisplayModeTest
- * @run main/othervm -Dsun.java2d.opengl=true NonExistentDisplayModeTest
*/
public class NonExistentDisplayModeTest {
--- a/test/jdk/java/awt/FullScreen/UninitializedDisplayModeChangeTest/UninitializedDisplayModeChangeTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/FullScreen/UninitializedDisplayModeChangeTest/UninitializedDisplayModeChangeTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -23,13 +23,12 @@
/**
* @test
- * @bug 6358034 6568560
+ * @bug 6358034 6568560 8198613
* @key headful
* @summary Tests that no exception is thrown when display mode is changed
* externally
* @compile UninitializedDisplayModeChangeTest.java DisplayModeChanger.java
* @run main/othervm UninitializedDisplayModeChangeTest
- * @run main/othervm -Dsun.java2d.opengl=true UninitializedDisplayModeChangeTest
*/
import java.awt.EventQueue;
--- a/test/jdk/java/awt/Graphics/CopyScaledArea/CopyScaledAreaTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/Graphics/CopyScaledArea/CopyScaledAreaTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -29,11 +29,10 @@
/**
* @test
* @key headful
- * @bug 8069348
+ * @bug 8069348 8198613
* @summary SunGraphics2D.copyArea() does not properly work for scaled graphics
* @modules java.desktop/sun.awt
* @run main/othervm -Dsun.java2d.uiScale=2 CopyScaledAreaTest
- * @run main/othervm -Dsun.java2d.opengl=true -Dsun.java2d.uiScale=2 CopyScaledAreaTest
* @run main/othervm -Dsun.java2d.d3d=true -Dsun.java2d.uiScale=2 CopyScaledAreaTest
* @run main/othervm -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false
* -Dsun.java2d.uiScale=2 CopyScaledAreaTest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Graphics2D/CopyAreaOOB.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key headful
+ * @bug 6430601 8198613
+ * @summary Verifies that copyArea() works properly when the
+ * destination parameters are outside the destination bounds.
+ * @run main/othervm CopyAreaOOB
+ * @author campbelc
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+
+public class CopyAreaOOB extends Canvas {
+
+ private static boolean done;
+
+ public void paint(Graphics g) {
+ synchronized (this) {
+ if (done) {
+ return;
+ }
+ }
+
+ int w = getWidth();
+ int h = getHeight();
+
+ Graphics2D g2d = (Graphics2D)g;
+ g2d.setColor(Color.black);
+ g2d.fillRect(0, 0, w, h);
+
+ g2d.setColor(Color.green);
+ g2d.fillRect(0, 0, w, 10);
+
+ g2d.setColor(Color.red);
+ g2d.fillRect(0, 10, 50, h-10);
+
+ // copy the region such that part of it goes below the bottom of the
+ // destination surface
+ g2d.copyArea(0, 10, 50, h-10, 60, 10);
+
+ Toolkit.getDefaultToolkit().sync();
+
+ synchronized (this) {
+ done = true;
+ notifyAll();
+ }
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(400, 400);
+ }
+
+ private static void testRegion(BufferedImage bi, String name,
+ int x1, int y1, int x2, int y2,
+ int expected)
+ {
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ int actual = bi.getRGB(x, y);
+ if (actual != expected) {
+ throw new RuntimeException("Test failed for " + name +
+ " region at x="+x+" y="+y+
+ " (expected="+
+ Integer.toHexString(expected) +
+ " actual="+
+ Integer.toHexString(actual) +
+ ")");
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ boolean show = (args.length == 1) && ("-show".equals(args[0]));
+
+ CopyAreaOOB test = new CopyAreaOOB();
+ Frame frame = new Frame();
+ frame.setUndecorated(true);
+ frame.add(test);
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+
+ // Wait until the component's been painted
+ synchronized (test) {
+ while (!done) {
+ try {
+ test.wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Failed: Interrupted");
+ }
+ }
+ }
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ex) {}
+
+ // Grab the screen region
+ BufferedImage capture = null;
+ try {
+ Robot robot = new Robot();
+ Point pt1 = test.getLocationOnScreen();
+ Rectangle rect = new Rectangle(pt1.x, pt1.y, 400, 400);
+ capture = robot.createScreenCapture(rect);
+ } catch (Exception e) {
+ throw new RuntimeException("Problems creating Robot");
+ } finally {
+ if (!show) {
+ frame.dispose();
+ }
+ }
+
+ // Test pixels
+ testRegion(capture, "green", 0, 0, 400, 10, 0xff00ff00);
+ testRegion(capture, "original red", 0, 10, 50, 400, 0xffff0000);
+ testRegion(capture, "background", 50, 10, 60, 400, 0xff000000);
+ testRegion(capture, "in-between", 60, 10, 110, 20, 0xff000000);
+ testRegion(capture, "copied red", 60, 20, 110, 400, 0xffff0000);
+ testRegion(capture, "background", 110, 10, 400, 400, 0xff000000);
+ }
+}
--- a/test/jdk/java/awt/GraphicsDevice/CloneConfigsTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/GraphicsDevice/CloneConfigsTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -24,14 +24,13 @@
/*
* @test
* @key headful
- * @bug 6822057 7124400 8059848
+ * @bug 6822057 7124400 8059848 8198613
*
* @summary Test verifies that list of supported graphics configurations
* can not be changed via modification of elements of an array
* returned by getConfiguration() method.
*
* @run main CloneConfigsTest
- * @run main/othervm -Dsun.java2d.opengl=True CloneConfigsTest
* @run main/othervm -Dsun.java2d.d3d=true CloneConfigsTest
* @run main/othervm -Dsun.java2d.noddraw=true CloneConfigsTest
*/
--- a/test/jdk/java/awt/Multiscreen/DeviceIdentificationTest/DeviceIdentificationTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/Multiscreen/DeviceIdentificationTest/DeviceIdentificationTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -22,7 +22,7 @@
*/
/**
* @test
- * @bug 6614214
+ * @bug 6614214 8198613
* @summary Verifies that we enter the fs mode on the correct screen.
* Here is how to test: start the test on on a multi-screen system.
* Verify that the display is correctly tracked by dragging the frame back
@@ -40,7 +40,6 @@
*
* @run main/manual/othervm DeviceIdentificationTest
* @run main/manual/othervm -Dsun.java2d.noddraw=true DeviceIdentificationTest
- * @run main/manual/othervm -Dsun.java2d.opengl=True DeviceIdentificationTest
*/
import java.awt.Button;
--- a/test/jdk/java/awt/Window/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/Window/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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
@@ -23,14 +23,13 @@
/*
* @test %I% %E%
- * @bug 6655001 6670649 6687141
+ * @bug 6655001 6670649 6687141 8198613
* @summary Tests that hw acceleration doesn't affect translucent/shaped windows
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @compile -XDignore.symbol.file=true TranslucentShapedFrameTest.java
* @compile -XDignore.symbol.file=true TSFrame.java
* @run main/manual/othervm TranslucentShapedFrameTest
* @run main/manual/othervm -Dsun.java2d.noddraw=true TranslucentShapedFrameTest
- * @run main/manual/othervm -Dsun.java2d.opengl=True TranslucentShapedFrameTest
*/
import java.awt.Color;
import java.awt.Frame;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/VolatileImage/CustomCompositeTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2012, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key headful
+ * @bug 7124347 8198613
+ * @summary Verifies that rendering with XOR composite, and arbitraty
+ * custom composite doesn not cause internal errors.
+ *
+ * @run main/othervm CustomCompositeTest
+ */
+
+import java.awt.AWTException;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.CompositeContext;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.ImageCapabilities;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBufferInt;
+import java.awt.image.Raster;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.VolatileImage;
+import java.awt.image.WritableRaster;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+public class CustomCompositeTest {
+
+ private static JFrame frame;
+ private static CountDownLatch paintLatch;
+ private static Throwable paintError;
+
+ public static void main(String[] args) {
+
+ paintLatch = new CountDownLatch(1);
+ paintError = null;
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ initGUI();
+ }
+ });
+
+ try {
+ paintLatch.await();
+ } catch (InterruptedException e) {
+ };
+ System.out.println("Paint is done!");
+ if (paintError != null) {
+ frame.dispose();
+ throw new RuntimeException("Test FAILED.", paintError);
+ }
+
+ System.out.println("Phase 1: PASSED.");
+
+ // now resise the frame in order to cause re-paint with accelerated
+ // source images.
+ paintError = null;
+ paintLatch = new CountDownLatch(1);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Dimension size = frame.getSize();
+ size.width += 50;
+ size.height += 50;
+
+ frame.setSize(size);
+ }
+ });
+
+ try {
+ paintLatch.await();
+ } catch (InterruptedException e) {
+ };
+ if (paintError != null) {
+ frame.dispose();
+ throw new RuntimeException("Resize test FAILED.", paintError);
+ }
+ frame.dispose();
+ System.out.println("Phase 2: PASSED.");
+
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsConfiguration cfg = env.getDefaultScreenDevice().getDefaultConfiguration();
+ // test rendering to accelerated volatile image
+ testVolatileImage(cfg, true);
+ System.out.println("Phase 3: PASSED.");
+
+ // test rendering to unaccelerated volatile image
+ testVolatileImage(cfg, false);
+ System.out.println("Phase 4: PASSED.");
+ }
+
+ private static void testVolatileImage(GraphicsConfiguration cfg,
+ boolean accelerated)
+ {
+ VolatileImage dst = null;
+ try {
+ dst = cfg.createCompatibleVolatileImage(640, 480,
+ new ImageCapabilities(accelerated));
+ } catch (AWTException e) {
+ System.out.println("Unable to create volatile image, skip the test.");
+ return;
+ }
+ renderToVolatileImage(dst);
+ }
+
+ private static void renderToVolatileImage(VolatileImage dst) {
+ Graphics2D g = dst.createGraphics();
+ do {
+ System.out.println("Render to volatile image..");
+ try {
+ MyComp.renderTest(g, dst.getHeight(), dst.getHeight());
+ } catch (Throwable e) {
+ throw new RuntimeException("Test FAILED.", e);
+ }
+ } while (dst.contentsLost());
+ System.out.println("Done.");
+ }
+
+ private static void initGUI() {
+ frame = new JFrame("Silly composite");
+ frame.getContentPane().add(new MyComp());
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private static class MyComp extends JComponent {
+
+ private static BufferedImage theImage;
+
+ public MyComp() {
+ }
+
+ private static BufferedImage getTestImage() {
+ if (theImage == null) {
+ theImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = theImage.createGraphics();
+ g2d.setColor(Color.red);
+ g2d.fillRect(0, 0, 256, 256);
+
+ g2d.setPaint(new GradientPaint(0, 0, Color.red, 256, 256, Color.blue));
+ g2d.fillRect(0, 100, 256, 256);
+ g2d.dispose();
+ }
+ return theImage;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(640, 375);
+ }
+
+ public void paintComponent(Graphics g) {
+
+
+ Graphics2D g2d = (Graphics2D) g;
+ try {
+ renderTest(g2d, getWidth(), getHeight());
+ } catch (Throwable e) {
+ paintError = e;
+ }
+ if (paintLatch != null) {
+ paintLatch.countDown();
+ }
+ }
+
+ public static void renderTest(Graphics2D g2d, int w, int h) {
+ g2d.setColor(Color.yellow);
+ g2d.fillRect(0, 0, w, h);
+
+ BufferedImage image = getTestImage();
+ // draw original image
+ g2d.drawRenderedImage(image, null);
+
+ // draw image with custom composite
+ g2d.translate(175, 25);
+ Composite currentComposite = g2d.getComposite();
+ g2d.setComposite(new TestComposite());
+ g2d.drawRenderedImage(image, null);
+ g2d.setComposite(currentComposite);
+
+ // draw image with XOR
+ g2d.translate(175, 25);
+ g2d.setXORMode(Color.red);
+ g2d.drawRenderedImage(image, null);
+
+
+ System.out.println("Painting is done...");
+ }
+ }
+
+ // A silly custom Composite to demonstrate the problem - just inverts the RGB
+ private static class TestComposite implements Composite {
+
+ public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints) {
+ return new TestCompositeContext();
+ }
+ }
+
+ private static class TestCompositeContext implements CompositeContext {
+
+ public void dispose() {
+ }
+
+ public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
+ int w = src.getWidth();
+ int h = src.getHeight();
+
+ DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
+ DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
+ int srcRGB[] = srcDB.getBankData()[0];
+ int dstOutRGB[] = dstOutDB.getBankData()[0];
+ int srcOffset = srcDB.getOffset();
+ int dstOutOffset = dstOutDB.getOffset();
+ int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
+ int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
+ int srcAdjust = srcScanStride - w;
+ int dstOutAdjust = dstOutScanStride - w;
+
+ int si = srcOffset;
+ int doi = dstOutOffset;
+
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
+ dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
+ si++;
+ doi++;
+ }
+
+ si += srcAdjust;
+ doi += dstOutAdjust;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/VolatileImage/DrawBufImgOp.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,484 @@
+/*
+ * Copyright (c) 2007, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @key headful
+ * @bug 6514990 8198613
+ * @summary Verifies that calling
+ * Graphics2D.drawImage(BufferedImage, BufferedImageOp, x, y) to an
+ * accelerated destination produces the same results when performed
+ * in software via BufferedImageOp.filter().
+ * @run main/othervm DrawBufImgOp -ignore
+ * @author campbelc
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import java.io.File;
+import javax.imageio.ImageIO;
+
+/**
+ * REMIND: This testcase was originally intended to automatically compare
+ * the results of the software BufferedImageOp implementations against
+ * the OGL-accelerated codepaths. However, there are just too many open
+ * bugs in the mediaLib-based codepaths (see below), which means that
+ * creating the reference image may cause crashes or exceptions,
+ * and even if we work around those cases using the "-ignore" flag,
+ * the visual results of the reference image are often buggy as well
+ * (so the comparison will fail even though the OGL results are correct).
+ * Therefore, for now we will run the testcase with the "-ignore" flag
+ * but without the "-compare" flag, so at least it will be checking for
+ * any exceptions/crashes in the OGL code. When we fix all of the
+ * outstanding bugs with the software codepaths, we can remove the
+ * "-ignore" flag and maybe even restore the "-compare" flag. In the
+ * meantime, it stil functions well as a manual testcase (with either
+ * the "-show" or "-dump" options).
+ */
+public class DrawBufImgOp extends Canvas {
+
+ private static final int TESTW = 600;
+ private static final int TESTH = 500;
+ private static boolean done;
+
+ /*
+ * If true, skips tests that are known to trigger bugs (which in
+ * turn may cause crashes, exceptions, or other artifacts).
+ */
+ private static boolean ignore;
+
+ // Test both pow2 and non-pow2 sized images
+ private static final int[] srcSizes = { 32, 17 };
+ private static final int[] srcTypes = {
+ BufferedImage.TYPE_INT_RGB,
+ BufferedImage.TYPE_INT_ARGB,
+ BufferedImage.TYPE_INT_ARGB_PRE,
+ BufferedImage.TYPE_INT_BGR,
+ BufferedImage.TYPE_3BYTE_BGR,
+ BufferedImage.TYPE_4BYTE_ABGR,
+ BufferedImage.TYPE_USHORT_565_RGB,
+ BufferedImage.TYPE_BYTE_GRAY,
+ BufferedImage.TYPE_USHORT_GRAY,
+ };
+
+ private static final RescaleOp
+ rescale1band, rescale3band, rescale4band;
+ private static final LookupOp
+ lookup1bandbyte, lookup3bandbyte, lookup4bandbyte;
+ private static final LookupOp
+ lookup1bandshort, lookup3bandshort, lookup4bandshort;
+ private static final ConvolveOp
+ convolve3x3zero, convolve5x5zero, convolve7x7zero;
+ private static final ConvolveOp
+ convolve3x3noop, convolve5x5noop, convolve7x7noop;
+
+ static {
+ rescale1band = new RescaleOp(0.5f, 10.0f, null);
+ rescale3band = new RescaleOp(
+ new float[] { 0.6f, 0.4f, 0.6f },
+ new float[] { 10.0f, -3.0f, 5.0f },
+ null);
+ rescale4band = new RescaleOp(
+ new float[] { 0.6f, 0.4f, 0.6f, 0.9f },
+ new float[] { -1.0f, 5.0f, 3.0f, 1.0f },
+ null);
+
+ // REMIND: we should probably test non-zero offsets, but that
+ // would require massaging the source image data to avoid going
+ // outside the lookup table array bounds
+ int offset = 0;
+ {
+ byte invert[] = new byte[256];
+ byte halved[] = new byte[256];
+ for (int j = 0; j < 256 ; j++) {
+ invert[j] = (byte) (255-j);
+ halved[j] = (byte) (j / 2);
+ }
+ ByteLookupTable lut1 = new ByteLookupTable(offset, invert);
+ lookup1bandbyte = new LookupOp(lut1, null);
+ ByteLookupTable lut3 =
+ new ByteLookupTable(offset,
+ new byte[][] {invert, halved, invert});
+ lookup3bandbyte = new LookupOp(lut3, null);
+ ByteLookupTable lut4 =
+ new ByteLookupTable(offset,
+ new byte[][] {invert, halved, invert, halved});
+ lookup4bandbyte = new LookupOp(lut4, null);
+ }
+
+ {
+ short invert[] = new short[256];
+ short halved[] = new short[256];
+ for (int j = 0; j < 256 ; j++) {
+ invert[j] = (short) ((255-j) * 255);
+ halved[j] = (short) ((j / 2) * 255);
+ }
+ ShortLookupTable lut1 = new ShortLookupTable(offset, invert);
+ lookup1bandshort = new LookupOp(lut1, null);
+ ShortLookupTable lut3 =
+ new ShortLookupTable(offset,
+ new short[][] {invert, halved, invert});
+ lookup3bandshort = new LookupOp(lut3, null);
+ ShortLookupTable lut4 =
+ new ShortLookupTable(offset,
+ new short[][] {invert, halved, invert, halved});
+ lookup4bandshort = new LookupOp(lut4, null);
+ }
+
+ // 3x3 blur
+ float[] data3 = {
+ 0.1f, 0.1f, 0.1f,
+ 0.1f, 0.2f, 0.1f,
+ 0.1f, 0.1f, 0.1f,
+ };
+ Kernel k3 = new Kernel(3, 3, data3);
+
+ // 5x5 edge
+ float[] data5 = {
+ -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
+ -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
+ -1.0f, -1.0f, 24.0f, -1.0f, -1.0f,
+ -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
+ -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
+ };
+ Kernel k5 = new Kernel(5, 5, data5);
+
+ // 7x7 blur
+ float[] data7 = {
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
+ };
+ Kernel k7 = new Kernel(7, 7, data7);
+
+ convolve3x3zero = new ConvolveOp(k3, ConvolveOp.EDGE_ZERO_FILL, null);
+ convolve5x5zero = new ConvolveOp(k5, ConvolveOp.EDGE_ZERO_FILL, null);
+ convolve7x7zero = new ConvolveOp(k7, ConvolveOp.EDGE_ZERO_FILL, null);
+
+ convolve3x3noop = new ConvolveOp(k3, ConvolveOp.EDGE_NO_OP, null);
+ convolve5x5noop = new ConvolveOp(k5, ConvolveOp.EDGE_NO_OP, null);
+ convolve7x7noop = new ConvolveOp(k7, ConvolveOp.EDGE_NO_OP, null);
+ }
+
+ public void paint(Graphics g) {
+ synchronized (this) {
+ if (done) {
+ return;
+ }
+ }
+
+ VolatileImage vimg = createVolatileImage(TESTW, TESTH);
+ vimg.validate(getGraphicsConfiguration());
+
+ Graphics2D g2d = vimg.createGraphics();
+ renderTest(g2d);
+ g2d.dispose();
+
+ g.drawImage(vimg, 0, 0, null);
+
+ Toolkit.getDefaultToolkit().sync();
+
+ synchronized (this) {
+ done = true;
+ notifyAll();
+ }
+ }
+
+ /*
+ * foreach source image size (once with pow2, once with non-pow2)
+ *
+ * foreach BufferedImage type
+ *
+ * RescaleOp (1 band)
+ * RescaleOp (3 bands, if src has 3 bands)
+ * RescaleOp (4 bands, if src has 4 bands)
+ *
+ * foreach LookupTable type (once with ByteLUT, once with ShortLUT)
+ * LookupOp (1 band)
+ * LookupOp (3 bands, if src has 3 bands)
+ * LookupOp (4 bands, if src has 4 bands)
+ *
+ * foreach edge condition (once with ZERO_FILL, once with EDGE_NO_OP)
+ * ConvolveOp (3x3)
+ * ConvolveOp (5x5)
+ * ConvolveOp (7x7)
+ */
+ private void renderTest(Graphics2D g2d) {
+ g2d.setColor(Color.white);
+ g2d.fillRect(0, 0, TESTW, TESTH);
+
+ int yorig = 2;
+ int xinc = 34;
+ int yinc = srcSizes[0] + srcSizes[1] + 2 + 2;
+
+ for (int srcType : srcTypes) {
+ int y = yorig;
+
+ for (int srcSize : srcSizes) {
+ int x = 2;
+ System.out.printf("type=%d size=%d\n", srcType, srcSize);
+
+ BufferedImage srcImg = makeSourceImage(srcSize, srcType);
+ ColorModel srcCM = srcImg.getColorModel();
+
+ // RescaleOp
+ g2d.drawImage(srcImg, rescale1band, x, y);
+ x += xinc;
+ // REMIND: 3-band RescaleOp.filter() throws IAE for images
+ // that contain an alpha channel (bug to be filed)
+ if (srcCM.getNumColorComponents() == 3 &&
+ !(ignore && srcCM.hasAlpha()))
+ {
+ g2d.drawImage(srcImg, rescale3band, x, y);
+ }
+ x += xinc;
+ if (srcCM.getNumComponents() == 4) {
+ g2d.drawImage(srcImg, rescale4band, x, y);
+ }
+ x += xinc;
+
+ // LookupOp
+ // REMIND: Our LUTs are only 256 elements long, so won't
+ // currently work with USHORT_GRAY data
+ if (srcType != BufferedImage.TYPE_USHORT_GRAY) {
+ g2d.drawImage(srcImg, lookup1bandbyte, x, y);
+ x += xinc;
+ if (srcCM.getNumColorComponents() == 3) {
+ g2d.drawImage(srcImg, lookup3bandbyte, x, y);
+ }
+ x += xinc;
+ if (srcCM.getNumComponents() == 4) {
+ g2d.drawImage(srcImg, lookup4bandbyte, x, y);
+ }
+ x += xinc;
+
+ // REMIND: LookupOp.createCompatibleDestImage() throws
+ // IAE for 3BYTE_BGR/4BYTE_ABGR (bug to be filed)
+ if (!(ignore &&
+ (srcType == BufferedImage.TYPE_3BYTE_BGR ||
+ srcType == BufferedImage.TYPE_4BYTE_ABGR)))
+ {
+ g2d.drawImage(srcImg, lookup1bandshort, x, y);
+ x += xinc;
+ // REMIND: 3-band LookupOp.filter() throws IAE for
+ // images that contain an alpha channel
+ // (bug to be filed)
+ if (srcCM.getNumColorComponents() == 3 &&
+ !(ignore && srcCM.hasAlpha()))
+ {
+ g2d.drawImage(srcImg, lookup3bandshort, x, y);
+ }
+ x += xinc;
+ if (srcCM.getNumComponents() == 4) {
+ g2d.drawImage(srcImg, lookup4bandshort, x, y);
+ }
+ x += xinc;
+ } else {
+ x += 3*xinc;
+ }
+ } else {
+ x += 6*xinc;
+ }
+
+ // ConvolveOp
+ // REMIND: ConvolveOp.filter() throws ImagingOpException
+ // for 3BYTE_BGR (see 4957775)
+ if (srcType != BufferedImage.TYPE_3BYTE_BGR) {
+ g2d.drawImage(srcImg, convolve3x3zero, x, y);
+ x += xinc;
+ g2d.drawImage(srcImg, convolve5x5zero, x, y);
+ x += xinc;
+ g2d.drawImage(srcImg, convolve7x7zero, x, y);
+ x += xinc;
+
+ g2d.drawImage(srcImg, convolve3x3noop, x, y);
+ x += xinc;
+ g2d.drawImage(srcImg, convolve5x5noop, x, y);
+ x += xinc;
+ g2d.drawImage(srcImg, convolve7x7noop, x, y);
+ x += xinc;
+ } else {
+ x += 6*xinc;
+ }
+
+ y += srcSize + 2;
+ }
+
+ yorig += yinc;
+ }
+ }
+
+ private BufferedImage makeSourceImage(int size, int type) {
+ int s2 = size/2;
+ BufferedImage img = new BufferedImage(size, size, type);
+ Graphics2D g2d = img.createGraphics();
+ g2d.setComposite(AlphaComposite.Src);
+ g2d.setColor(Color.orange);
+ g2d.fillRect(0, 0, size, size);
+ g2d.setColor(Color.red);
+ g2d.fillRect(0, 0, s2, s2);
+ g2d.setColor(Color.green);
+ g2d.fillRect(s2, 0, s2, s2);
+ g2d.setColor(Color.blue);
+ g2d.fillRect(0, s2, s2, s2);
+ g2d.setColor(new Color(255, 255, 0, 128));
+ g2d.fillRect(s2, s2, s2, s2);
+ g2d.setColor(Color.pink);
+ g2d.fillOval(s2-3, s2-3, 6, 6);
+ g2d.dispose();
+ return img;
+ }
+
+ public BufferedImage makeReferenceImage() {
+ BufferedImage img = new BufferedImage(TESTW, TESTH,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = img.createGraphics();
+ renderTest(g2d);
+ g2d.dispose();
+ return img;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(TESTW, TESTH);
+ }
+
+ private static void compareImages(BufferedImage refImg,
+ BufferedImage testImg,
+ int tolerance)
+ {
+ int x1 = 0;
+ int y1 = 0;
+ int x2 = refImg.getWidth();
+ int y2 = refImg.getHeight();
+
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ Color expected = new Color(refImg.getRGB(x, y));
+ Color actual = new Color(testImg.getRGB(x, y));
+ if (!isSameColor(expected, actual, tolerance)) {
+ throw new RuntimeException("Test failed at x="+x+" y="+y+
+ " (expected="+expected+
+ " actual="+actual+
+ ")");
+ }
+ }
+ }
+ }
+
+ private static boolean isSameColor(Color c1, Color c2, int e) {
+ int r1 = c1.getRed();
+ int g1 = c1.getGreen();
+ int b1 = c1.getBlue();
+ int r2 = c2.getRed();
+ int g2 = c2.getGreen();
+ int b2 = c2.getBlue();
+ int rmin = Math.max(r2-e, 0);
+ int gmin = Math.max(g2-e, 0);
+ int bmin = Math.max(b2-e, 0);
+ int rmax = Math.min(r2+e, 255);
+ int gmax = Math.min(g2+e, 255);
+ int bmax = Math.min(b2+e, 255);
+ if (r1 >= rmin && r1 <= rmax &&
+ g1 >= gmin && g1 <= gmax &&
+ b1 >= bmin && b1 <= bmax)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static void main(String[] args) throws Exception {
+ boolean show = false;
+ boolean dump = false;
+ boolean compare = false;
+
+ for (String arg : args) {
+ if (arg.equals("-show")) {
+ show = true;
+ } else if (arg.equals("-dump")) {
+ dump = true;
+ } else if (arg.equals("-compare")) {
+ compare = true;
+ } else if (arg.equals("-ignore")) {
+ ignore = true;
+ }
+ }
+
+ DrawBufImgOp test = new DrawBufImgOp();
+ Frame frame = new Frame();
+ frame.add(test);
+ frame.pack();
+ frame.setVisible(true);
+
+ // Wait until the component's been painted
+ synchronized (test) {
+ while (!done) {
+ try {
+ test.wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Failed: Interrupted");
+ }
+ }
+ }
+
+ GraphicsConfiguration gc = frame.getGraphicsConfiguration();
+ if (gc.getColorModel() instanceof IndexColorModel) {
+ System.out.println("IndexColorModel detected: " +
+ "test considered PASSED");
+ frame.dispose();
+ return;
+ }
+
+ // Grab the screen region
+ BufferedImage capture = null;
+ try {
+ Robot robot = new Robot();
+ Point pt1 = test.getLocationOnScreen();
+ Rectangle rect = new Rectangle(pt1.x, pt1.y, TESTW, TESTH);
+ capture = robot.createScreenCapture(rect);
+ } catch (Exception e) {
+ throw new RuntimeException("Problems creating Robot");
+ } finally {
+ if (!show) {
+ frame.dispose();
+ }
+ }
+
+ // Compare the images (allow for +/- 1 bit differences in color comps)
+ if (dump || compare) {
+ BufferedImage ref = test.makeReferenceImage();
+ if (dump) {
+ ImageIO.write(ref, "png",
+ new File("DrawBufImgOp.ref.png"));
+ ImageIO.write(capture, "png",
+ new File("DrawBufImgOp.cap.png"));
+ }
+ if (compare) {
+ test.compareImages(ref, capture, 1);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/VolatileImage/DrawHugeImageTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @key headful
+ * @bug 8040617 8198613
+ * @summary Test verifies that an attempt to get an accelerated copy of
+ * a huge buffered image does not result in an OOME.
+ *
+ * @run main DrawHugeImageTest
+ */
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+public class DrawHugeImageTest {
+ // we have to render the BI source several times in order
+ // to get an accelerated copy to be used.
+ static {
+ System.setProperty("sun.java2d.accthreshold", "1");
+ }
+ private static final int max_rendering_count = 5;
+
+ private static final Color srcColor = Color.red;
+ private static final Color dstColor = Color.blue;
+
+ public static void main(String[] args) {
+ BufferedImage src = createSrc();
+
+ VolatileImage dst = createDst();
+ System.out.println("Dst: " + dst);
+ boolean status;
+ int count = max_rendering_count;
+
+ do {
+ System.out.println("render image: " + (max_rendering_count - count));
+ status = render(src, dst);
+
+ } while (status && count-- > 0);
+
+ if (!status || count > 0) {
+ throw new RuntimeException("Test failed: " + count);
+ }
+ }
+
+ private static boolean render(BufferedImage src, VolatileImage dst) {
+ int cnt = 5;
+ do {
+ Graphics2D g = dst.createGraphics();
+ g.setColor(dstColor);
+ g.fillRect(0, 0, dst.getWidth(), dst.getHeight());
+ g.drawImage(src, 0, 0, null);
+ g.dispose();
+ } while (dst.contentsLost() && (--cnt > 0));
+
+ if (cnt == 0) {
+ System.err.println("Test failed: unable to render to volatile destination");
+ return false;
+ }
+
+ BufferedImage s = dst.getSnapshot();
+
+ return s.getRGB(1,1) == srcColor.getRGB();
+ }
+
+ private static BufferedImage createSrc() {
+ final int w = 20000;
+ final int h = 5;
+
+ BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
+ Graphics2D g = img.createGraphics();
+ g.setColor(srcColor);
+ g.fillRect(0, 0, w, h);
+ g.dispose();
+
+ return img;
+ }
+
+ private static VolatileImage createDst() {
+ GraphicsConfiguration gc =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
+
+ return gc.createCompatibleVolatileImage(200, 200);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/VolatileImage/GradientPaints.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2007, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key headful
+ * @bug 6521533 6525997 7102282 8198613
+ * @summary Verifies that the accelerated codepaths for GradientPaint,
+ * LinearGradientPaint, and RadialGradientPaint produce results that are
+ * sufficiently close to those produced by the software codepaths.
+ * @run main/othervm -Dsun.java2d.uiScale=1 GradientPaints
+ * @author campbelc
+ */
+
+import java.awt.*;
+import java.awt.MultipleGradientPaint.ColorSpaceType;
+import java.awt.MultipleGradientPaint.CycleMethod;
+import java.awt.geom.*;
+import java.awt.image.*;
+import java.io.File;
+import java.util.Arrays;
+import javax.imageio.ImageIO;
+
+public class GradientPaints extends Canvas {
+
+ private static final int TESTW = 600;
+ private static final int TESTH = 500;
+
+ /*
+ * We expect slight differences in rendering between the OpenGL and
+ * software pipelines due to algorithmic and rounding differences.
+ * The purpose of this test is just to make sure that the OGL pipeline
+ * is producing results that are "reasonably" consistent with those
+ * produced in software, so we will allow +/-TOLERANCE differences
+ * in each component. When comparing the test and reference images,
+ * we add up the number of pixels that fall outside this tolerance
+ * range and if the sum is larger than some percentage of the total
+ * number of pixels.
+ *
+ * REMIND: Note that we have separate thresholds for linear and radial
+ * gradients because the visible differences between OGL and software
+ * are more apparent in the radial cases. In the future we should try
+ * to reduce the number of mismatches between the two approaches, but
+ * for now the visible differences are slight enough to not cause worry.
+ */
+ private static final int TOLERANCE = 5;
+ private static final int ALLOWED_MISMATCHES_LINEAR =
+ (int)(TESTW * TESTH * 0.18);
+ private static final int ALLOWED_MISMATCHES_RADIAL =
+ (int)(TESTW * TESTH * 0.45);
+
+ private static boolean done;
+ private static boolean verbose;
+
+ private static final Color[] COLORS = {
+ new Color(0, 0, 0),
+ new Color(128, 128, 128),
+ new Color(255, 0, 0),
+ new Color(255, 255, 0),
+ new Color(0, 255, 0),
+ new Color(0, 255, 255),
+ new Color(128, 0, 255),
+ new Color(128, 128, 128),
+ };
+
+ private static enum PaintType {BASIC, LINEAR, RADIAL};
+ private static enum XformType {IDENTITY, TRANSLATE, SCALE, SHEAR, ROTATE};
+ private static final int[] numStopsArray = {2, 4, 7};
+ private static final Object[] hints = {
+ RenderingHints.VALUE_ANTIALIAS_OFF,
+ RenderingHints.VALUE_ANTIALIAS_ON,
+ };
+
+ public void paint(Graphics g) {
+ synchronized (this) {
+ if (!done) {
+ done = true;
+ notifyAll();
+ }
+ }
+ }
+
+ private void testOne(BufferedImage refImg, VolatileImage testImg) {
+ Graphics2D gref = refImg.createGraphics();
+ Graphics2D gtest = testImg.createGraphics();
+ Paint paint =
+ makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
+ ColorSpaceType.SRGB, XformType.IDENTITY, 7);
+ Object aahint = hints[0];
+ renderTest(gref, paint, aahint);
+ renderTest(gtest, paint, aahint);
+ Toolkit.getDefaultToolkit().sync();
+ compareImages(refImg, testImg.getSnapshot(),
+ TOLERANCE, 0, "");
+ gref.dispose();
+ gtest.dispose();
+ }
+
+ private void testAll(Graphics gscreen,
+ BufferedImage refImg, VolatileImage testImg)
+ {
+ Graphics2D gref = refImg.createGraphics();
+ Graphics2D gtest = testImg.createGraphics();
+ for (PaintType paintType : PaintType.values()) {
+ for (CycleMethod cycleMethod : CycleMethod.values()) {
+ for (ColorSpaceType colorSpace : ColorSpaceType.values()) {
+ for (XformType xform : XformType.values()) {
+ for (Object aahint : hints) {
+ for (int numStops : numStopsArray) {
+ Paint paint =
+ makePaint(paintType, cycleMethod,
+ colorSpace, xform, numStops);
+ String msg =
+ "type=" + paintType +
+ " cycleMethod=" + cycleMethod +
+ " colorSpace=" + colorSpace +
+ " xformType=" + xform +
+ " numStops=" + numStops +
+ " aa=" + aahint;
+ renderTest(gref, paint, aahint);
+ renderTest(gtest, paint, aahint);
+ gscreen.drawImage(testImg, 0, 0, null);
+ Toolkit.getDefaultToolkit().sync();
+ int allowedMismatches =
+ paintType == PaintType.RADIAL ?
+ ALLOWED_MISMATCHES_RADIAL :
+ ALLOWED_MISMATCHES_LINEAR;
+ compareImages(refImg, testImg.getSnapshot(),
+ TOLERANCE, allowedMismatches,
+ msg);
+ }
+ }
+ }
+ }
+ }
+ }
+ gref.dispose();
+ gtest.dispose();
+ }
+
+ private Paint makePaint(PaintType paintType,
+ CycleMethod cycleMethod,
+ ColorSpaceType colorSpace,
+ XformType xformType, int numStops)
+ {
+ int startX = TESTW/6;
+ int startY = TESTH/6;
+ int endX = TESTW/2;
+ int endY = TESTH/2;
+ int ctrX = TESTW/2;
+ int ctrY = TESTH/2;
+ int focusX = ctrX + 20;
+ int focusY = ctrY + 20;
+ float radius = 100.0f;
+ Paint paint;
+ AffineTransform transform;
+
+ Color[] colors = Arrays.copyOf(COLORS, numStops);
+ float[] fractions = new float[colors.length];
+ for (int i = 0; i < fractions.length; i++) {
+ fractions[i] = ((float)i) / (fractions.length-1);
+ }
+
+ switch (xformType) {
+ default:
+ case IDENTITY:
+ transform = new AffineTransform();
+ break;
+ case TRANSLATE:
+ transform = AffineTransform.getTranslateInstance(2, 2);
+ break;
+ case SCALE:
+ transform = AffineTransform.getScaleInstance(1.2, 1.4);
+ break;
+ case SHEAR:
+ transform = AffineTransform.getShearInstance(0.1, 0.1);
+ break;
+ case ROTATE:
+ transform = AffineTransform.getRotateInstance(Math.PI / 4,
+ getWidth()/2,
+ getHeight()/2);
+ break;
+ }
+
+ switch (paintType) {
+ case BASIC:
+ boolean cyclic = (cycleMethod != CycleMethod.NO_CYCLE);
+ paint =
+ new GradientPaint(startX, startY, Color.RED,
+ endX, endY, Color.BLUE, cyclic);
+ break;
+
+ default:
+ case LINEAR:
+ paint =
+ new LinearGradientPaint(new Point2D.Float(startX, startY),
+ new Point2D.Float(endX, endY),
+ fractions, colors,
+ cycleMethod, colorSpace,
+ transform);
+ break;
+
+ case RADIAL:
+ paint =
+ new RadialGradientPaint(new Point2D.Float(ctrX, ctrY),
+ radius,
+ new Point2D.Float(focusX, focusY),
+ fractions, colors,
+ cycleMethod, colorSpace,
+ transform);
+ break;
+ }
+
+ return paint;
+ }
+
+ private void renderTest(Graphics2D g2d, Paint p, Object aahint) {
+ g2d.setColor(Color.white);
+ g2d.fillRect(0, 0, TESTW, TESTH);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aahint);
+ g2d.setPaint(p);
+ g2d.fillOval(0, 0, TESTW, TESTH);
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(TESTW, TESTH);
+ }
+
+ private static void compareImages(BufferedImage refImg,
+ BufferedImage testImg,
+ int tolerance, int allowedMismatches,
+ String msg)
+ {
+ int numMismatches = 0;
+ int x1 = 0;
+ int y1 = 0;
+ int x2 = refImg.getWidth();
+ int y2 = refImg.getHeight();
+
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ Color expected = new Color(refImg.getRGB(x, y));
+ Color actual = new Color(testImg.getRGB(x, y));
+ if (!isSameColor(expected, actual, tolerance)) {
+ numMismatches++;
+ }
+ }
+ }
+
+ if (verbose) {
+ System.out.println(msg);
+ }
+ if (numMismatches > allowedMismatches) {
+ try {
+ ImageIO.write(refImg, "png",
+ new File("GradientPaints.ref.png"));
+ ImageIO.write(testImg, "png",
+ new File("GradientPaints.cap.png"));
+ } catch (Exception e) {
+ }
+ if (!verbose) {
+ System.err.println(msg);
+ }
+ throw new RuntimeException("Test failed: Number of mismatches (" +
+ numMismatches +
+ ") exceeds limit (" +
+ allowedMismatches +
+ ") with tolerance=" +
+ tolerance);
+ }
+ }
+
+ private static boolean isSameColor(Color c1, Color c2, int e) {
+ int r1 = c1.getRed();
+ int g1 = c1.getGreen();
+ int b1 = c1.getBlue();
+ int r2 = c2.getRed();
+ int g2 = c2.getGreen();
+ int b2 = c2.getBlue();
+ int rmin = Math.max(r2-e, 0);
+ int gmin = Math.max(g2-e, 0);
+ int bmin = Math.max(b2-e, 0);
+ int rmax = Math.min(r2+e, 255);
+ int gmax = Math.min(g2+e, 255);
+ int bmax = Math.min(b2+e, 255);
+ if (r1 >= rmin && r1 <= rmax &&
+ g1 >= gmin && g1 <= gmax &&
+ b1 >= bmin && b1 <= bmax)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static void main(String[] args) {
+ if (args.length == 1 && args[0].equals("-verbose")) {
+ verbose = true;
+ }
+
+ GradientPaints test = new GradientPaints();
+ Frame frame = new Frame();
+ frame.add(test);
+ frame.pack();
+ frame.setVisible(true);
+
+ // Wait until the component's been painted
+ synchronized (test) {
+ while (!done) {
+ try {
+ test.wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Failed: Interrupted");
+ }
+ }
+ }
+
+ GraphicsConfiguration gc = frame.getGraphicsConfiguration();
+ if (gc.getColorModel() instanceof IndexColorModel) {
+ System.out.println("IndexColorModel detected: " +
+ "test considered PASSED");
+ frame.dispose();
+ return;
+ }
+
+ BufferedImage refImg =
+ new BufferedImage(TESTW, TESTH, BufferedImage.TYPE_INT_RGB);
+ VolatileImage testImg = frame.createVolatileImage(TESTW, TESTH);
+ testImg.validate(gc);
+
+ try {
+ test.testAll(test.getGraphics(), refImg, testImg);
+ } finally {
+ frame.dispose();
+ }
+ }
+}
--- a/test/jdk/java/awt/image/VolatileImage/TransparentVImage.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/java/awt/image/VolatileImage/TransparentVImage.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -23,14 +23,12 @@
/*
* @test
- * @bug 4881082 4916294 5002129 8158524
+ * @bug 4881082 4916294 5002129 8158524 8198613
* @summary The test verifies whether the rendering operations on transparent
* and translucent VolatileImage objects generate identical output
* as generated with transparent and translucent BufferedImages.
* @key headful
* @run main/othervm -Dsun.java2d.uiScale=1 TransparentVImage
- * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=false TransparentVImage
- * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=true TransparentVImage
*/
import java.awt.GraphicsConfiguration;
import java.awt.Graphics;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/VolatileImage/bug7181438.java Fri Mar 02 14:39:29 2018 +0530
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2012, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+/**
+ * @test
+ * @key headful
+ * @bug 7181438 8198613
+ * @summary Verifies that we get correct alpha, when we draw opaque
+ * BufferedImage to non opaque VolatileImage via intermediate opaque texture.
+ * @author Sergey Bylokhov
+ * @run main/othervm -Dsun.java2d.accthreshold=0 bug7181438
+ */
+public final class bug7181438 {
+
+ private static final int SIZE = 500;
+
+ public static void main(final String[] args) {
+
+ final BufferedImage bi = createBufferedImage();
+ final VolatileImage vi = createVolatileImage();
+ final Graphics s2dVi = vi.getGraphics();
+
+ //sw->texture->surface blit
+ s2dVi.drawImage(bi, 0, 0, null);
+
+ final BufferedImage results = vi.getSnapshot();
+ for (int i = 0; i < SIZE; ++i) {
+ for (int j = 0; j < SIZE; ++j) {
+ //Image should be opaque: (black color and alpha = 255)
+ if (results.getRGB(i, j) != 0xFF000000) {
+ throw new RuntimeException("Failed: Wrong alpha");
+ }
+ }
+ }
+ System.out.println("Passed");
+ }
+
+
+ private static VolatileImage createVolatileImage() {
+ final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
+ return gc.createCompatibleVolatileImage(SIZE, SIZE,
+ Transparency.TRANSLUCENT);
+ }
+
+ private static BufferedImage createBufferedImage() {
+ final BufferedImage bi = new BufferedImage(SIZE, SIZE,
+ BufferedImage.TYPE_INT_RGB);
+ final Graphics bg = bi.getGraphics();
+ //Black color and alpha = 0
+ bg.setColor(new Color(0, 0, 0, 0));
+ bg.fillRect(0, 0, SIZE, SIZE);
+ bg.dispose();
+ return bi;
+ }
+}
--- a/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -31,11 +31,10 @@
/**
* @test
* @key headful
- * @bug 8175301
+ * @bug 8175301 8198613
* @summary Java GUI hangs on Windows when Display set to 125%
* @run main/othervm -Dsun.java2d.uiScale=2 ScaledFrameBackgroundTest
* @run main/othervm -Dsun.java2d.uiScale=2 -Dsun.java2d.d3d=true ScaledFrameBackgroundTest
- * @run main/othervm -Dsun.java2d.uiScale=2 -Dsun.java2d.opengl=true ScaledFrameBackgroundTest
*/
public class ScaledFrameBackgroundTest {
--- a/test/jdk/javax/swing/JInternalFrame/8069348/bug8069348.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/javax/swing/JInternalFrame/8069348/bug8069348.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -37,12 +37,11 @@
/**
* @test
* @key headful
- * @bug 8069348 8159902
+ * @bug 8069348 8159902 8198613
* @summary SunGraphics2D.copyArea() does not properly work for scaled graphics
* @author Alexandr Scherbatiy
* @modules java.desktop/sun.awt
* @run main/othervm -Dsun.java2d.uiScale=2 bug8069348
- * @run main/othervm -Dsun.java2d.opengl=true -Dsun.java2d.uiScale=2 bug8069348
* @run main/othervm -Dsun.java2d.d3d=true -Dsun.java2d.uiScale=2 bug8069348
*/
public class bug8069348 {
--- a/test/jdk/sun/java2d/DirectX/AccelPaintsTest/AccelPaintsTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/AccelPaintsTest/AccelPaintsTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,12 +24,11 @@
/*
* @test
* @key headful
- * @bug 6659345
+ * @bug 6659345 8198613
* @summary Tests that various paints work correctly when preceeded by a
* textured operaiton.
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm AccelPaintsTest
- * @run main/othervm -Dsun.java2d.opengl=True AccelPaintsTest
*/
import java.awt.Color;
--- a/test/jdk/sun/java2d/DirectX/AcceleratedScaleTest/AcceleratedScaleTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/AcceleratedScaleTest/AcceleratedScaleTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -38,13 +38,11 @@
/**
* @test
* @key headful
- * @bug 6429665
- * @bug 6588884
+ * @bug 6429665 6588884 8198613
* @summary Tests that the transform is correctly handled
* @author Dmitri.Trembovetski area=Graphics
* @run main AcceleratedScaleTest
* @run main/othervm -Dsun.java2d.d3d=true AcceleratedScaleTest
- * @run main/othervm -Dsun.java2d.opengl=true AcceleratedScaleTest
*/
public class AcceleratedScaleTest {
private static final int IMAGE_SIZE = 200;
--- a/test/jdk/sun/java2d/DirectX/NonOpaqueDestLCDAATest/NonOpaqueDestLCDAATest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/NonOpaqueDestLCDAATest/NonOpaqueDestLCDAATest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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
@@ -23,13 +23,12 @@
/*
* @test
- * @bug 6728834 6749060
+ * @bug 6728834 6749060 8198613
* @summary Tests that LCD AA text rendering works properly with destinations
* being VolatileImage of all transparency types
* @author Dmitri.Trembovetski: area=Graphics
* @run main/manual/othervm -Dsun.java2d.d3d=false NonOpaqueDestLCDAATest
* @run main/manual/othervm NonOpaqueDestLCDAATest
- * @run main/manual/othervm -Dsun.java2d.opengl=True NonOpaqueDestLCDAATest
*/
import java.awt.AlphaComposite;
--- a/test/jdk/sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,13 +24,12 @@
/*
* @test
* @key headful
- * @bug 6764257
+ * @bug 6764257 8198613
* @summary Tests that the alpha in opaque images doesn't affect result of alpha
* compositing
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm OpaqueImageToSurfaceBlitTest
* @run main/othervm -Dsun.java2d.noddraw=true OpaqueImageToSurfaceBlitTest
- * @run main/othervm -Dsun.java2d.opengl=True OpaqueImageToSurfaceBlitTest
*/
import java.awt.AlphaComposite;
--- a/test/jdk/sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,11 +24,10 @@
/*
* @test
* @key headful
- * @bug 6694230
+ * @bug 6694230 8198613
* @summary Tests that components overriding getInsets paint correctly
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm OverriddenInsetsTest
- * @run main/othervm -Dsun.java2d.opengl=True OverriddenInsetsTest
*/
import java.awt.Color;
--- a/test/jdk/sun/java2d/DirectX/StrikeDisposalCrashTest/StrikeDisposalCrashTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/StrikeDisposalCrashTest/StrikeDisposalCrashTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,13 +24,12 @@
/**
* @test
* @key headful
- * @bug 6705443
+ * @bug 6705443 8198613
* @summary tests that we don't crash during exit if font strikes were disposed
* during the lifetime of the application
*
* @run main/othervm -Dsun.java2d.font.reftype=weak StrikeDisposalCrashTest
* @run main/othervm -Dsun.java2d.font.reftype=weak -Dsun.java2d.noddraw=true StrikeDisposalCrashTest
- * @run main/othervm -Dsun.java2d.font.reftype=weak -Dsun.java2d.opengl=True StrikeDisposalCrashTest
*/
import java.awt.Font;
--- a/test/jdk/sun/java2d/DirectX/SwingOnScreenScrollingTest/SwingOnScreenScrollingTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/SwingOnScreenScrollingTest/SwingOnScreenScrollingTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -23,12 +23,11 @@
/*
* @test
* @key headful
- * @bug 6630702
+ * @bug 6630702 8198613
* @summary Tests that scrolling after paint() is performed correctly.
* This is really only applicable to Vista
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm SwingOnScreenScrollingTest
- * run main/othervm -Dsun.java2d.opengl=True SwingOnScreenScrollingTest
*/
import java.awt.AWTException;
--- a/test/jdk/sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,11 +24,10 @@
/*
* @test
* @key headful
- * @bug 6689025 8023483
+ * @bug 6689025 8023483 8198613
* @summary Tests that transformed Paints are rendered correctly
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm TransformedPaintTest
- * @run main/othervm -Dsun.java2d.opengl=True TransformedPaintTest
*/
import java.awt.Color;
--- a/test/jdk/sun/java2d/OpenGL/CopyAreaOOB.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @key headful
- * @bug 6430601
- * @summary Verifies that copyArea() works properly when the
- * destination parameters are outside the destination bounds.
- * @run main/othervm CopyAreaOOB
- * @run main/othervm -Dsun.java2d.opengl=True CopyAreaOOB
- * @author campbelc
- */
-
-import java.awt.*;
-import java.awt.image.*;
-
-public class CopyAreaOOB extends Canvas {
-
- private static boolean done;
-
- public void paint(Graphics g) {
- synchronized (this) {
- if (done) {
- return;
- }
- }
-
- int w = getWidth();
- int h = getHeight();
-
- Graphics2D g2d = (Graphics2D)g;
- g2d.setColor(Color.black);
- g2d.fillRect(0, 0, w, h);
-
- g2d.setColor(Color.green);
- g2d.fillRect(0, 0, w, 10);
-
- g2d.setColor(Color.red);
- g2d.fillRect(0, 10, 50, h-10);
-
- // copy the region such that part of it goes below the bottom of the
- // destination surface
- g2d.copyArea(0, 10, 50, h-10, 60, 10);
-
- Toolkit.getDefaultToolkit().sync();
-
- synchronized (this) {
- done = true;
- notifyAll();
- }
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(400, 400);
- }
-
- private static void testRegion(BufferedImage bi, String name,
- int x1, int y1, int x2, int y2,
- int expected)
- {
- for (int y = y1; y < y2; y++) {
- for (int x = x1; x < x2; x++) {
- int actual = bi.getRGB(x, y);
- if (actual != expected) {
- throw new RuntimeException("Test failed for " + name +
- " region at x="+x+" y="+y+
- " (expected="+
- Integer.toHexString(expected) +
- " actual="+
- Integer.toHexString(actual) +
- ")");
- }
- }
- }
- }
-
- public static void main(String[] args) {
- boolean show = (args.length == 1) && ("-show".equals(args[0]));
-
- CopyAreaOOB test = new CopyAreaOOB();
- Frame frame = new Frame();
- frame.setUndecorated(true);
- frame.add(test);
- frame.pack();
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
-
- // Wait until the component's been painted
- synchronized (test) {
- while (!done) {
- try {
- test.wait();
- } catch (InterruptedException e) {
- throw new RuntimeException("Failed: Interrupted");
- }
- }
- }
-
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ex) {}
-
- // Grab the screen region
- BufferedImage capture = null;
- try {
- Robot robot = new Robot();
- Point pt1 = test.getLocationOnScreen();
- Rectangle rect = new Rectangle(pt1.x, pt1.y, 400, 400);
- capture = robot.createScreenCapture(rect);
- } catch (Exception e) {
- throw new RuntimeException("Problems creating Robot");
- } finally {
- if (!show) {
- frame.dispose();
- }
- }
-
- // Test pixels
- testRegion(capture, "green", 0, 0, 400, 10, 0xff00ff00);
- testRegion(capture, "original red", 0, 10, 50, 400, 0xffff0000);
- testRegion(capture, "background", 50, 10, 60, 400, 0xff000000);
- testRegion(capture, "in-between", 60, 10, 110, 20, 0xff000000);
- testRegion(capture, "copied red", 60, 20, 110, 400, 0xffff0000);
- testRegion(capture, "background", 110, 10, 400, 400, 0xff000000);
- }
-}
--- a/test/jdk/sun/java2d/OpenGL/CustomCompositeTest.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @key headful
- * @bug 7124347
- * @summary Verifies that rendering with XOR composite, and arbitraty
- * custom composite doesn not cause internal errors.
- *
- * @run main/othervm -Dsun.java2d.opengl=True CustomCompositeTest
- */
-
-import java.awt.AWTException;
-import java.awt.Color;
-import java.awt.Composite;
-import java.awt.CompositeContext;
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.ImageCapabilities;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBufferInt;
-import java.awt.image.Raster;
-import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.VolatileImage;
-import java.awt.image.WritableRaster;
-import java.util.concurrent.CountDownLatch;
-import javax.swing.JComponent;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-public class CustomCompositeTest {
-
- private static JFrame frame;
- private static CountDownLatch paintLatch;
- private static Throwable paintError;
-
- public static void main(String[] args) {
-
- paintLatch = new CountDownLatch(1);
- paintError = null;
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- initGUI();
- }
- });
-
- try {
- paintLatch.await();
- } catch (InterruptedException e) {
- };
- System.out.println("Paint is done!");
- if (paintError != null) {
- frame.dispose();
- throw new RuntimeException("Test FAILED.", paintError);
- }
-
- System.out.println("Phase 1: PASSED.");
-
- // now resise the frame in order to cause re-paint with accelerated
- // source images.
- paintError = null;
- paintLatch = new CountDownLatch(1);
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- Dimension size = frame.getSize();
- size.width += 50;
- size.height += 50;
-
- frame.setSize(size);
- }
- });
-
- try {
- paintLatch.await();
- } catch (InterruptedException e) {
- };
- if (paintError != null) {
- frame.dispose();
- throw new RuntimeException("Resize test FAILED.", paintError);
- }
- frame.dispose();
- System.out.println("Phase 2: PASSED.");
-
- GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsConfiguration cfg = env.getDefaultScreenDevice().getDefaultConfiguration();
- // test rendering to accelerated volatile image
- testVolatileImage(cfg, true);
- System.out.println("Phase 3: PASSED.");
-
- // test rendering to unaccelerated volatile image
- testVolatileImage(cfg, false);
- System.out.println("Phase 4: PASSED.");
- }
-
- private static void testVolatileImage(GraphicsConfiguration cfg,
- boolean accelerated)
- {
- VolatileImage dst = null;
- try {
- dst = cfg.createCompatibleVolatileImage(640, 480,
- new ImageCapabilities(accelerated));
- } catch (AWTException e) {
- System.out.println("Unable to create volatile image, skip the test.");
- return;
- }
- renderToVolatileImage(dst);
- }
-
- private static void renderToVolatileImage(VolatileImage dst) {
- Graphics2D g = dst.createGraphics();
- do {
- System.out.println("Render to volatile image..");
- try {
- MyComp.renderTest(g, dst.getHeight(), dst.getHeight());
- } catch (Throwable e) {
- throw new RuntimeException("Test FAILED.", e);
- }
- } while (dst.contentsLost());
- System.out.println("Done.");
- }
-
- private static void initGUI() {
- frame = new JFrame("Silly composite");
- frame.getContentPane().add(new MyComp());
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.pack();
- frame.setVisible(true);
- }
-
- private static class MyComp extends JComponent {
-
- private static BufferedImage theImage;
-
- public MyComp() {
- }
-
- private static BufferedImage getTestImage() {
- if (theImage == null) {
- theImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = theImage.createGraphics();
- g2d.setColor(Color.red);
- g2d.fillRect(0, 0, 256, 256);
-
- g2d.setPaint(new GradientPaint(0, 0, Color.red, 256, 256, Color.blue));
- g2d.fillRect(0, 100, 256, 256);
- g2d.dispose();
- }
- return theImage;
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(640, 375);
- }
-
- public void paintComponent(Graphics g) {
-
-
- Graphics2D g2d = (Graphics2D) g;
- try {
- renderTest(g2d, getWidth(), getHeight());
- } catch (Throwable e) {
- paintError = e;
- }
- if (paintLatch != null) {
- paintLatch.countDown();
- }
- }
-
- public static void renderTest(Graphics2D g2d, int w, int h) {
- g2d.setColor(Color.yellow);
- g2d.fillRect(0, 0, w, h);
-
- BufferedImage image = getTestImage();
- // draw original image
- g2d.drawRenderedImage(image, null);
-
- // draw image with custom composite
- g2d.translate(175, 25);
- Composite currentComposite = g2d.getComposite();
- g2d.setComposite(new TestComposite());
- g2d.drawRenderedImage(image, null);
- g2d.setComposite(currentComposite);
-
- // draw image with XOR
- g2d.translate(175, 25);
- g2d.setXORMode(Color.red);
- g2d.drawRenderedImage(image, null);
-
-
- System.out.println("Painting is done...");
- }
- }
-
- // A silly custom Composite to demonstrate the problem - just inverts the RGB
- private static class TestComposite implements Composite {
-
- public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints) {
- return new TestCompositeContext();
- }
- }
-
- private static class TestCompositeContext implements CompositeContext {
-
- public void dispose() {
- }
-
- public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
- int w = src.getWidth();
- int h = src.getHeight();
-
- DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
- DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
- int srcRGB[] = srcDB.getBankData()[0];
- int dstOutRGB[] = dstOutDB.getBankData()[0];
- int srcOffset = srcDB.getOffset();
- int dstOutOffset = dstOutDB.getOffset();
- int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
- int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
- int srcAdjust = srcScanStride - w;
- int dstOutAdjust = dstOutScanStride - w;
-
- int si = srcOffset;
- int doi = dstOutOffset;
-
- for (int i = 0; i < h; i++) {
- for (int j = 0; j < w; j++) {
- dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
- si++;
- doi++;
- }
-
- si += srcAdjust;
- doi += dstOutAdjust;
- }
- }
- }
-}
--- a/test/jdk/sun/java2d/OpenGL/DrawBufImgOp.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,484 +0,0 @@
-/*
- * Copyright (c) 2007, 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * @test
- * @key headful
- * @bug 6514990
- * @summary Verifies that calling
- * Graphics2D.drawImage(BufferedImage, BufferedImageOp, x, y) to an
- * OpenGL-accelerated destination produces the same results when performed
- * in software via BufferedImageOp.filter().
- * @run main/othervm -Dsun.java2d.opengl=True DrawBufImgOp -ignore
- * @author campbelc
- */
-
-import java.awt.*;
-import java.awt.image.*;
-import java.io.File;
-import javax.imageio.ImageIO;
-
-/**
- * REMIND: This testcase was originally intended to automatically compare
- * the results of the software BufferedImageOp implementations against
- * the OGL-accelerated codepaths. However, there are just too many open
- * bugs in the mediaLib-based codepaths (see below), which means that
- * creating the reference image may cause crashes or exceptions,
- * and even if we work around those cases using the "-ignore" flag,
- * the visual results of the reference image are often buggy as well
- * (so the comparison will fail even though the OGL results are correct).
- * Therefore, for now we will run the testcase with the "-ignore" flag
- * but without the "-compare" flag, so at least it will be checking for
- * any exceptions/crashes in the OGL code. When we fix all of the
- * outstanding bugs with the software codepaths, we can remove the
- * "-ignore" flag and maybe even restore the "-compare" flag. In the
- * meantime, it stil functions well as a manual testcase (with either
- * the "-show" or "-dump" options).
- */
-public class DrawBufImgOp extends Canvas {
-
- private static final int TESTW = 600;
- private static final int TESTH = 500;
- private static boolean done;
-
- /*
- * If true, skips tests that are known to trigger bugs (which in
- * turn may cause crashes, exceptions, or other artifacts).
- */
- private static boolean ignore;
-
- // Test both pow2 and non-pow2 sized images
- private static final int[] srcSizes = { 32, 17 };
- private static final int[] srcTypes = {
- BufferedImage.TYPE_INT_RGB,
- BufferedImage.TYPE_INT_ARGB,
- BufferedImage.TYPE_INT_ARGB_PRE,
- BufferedImage.TYPE_INT_BGR,
- BufferedImage.TYPE_3BYTE_BGR,
- BufferedImage.TYPE_4BYTE_ABGR,
- BufferedImage.TYPE_USHORT_565_RGB,
- BufferedImage.TYPE_BYTE_GRAY,
- BufferedImage.TYPE_USHORT_GRAY,
- };
-
- private static final RescaleOp
- rescale1band, rescale3band, rescale4band;
- private static final LookupOp
- lookup1bandbyte, lookup3bandbyte, lookup4bandbyte;
- private static final LookupOp
- lookup1bandshort, lookup3bandshort, lookup4bandshort;
- private static final ConvolveOp
- convolve3x3zero, convolve5x5zero, convolve7x7zero;
- private static final ConvolveOp
- convolve3x3noop, convolve5x5noop, convolve7x7noop;
-
- static {
- rescale1band = new RescaleOp(0.5f, 10.0f, null);
- rescale3band = new RescaleOp(
- new float[] { 0.6f, 0.4f, 0.6f },
- new float[] { 10.0f, -3.0f, 5.0f },
- null);
- rescale4band = new RescaleOp(
- new float[] { 0.6f, 0.4f, 0.6f, 0.9f },
- new float[] { -1.0f, 5.0f, 3.0f, 1.0f },
- null);
-
- // REMIND: we should probably test non-zero offsets, but that
- // would require massaging the source image data to avoid going
- // outside the lookup table array bounds
- int offset = 0;
- {
- byte invert[] = new byte[256];
- byte halved[] = new byte[256];
- for (int j = 0; j < 256 ; j++) {
- invert[j] = (byte) (255-j);
- halved[j] = (byte) (j / 2);
- }
- ByteLookupTable lut1 = new ByteLookupTable(offset, invert);
- lookup1bandbyte = new LookupOp(lut1, null);
- ByteLookupTable lut3 =
- new ByteLookupTable(offset,
- new byte[][] {invert, halved, invert});
- lookup3bandbyte = new LookupOp(lut3, null);
- ByteLookupTable lut4 =
- new ByteLookupTable(offset,
- new byte[][] {invert, halved, invert, halved});
- lookup4bandbyte = new LookupOp(lut4, null);
- }
-
- {
- short invert[] = new short[256];
- short halved[] = new short[256];
- for (int j = 0; j < 256 ; j++) {
- invert[j] = (short) ((255-j) * 255);
- halved[j] = (short) ((j / 2) * 255);
- }
- ShortLookupTable lut1 = new ShortLookupTable(offset, invert);
- lookup1bandshort = new LookupOp(lut1, null);
- ShortLookupTable lut3 =
- new ShortLookupTable(offset,
- new short[][] {invert, halved, invert});
- lookup3bandshort = new LookupOp(lut3, null);
- ShortLookupTable lut4 =
- new ShortLookupTable(offset,
- new short[][] {invert, halved, invert, halved});
- lookup4bandshort = new LookupOp(lut4, null);
- }
-
- // 3x3 blur
- float[] data3 = {
- 0.1f, 0.1f, 0.1f,
- 0.1f, 0.2f, 0.1f,
- 0.1f, 0.1f, 0.1f,
- };
- Kernel k3 = new Kernel(3, 3, data3);
-
- // 5x5 edge
- float[] data5 = {
- -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
- -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
- -1.0f, -1.0f, 24.0f, -1.0f, -1.0f,
- -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
- -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
- };
- Kernel k5 = new Kernel(5, 5, data5);
-
- // 7x7 blur
- float[] data7 = {
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f, 0.02f,
- };
- Kernel k7 = new Kernel(7, 7, data7);
-
- convolve3x3zero = new ConvolveOp(k3, ConvolveOp.EDGE_ZERO_FILL, null);
- convolve5x5zero = new ConvolveOp(k5, ConvolveOp.EDGE_ZERO_FILL, null);
- convolve7x7zero = new ConvolveOp(k7, ConvolveOp.EDGE_ZERO_FILL, null);
-
- convolve3x3noop = new ConvolveOp(k3, ConvolveOp.EDGE_NO_OP, null);
- convolve5x5noop = new ConvolveOp(k5, ConvolveOp.EDGE_NO_OP, null);
- convolve7x7noop = new ConvolveOp(k7, ConvolveOp.EDGE_NO_OP, null);
- }
-
- public void paint(Graphics g) {
- synchronized (this) {
- if (done) {
- return;
- }
- }
-
- VolatileImage vimg = createVolatileImage(TESTW, TESTH);
- vimg.validate(getGraphicsConfiguration());
-
- Graphics2D g2d = vimg.createGraphics();
- renderTest(g2d);
- g2d.dispose();
-
- g.drawImage(vimg, 0, 0, null);
-
- Toolkit.getDefaultToolkit().sync();
-
- synchronized (this) {
- done = true;
- notifyAll();
- }
- }
-
- /*
- * foreach source image size (once with pow2, once with non-pow2)
- *
- * foreach BufferedImage type
- *
- * RescaleOp (1 band)
- * RescaleOp (3 bands, if src has 3 bands)
- * RescaleOp (4 bands, if src has 4 bands)
- *
- * foreach LookupTable type (once with ByteLUT, once with ShortLUT)
- * LookupOp (1 band)
- * LookupOp (3 bands, if src has 3 bands)
- * LookupOp (4 bands, if src has 4 bands)
- *
- * foreach edge condition (once with ZERO_FILL, once with EDGE_NO_OP)
- * ConvolveOp (3x3)
- * ConvolveOp (5x5)
- * ConvolveOp (7x7)
- */
- private void renderTest(Graphics2D g2d) {
- g2d.setColor(Color.white);
- g2d.fillRect(0, 0, TESTW, TESTH);
-
- int yorig = 2;
- int xinc = 34;
- int yinc = srcSizes[0] + srcSizes[1] + 2 + 2;
-
- for (int srcType : srcTypes) {
- int y = yorig;
-
- for (int srcSize : srcSizes) {
- int x = 2;
- System.out.printf("type=%d size=%d\n", srcType, srcSize);
-
- BufferedImage srcImg = makeSourceImage(srcSize, srcType);
- ColorModel srcCM = srcImg.getColorModel();
-
- // RescaleOp
- g2d.drawImage(srcImg, rescale1band, x, y);
- x += xinc;
- // REMIND: 3-band RescaleOp.filter() throws IAE for images
- // that contain an alpha channel (bug to be filed)
- if (srcCM.getNumColorComponents() == 3 &&
- !(ignore && srcCM.hasAlpha()))
- {
- g2d.drawImage(srcImg, rescale3band, x, y);
- }
- x += xinc;
- if (srcCM.getNumComponents() == 4) {
- g2d.drawImage(srcImg, rescale4band, x, y);
- }
- x += xinc;
-
- // LookupOp
- // REMIND: Our LUTs are only 256 elements long, so won't
- // currently work with USHORT_GRAY data
- if (srcType != BufferedImage.TYPE_USHORT_GRAY) {
- g2d.drawImage(srcImg, lookup1bandbyte, x, y);
- x += xinc;
- if (srcCM.getNumColorComponents() == 3) {
- g2d.drawImage(srcImg, lookup3bandbyte, x, y);
- }
- x += xinc;
- if (srcCM.getNumComponents() == 4) {
- g2d.drawImage(srcImg, lookup4bandbyte, x, y);
- }
- x += xinc;
-
- // REMIND: LookupOp.createCompatibleDestImage() throws
- // IAE for 3BYTE_BGR/4BYTE_ABGR (bug to be filed)
- if (!(ignore &&
- (srcType == BufferedImage.TYPE_3BYTE_BGR ||
- srcType == BufferedImage.TYPE_4BYTE_ABGR)))
- {
- g2d.drawImage(srcImg, lookup1bandshort, x, y);
- x += xinc;
- // REMIND: 3-band LookupOp.filter() throws IAE for
- // images that contain an alpha channel
- // (bug to be filed)
- if (srcCM.getNumColorComponents() == 3 &&
- !(ignore && srcCM.hasAlpha()))
- {
- g2d.drawImage(srcImg, lookup3bandshort, x, y);
- }
- x += xinc;
- if (srcCM.getNumComponents() == 4) {
- g2d.drawImage(srcImg, lookup4bandshort, x, y);
- }
- x += xinc;
- } else {
- x += 3*xinc;
- }
- } else {
- x += 6*xinc;
- }
-
- // ConvolveOp
- // REMIND: ConvolveOp.filter() throws ImagingOpException
- // for 3BYTE_BGR (see 4957775)
- if (srcType != BufferedImage.TYPE_3BYTE_BGR) {
- g2d.drawImage(srcImg, convolve3x3zero, x, y);
- x += xinc;
- g2d.drawImage(srcImg, convolve5x5zero, x, y);
- x += xinc;
- g2d.drawImage(srcImg, convolve7x7zero, x, y);
- x += xinc;
-
- g2d.drawImage(srcImg, convolve3x3noop, x, y);
- x += xinc;
- g2d.drawImage(srcImg, convolve5x5noop, x, y);
- x += xinc;
- g2d.drawImage(srcImg, convolve7x7noop, x, y);
- x += xinc;
- } else {
- x += 6*xinc;
- }
-
- y += srcSize + 2;
- }
-
- yorig += yinc;
- }
- }
-
- private BufferedImage makeSourceImage(int size, int type) {
- int s2 = size/2;
- BufferedImage img = new BufferedImage(size, size, type);
- Graphics2D g2d = img.createGraphics();
- g2d.setComposite(AlphaComposite.Src);
- g2d.setColor(Color.orange);
- g2d.fillRect(0, 0, size, size);
- g2d.setColor(Color.red);
- g2d.fillRect(0, 0, s2, s2);
- g2d.setColor(Color.green);
- g2d.fillRect(s2, 0, s2, s2);
- g2d.setColor(Color.blue);
- g2d.fillRect(0, s2, s2, s2);
- g2d.setColor(new Color(255, 255, 0, 128));
- g2d.fillRect(s2, s2, s2, s2);
- g2d.setColor(Color.pink);
- g2d.fillOval(s2-3, s2-3, 6, 6);
- g2d.dispose();
- return img;
- }
-
- public BufferedImage makeReferenceImage() {
- BufferedImage img = new BufferedImage(TESTW, TESTH,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D g2d = img.createGraphics();
- renderTest(g2d);
- g2d.dispose();
- return img;
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(TESTW, TESTH);
- }
-
- private static void compareImages(BufferedImage refImg,
- BufferedImage testImg,
- int tolerance)
- {
- int x1 = 0;
- int y1 = 0;
- int x2 = refImg.getWidth();
- int y2 = refImg.getHeight();
-
- for (int y = y1; y < y2; y++) {
- for (int x = x1; x < x2; x++) {
- Color expected = new Color(refImg.getRGB(x, y));
- Color actual = new Color(testImg.getRGB(x, y));
- if (!isSameColor(expected, actual, tolerance)) {
- throw new RuntimeException("Test failed at x="+x+" y="+y+
- " (expected="+expected+
- " actual="+actual+
- ")");
- }
- }
- }
- }
-
- private static boolean isSameColor(Color c1, Color c2, int e) {
- int r1 = c1.getRed();
- int g1 = c1.getGreen();
- int b1 = c1.getBlue();
- int r2 = c2.getRed();
- int g2 = c2.getGreen();
- int b2 = c2.getBlue();
- int rmin = Math.max(r2-e, 0);
- int gmin = Math.max(g2-e, 0);
- int bmin = Math.max(b2-e, 0);
- int rmax = Math.min(r2+e, 255);
- int gmax = Math.min(g2+e, 255);
- int bmax = Math.min(b2+e, 255);
- if (r1 >= rmin && r1 <= rmax &&
- g1 >= gmin && g1 <= gmax &&
- b1 >= bmin && b1 <= bmax)
- {
- return true;
- }
- return false;
- }
-
- public static void main(String[] args) throws Exception {
- boolean show = false;
- boolean dump = false;
- boolean compare = false;
-
- for (String arg : args) {
- if (arg.equals("-show")) {
- show = true;
- } else if (arg.equals("-dump")) {
- dump = true;
- } else if (arg.equals("-compare")) {
- compare = true;
- } else if (arg.equals("-ignore")) {
- ignore = true;
- }
- }
-
- DrawBufImgOp test = new DrawBufImgOp();
- Frame frame = new Frame();
- frame.add(test);
- frame.pack();
- frame.setVisible(true);
-
- // Wait until the component's been painted
- synchronized (test) {
- while (!done) {
- try {
- test.wait();
- } catch (InterruptedException e) {
- throw new RuntimeException("Failed: Interrupted");
- }
- }
- }
-
- GraphicsConfiguration gc = frame.getGraphicsConfiguration();
- if (gc.getColorModel() instanceof IndexColorModel) {
- System.out.println("IndexColorModel detected: " +
- "test considered PASSED");
- frame.dispose();
- return;
- }
-
- // Grab the screen region
- BufferedImage capture = null;
- try {
- Robot robot = new Robot();
- Point pt1 = test.getLocationOnScreen();
- Rectangle rect = new Rectangle(pt1.x, pt1.y, TESTW, TESTH);
- capture = robot.createScreenCapture(rect);
- } catch (Exception e) {
- throw new RuntimeException("Problems creating Robot");
- } finally {
- if (!show) {
- frame.dispose();
- }
- }
-
- // Compare the images (allow for +/- 1 bit differences in color comps)
- if (dump || compare) {
- BufferedImage ref = test.makeReferenceImage();
- if (dump) {
- ImageIO.write(ref, "png",
- new File("DrawBufImgOp.ref.png"));
- ImageIO.write(capture, "png",
- new File("DrawBufImgOp.cap.png"));
- }
- if (compare) {
- test.compareImages(ref, capture, 1);
- }
- }
- }
-}
--- a/test/jdk/sun/java2d/OpenGL/DrawHugeImageTest.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2014, 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/*
- * @test
- * @key headful
- * @bug 8040617
- * @summary Test verifies that an attempt to get an accelerated copy of
- * a huge buffered image does not result in an OOME.
- *
- * @run main DrawHugeImageTest
- */
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.image.BufferedImage;
-import java.awt.image.VolatileImage;
-
-public class DrawHugeImageTest {
- // we have to render the BI source several times in order
- // to get an accelerated copy to be used.
- static {
- System.setProperty("sun.java2d.accthreshold", "1");
- }
- private static final int max_rendering_count = 5;
-
- private static final Color srcColor = Color.red;
- private static final Color dstColor = Color.blue;
-
- public static void main(String[] args) {
- BufferedImage src = createSrc();
-
- VolatileImage dst = createDst();
- System.out.println("Dst: " + dst);
- boolean status;
- int count = max_rendering_count;
-
- do {
- System.out.println("render image: " + (max_rendering_count - count));
- status = render(src, dst);
-
- } while (status && count-- > 0);
-
- if (!status || count > 0) {
- throw new RuntimeException("Test failed: " + count);
- }
- }
-
- private static boolean render(BufferedImage src, VolatileImage dst) {
- int cnt = 5;
- do {
- Graphics2D g = dst.createGraphics();
- g.setColor(dstColor);
- g.fillRect(0, 0, dst.getWidth(), dst.getHeight());
- g.drawImage(src, 0, 0, null);
- g.dispose();
- } while (dst.contentsLost() && (--cnt > 0));
-
- if (cnt == 0) {
- System.err.println("Test failed: unable to render to volatile destination");
- return false;
- }
-
- BufferedImage s = dst.getSnapshot();
-
- return s.getRGB(1,1) == srcColor.getRGB();
- }
-
- private static BufferedImage createSrc() {
- final int w = 20000;
- final int h = 5;
-
- BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
- Graphics2D g = img.createGraphics();
- g.setColor(srcColor);
- g.fillRect(0, 0, w, h);
- g.dispose();
-
- return img;
- }
-
- private static VolatileImage createDst() {
- GraphicsConfiguration gc =
- GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
-
- return gc.createCompatibleVolatileImage(200, 200);
- }
-}
--- a/test/jdk/sun/java2d/OpenGL/GradientPaints.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,356 +0,0 @@
-/*
- * Copyright (c) 2007, 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @key headful
- * @bug 6521533 6525997 7102282
- * @summary Verifies that the OGL-accelerated codepaths for GradientPaint,
- * LinearGradientPaint, and RadialGradientPaint produce results that are
- * sufficiently close to those produced by the software codepaths.
- * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True GradientPaints
- * @author campbelc
- */
-
-import java.awt.*;
-import java.awt.MultipleGradientPaint.ColorSpaceType;
-import java.awt.MultipleGradientPaint.CycleMethod;
-import java.awt.geom.*;
-import java.awt.image.*;
-import java.io.File;
-import java.util.Arrays;
-import javax.imageio.ImageIO;
-
-public class GradientPaints extends Canvas {
-
- private static final int TESTW = 600;
- private static final int TESTH = 500;
-
- /*
- * We expect slight differences in rendering between the OpenGL and
- * software pipelines due to algorithmic and rounding differences.
- * The purpose of this test is just to make sure that the OGL pipeline
- * is producing results that are "reasonably" consistent with those
- * produced in software, so we will allow +/-TOLERANCE differences
- * in each component. When comparing the test and reference images,
- * we add up the number of pixels that fall outside this tolerance
- * range and if the sum is larger than some percentage of the total
- * number of pixels.
- *
- * REMIND: Note that we have separate thresholds for linear and radial
- * gradients because the visible differences between OGL and software
- * are more apparent in the radial cases. In the future we should try
- * to reduce the number of mismatches between the two approaches, but
- * for now the visible differences are slight enough to not cause worry.
- */
- private static final int TOLERANCE = 5;
- private static final int ALLOWED_MISMATCHES_LINEAR =
- (int)(TESTW * TESTH * 0.18);
- private static final int ALLOWED_MISMATCHES_RADIAL =
- (int)(TESTW * TESTH * 0.45);
-
- private static boolean done;
- private static boolean verbose;
-
- private static final Color[] COLORS = {
- new Color(0, 0, 0),
- new Color(128, 128, 128),
- new Color(255, 0, 0),
- new Color(255, 255, 0),
- new Color(0, 255, 0),
- new Color(0, 255, 255),
- new Color(128, 0, 255),
- new Color(128, 128, 128),
- };
-
- private static enum PaintType {BASIC, LINEAR, RADIAL};
- private static enum XformType {IDENTITY, TRANSLATE, SCALE, SHEAR, ROTATE};
- private static final int[] numStopsArray = {2, 4, 7};
- private static final Object[] hints = {
- RenderingHints.VALUE_ANTIALIAS_OFF,
- RenderingHints.VALUE_ANTIALIAS_ON,
- };
-
- public void paint(Graphics g) {
- synchronized (this) {
- if (!done) {
- done = true;
- notifyAll();
- }
- }
- }
-
- private void testOne(BufferedImage refImg, VolatileImage testImg) {
- Graphics2D gref = refImg.createGraphics();
- Graphics2D gtest = testImg.createGraphics();
- Paint paint =
- makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
- ColorSpaceType.SRGB, XformType.IDENTITY, 7);
- Object aahint = hints[0];
- renderTest(gref, paint, aahint);
- renderTest(gtest, paint, aahint);
- Toolkit.getDefaultToolkit().sync();
- compareImages(refImg, testImg.getSnapshot(),
- TOLERANCE, 0, "");
- gref.dispose();
- gtest.dispose();
- }
-
- private void testAll(Graphics gscreen,
- BufferedImage refImg, VolatileImage testImg)
- {
- Graphics2D gref = refImg.createGraphics();
- Graphics2D gtest = testImg.createGraphics();
- for (PaintType paintType : PaintType.values()) {
- for (CycleMethod cycleMethod : CycleMethod.values()) {
- for (ColorSpaceType colorSpace : ColorSpaceType.values()) {
- for (XformType xform : XformType.values()) {
- for (Object aahint : hints) {
- for (int numStops : numStopsArray) {
- Paint paint =
- makePaint(paintType, cycleMethod,
- colorSpace, xform, numStops);
- String msg =
- "type=" + paintType +
- " cycleMethod=" + cycleMethod +
- " colorSpace=" + colorSpace +
- " xformType=" + xform +
- " numStops=" + numStops +
- " aa=" + aahint;
- renderTest(gref, paint, aahint);
- renderTest(gtest, paint, aahint);
- gscreen.drawImage(testImg, 0, 0, null);
- Toolkit.getDefaultToolkit().sync();
- int allowedMismatches =
- paintType == PaintType.RADIAL ?
- ALLOWED_MISMATCHES_RADIAL :
- ALLOWED_MISMATCHES_LINEAR;
- compareImages(refImg, testImg.getSnapshot(),
- TOLERANCE, allowedMismatches,
- msg);
- }
- }
- }
- }
- }
- }
- gref.dispose();
- gtest.dispose();
- }
-
- private Paint makePaint(PaintType paintType,
- CycleMethod cycleMethod,
- ColorSpaceType colorSpace,
- XformType xformType, int numStops)
- {
- int startX = TESTW/6;
- int startY = TESTH/6;
- int endX = TESTW/2;
- int endY = TESTH/2;
- int ctrX = TESTW/2;
- int ctrY = TESTH/2;
- int focusX = ctrX + 20;
- int focusY = ctrY + 20;
- float radius = 100.0f;
- Paint paint;
- AffineTransform transform;
-
- Color[] colors = Arrays.copyOf(COLORS, numStops);
- float[] fractions = new float[colors.length];
- for (int i = 0; i < fractions.length; i++) {
- fractions[i] = ((float)i) / (fractions.length-1);
- }
-
- switch (xformType) {
- default:
- case IDENTITY:
- transform = new AffineTransform();
- break;
- case TRANSLATE:
- transform = AffineTransform.getTranslateInstance(2, 2);
- break;
- case SCALE:
- transform = AffineTransform.getScaleInstance(1.2, 1.4);
- break;
- case SHEAR:
- transform = AffineTransform.getShearInstance(0.1, 0.1);
- break;
- case ROTATE:
- transform = AffineTransform.getRotateInstance(Math.PI / 4,
- getWidth()/2,
- getHeight()/2);
- break;
- }
-
- switch (paintType) {
- case BASIC:
- boolean cyclic = (cycleMethod != CycleMethod.NO_CYCLE);
- paint =
- new GradientPaint(startX, startY, Color.RED,
- endX, endY, Color.BLUE, cyclic);
- break;
-
- default:
- case LINEAR:
- paint =
- new LinearGradientPaint(new Point2D.Float(startX, startY),
- new Point2D.Float(endX, endY),
- fractions, colors,
- cycleMethod, colorSpace,
- transform);
- break;
-
- case RADIAL:
- paint =
- new RadialGradientPaint(new Point2D.Float(ctrX, ctrY),
- radius,
- new Point2D.Float(focusX, focusY),
- fractions, colors,
- cycleMethod, colorSpace,
- transform);
- break;
- }
-
- return paint;
- }
-
- private void renderTest(Graphics2D g2d, Paint p, Object aahint) {
- g2d.setColor(Color.white);
- g2d.fillRect(0, 0, TESTW, TESTH);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aahint);
- g2d.setPaint(p);
- g2d.fillOval(0, 0, TESTW, TESTH);
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(TESTW, TESTH);
- }
-
- private static void compareImages(BufferedImage refImg,
- BufferedImage testImg,
- int tolerance, int allowedMismatches,
- String msg)
- {
- int numMismatches = 0;
- int x1 = 0;
- int y1 = 0;
- int x2 = refImg.getWidth();
- int y2 = refImg.getHeight();
-
- for (int y = y1; y < y2; y++) {
- for (int x = x1; x < x2; x++) {
- Color expected = new Color(refImg.getRGB(x, y));
- Color actual = new Color(testImg.getRGB(x, y));
- if (!isSameColor(expected, actual, tolerance)) {
- numMismatches++;
- }
- }
- }
-
- if (verbose) {
- System.out.println(msg);
- }
- if (numMismatches > allowedMismatches) {
- try {
- ImageIO.write(refImg, "png",
- new File("GradientPaints.ref.png"));
- ImageIO.write(testImg, "png",
- new File("GradientPaints.cap.png"));
- } catch (Exception e) {
- }
- if (!verbose) {
- System.err.println(msg);
- }
- throw new RuntimeException("Test failed: Number of mismatches (" +
- numMismatches +
- ") exceeds limit (" +
- allowedMismatches +
- ") with tolerance=" +
- tolerance);
- }
- }
-
- private static boolean isSameColor(Color c1, Color c2, int e) {
- int r1 = c1.getRed();
- int g1 = c1.getGreen();
- int b1 = c1.getBlue();
- int r2 = c2.getRed();
- int g2 = c2.getGreen();
- int b2 = c2.getBlue();
- int rmin = Math.max(r2-e, 0);
- int gmin = Math.max(g2-e, 0);
- int bmin = Math.max(b2-e, 0);
- int rmax = Math.min(r2+e, 255);
- int gmax = Math.min(g2+e, 255);
- int bmax = Math.min(b2+e, 255);
- if (r1 >= rmin && r1 <= rmax &&
- g1 >= gmin && g1 <= gmax &&
- b1 >= bmin && b1 <= bmax)
- {
- return true;
- }
- return false;
- }
-
- public static void main(String[] args) {
- if (args.length == 1 && args[0].equals("-verbose")) {
- verbose = true;
- }
-
- GradientPaints test = new GradientPaints();
- Frame frame = new Frame();
- frame.add(test);
- frame.pack();
- frame.setVisible(true);
-
- // Wait until the component's been painted
- synchronized (test) {
- while (!done) {
- try {
- test.wait();
- } catch (InterruptedException e) {
- throw new RuntimeException("Failed: Interrupted");
- }
- }
- }
-
- GraphicsConfiguration gc = frame.getGraphicsConfiguration();
- if (gc.getColorModel() instanceof IndexColorModel) {
- System.out.println("IndexColorModel detected: " +
- "test considered PASSED");
- frame.dispose();
- return;
- }
-
- BufferedImage refImg =
- new BufferedImage(TESTW, TESTH, BufferedImage.TYPE_INT_RGB);
- VolatileImage testImg = frame.createVolatileImage(TESTW, TESTH);
- testImg.validate(gc);
-
- try {
- test.testAll(test.getGraphics(), refImg, testImg);
- } finally {
- frame.dispose();
- }
- }
-}
--- a/test/jdk/sun/java2d/OpenGL/bug7181438.java Fri Mar 02 09:59:02 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Transparency;
-import java.awt.image.BufferedImage;
-import java.awt.image.VolatileImage;
-
-/**
- * @test
- * @key headful
- * @bug 7181438
- * @summary Verifies that we get correct alpha, when we draw opaque
- * BufferedImage to non opaque VolatileImage via intermediate opaque texture.
- * @author Sergey Bylokhov
- * @run main/othervm -Dsun.java2d.accthreshold=0 bug7181438
- */
-public final class bug7181438 {
-
- private static final int SIZE = 500;
-
- public static void main(final String[] args) {
-
- final BufferedImage bi = createBufferedImage();
- final VolatileImage vi = createVolatileImage();
- final Graphics s2dVi = vi.getGraphics();
-
- //sw->texture->surface blit
- s2dVi.drawImage(bi, 0, 0, null);
-
- final BufferedImage results = vi.getSnapshot();
- for (int i = 0; i < SIZE; ++i) {
- for (int j = 0; j < SIZE; ++j) {
- //Image should be opaque: (black color and alpha = 255)
- if (results.getRGB(i, j) != 0xFF000000) {
- throw new RuntimeException("Failed: Wrong alpha");
- }
- }
- }
- System.out.println("Passed");
- }
-
-
- private static VolatileImage createVolatileImage() {
- final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
- return gc.createCompatibleVolatileImage(SIZE, SIZE,
- Transparency.TRANSLUCENT);
- }
-
- private static BufferedImage createBufferedImage() {
- final BufferedImage bi = new BufferedImage(SIZE, SIZE,
- BufferedImage.TYPE_INT_RGB);
- final Graphics bg = bi.getGraphics();
- //Black color and alpha = 0
- bg.setColor(new Color(0, 0, 0, 0));
- bg.fillRect(0, 0, SIZE, SIZE);
- bg.dispose();
- return bi;
- }
-}
--- a/test/jdk/sun/java2d/SunGraphics2D/DrawImageBilinear.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/SunGraphics2D/DrawImageBilinear.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -23,11 +23,10 @@
/*
* @test
* @key headful
- * @bug 5009033 6603000 6666362 8159142
+ * @bug 5009033 6603000 6666362 8159142 8198613
* @summary Verifies that images transformed with bilinear filtering do not
* leave artifacts at the edges.
* @run main/othervm -Dsun.java2d.uiScale=2.5 DrawImageBilinear
- * @run main/othervm -Dsun.java2d.uiScale=2.5 -Dsun.java2d.opengl=True DrawImageBilinear
* @run main/othervm -Dsun.java2d.uiScale=2.5 -Dsun.java2d.d3d=false DrawImageBilinear
* @author campbelc
*/
--- a/test/jdk/sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -48,14 +48,13 @@
/**
* @test
* @key headful
- * @bug 6335200 6419610
+ * @bug 6335200 6419610 8198613
* @summary Tests that we don't render anything if specific empty clip is set
* @author Dmitri.Trembovetski@Sun.COM: area=Graphics
* @modules java.desktop/sun.awt
* @run main EmptyClipRenderingTest
* @run main/othervm -Dsun.java2d.noddraw=true EmptyClipRenderingTest
* @run main/othervm -Dsun.java2d.pmoffscreen=true EmptyClipRenderingTest
- * @run main/othervm -Dsun.java2d.opengl=true EmptyClipRenderingTest
*/
public class EmptyClipRenderingTest {
static final int IMG_W = 400;
--- a/test/jdk/sun/java2d/SunGraphics2D/PolyVertTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/SunGraphics2D/PolyVertTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, 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
@@ -24,11 +24,10 @@
/*
* @test
* @key headful
- * @bug 4678208 4771101 6328481 6588884
+ * @bug 4678208 4771101 6328481 6588884 8198613
* @summary verify the pixelization of degenerate polylines and polygons
* @run main PolyVertTest
* @run main/othervm -Dsun.java2d.d3d=True PolyVertTest -hwonly
- * @run main/othervm -Dsun.java2d.opengl=True PolyVertTest -hwonly
*/
import java.awt.*;
--- a/test/jdk/sun/java2d/SunGraphics2D/SimplePrimQuality.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/SunGraphics2D/SimplePrimQuality.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -24,7 +24,7 @@
/*
* @test
* @key headful
- * @bug 4832224 6322584 6328478 6328481 6322580 6588884 6587863
+ * @bug 4832224 6322584 6328478 6328481 6322580 6588884 6587863 8198613
* @summary Verifies that the pixelization of simple primitives (drawLine,
* fillRect, drawRect, fill, draw) with the OGL pipeline enabled
* matches that produced by our software loops. (The primitives tested here
@@ -34,7 +34,6 @@
* more appropriate for quick OGL testing. This test is also useful for
* comparing quality between our X11/GDI and software pipelines.
* @run main/othervm SimplePrimQuality
- * @run main/othervm -Dsun.java2d.opengl=True SimplePrimQuality
* @author campbelc
*/
--- a/test/jdk/sun/java2d/pipe/InterpolationQualityTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/pipe/InterpolationQualityTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -24,16 +24,16 @@
/*
* @test
* @key headful
- * @bug 7188093 8000176
+ * @bug 7188093 8000176 8198613
* @summary Tests each of the 3 possible methods for rendering an upscaled
* image via rendering hints for default, xrender and opengl pipelines.
*
* @author Vadim.Pakhnushev@oracle.com
* @run main/othervm -Dsun.java2d.xrender=false InterpolationQualityTest
* @run main/othervm -Dsun.java2d.xrender=True InterpolationQualityTest
- * @run main/othervm -Dsun.java2d.opengl=True InterpolationQualityTest
* @run main/othervm -Dsun.java2d.d3d=false InterpolationQualityTest
* @run main/othervm -Dsun.java2d.d3d=True InterpolationQualityTest
+ * @run main/othervm InterpolationQualityTest
*/
import java.awt.*;
--- a/test/jdk/sun/java2d/pipe/MutableColorTest/MutableColorTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/pipe/MutableColorTest/MutableColorTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,13 +24,12 @@
/**
* @test
* @key headful
- * @bug 6613860 6691934
+ * @bug 6613860 6691934 8198613
* @summary Tests that the pipelines can handle (in somewhat limited
* manner) mutable Colors
*
* @run main/othervm MutableColorTest
* @run main/othervm -Dsun.java2d.noddraw=true MutableColorTest
- * @run main/othervm -Dsun.java2d.opengl=True MutableColorTest
*/
import java.awt.Color;
--- a/test/jdk/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -23,7 +23,7 @@
/*
* @test
* @key headful
- * @bug 6635805 6653780 6667607
+ * @bug 6635805 6653780 6667607 8198613
* @summary Tests that the resource sharing layer API is not broken
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @modules java.desktop/sun.java2d
@@ -32,7 +32,6 @@
* @compile -XDignore.symbol.file=true RSLAPITest.java
* @run main/othervm RSLAPITest
* @run main/othervm -Dsun.java2d.noddraw=true RSLAPITest
- * @run main/othervm -Dsun.java2d.opengl=True RSLAPITest
*/
import java.awt.Graphics;
--- a/test/jdk/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -24,7 +24,7 @@
/*
* @test
* @key headful
- * @bug 6764257
+ * @bug 6764257 8198613
* @summary Tests that the color is reset properly after save/restore context
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @modules java.desktop/sun.java2d
@@ -33,7 +33,6 @@
* @compile -XDignore.symbol.file=true RSLContextInvalidationTest.java
* @run main/othervm RSLContextInvalidationTest
* @run main/othervm -Dsun.java2d.noddraw=true RSLContextInvalidationTest
- * @run main/othervm -Dsun.java2d.opengl=True RSLContextInvalidationTest
*/
import java.awt.Color;
--- a/test/jdk/sun/java2d/pipe/hw/VSyncedBufferStrategyTest/VSyncedBufferStrategyTest.java Fri Mar 02 09:59:02 2018 +0530
+++ b/test/jdk/sun/java2d/pipe/hw/VSyncedBufferStrategyTest/VSyncedBufferStrategyTest.java Fri Mar 02 14:39:29 2018 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -22,13 +22,12 @@
*/
/*
* @test
- * @bug 6678218 6681745 6691737
+ * @bug 6678218 6681745 6691737 8198613
* @summary Tests that v-synced BufferStrategies works (if vsync is supported)
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @modules java.desktop/sun.java2d.pipe.hw
* @compile -XDignore.symbol.file=true VSyncedBufferStrategyTest.java
* @run main/manual/othervm VSyncedBufferStrategyTest
- * @run main/manual/othervm -Dsun.java2d.opengl=True VSyncedBufferStrategyTest
*/
import java.awt.AWTException;