diff options
author | Chien Yang <[email protected]> | 2007-04-13 21:26:47 +0000 |
---|---|---|
committer | Chien Yang <[email protected]> | 2007-04-13 21:26:47 +0000 |
commit | c29c72d93cd2979469efc8c4c11b7ee8b87f1176 (patch) | |
tree | ca4eab948ef372719480de4dc2e1585a1112112a /src | |
parent | 4b7f00ce1b26ac4a7347df5cbb34dbba74219c99 (diff) |
Fixed to Issue 396 : Off-screen Canvas3D / D3D: Resizing crashes VM
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@821 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/javax/media/j3d/Canvas3D.java | 16 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/Renderer.java | 5 | ||||
-rw-r--r-- | src/native/d3d/Canvas3D.cpp | 16 |
3 files changed, 17 insertions, 20 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index 4b10aab..e15da57 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -1846,7 +1846,7 @@ public class Canvas3D extends Canvas { if (buffer != null) { ImageComponent2DRetained bufferRetained = (ImageComponent2DRetained)buffer.retained; - + if (bufferRetained.byReference && !(bufferRetained.getRefImage(0) instanceof BufferedImage)) { @@ -1896,23 +1896,25 @@ public class Canvas3D extends Canvas { // Will do destroyOffScreenBuffer in the Renderer thread. sendDestroyCtxAndOffScreenBuffer(); drawable = null; - } - + } + // Issue 396. Since context is invalid here, we should set it to null. + ctx = null; + // set the canvas dimension according to the buffer dimension offScreenCanvasSize.setSize(width, height); this.setSize(offScreenCanvasSize); - if (width > 0 && height > 0) { + if (width > 0 && height > 0) { sendCreateOffScreenBuffer(); } - ctx = null; + } - else if (ctx != null) { + else if (ctx != null) { removeCtx(); } if (freeCanvasId) { - sendFreeCanvasId(); + sendFreeCanvasId(); } offScreenBuffer = buffer; diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java index 80d12f9..21e7534 100644 --- a/src/classes/share/javax/media/j3d/Renderer.java +++ b/src/classes/share/javax/media/j3d/Renderer.java @@ -546,8 +546,11 @@ class Renderer extends J3dThread { canvas.drawable = null; try { + // Issue 396. Pass in a null ctx for 2 reasons : + // 1) We should not use ctx field directly without buffering in a msg. + // 2) canvas.ctx should be null. canvas.drawable = - canvas.createOffScreenBuffer(canvas.ctx, + canvas.createOffScreenBuffer(null, canvas.screen.display, canvas.fbConfig, canvas.offScreenCanvasSize.width, diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp index 010da46..0bc73cb 100644 --- a/src/native/d3d/Canvas3D.cpp +++ b/src/native/d3d/Canvas3D.cpp @@ -1112,18 +1112,10 @@ jlong JNICALL Java_javax_media_j3d_NativePipeline_createOffScreenBuffer( jlong fbConfigListPtr, jint width, jint height) -{ - - - if (ctx == 0) { - // createContext() will be invoked later in Renderer - return 1; - } else { - GetCtx2(); - d3dCtx->d3dPresent.BackBufferWidth = width; - d3dCtx->d3dPresent.BackBufferHeight = height; - return SUCCEEDED(d3dCtx->resetSurface(env, cv)); - } + { + // Issue 396. + // createContext() will be invoked later in Renderer + return 1; } |