aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-21 01:42:54 +0100
committerSven Gothel <[email protected]>2013-11-21 01:42:54 +0100
commit94f3c1b5d3af65cf9d985833b2c8e40ec1af4592 (patch)
treea66732a1b7957a17a92aa98a8e514c92e324c7d5 /src/jogl
parent291c5ac4f0f55807172d1036e7c746db9af7ceec (diff)
Bug 909 - Reccreate GLJPanel's BufferedImage is no more sourced by singleton AWTGLPixelBuffer
GLJPanel must validate whether it's local BufferedImage's DataBuffer is sourced by the current singleton AWTGLPixelBuffer. Case: GLJPanel-B has created a new singleton AWTGLPixelBuffer w/ increased size. Previous created GLJPanel-A's local BufferedImage's DataBuffer is no more sourced by the singleton AWTGLPixelBuffer and hence must be re-created.
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java30
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java18
2 files changed, 27 insertions, 21 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
index 77b14b424..a33356067 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java
@@ -101,20 +101,24 @@ public class AWTGLPixelBuffer extends GLPixelBuffer {
if( width * height > image.getWidth() * image.getHeight() ) {
throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight());
}
- if( width == image.getWidth() ) {
- if( height == image.getHeight() ) {
- return image;
- }
- return image.getSubimage(0, 0, width, height);
+ if( width == image.getWidth() && height == image.getHeight() ) {
+ return image;
+ } else {
+ final ColorModel cm = image.getColorModel();
+ final WritableRaster raster0 = image.getRaster();
+ final DataBuffer dataBuffer = raster0.getDataBuffer();
+ final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster0.getSampleModel();
+ final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
+ width, height, width /* scanLineStride */, sppsm0.getBitMasks());
+ final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null);
+ return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null);
}
- final ColorModel cm = image.getColorModel();
- final WritableRaster raster = image.getRaster();
- final DataBuffer dataBuffer = raster.getDataBuffer();
- final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster.getSampleModel();
- final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
- width, height, width /* scanLineStride */, sppsm0.getBitMasks());
- final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null);
- return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null);
+ }
+
+ public final boolean isDataBufferSource(BufferedImage imageU) {
+ final DataBuffer dataBuffer0 = image.getRaster().getDataBuffer();
+ final DataBuffer dataBufferU = imageU.getRaster().getDataBuffer();
+ return dataBufferU == dataBuffer0;
}
@Override
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index bff8a1880..70dd8b99d 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -580,7 +580,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
super.reshape(x, y, width, height);
if( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.reshape resize"+(printActive?"WithinPrint":"")+" [ panel "+
+ System.err.println(getThreadName()+": GLJPanel.reshape.0 "+this.getName()+" resize"+(printActive?"WithinPrint":"")+" [ this "+getWidth()+"x"+getHeight()+", panel "+
panelWidth+"x"+panelHeight +
", reshape: " +reshapeWidth+"x"+reshapeHeight +
"] -> "+(printActive?"skipped":"") + width+"x"+height);
@@ -1588,19 +1588,21 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0);
if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName());
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName());
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight);
}
}
if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) {
throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName());
}
- if( null == alignedImage || panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ) {
+ if( null == alignedImage ||
+ panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ||
+ !pixelBuffer.isDataBufferSource(alignedImage) ) {
alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight);
if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" new alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", "+alignedImage+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height+", "+pixelBuffer);
}
}
final IntBuffer readBackInts;
@@ -1652,7 +1654,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] ||
offscreenDrawable.getWidth() != usrViewport[2] || offscreenDrawable.getHeight() != usrViewport[3];
if( DEBUG_VIEWPORT ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: change "+viewportChange+
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: "+GLJPanel.this.getName()+" Viewport: change "+viewportChange+
", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+
" -> 0/0 "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight());
}