AWTGLCanvas: Synchronize paintGL() to avoid destroyContext while painting
This commit is contained in:
parent
8164a4a00a
commit
9f3de4fd81
|
@ -283,43 +283,45 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener,
|
||||||
* be overridden to do GL operations.
|
* be overridden to do GL operations.
|
||||||
*/
|
*/
|
||||||
public final void paint(Graphics g) {
|
public final void paint(Graphics g) {
|
||||||
try {
|
synchronized (SYNC_LOCK) {
|
||||||
if (peer_info == null) {
|
|
||||||
this.peer_info = implementation.createPeerInfo(this, pixel_format);
|
|
||||||
}
|
|
||||||
peer_info.lockAndGetHandle();
|
|
||||||
try {
|
try {
|
||||||
if (context == null) {
|
if (peer_info == null) {
|
||||||
this.context = new Context(peer_info, drawable != null ? drawable.getContext() : null);
|
this.peer_info = implementation.createPeerInfo(this, pixel_format);
|
||||||
first_run = true;
|
|
||||||
}
|
}
|
||||||
|
peer_info.lockAndGetHandle();
|
||||||
if (reentry_count == 0)
|
|
||||||
context.makeCurrent();
|
|
||||||
reentry_count++;
|
|
||||||
try {
|
try {
|
||||||
if (update_context) {
|
if (context == null) {
|
||||||
context.update();
|
this.context = new Context(peer_info, drawable != null ? drawable.getContext() : null);
|
||||||
update_context = false;
|
first_run = true;
|
||||||
}
|
}
|
||||||
AWTCanvasInputImplementation current_input = awt_input;
|
|
||||||
if (current_input != null)
|
|
||||||
current_input.processInput(peer_info);
|
|
||||||
if (first_run) {
|
|
||||||
first_run = false;
|
|
||||||
initGL();
|
|
||||||
}
|
|
||||||
paintGL();
|
|
||||||
} finally {
|
|
||||||
reentry_count--;
|
|
||||||
if (reentry_count == 0)
|
if (reentry_count == 0)
|
||||||
Context.releaseCurrentContext();
|
context.makeCurrent();
|
||||||
|
reentry_count++;
|
||||||
|
try {
|
||||||
|
if (update_context) {
|
||||||
|
context.update();
|
||||||
|
update_context = false;
|
||||||
|
}
|
||||||
|
AWTCanvasInputImplementation current_input = awt_input;
|
||||||
|
if (current_input != null)
|
||||||
|
current_input.processInput(peer_info);
|
||||||
|
if (first_run) {
|
||||||
|
first_run = false;
|
||||||
|
initGL();
|
||||||
|
}
|
||||||
|
paintGL();
|
||||||
|
} finally {
|
||||||
|
reentry_count--;
|
||||||
|
if (reentry_count == 0)
|
||||||
|
Context.releaseCurrentContext();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
peer_info.unlock();
|
||||||
}
|
}
|
||||||
} finally {
|
} catch (LWJGLException e) {
|
||||||
peer_info.unlock();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} catch (LWJGLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue