JRE-457 OGLTR_DisableGlyphModeState is slow
Added support for OSX low res modes in the rendering test. Minor refactoring
diff --git a/test/jbu/quality/util/RenderUtil.java b/test/jbu/quality/util/RenderUtil.java
index 2c8949a..b78c2da 100644
--- a/test/jbu/quality/util/RenderUtil.java
+++ b/test/jbu/quality/util/RenderUtil.java
@@ -23,6 +23,8 @@
import quality.util.osx.ID;
import quality.util.osx.MacUtil;
+import javax.imageio.ImageIO;
+import javax.swing.*;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
@@ -32,8 +34,6 @@
import java.io.File;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
-import javax.imageio.ImageIO;
-import javax.swing.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -49,11 +49,17 @@
int windowListOptions = cgWindowId != null
? FoundationLibrary.kCGWindowListOptionIncludingWindow
: FoundationLibrary.kCGWindowListOptionAll;
- int windowImageOptions = FoundationLibrary.kCGWindowImageBestResolution | FoundationLibrary.kCGWindowImageShouldBeOpaque;
- ID cgImageRef = Foundation.cgWindowListCreateImage(nsRect, windowListOptions, cgWindowId, windowImageOptions);
+ int windowImageOptions = FoundationLibrary.kCGWindowImageBestResolution |
+ FoundationLibrary.kCGWindowImageShouldBeOpaque;
+ ID cgImageRef = Foundation.cgWindowListCreateImage(
+ nsRect, windowListOptions, cgWindowId, windowImageOptions);
- ID bitmapRep = Foundation.invoke(Foundation.invoke("NSBitmapImageRep", "alloc"), "initWithCGImage:", cgImageRef);
- ID nsImage = Foundation.invoke(Foundation.invoke("NSImage", "alloc"), "init");
+ ID bitmapRep = Foundation.invoke(
+ Foundation.invoke("NSBitmapImageRep", "alloc"),
+ "initWithCGImage:", cgImageRef);
+ ID nsImage = Foundation.invoke(
+ Foundation.invoke("NSImage", "alloc"),
+ "init");
Foundation.invoke(nsImage, "addRepresentation:", bitmapRep);
ID data = Foundation.invoke(nsImage, "TIFFRepresentation");
ID bytes = Foundation.invoke(data, "bytes");
@@ -80,7 +86,9 @@
}
}
- public static BufferedImage capture(int width, int height, Consumer<Graphics2D> painter) throws Exception {
+ public static BufferedImage capture(int width, int height, Consumer<Graphics2D> painter)
+ throws Exception
+ {
JFrame[] f = new JFrame[1];
Point[] p = new Point[1];
SwingUtilities.invokeAndWait(() -> {
@@ -90,31 +98,25 @@
f[0].add(c);
c.setSize(width + 10, height + 10);
- f[0].setSize(width + 100, height + 100); // giving some space for frame border effects, e.g. rounded frame
+ f[0].setSize(width + 100, height + 100); // giving some space
+ // for frame border effects,
+ // e.g. rounded frame
c.setLocation(50, 50);
f[0].setVisible(true);
p[0]= c.getLocationOnScreen();
});
Rectangle screenRect;
-
- if (SystemUtils.IS_OS_MAC) {
- Robot r = new Robot();
- while (f[0] == null || !Color.black.equals(r.getPixelColor(p[0].x, p[0].y))) {
- Thread.sleep(100);
- }
- screenRect = new Rectangle(p[0].x + 5, p[0].y + 5, width, height);
-
- return captureScreen(f[0], screenRect);
- } else {
- Robot r = new Robot();
- while (!Color.black.equals(r.getPixelColor(p[0].x, p[0].y))) {
- Thread.sleep(100);
- }
- screenRect = new Rectangle(p[0].x + 5, p[0].y + 5, width, height);
-
- return r.createScreenCapture(screenRect);
+ Robot r = new Robot();
+ while (!Color.black.equals(r.getPixelColor(p[0].x, p[0].y))) {
+ Thread.sleep(100);
}
+ screenRect = new Rectangle(p[0].x + 5, p[0].y + 5, width, height);
+
+ BufferedImage result = SystemUtils.IS_OS_MAC ?
+ captureScreen(f[0], screenRect) : r.createScreenCapture(screenRect);
+ SwingUtilities.invokeAndWait(f[0]::dispose);
+ return result;
}
private static class MyComponent extends JComponent {
@@ -142,7 +144,8 @@
public static void checkImage(BufferedImage image, String path, String gfName) throws Exception {
String[] testDataVariant = {
- "osx_hardware_rendering", "osx_software_rendering", "osx_sierra_rendering",
+ "osx_hardware_rendering", "osx_software_rendering",
+ "osx_sierra_rendering", "osx_lowres_rendering",
"linux_rendering"};
String testDataStr = System.getProperty("testdata");
diff --git a/test/jbu/testdata/quality/text/osx_lowres_rendering/lcdgray.png b/test/jbu/testdata/quality/text/osx_lowres_rendering/lcdgray.png
new file mode 100644
index 0000000..b1ae47d
--- /dev/null
+++ b/test/jbu/testdata/quality/text/osx_lowres_rendering/lcdgray.png
Binary files differ