aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java47
-rw-r--r--src/classes/share/javax/media/j3d/J3dMessage.java7
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java28
-rw-r--r--src/classes/share/javax/media/j3d/Renderer.java27
-rw-r--r--src/classes/share/javax/media/j3d/SoundStructure.java7
5 files changed, 77 insertions, 39 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index c79b3c2..6fbdcac 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1895,10 +1895,9 @@ public class Canvas3D extends Canvas {
(offScreenCanvasSize.height != height)) {
if (window != 0) {
- removeCtx();
- // Fix for Issue 18.
+ // Fix for Issue 18 and Issue 175
// Will do destroyOffScreenBuffer in the Renderer thread.
- sendDestroyOffScreenBuffer();
+ sendDestroyCtxAndOffScreenBuffer();
window = 0;
}
@@ -1909,11 +1908,10 @@ public class Canvas3D extends Canvas {
if (width > 0 && height > 0) {
sendCreateOffScreenBuffer();
}
-
ctx = 0;
}
else if (ctx != 0) {
- removeCtx();
+ removeCtx();
}
offScreenBuffer = buffer;
@@ -2470,7 +2468,7 @@ public class Canvas3D extends Canvas {
// The native method that sets this ctx to be the current one
- static native void useCtx(long ctx, long display, int window);
+ static native boolean useCtx(long ctx, long display, int window);
native void clear(long ctx, float r, float g, float b, int winWidth, int winHeight,
ImageComponent2DRetained image, int imageScaleMode, byte[] imageYdown);
@@ -4363,12 +4361,7 @@ public class Canvas3D extends Canvas {
// Send a destroyOffScreenBuffer message to Renderer (via
// MasterControl) and wait for it to be done
- private void sendDestroyOffScreenBuffer() {
- // Nothing to do unless screen.renderer is non-null
- if ((screen == null) || (screen.renderer == null)) {
- return;
- }
-
+ private void sendDestroyCtxAndOffScreenBuffer() {
// Wait for the buffer to be destroyed unless called from
// a Behavior or from a Rendering thread
Thread currentThread = Thread.currentThread();
@@ -4378,32 +4371,27 @@ public class Canvas3D extends Canvas {
offScreenBufferPending = true;
}
- // Fix for Issue 18
- // Send message to Renderer thread to perform destroyOffScreenBuffer.
- VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
- new Object[]{this,
- new Long(screen.display),
- new Integer(window),
- new Long(0),
- Boolean.TRUE});
+ // Fix for Issue 18 and Issue 175
+ // Send message to Renderer thread to perform remove Ctx and destroyOffScreenBuffer.
+
+ VirtualUniverse.mc.sendDestroyCtxAndOffScreenBuffer(this);
- // Wait for off-screen buffer to be destroyed
+ // Wait for ctx and off-screen buffer to be destroyed
while (offScreenBufferPending) {
MasterControl.threadYield();
}
}
private void removeCtx() {
+
if ((screen != null) &&
(screen.renderer != null) &&
(ctx != 0)) {
- VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
- new Object[]{this,
- new Long(screen.display),
- new Integer(window),
- new Long(ctx),
- Boolean.FALSE});
-
+ VirtualUniverse.mc.postRequest(MasterControl.FREE_CONTEXT,
+ new Object[]{this,
+ new Long(screen.display),
+ new Integer(window),
+ new Long(ctx)});
// Fix for Issue 19
// Wait for the context to be freed unless called from
// a Behavior or from a Rendering thread
@@ -4413,7 +4401,8 @@ public class Canvas3D extends Canvas {
while (ctxTimeStamp != 0) {
MasterControl.threadYield();
}
- }
+
+ }
ctx = 0;
}
}
diff --git a/src/classes/share/javax/media/j3d/J3dMessage.java b/src/classes/share/javax/media/j3d/J3dMessage.java
index d2d073d..c717388 100644
--- a/src/classes/share/javax/media/j3d/J3dMessage.java
+++ b/src/classes/share/javax/media/j3d/J3dMessage.java
@@ -84,9 +84,10 @@ class J3dMessage extends Object {
static final int ORDERED_GROUP_TABLE_CHANGED = 59;
static final int BEHAVIOR_REEVALUATE = 60;
static final int CREATE_OFFSCREENBUFFER = 61;
- static final int SHADER_ATTRIBUTE_CHANGED = 62;
- static final int SHADER_ATTRIBUTE_SET_CHANGED = 63;
- static final int SHADER_APPEARANCE_CHANGED = 64;
+ static final int DESTROY_CTX_AND_OFFSCREENBUFFER = 62;
+ static final int SHADER_ATTRIBUTE_CHANGED = 63;
+ static final int SHADER_ATTRIBUTE_SET_CHANGED = 64;
+ static final int SHADER_APPEARANCE_CHANGED = 65;
/**
* This is the time snapshot at which this change occured
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index c5ba916..e1ead5e 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -3000,6 +3000,31 @@ class MasterControl {
setWorkForRequestRenderer();
}
+ // Issue for Issue 175
+ // Pass DestroyCtxAndOffScreenBuffer to the Renderer thread for execution.
+ void sendDestroyCtxAndOffScreenBuffer(Canvas3D c) {
+ // Assertion check. Look for comment in sendCreateOffScreenBuffer.
+ GraphicsDevice gd = c.graphicsConfiguration.getDevice();
+ J3dDebug.doAssert((Screen3D.deviceRendererMap.get(gd) != null),
+ "Screen3D.deviceRendererMap.get(gd) != null");
+ synchronized (mcThreadLock) {
+ // Assert the master control thread is created.
+ J3dDebug.doAssert((mcThread != null), "mcThread != null");
+ Renderer rdr = createRenderer(c.graphicsConfiguration);
+ J3dMessage createMessage = VirtualUniverse.mc.getMessage();
+ createMessage.threads = J3dThread.RENDER_THREAD;
+ createMessage.type = J3dMessage.DESTROY_CTX_AND_OFFSCREENBUFFER;
+ createMessage.universe = null;
+ createMessage.view = null;
+ createMessage.args[0] = c;
+ rdr.rendererStructure.addMessage(createMessage);
+ synchronized (requestObjList) {
+ setWorkForRequestRenderer();
+ pendingRequest = true;
+ }
+ }
+ }
+
// Fix for Issue 18
// Pass CreateOffScreenBuffer to the Renderer thread for execution.
void sendCreateOffScreenBuffer(Canvas3D c) {
@@ -3046,7 +3071,7 @@ class MasterControl {
*/
void doWork() {
runMonitor(CHECK_FOR_WORK, null, null, null, null);
-
+
synchronized (timeLock) {
synchronized (requestObjList) {
if (pendingRequest) {
@@ -3366,7 +3391,6 @@ class MasterControl {
}
}
-
while (!done) {
// First try a RenderThread
while (!renderWaiting &&
diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java
index 8abfe00..e3237ae 100644
--- a/src/classes/share/javax/media/j3d/Renderer.java
+++ b/src/classes/share/javax/media/j3d/Renderer.java
@@ -342,8 +342,7 @@ class Renderer extends J3dThread {
((Integer) obj[2]).intValue(),
((Long) obj[3]).longValue(),
false, !c.offScreen,
- ((Boolean)obj[4]).booleanValue());
-
+ false);
}
return;
} else { // RENDER || REQUESTRENDER
@@ -473,6 +472,21 @@ class Renderer extends J3dThread {
m[nmesg++].decRefcount();
continue;
}
+ else if (renderType == J3dMessage.DESTROY_CTX_AND_OFFSCREENBUFFER) {
+ // Fix for issue 175.
+ // destroy ctx.
+ // Should be able to collaspe both call into one. Will do this in 1.5,
+ // it is a little risky for 1.4 beta3.
+ removeCtx(canvas, canvas.screen.display, canvas.window, canvas.ctx,
+ false, !canvas.offScreen, false);
+ // destroy offScreenBuffer.
+ removeCtx(canvas, canvas.screen.display, canvas.window, 0,
+ false, !canvas.offScreen, true);
+
+ canvas.offScreenBufferPending = false;
+ m[nmesg++].decRefcount();
+ continue;
+ }
if ((canvas.view == null) || !canvas.firstPaintCalled) {
// This happen when the canvas just remove from the View
@@ -642,7 +656,6 @@ class Renderer extends J3dThread {
ImageComponent2DRetained offBufRetained = null;
if (renderType == J3dMessage.RENDER_OFFSCREEN) {
-
if (canvas.window == 0 || !canvas.active) {
canvas.offScreenRendering = false;
continue;
@@ -1449,7 +1462,13 @@ class Renderer extends J3dThread {
// with drawingSurface already lock
final void makeCtxCurrent(long sharedCtx, long display, int window) {
if (sharedCtx != currentCtx) {
- Canvas3D.useCtx(sharedCtx, display, window);
+ Canvas3D.useCtx(sharedCtx, display, window);
+ /*
+ if(!Canvas3D.useCtx(sharedCtx, display, window)) {
+ Thread.dumpStack();
+ System.err.println("useCtx Fail");
+ }
+ */
currentCtx = sharedCtx;
}
}
diff --git a/src/classes/share/javax/media/j3d/SoundStructure.java b/src/classes/share/javax/media/j3d/SoundStructure.java
index e2407b6..dd18252 100644
--- a/src/classes/share/javax/media/j3d/SoundStructure.java
+++ b/src/classes/share/javax/media/j3d/SoundStructure.java
@@ -106,7 +106,8 @@ class SoundStructure extends J3dStructure {
transformMsg = true;
break;
case J3dMessage.SWITCH_CHANGED:
- processSwitchChanged(m);
+ // This method isn't implemented yet.
+ // processSwitchChanged(m);
// may need to process dirty switched-on transform
if (universe.transformStructure.getLazyUpdate()) {
transformMsg = true;
@@ -442,7 +443,9 @@ class SoundStructure extends J3dStructure {
}
}
+ // Implementation be needed.
void processSwitchChanged(J3dMessage m) {
+ /*
SoundRetained sound;
LeafRetained leaf;
UnorderList arrList;
@@ -468,6 +471,7 @@ class SoundStructure extends J3dStructure {
}
}
}
+ */
}
// How can active flag (based on View orientataion) be set here for all Views?!?
@@ -718,4 +722,5 @@ class SoundStructure extends J3dStructure {
}
void cleanup() {}
+
}