Update baseline image with new text renderer

This commit is contained in:
Martin Pernollet 2022-04-29 15:53:16 +02:00
parent 9d992d8398
commit d5311e6633
21 changed files with 276 additions and 123 deletions

View File

@ -588,7 +588,7 @@ public class EmulGLCanvas extends GLCanvas implements IScreenCanvas, IMonitorabl
@Override
public String getDebugInfo() {
return null;
return "EmulGL (CPU rendering)";
}

View File

@ -23,8 +23,7 @@ public class ITTestEmulGLDisk {
// Then
ChartTester tester = new ChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}
}

View File

@ -27,8 +27,7 @@ public class ITTestEmulGLScatterChart {
// Then
ChartTester tester = new ChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}
private static Scatter scatter() {

View File

@ -33,8 +33,7 @@ public class ITTestEmulGLSurfaceChart {
// Then
ChartTester tester = new ChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}

View File

@ -9,14 +9,13 @@ import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.jzy3d.awt.AWTHelper;
import org.jzy3d.chart.IAnimator;
import org.jzy3d.chart.factories.IChartFactory;
import org.jzy3d.chart.factories.NativePainterFactory;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.painters.IPainter;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.Renderer3d;
import org.jzy3d.plot3d.rendering.view.View;
@ -203,30 +202,10 @@ public class CanvasAWT extends GLCanvas implements IScreenCanvas, INativeCanvas
GLCapabilitiesImmutable caps = getChosenGLCapabilities();
GL gl = (GL) painter.acquireGL();
StringBuffer sb = new StringBuffer();
sb.append("Capabilities : " + caps + "\n");
sb.append("GL_VENDOR : " + gl.glGetString(GL.GL_VENDOR) + "\n");
sb.append("GL_RENDERER : " + gl.glGetString(GL.GL_RENDERER) + "\n");
sb.append("GL_VERSION : " + gl.glGetString(GL.GL_VERSION) + "\n");
String ext = gl.glGetString(GL.GL_EXTENSIONS);
if(ext!=null) {
sb.append("GL_EXTENSIONS : " + "\n");
for(String e: ext.split(" ")) {
sb.append("\t" + e + "\n");
}
}
else {
sb.append("GL_EXTENSIONS : null\n");
}
// sb.append("INIT GL IS: " + gl.getClass().getName() + "\n");
GPUInfo info = GPUInfo.load(gl);
painter.releaseGL();
return sb.toString();
return "Capabilities : " + caps + "\n" + info.toString();
}
@Override

View File

@ -2,6 +2,7 @@ package jogl;
import org.junit.Test;
import org.jzy3d.os.OperatingSystem;
import org.jzy3d.plot3d.GPUInfo;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
@ -76,7 +77,7 @@ public class Test_OpenGLVersion {
System.out.println("CAPS (found) : " + drawable.getChosenGLCapabilities());
System.out.println("--------------------------------------------------");
System.out.println(getDebugInfo(gl));
System.out.println(GPUInfo.load(gl));
System.out.println("--------------------------------------------------");
System.out.println(drawable.getContext());

View File

@ -0,0 +1,114 @@
package org.jzy3d.plot3d;
import java.util.ArrayList;
import java.util.List;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLDrawableFactory;
import com.jogamp.opengl.GLProfile;
public class GPUInfo {
protected String vendor;
protected String renderer;
protected String version;
protected List<String> extensions = new ArrayList<>();
public static void main(String[] args) {
GPUInfo gpu = GPUInfo.load();
System.out.println("GPU : " + gpu.renderer + "\n");
}
/** Initialize a GL context offscreen to query GPU information */
public static GPUInfo load() {
GLProfile glp = GLProfile.getMaxProgrammable(true);
GLCapabilities caps = new GLCapabilities(glp);
caps.setOnscreen(false);
GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
GLAutoDrawable drawable =
factory.createOffscreenAutoDrawable(factory.getDefaultDevice(), caps, null, 1, 1);
drawable.display();
drawable.getContext().makeCurrent();
GL gl = drawable.getContext().getGL();
//System.out.println(drawable.getContext().getGLVendorVersionNumber());
GPUInfo gpu = load(gl);
drawable.getContext().release();
return gpu;
}
/** Use an existing GL context to query GPU information */
public static GPUInfo load(GL gl) {
// Load Info
GPUInfo gpu = new GPUInfo();
gpu.vendor = gl.glGetString(GL.GL_VENDOR);
gpu.renderer = gl.glGetString(GL.GL_RENDERER);
gpu.version = gl.glGetString(GL.GL_VERSION);
String ext = gl.glGetString(GL.GL_EXTENSIONS);
if(ext!=null) {
for(String e: ext.split(" ")) {
gpu.extensions.add(e);
}
}
return gpu;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("GL_VENDOR : " + vendor + "\n");
sb.append("GL_RENDERER : " + renderer + "\n");
sb.append("GL_VERSION : " + version + "\n");
if(extensions!=null) {
sb.append("GL_EXTENSIONS : (" + extensions.size() + ")\n");
for(String e: extensions) {
sb.append("\t" + e + "\n");
}
}
else {
sb.append("GL_EXTENSIONS : null\n");
}
return sb.toString();
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getRenderer() {
return renderer;
}
public void setRenderer(String renderer) {
this.renderer = renderer;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public List<String> getExtensions() {
return extensions;
}
public void setExtensions(List<String> extensions) {
this.extensions = extensions;
}
}

View File

@ -8,13 +8,16 @@ import org.apache.logging.log4j.LogManager;
import org.jzy3d.chart.factories.IChartFactory;
import org.jzy3d.chart.factories.NativePainterFactory;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.painters.IPainter;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.pipelines.NotImplementedException;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.Renderer3d;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLCapabilitiesImmutable;
import com.jogamp.opengl.GLDrawableFactory;
import com.jogamp.opengl.GLFBODrawable;
import com.jogamp.opengl.GLOffscreenAutoDrawable;
@ -184,16 +187,18 @@ public class OffscreenCanvas implements ICanvas, INativeCanvas {
@Override
public String getDebugInfo() {
GL gl = ((NativeDesktopPainter) getView().getPainter()).getCurrentGL(this);
IPainter painter = getView().getPainter();
StringBuffer sb = new StringBuffer();
sb.append("Chosen GLCapabilities: " + offscreenDrawable.getChosenGLCapabilities() + "\n");
sb.append("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR) + "\n");
sb.append("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER) + "\n");
sb.append("GL_VERSION: " + gl.glGetString(GL.GL_VERSION) + "\n");
return sb.toString();
GLCapabilitiesImmutable caps = offscreenDrawable.getChosenGLCapabilities();
GL gl = (GL) painter.acquireGL();
GPUInfo info = GPUInfo.load(gl);
painter.releaseGL();
return "Capabilities : " + caps + "\n" + info.toString();
}
@Override
public void addMouseController(Object o) {}

View File

@ -17,7 +17,9 @@ import org.jzy3d.chart.NativeAnimator;
import org.jzy3d.chart.factories.IChartFactory;
import org.jzy3d.chart.factories.NativePainterFactory;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.painters.IPainter;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.Renderer3d;
import org.jzy3d.plot3d.rendering.view.View;
@ -222,15 +224,15 @@ public class CanvasNewtAwt extends Panel implements IScreenCanvas, INativeCanvas
@Override
public String getDebugInfo() {
GL gl = ((NativeDesktopPainter) getView().getPainter()).getCurrentGL(this);
IPainter painter = getView().getPainter();
StringBuffer sb = new StringBuffer();
sb.append("Chosen GLCapabilities: " + window.getChosenGLCapabilities() + "\n");
sb.append("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR) + "\n");
sb.append("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER) + "\n");
sb.append("GL_VERSION: " + gl.glGetString(GL.GL_VERSION) + "\n");
// sb.append("INIT GL IS: " + gl.getClass().getName() + "\n");
return sb.toString();
GLCapabilitiesImmutable caps = window.getChosenGLCapabilities();
GL gl = (GL) painter.acquireGL();
GPUInfo info = GPUInfo.load(gl);
painter.releaseGL();
return "Capabilities : " + caps + "\n" + info.toString();
}
/**

View File

@ -16,7 +16,9 @@ import org.jzy3d.chart.IAnimator;
import org.jzy3d.chart.factories.IChartFactory;
import org.jzy3d.chart.factories.NativePainterFactory;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.painters.IPainter;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.Renderer3d;
import org.jzy3d.plot3d.rendering.view.View;
@ -249,15 +251,15 @@ public class CanvasSwing extends GLJPanel implements IScreenCanvas, INativeCanva
@Override
public String getDebugInfo() {
GL gl = ((NativeDesktopPainter) getView().getPainter()).getCurrentGL(this);
IPainter painter = getView().getPainter();
StringBuffer sb = new StringBuffer();
sb.append("Chosen GLCapabilities: " + getChosenGLCapabilities() + "\n");
sb.append("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR) + "\n");
sb.append("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER) + "\n");
sb.append("GL_VERSION: " + gl.glGetString(GL.GL_VERSION) + "\n");
// sb.append("INIT GL IS: " + gl.getClass().getName() + "\n");
return sb.toString();
GLCapabilitiesImmutable caps = getChosenGLCapabilities();
GL gl = (GL) painter.acquireGL();
GPUInfo info = GPUInfo.load(gl);
painter.releaseGL();
return "Capabilities : " + caps + "\n" + info.toString();
}
@Override

View File

@ -13,7 +13,9 @@ import org.eclipse.swt.widgets.Composite;
import org.jzy3d.awt.AWTHelper;
import org.jzy3d.chart.IAnimator;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.painters.IPainter;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.rendering.canvas.ICanvasListener;
import org.jzy3d.plot3d.rendering.canvas.INativeCanvas;
import org.jzy3d.plot3d.rendering.canvas.IScreenCanvas;
@ -204,14 +206,15 @@ public class CanvasNewtSWT extends Composite implements IScreenCanvas, INativeCa
@Override
public String getDebugInfo() {
GL gl = ((NativeDesktopPainter) getView().getPainter()).getCurrentGL(this);
IPainter painter = getView().getPainter();
StringBuilder sb = new StringBuilder();
sb.append("Chosen GLCapabilities: " + window.getChosenGLCapabilities() + "\n");
sb.append("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR) + "\n");
sb.append("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER) + "\n");
sb.append("GL_VERSION: " + gl.glGetString(GL.GL_VERSION) + "\n");
return sb.toString();
GLCapabilitiesImmutable caps = window.getChosenGLCapabilities();
GL gl = (GL) painter.acquireGL();
GPUInfo info = GPUInfo.load(gl);
painter.releaseGL();
return "Capabilities : " + caps + "\n" + info.toString();
}
/**

View File

@ -8,7 +8,9 @@ import org.jzy3d.chart.AWTNativeChart;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.mouse.camera.AWTCameraMouseController;
import org.jzy3d.chart.factories.AWTChartFactory;
import org.jzy3d.os.OperatingSystem;
import org.jzy3d.painters.NativeDesktopPainter;
import org.jzy3d.plot3d.GPUInfo;
import org.jzy3d.plot3d.primitives.Drawable;
import org.jzy3d.plot3d.rendering.canvas.INativeCanvas;
import org.jzy3d.plot3d.rendering.canvas.Quality;
@ -21,6 +23,7 @@ import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
public class NativeChartTester extends ChartTester {
protected BufferedImage getBufferedImage(Chart chart) throws IOException {
if (classicScreenshotGen) {
// This screenshot generation is working well

View File

@ -0,0 +1,11 @@
package org.jzy3d.junit;
import org.jzy3d.plot3d.GPUInfo;
public class NativePlatform extends Platform{
protected GPUInfo info = GPUInfo.load();
public NativePlatform() {
gpuName = info.getRenderer().replace(" ", "");
}
}

View File

@ -32,13 +32,29 @@ public class ChartTester {
protected String testCaseOutputFolder = ERROR_IMAGE_FOLDER_DEFAULT;
protected String testCaseInputFolder = EXPECTED_IMAGE_FOLDER;
public static final String EXPECTED_IMAGE_FOLDER = "src/test/resources/";
private static final String EXPECTED_IMAGE_FOLDER = "src/test/resources/";
public static final String ERROR_IMAGE_FOLDER_DEFAULT = "target/";
// int bufImgType = BufferedImage.TYPE_3BYTE_BGR;// );
protected int WIDTH = 800;
protected int HEIGHT = 600;
public String path(Object obj) {
return path(obj.getClass());
}
public String path(Class<?> clazz) {
return path(clazz.getSimpleName());
}
public String path(String filename) {
if (!filename.contains("."))
return ChartTester.EXPECTED_IMAGE_FOLDER + filename + ".png";
else
return ChartTester.EXPECTED_IMAGE_FOLDER + filename;
}
public boolean isTextInvisible() {
return textInvisible;
}
@ -320,7 +336,8 @@ public class ChartTester {
}
} else {
String m = "image size differ: actual={" + i1W + "," + i1H + "} expected={" + i2W + "," + i2H + "}";
String m =
"image size differ: actual={" + i1W + "," + i1H + "} expected={" + i2W + "," + i2H + "}";
throw new ChartTestFailed(m, actual, expected);
}
}

View File

@ -0,0 +1,21 @@
package org.jzy3d.junit;
import org.jzy3d.os.OperatingSystem;
public class Platform {
protected OperatingSystem os = new OperatingSystem();
protected String gpuName = "unknownGPU";
public String getLabel() {
String osName = clean(os.getName());
String osVer = clean(os.getVersion());
return osName + "_" + osVer + "_" + gpuName;
}
protected String clean(String s) {
return s.toLowerCase().replace(" ", "");
}
}

View File

@ -250,17 +250,14 @@ public class ITTest {
chart.render();
}
// EMULGL
if(chart.getFactory() instanceof EmulGLChartFactory) {
// Verify
ChartTester tester = new ChartTester();
tester.assertSimilar(chart, ChartTester.EXPECTED_IMAGE_FOLDER + name + ".png");
}
// NATIVE
else {
NativeChartTester tester = new NativeChartTester();
tester.assertSimilar(chart, ChartTester.EXPECTED_IMAGE_FOLDER + name + ".png");
if(!(chart.getFactory() instanceof EmulGLChartFactory)) {
tester = new NativeChartTester();
}
tester.assertSimilar(chart, tester.path(name));
}
// ---------------------------------------------------------------------------------------------- //

View File

@ -5,7 +5,6 @@ import org.junit.Test;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.factories.AWTChartFactory;
import org.jzy3d.colors.Color;
import org.jzy3d.junit.ChartTester;
import org.jzy3d.junit.NativeChartTester;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.primitives.Scatter;
@ -24,8 +23,7 @@ public class ITTestNativeScatterChart {
// Then
NativeChartTester tester = new NativeChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}
private static Scatter scatter() {

View File

@ -47,8 +47,7 @@ public class ITTestNativeSurfaceChart {
// Then
ChartTester tester = new NativeChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}

View File

@ -49,8 +49,7 @@ public class ITTestNativeSurfaceChart_Swing {
// Then
ChartTester tester = new NativeChartTester();
tester.assertSimilar(chart,
ChartTester.EXPECTED_IMAGE_FOLDER + this.getClass().getSimpleName() + ".png");
tester.assertSimilar(chart, tester.path(this));
}
@ -62,7 +61,8 @@ public class ITTestNativeSurfaceChart_Swing {
// Create the object to represent the function over the given range.
final Shape surface = new SurfaceBuilder().orthonormal(new OrthonormalGrid(range, steps), func);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface, new Color(1, 1, 1, .5f)));
surface
.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface, new Color(1, 1, 1, .5f)));
surface.setFaceDisplayed(true);
surface.setWireframeDisplayed(true);
return surface;

14
pom.xml
View File

@ -1,6 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzy3d</groupId>
@ -61,12 +59,11 @@
<module>jzy3d-native-jogl-swing</module>
<module>jzy3d-native-jogl-swt</module>
<!-- <module>jzy3d-native-jogl-newt</module> -->
<module>jzy3d-native-jogl-newt</module>
<!-- <module>jzy3d-native-jogl-javafx</module> -->
<module>jzy3d-tester</module>
<module>jzy3d-tester-native</module>
@ -225,6 +222,13 @@
<version>${version.swt}</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt.gtk.linux.aarch64</artifactId>
<optional>true</optional>
<version>${version.swt}</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>