diff options
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Display.java | 8 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/DisplayImpl.java | 17 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/PointerIconImpl.java | 31 |
3 files changed, 16 insertions, 40 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index d683eb9f2..de2f698c9 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -147,14 +147,6 @@ public abstract class Display { boolean isValid(); /** - * Returns true if instance {@link #isValid()} or validation was successful, otherwise false. - * <p> - * Validation, i.e. recreation, is required if instance became invalid, see {@link #isValid()}. - * </p> - */ - boolean validate(); - - /** * Destroys this instance. * <p> * Will be called automatically if it's {@link #getDisplay() associated Display} is destroyed. diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 8037ffdce..62550ee0c 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -140,12 +140,8 @@ public abstract class DisplayImpl extends Display { if( DEBUG_POINTER_ICON ) { System.err.println("createPointerIconPNG.0: "+image+", handle: "+toHexString(handle)+", hot "+hotspot); } - if( 0 == handle ) { - throw new IOException(exStr); - } - res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); - if( DEBUG_POINTER_ICON ) { - System.err.println("createPointerIconPNG.0: "+res[0]); + if( 0 != handle ) { + res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); } } catch (final Exception e) { ex[0] = e; @@ -161,11 +157,10 @@ public abstract class DisplayImpl extends Display { } throw new IOException(e); } - if( null == res[0] ) { - throw new IOException(exStr); - } - synchronized(pointerIconList) { - pointerIconList.add(res[0]); + if( null != res[0] ) { + synchronized(pointerIconList) { + pointerIconList.add(res[0]); + } } return res[0]; } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java index da72752fa..e0a47fed2 100644 --- a/src/newt/classes/jogamp/newt/PointerIconImpl.java +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -29,6 +29,7 @@ package jogamp.newt; import java.nio.ByteBuffer; +import com.jogamp.nativewindow.NativeWindowException; import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.PixelFormat; import com.jogamp.nativewindow.util.PixelRectangle; @@ -53,7 +54,6 @@ public class PointerIconImpl implements PointerIcon { this.size = size; this.pixels = pixels; this.hotspot = hotspot; - this.handle=handle; } public PointerIconImpl(final DisplayImpl display, final PixelRectangle pixelrect, final PointImmutable hotspot, final long handle) { @@ -84,21 +84,17 @@ public class PointerIconImpl implements PointerIcon { return hashCode; } + /** + * @return the native handle of this pointer icon, maybe {@code null} + */ public synchronized final long getHandle() { return handle; } - public synchronized final long validatedHandle() { - synchronized(display.pointerIconList) { - if( !display.pointerIconList.contains(this) ) { - display.pointerIconList.add(this); - } - } + /** + * @return the {@link #getHandle()} if not {@code null}, otherwise throws NativeWindowException + * @throws NativeWindowException if {@link #getHandle()} is {@code null} + */ + public synchronized final long validatedHandle() throws NativeWindowException { if( 0 == handle ) { - try { - handle = display.createPointerIconImpl(pixelformat, size.getWidth(), size.getHeight(), pixels, hotspot.getX(), hotspot.getY()); - return handle; - } catch (final Exception e) { - e.printStackTrace(); - return 0; - } + throw new NativeWindowException("PointerIconImpl has null handle: "+this); } else { return handle; } @@ -111,13 +107,6 @@ public class PointerIconImpl implements PointerIcon { public final ByteBuffer getPixels() { return pixels; } @Override public synchronized final boolean isValid() { return 0 != handle; } - @Override - public synchronized final boolean validate() { - if( 0 == handle ) { - return 0 != validatedHandle(); - } - return true; - } @Override public synchronized void destroy() { |