aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/scripts/tests.sh4
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java27
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java29
-rw-r--r--src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java21
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java30
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java31
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java42
15 files changed, 187 insertions, 107 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 84f487c38..a302666f7 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -299,7 +299,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
-testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $*
@@ -333,7 +333,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA
#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $*
#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $*
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 20dd802fb..b9576b8d6 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -723,18 +723,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
private volatile boolean printActive = false;
- private int printNumSamples = 0;
private GLAnimatorControl printAnimator = null;
private GLAutoDrawable printGLAD = null;
private AWTTilePainter printAWTTiles = null;
@Override
- public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) {
+ public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) {
printActive = true;
- printNumSamples = numSamples;
final int componentCount = isOpaque() ? 3 : 4;
final TileRenderer printRenderer = new TileRenderer();
- printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG);
+ printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG);
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT);
}
private final Runnable setupPrintOnEDT = new Runnable() {
@@ -760,10 +758,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAnimator.remove(GLCanvas.this);
}
final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable();
- final int reqNumSamples = printNumSamples;
- printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps);
+ final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
+ final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() ||
+ printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight();
+ final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ;
if( DEBUG ) {
- System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+
+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
if( caps.getSampleBuffers() ) {
// Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
@@ -776,10 +782,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
caps.setNumSamples(printNumSamples);
}
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null);
+ printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE,
+ null);
GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
}
- final GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
printAWTTiles.setIsGLOriented(printGLAD.isGLOriented());
printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0);
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 673f22aff..1ec0ad7bc 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -510,18 +510,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
private volatile boolean printActive = false;
- private int printNumSamples = 0;
private GLAnimatorControl printAnimator = null;
private GLAutoDrawable printGLAD = null;
private AWTTilePainter printAWTTiles = null;
@Override
- public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) {
+ public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) {
printActive = true;
- printNumSamples = numSamples;
final int componentCount = isOpaque() ? 3 : 4;
final TileRenderer printRenderer = new TileRenderer();
- printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG);
+ printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG);
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT);
}
private final Runnable setupPrintOnEDT = new Runnable() {
@@ -553,21 +551,32 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
printGLAD = GLJPanel.this; // default: re-use
final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable();
- final int reqNumSamples = printNumSamples;
- printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps);
+ final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
+ final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() ||
+ printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight();
+ final boolean reqNewGLAD = reqNewGLADSamples || reqNewGLADSize ;
if( DEBUG ) {
- System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+
+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
- if( printNumSamples != caps.getNumSamples() ) {
+ if( reqNewGLAD ) {
caps.setDoubleBuffered(false);
caps.setOnscreen(false);
caps.setSampleBuffers(0 < printNumSamples);
caps.setNumSamples(printNumSamples);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null);
+ printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE,
+ null);
GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
}
- final GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
printAWTTiles.setIsGLOriented(printGLAD.isGLOriented());
printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0);
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
index 0600d99f5..9bdceff48 100644
--- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
+++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java
@@ -71,6 +71,7 @@ public class AWTTilePainter {
public final TileRenderer renderer;
public final int componentCount;
public final double scaleMatX, scaleMatY;
+ public final int customTileWidth, customTileHeight, customNumSamples;
public final boolean verbose;
public boolean flipVertical;
@@ -99,18 +100,16 @@ public class AWTTilePainter {
}
/**
- * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
- * @param caps used capabilties
- * @return resulting number of samples, 0 if disabled
+ * @return resulting number of samples by comparing w/ {@link #customNumSamples} and the caps-config, 0 if disabled
*/
- public static int getNumSamples(int numSamples, GLCapabilitiesImmutable caps) {
- if( 0 > numSamples ) {
+ public int getNumSamples(GLCapabilitiesImmutable caps) {
+ if( 0 > customNumSamples ) {
return 0;
- } else if( 0 < numSamples ) {
+ } else if( 0 < customNumSamples ) {
if ( !caps.getGLProfile().isGL2ES3() ) {
return 0;
}
- return Math.max(caps.getNumSamples(), numSamples);
+ return Math.max(caps.getNumSamples(), customNumSamples);
} else {
return caps.getNumSamples();
}
@@ -130,14 +129,20 @@ public class AWTTilePainter {
* @param componentCount
* @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels
* @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels
+ * @param numSamples custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
* @param verbose
*/
- public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, boolean verbose) {
+ public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight, boolean verbose) {
this.renderer = renderer;
this.renderer.setGLEventListener(preTileGLEL, postTileGLEL);
this.componentCount = componentCount;
this.scaleMatX = scaleMatX;
this.scaleMatY = scaleMatY;
+ this.customNumSamples = numSamples;
+ this.customTileWidth= tileWidth;
+ this.customTileHeight = tileHeight;
this.verbose = verbose;
this.flipVertical = true;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
index 65e5ab3f0..e5290aee1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
@@ -47,9 +47,9 @@ import jogamp.nativewindow.awt.AWTMisc;
* <p>
* Users attempting to print an AWT {@link Container} containing {@link AWTPrintLifecycle} elements
* shall consider decorating the {@link Container#printAll(Graphics)} call with<br>
- * {@link #setupPrint(double, double, int) setupPrint(..)} and {@link #releasePrint()}
+ * {@link #setupPrint(double, double, int, int, int) setupPrint(..)} and {@link #releasePrint()}
* on all {@link AWTPrintLifecycle} elements in the {@link Container}.<br>
- * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int) Context.setupPrint(..)}:
+ * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int, int, int) Context.setupPrint(..)}:
* <pre>
* Container cont;
* double scaleGLMatXY = 72.0/glDPI;
@@ -75,7 +75,7 @@ import jogamp.nativewindow.awt.AWTMisc;
*/
public interface AWTPrintLifecycle {
- public static final int DEFAULT_PRINT_TILE_SIZE = 512;
+ public static final int DEFAULT_PRINT_TILE_SIZE = 1024;
/**
@@ -86,8 +86,10 @@ public interface AWTPrintLifecycle {
* @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels
* @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
*/
- void setupPrint(double scaleMatX, double scaleMatY, int numSamples);
+ void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight);
/**
* Shall be called after {@link PrinterJob#print()}.
@@ -98,7 +100,7 @@ public interface AWTPrintLifecycle {
void releasePrint();
/**
- * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)}
+ * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)}
* and {@link AWTPrintLifecycle#releasePrint()} on all {@link AWTPrintLifecycle} elements of a {@link Container}.
* <p>
* See <a href="#usage">Usage</a>.
@@ -110,14 +112,16 @@ public interface AWTPrintLifecycle {
* See <a href="#usage">Usage</a>.
* </p>
*
- * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements.
+ * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements.
* @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels
* @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
* @return the context
*/
- public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples) {
- final Context t = new Context(c, scaleMatX, scaleMatY, numSamples);
+ public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) {
+ final Context t = new Context(c, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight);
t.setupPrint(c);
return t;
}
@@ -132,7 +136,7 @@ public interface AWTPrintLifecycle {
}
/**
- * @return count of performed actions of last {@link #setupPrint(Container, double, double, int) setupPrint(..)} or {@link #releasePrint()}.
+ * @return count of performed actions of last {@link #setupPrint(Container, double, double, int, int, int) setupPrint(..)} or {@link #releasePrint()}.
*/
public int getCount() { return count; }
@@ -140,12 +144,14 @@ public interface AWTPrintLifecycle {
private final double scaleMatX;
private final double scaleMatY;
private final int numSamples;
+ private final int tileWidth;
+ private final int tileHeight;
private int count;
private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() {
@Override
public void run(Component c) {
- ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples);
+ ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight);
} };
private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() {
@Override
@@ -153,11 +159,13 @@ public interface AWTPrintLifecycle {
((AWTPrintLifecycle)c).releasePrint();
} };
- private Context(Container c, double scaleMatX, double scaleMatY, int numSamples) {
+ private Context(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) {
this.cont = c;
this.scaleMatX = scaleMatX;
this.scaleMatY = scaleMatY;
this.numSamples = numSamples;
+ this.tileWidth = tileWidth;
+ this.tileHeight = tileHeight;
this.count = 0;
}
private void setupPrint(Container c) {
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 73b3bc368..767533d40 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -471,7 +471,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
private volatile boolean printActive = false;
- private int printNumSamples = 0;
private GLAnimatorControl printAnimator = null;
private GLAutoDrawable printGLAD = null;
private AWTTilePainter printAWTTiles = null;
@@ -484,12 +483,11 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
@Override
- public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) {
+ public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) {
printActive = true;
- printNumSamples = numSamples;
final int componentCount = isOpaque() ? 3 : 4;
final TileRenderer printRenderer = new TileRenderer();
- printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG);
+ printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG);
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT);
}
private final Runnable setupPrintOnEDT = new Runnable() {
@@ -522,10 +520,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
printAnimator.remove(glad);
}
final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable();
- final int reqNumSamples = printNumSamples;
- printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps);
+ final int printNumSamples = printAWTTiles.getNumSamples(caps);
+ GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
+ final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples();
+ final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() ||
+ printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight();
+ final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ;
if( DEBUG ) {
- System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+
+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+
+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
}
if( caps.getSampleBuffers() ) {
// Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
@@ -538,10 +544,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
caps.setNumSamples(printNumSamples);
}
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null);
+ printGLAD = factory.createOffscreenAutoDrawable(null, caps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE,
+ null);
GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
}
- final GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
printAWTTiles.setIsGLOriented(printGLAD.isGLOriented());
printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0);
printAWTTiles.renderer.attachAutoDrawable(printGLAD);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java
index bd526419c..78fdde3ee 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java
@@ -45,6 +45,7 @@ import javax.imageio.ImageIO;
import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.nativewindow.awt.DirectDataBufferInt;
+import com.jogamp.opengl.util.TileRenderer;
/**
* {@link Printable} implementation using NIO {@link DirectDataBufferInt} {@link BufferedImage}
@@ -64,11 +65,13 @@ public class OffscreenPrintable extends PrintableBase implements Printable {
* @param printContainer
* @param printDPI
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
* @param imageType AWT BufferedImage type (must be one of the integer types)
* @param pngFilename TODO
*/
- public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int imageType, String pngFilename) {
- super(job, printContainer, printDPI, numSamples);
+ public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight, int imageType, String pngFilename) {
+ super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight);
this.imageType = imageType;
this.pngFilename = pngFilename;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java
index 7e8bac295..6f73ef2b4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java
@@ -39,6 +39,7 @@ import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import com.jogamp.common.util.awt.AWTEDTExecutor;
+import com.jogamp.opengl.util.TileRenderer;
/**
* <h5>Scaling of Frame and GL content</h5>
@@ -66,11 +67,14 @@ public class OnscreenPrintable extends PrintableBase implements Printable {
* @param printContainer
* @param printDPI
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
*/
- public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples) {
- super(job, printContainer, printDPI, numSamples);
+ public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) {
+ super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight);
}
+
@Override
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
if (page > 0) { // We have only one page, and 'page' is zero-based
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java
index 830ded960..dd9de60c3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java
@@ -33,6 +33,7 @@ import java.awt.print.PrinterJob;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
+import com.jogamp.opengl.util.TileRenderer;
/**
* Base {@link Printable} implementation class.
@@ -58,6 +59,7 @@ public abstract class PrintableBase implements Printable {
public final Container cont;
public final int dpi;
public final int numSamples;
+ public final int tileWidth, tileHeight;
protected final RecursiveLock lockPrinting = LockFactory.createRecursiveLock();
/**
@@ -66,12 +68,16 @@ public abstract class PrintableBase implements Printable {
* @param printContainer
* @param printDPI
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
*/
- public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples) {
+ public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) {
this.job = job;
this.cont = printContainer;
this.dpi = printDPI;
this.numSamples = numSamples;
+ this.tileWidth = tileWidth;
+ this.tileHeight = tileHeight;
}
/** Wait for idle .. simply acquiring all locks and releasing them. */
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java
index 4883df501..30e0ba4e6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java
@@ -116,15 +116,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase {
final ActionListener print72DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 72, 0);
+ doPrintManual(frame, 72, 0, -1, -1);
} };
final ActionListener print300DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 300, -1);
+ doPrintManual(frame, 300, -1, -1, -1);
} };
final ActionListener print600DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 600, -1);
+ doPrintManual(frame, 600, -1, -1, -1);
} };
final Button print72DPIButton = new Button("72dpi");
print72DPIButton.addActionListener(print72DPIAction);
@@ -178,36 +178,41 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase {
if( !printDone ) {
printDone = true;
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true/* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
+ waitUntilPrintJobsIdle(p);
+ }
+ {
+ // No AA needed for 150 dpi and greater :)
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true/* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
if( allow600dpi ) {
// No AA needed for 300 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java
index a256d964f..ec1d7b1d6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java
@@ -121,15 +121,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase {
final ActionListener print72DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 72, 0);
+ doPrintManual(frame, 72, 0, -1, -1);
} };
final ActionListener print300DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 300, -1);
+ doPrintManual(frame, 300, -1, -1, -1);
} };
final ActionListener print600DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 600, -1);
+ doPrintManual(frame, 600, -1, -1, -1);
} };
final Button print72DPIButton = new Button("72dpi");
print72DPIButton.addActionListener(print72DPIAction);
@@ -183,36 +183,41 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase {
if( !printDone ) {
printDone = true;
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
+ waitUntilPrintJobsIdle(p);
+ }
+ {
+ // No AA needed for 150 dpi and greater :)
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
if( allow600dpi ) {
// No AA needed for 300 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java
index f1759798b..72cb219ab 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java
@@ -152,15 +152,15 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase {
final ActionListener print72DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 72, 0);
+ doPrintManual(frame, 72, 0, -1, -1);
} };
final ActionListener print300DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 300, -1);
+ doPrintManual(frame, 300, -1, -1, -1);
} };
final ActionListener print600DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 600, -1);
+ doPrintManual(frame, 600, -1, -1, -1);
} };
final Button print72DPIButton = new Button("72dpi");
print72DPIButton.addActionListener(print72DPIAction);
@@ -217,51 +217,56 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase {
if( !printDone ) {
printDone = true;
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
+ waitUntilPrintJobsIdle(p);
+ }
+ {
+ // No AA needed for 150 dpi and greater :)
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
if( allow600dpi ) {
// No AA needed for 300 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */);
waitUntilPrintJobsIdle(p);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java
index d18def075..2d4973d6b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java
@@ -142,15 +142,15 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase {
final ActionListener print72DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 72, 0);
+ doPrintManual(frame, 72, 0, -1, -1);
} };
final ActionListener print150DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 150, -1);
+ doPrintManual(frame, 150, -1, -1, -1);
} };
final ActionListener print300DPIAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
- doPrintManual(frame, 300, -1);
+ doPrintManual(frame, 300, -1, -1, -1);
} };
final Button print72DPIButton = new Button("72dpi");
print72DPIButton.addActionListener(print72DPIAction);
@@ -220,7 +220,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase {
printDone = true;
{
// No AA needed for 150 dpi and greater :)
- final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, false);
+ final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, -1, -1, false);
waitUntilPrintJobsIdle(p);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java
index 0fe08ebc2..b51bfae87 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java
@@ -128,7 +128,7 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
// frame.paintAll(g2d);
- final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0);
+ final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0, -1, -1);
try {
frame.printAll(g2d);
} finally {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
index e6179aa95..4e9d4bdbe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
@@ -51,11 +51,13 @@ import jogamp.nativewindow.awt.AWTMisc;
import org.junit.Assert;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.nativewindow.awt.AWTPrintLifecycle;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.TileRenderer;
/**
* Base unit test class implementing
@@ -79,9 +81,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
* @param offscrnImageType if < 0 onscreen, otherwise integer BufferedImage type
* @param dpi
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
* @param resizeWithinPrintTest TODO
*/
- public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) {
+ public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper,
+ int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) {
lock.lock();
try {
final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
@@ -98,12 +103,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType);
if (factories.length > 0) {
- final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf", resizeWithinPrintTest);
+ final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "pdf", resizeWithinPrintTest);
System.err.println("doPrint: dpi "+dpi+", "+fname);
FileOutputStream outstream;
try {
outstream = new FileOutputStream(fname);
- return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest);
+ return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper,
+ offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest);
} catch (FileNotFoundException e) {
Assert.assertNull("Unexpected exception", e);
}
@@ -112,12 +118,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
factories = PrinterJob.lookupStreamPrintServices(psMimeType);
if (factories.length > 0) {
- final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps", resizeWithinPrintTest);
+ final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "ps", resizeWithinPrintTest);
System.err.println("doPrint: dpi "+dpi+", "+fname);
FileOutputStream outstream;
try {
outstream = new FileOutputStream(fname);
- return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest);
+ return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest);
} catch (FileNotFoundException e) {
Assert.assertNull("Unexpected exception", e);
}
@@ -128,17 +134,17 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
lock.unlock();
}
}
- private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix, boolean resizeWithinPrintTest) {
+ private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, String suffix, boolean resizeWithinPrintTest) {
final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1;
final String simpleTestName = getSimpleTestName(".");
final String onoffscrn = 0 > offscrnImageType ? "on_screen" : "offscrn_"+offscrnImageType;
final String aa = 0 <= numSamples ? "aa"+numSamples : "aaN";
- return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-resize%d.%s",
- simpleTestName, printCount, onoffscrn, dpi, aa, resizeWithinPrintTest?1:0, suffix).replace(' ', '_');
+ return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-tSz%04dx%04d-resize%d.%s",
+ simpleTestName, printCount, onoffscrn, dpi, aa, tileWidth, tileHeight, resizeWithinPrintTest?1:0, suffix).replace(' ', '_');
}
private PrintableBase doPrintAutoImpl(Container cont, PrinterJob job,
StreamPrintService ps, int pOrientation, Paper paper,
- int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) {
+ int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) {
try {
PageFormat pageFormat = job.defaultPage();
if( null != paper ) {
@@ -152,9 +158,9 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
job.setPrintService(ps);
final PrintableBase printable;
if( 0 < offscrnImageType ) {
- printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png", resizeWithinPrintTest));
+ printable = new OffscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "png", resizeWithinPrintTest));
} else {
- printable = new OnscreenPrintable(job, cont, dpi, numSamples);
+ printable = new OnscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight);
}
printable.job.setPrintable(printable, pageFormat);
doPrintImpl(printable, resizeWithinPrintTest);
@@ -166,15 +172,16 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
}
/**
- *
* @param cont
* @param dpi
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
+ * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
*/
- public PrintableBase doPrintManual(Container cont, int dpi, int numSamples) {
+ public PrintableBase doPrintManual(Container cont, int dpi, int numSamples, int tileWidth, int tileHeight) {
lock.lock();
try {
- final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples);
+ final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples, tileWidth, tileHeight);
printable.job.setPrintable(printable);
boolean ok = printable.job.printDialog();
if (ok) {
@@ -207,10 +214,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
final double scaleGLMatXY = 72.0 / printable.dpi;
System.err.println("PRINTable: "+printable.getClass().getSimpleName());
System.err.println("PRINT DPI: "+printable.dpi+", AA "+printable.numSamples+", scaleGL "+scaleGLMatXY);
- final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, printable.numSamples);
+ final AWTPrintLifecycle.Context ctx =
+ AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY,
+ printable.numSamples, printable.tileWidth, printable.tileHeight);
System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount());
final int w = printable.cont.getWidth();
final int h = printable.cont.getHeight();
+ final long t0 = Platform.currentTimeMillis();
try {
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
public void run() {
@@ -230,6 +240,8 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
} });
} finally {
ctx.releasePrint();
+ final long td = Platform.currentTimeMillis() - t0;
+ System.err.println("PRINT Duration "+td+" ms");
if( resizeWithinPrintTest ) {
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
public void run() {