aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2004-09-15 01:27:07 +0000
committerKevin Rushforth <[email protected]>2004-09-15 01:27:07 +0000
commitc181472e7c9058d5137c518302e5f9e803f1a513 (patch)
tree9fabc05997c7e712a859e219f8f926c9282c7b37
parent1550c521edcbbd02d0c5a991292d8ff0b394f381 (diff)
Issue number: Issue 72
Submitted by: kcr Fixed Issue 72 - Exception in setOffScreenBuffer when Canvas3D not in View git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@38 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java17
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java35
-rw-r--r--src/classes/share/javax/media/j3d/Renderer.java19
3 files changed, 43 insertions, 28 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 01f630e..fc693a6 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1772,7 +1772,7 @@ public class Canvas3D extends Canvas {
bufferRetained.height);
this.setSize(offScreenCanvasSize);
- sendCreateOffScreenBuffer();
+ VirtualUniverse.mc.sendCreateOffScreenBuffer(this);
ctx = 0;
}
@@ -3960,21 +3960,6 @@ public class Canvas3D extends Canvas {
}
- // Fix for Issue 18
- // Pass CreateOffScreenBuffer to the Renderer thread for execution.
- private void sendCreateOffScreenBuffer() {
-
- J3dMessage createMessage = VirtualUniverse.mc.getMessage();
- createMessage.threads = J3dThread.RENDER_THREAD;
- createMessage.type = J3dMessage.CREATE_OFFSCREENBUFFER;
- createMessage.universe = this.view.universe;
- createMessage.view = this.view;
- createMessage.args[0] = this;
- screen.renderer.rendererStructure.addMessage(createMessage);
- VirtualUniverse.mc.setWorkForRequestRenderer();
-
- }
-
private void removeCtx(boolean destroyOffscreen) {
if ((screen != null) &&
(screen.renderer != null) &&
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index 71122df..d846f96 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -944,9 +944,10 @@ class MasterControl {
/**
* Create a Renderer if it is not already done so.
* This is used for GraphicsConfigTemplate3D passing
- * graphics call to RequestRenderer.
+ * graphics call to RequestRenderer, and for creating
+ * an off-screen buffer for an off-screen Canvas3D.
*/
- Renderer createRenderer(GraphicsConfiguration gc) {
+ private Renderer createRenderer(GraphicsConfiguration gc) {
final GraphicsDevice gd = gc.getDevice();
Renderer rdr = (Renderer) Screen3D.deviceRendererMap.get(gd);
@@ -2783,6 +2784,36 @@ class MasterControl {
VirtualUniverse.mc.setWorkForRequestRenderer();
}
+ // Fix for Issue 18
+ // Pass CreateOffScreenBuffer to the Renderer thread for execution.
+ void sendCreateOffScreenBuffer(Canvas3D c) {
+ // Assertion check that the renderer has already been created.
+ // If it hasn't, this is very, very bad because it opens up
+ // the possibility of an MT race condition since this method
+ // can be called from the user's thread, possibly at the same
+ // time as the MasterControl thread is trying to create a new
+ // Renderer. Fortunately, this should never happen since both
+ // the GraphicsTemplate3D methods that return a valid Graphics
+ // Configuration and the Canvas3D constructor will ultimately
+ // cause a renderer to be created via sendRenderMessage().
+ GraphicsDevice gd = c.graphicsConfiguration.getDevice();
+ J3dDebug.doAssert((Screen3D.deviceRendererMap.get(gd) != null),
+ "Screen3D.deviceRendererMap.get(gd) != null");
+
+ // Fix for Issue 72 : call createRenderer rather than getting
+ // the renderer from the canvas.screen object
+ Renderer rdr = createRenderer(c.graphicsConfiguration);
+ J3dMessage createMessage = VirtualUniverse.mc.getMessage();
+ createMessage.threads = J3dThread.RENDER_THREAD;
+ createMessage.type = J3dMessage.CREATE_OFFSCREENBUFFER;
+ createMessage.universe = null;
+ createMessage.view = null;
+ createMessage.args[0] = c;
+ rdr.rendererStructure.addMessage(createMessage);
+ VirtualUniverse.mc.setWorkForRequestRenderer();
+ }
+
+
/**
* This is the MasterControl work method for Java 3D
*/
diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java
index df39882..3659f20 100644
--- a/src/classes/share/javax/media/j3d/Renderer.java
+++ b/src/classes/share/javax/media/j3d/Renderer.java
@@ -442,16 +442,6 @@ class Renderer extends J3dThread {
renderType = m[nmesg].type;
- if ((canvas.view == null) || !canvas.firstPaintCalled) {
- // This happen when the canvas just remove from the View
- if (renderType == J3dMessage.RENDER_OFFSCREEN) {
- canvas.offScreenRendering = false;
- }
- m[nmesg++].decRefcount();
- continue;
- }
-
-
if (renderType == J3dMessage.CREATE_OFFSCREENBUFFER) {
// Fix for issue 18.
canvas.window =
@@ -464,6 +454,15 @@ class Renderer extends J3dThread {
continue;
}
+ if ((canvas.view == null) || !canvas.firstPaintCalled) {
+ // This happen when the canvas just remove from the View
+ if (renderType == J3dMessage.RENDER_OFFSCREEN) {
+ canvas.offScreenRendering = false;
+ }
+ m[nmesg++].decRefcount();
+ continue;
+ }
+
if (!canvas.validCanvas &&
(renderType != J3dMessage.RENDER_OFFSCREEN)) {
m[nmesg++].decRefcount();