aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java')
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java80
1 files changed, 6 insertions, 74 deletions
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
index b1a3ebac7..6ee4d453e 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
@@ -39,23 +39,12 @@
package com.sun.opengl.impl.x11;
-import java.awt.Component;
-
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
public class X11OnscreenGLDrawable extends X11GLDrawable {
- public static final int LOCK_SURFACE_NOT_READY = 1;
- public static final int LOCK_SURFACE_CHANGED = 2;
- public static final int LOCK_SUCCESS = 3;
-
- protected Component component;
+ protected NativeWindow component;
- // Variables for lockSurface/unlockSurface
- private JAWT_DrawingSurface ds;
- private JAWT_DrawingSurfaceInfo dsi;
- private JAWT_X11DrawingSurfaceInfo x11dsi;
-
// Indicates whether the component (if an onscreen context) has been
// realized. Plausibly, before the component is realized the JAWT
// should return an error or NULL object from some of its
@@ -68,7 +57,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
// addNotify() is called on the component.
protected boolean realized;
- public X11OnscreenGLDrawable(Component component) {
+ public X11OnscreenGLDrawable(NativeWindow component) {
super(null, null);
this.component = component;
}
@@ -98,7 +87,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
try {
boolean didLock = false;
- if (drawable == 0) {
+ if (component.getWindowHandle() == 0) {
if (lockSurface() == LOCK_SURFACE_NOT_READY) {
return;
}
@@ -106,7 +95,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
didLock = true;
}
- GLX.glXSwapBuffers(display, drawable);
+ GLX.glXSwapBuffers(component.getDisplayHandle(), component.getWindowHandle());
if (didLock) {
unlockSurface();
@@ -120,67 +109,10 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
if (!realized) {
return LOCK_SURFACE_NOT_READY;
}
- if (drawable != 0) {
- throw new GLException("Surface already locked");
- }
- ds = JAWT.getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return LOCK_SURFACE_NOT_READY;
- }
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
- // See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated (NOTE: removeNotify
- // should handle this case, but it may be possible that race
- // conditions can cause this code to be triggered -- should test
- // more)
- int ret = LOCK_SUCCESS;
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- ret = LOCK_SURFACE_CHANGED;
- }
- dsi = ds.GetDrawingSurfaceInfo();
- if (dsi == null) {
- // Widget not yet realized
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- return LOCK_SURFACE_NOT_READY;
- }
- x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
- display = x11dsi.display();
- drawable = x11dsi.drawable();
- visualID = x11dsi.visualID();
- if (display == 0 || drawable == 0) {
- // Widget not yet realized
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- return LOCK_SURFACE_NOT_READY;
- }
- return ret;
+ return component.lockSurface();
}
public void unlockSurface() {
- if (drawable == 0) {
- throw new GLException("Surface already unlocked");
- }
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
+ return component.lockSurface();
}
}