aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-09-07 19:59:15 +0200
committerSven Gothel <[email protected]>2013-09-07 19:59:15 +0200
commit9b5cee85c299e72735bebbfea5c23d3c71bc704e (patch)
treef98bfacda594aecddd9899351350b50b011c3a34 /src/jogl
parent4965923722fe44dfcf7eaff16cd5449707773123 (diff)
TiledPrintingAWTBase: Fix scaling - Fit frame to page, add MSAA RenderingHints test; setupPrint(Graphics2D): Query RenderingHints to use MSAA rendering
- AWTPrintLifecycle.setupPrint(Graphics2D): Query RenderingHints to use MSAA rendering - Impl. in GLCanvas - TODO GLJPanel (would need a new offscreen buffer) - TiledPrintingAWTBase: - Fix scaling - Fit frame to page - add MSAA RenderingHints test - GLCanvas: Remove dumpStack() DEBUG output
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java62
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java2
4 files changed, 52 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java
index afa27dbd8..077ee42a9 100644
--- a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java
+++ b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java
@@ -1,5 +1,3 @@
-package javax.media.opengl.awt;
-
/**
* Copyright 2013 JogAmp Community. All rights reserved.
*
@@ -27,9 +25,12 @@ package javax.media.opengl.awt;
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
+package javax.media.opengl.awt;
import javax.media.opengl.GLAutoDrawable;
import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
/**
* Interface describing print lifecycle to support AWT printing
@@ -38,12 +39,13 @@ import java.awt.Component;
public interface AWTPrintLifecycle {
/**
- * Shall be called before {@link Component#print(java.awt.Graphics)}.
+ * Shall be called before {@link Component#print(Graphics)}.
+ * @param g2d the {@link Graphics2D} instance, which will be used for printing.
*/
- void setupPrint();
+ void setupPrint(Graphics2D g2d);
/**
- * Shall be called after very last {@link Component#print(java.awt.Graphics)}.
+ * Shall be called after very last {@link Component#print(Graphics)}.
*/
void releasePrint();
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 5ada2d80f..8f9684db1 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -375,7 +375,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
System.err.println("Created Config (n): HAVE CF "+awtConfig);
System.err.println("Created Config (n): Choosen CF "+config);
System.err.println("Created Config (n): EQUALS CAPS "+equalCaps);
- Thread.dumpStack();
+ // Thread.dumpStack();
}
if (compatible != null) {
@@ -565,7 +565,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
if(DEBUG) {
System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()+", isBeansDesignTime "+isBeansDesignTime);
- Thread.dumpStack();
+ // Thread.dumpStack();
}
if( isBeansDesignTime ) {
@@ -642,7 +642,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
final boolean res = _drawable.isRealized();
if(DEBUG) {
System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString());
- Thread.dumpStack();
+ // Thread.dumpStack();
}
return res;
}
@@ -662,7 +662,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
public void removeNotify() {
if(DEBUG) {
System.err.println(getThreadName()+": Info: removeNotify - start");
- Thread.dumpStack();
+ // Thread.dumpStack();
}
awtWindowClosingProtocol.removeClosingListener();
@@ -731,12 +731,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private static final int PRINT_TILE_SIZE = 512;
private volatile boolean printActive = false;
+ private boolean printUseAA = false;
private GLAnimatorControl printAnimator = null;
private GLOffscreenAutoDrawable printGLAD = null;
private AWTTilePainter printAWTTiles = null;
@Override
- public void setupPrint() {
+ public void setupPrint(Graphics2D g2d) {
if( !validateGLDrawable() ) {
if(DEBUG) {
System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet");
@@ -751,6 +752,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
printActive = true;
sendReshape = false; // clear reshape flag
+ final RenderingHints rHints = g2d.getRenderingHints();
+ {
+ final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING);
+ printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON );
+ }
+ if( DEBUG ) {
+ System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", useAA "+printUseAA+", printAnimator "+printAnimator);
+ {
+ final Set<Entry<Object, Object>> rEntries = rHints.entrySet();
+ int count = 0;
+ for(Iterator<Entry<Object, Object>> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) {
+ final Entry<Object, Object> rEntry = rEntryIter.next();
+ System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue());
+ }
+ }
+ final AffineTransform aTrans = g2d.getTransform();
+ System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY());
+ System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY());
+ }
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT);
}
private final Runnable setupPrintOnEDT = new Runnable() {
@@ -762,6 +782,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAnimator.remove(GLCanvas.this);
}
final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable();
+ caps.setDoubleBuffered(false);
+ final GLProfile glp = caps.getGLProfile();
+ if( printUseAA && !caps.getSampleBuffers() ) {
+ if ( !glp.isGL2ES3() ) {
+ if( DEBUG ) {
+ System.err.println("Ignore MSAA due to gl-profile < GL2ES3");
+ }
+ printUseAA = false;
+ } else {
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(8); // FIXME
+ }
+ }
caps.setOnscreen(false);
final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null);
@@ -775,6 +808,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAWTTiles = new AWTTilePainter(printRenderer, componentCount, DEBUG);
if( DEBUG ) {
System.err.println("AWT print.setup "+printAWTTiles);
+ System.err.println("AWT print.setup AA "+printUseAA+", "+caps);
+ System.err.println("AWT print.setup "+printGLAD);
}
}
};
@@ -820,21 +855,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
sendReshape = false; // clear reshape flag
final Graphics2D printGraphics = (Graphics2D)graphics;
- if( DEBUG ) {
- System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator);
- {
- final RenderingHints rHints = printGraphics.getRenderingHints();
- final Set<Entry<Object, Object>> rEntries = rHints.entrySet();
- int count = 0;
- for(Iterator<Entry<Object, Object>> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) {
- final Entry<Object, Object> rEntry = rEntryIter.next();
- System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue());
- }
- }
- final AffineTransform aTrans = printGraphics.getTransform();
- System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY());
- System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY());
- }
printAWTTiles.updateGraphics2DAndClipBounds(printGraphics);
final TileRenderer tileRenderer = printAWTTiles.getTileRenderer();
if( DEBUG ) {
@@ -1070,7 +1090,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
if(DEBUG) {
System.err.println(getThreadName()+": Info: destroyOnEDTAction() - START, hasContext " +
(null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator);
- Thread.dumpStack();
+ // Thread.dumpStack();
}
final boolean animatorPaused;
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 1f9e65a7d..2488bd443 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -505,7 +505,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private AWTTilePainter printAWTTiles = null;
@Override
- public void setupPrint() {
+ public void setupPrint(Graphics2D g2d) {
if (!isInitialized) {
if(DEBUG) {
System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet");
@@ -1200,8 +1200,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) {
if(null == custom) {
- pixelBufferProvider = ( glp.isGL2GL3() || glp.isGL3ES3() ) ? getSingleAWTGLPixelBufferProvider() :
- new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ;
+ pixelBufferProvider = glp.isGL2ES3() ? getSingleAWTGLPixelBufferProvider() :
+ new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ;
} else {
pixelBufferProvider = custom;
}
diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
index d7979efdb..f2248b388 100644
--- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
@@ -43,7 +43,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
static {
Debug.initSingleton();
DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject");
- DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true);
+ DEBUG_SWAP = DEBUG || Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true);
}
private final GLDrawableImpl parent;