package NET.worlds.scape; import NET.worlds.network.URL; import java.io.IOException; import java.net.MalformedURLException; public abstract class Texture implements Persister { protected int textureID = 0; int refs = 1; private static Object classCookie = new Object(); static { nativeInit(); } protected Texture() { } public static native void nativeInit(); private static native int nativeGetW(int var0); public int getW() { return nativeGetW(this.textureID); } private static native int nativeGetH(int var0); public int getH() { return nativeGetH(this.textureID); } public URL getURL() { URL u = null; String s = this.getName(); if (s != null) { try { u = new URL(URL.getCurDir(), s); } catch (MalformedURLException var4) { } } return u; } public void incRef() { assert this.refs > 0; if (this.textureID != 0) { this.refs++; } } public void copyFrom(int dc, int x1, int x2, int y1, int y2) { assert this.textureID != 0; nativeCopyFrom(this.textureID, dc, x1, x2, y1, y2); } private static native void nativeCopyFrom(int var0, int var1, int var2, int var3, int var4, int var5); private static native void nativeRelease(int var0); public synchronized void decRef() { if (--this.refs <= 0 && this.textureID != 0) { nativeRelease(this.textureID); this.textureID = 0; } } @Override protected void finalize() { if (this.refs > 0) { this.refs = 1; this.decRef(); this.refs = 1000000; } } protected String getName() { return null; } @Override public void saveState(Saver s) throws IOException { s.saveVersion(0, classCookie); } @Override public void restoreState(Restorer r) throws IOException, TooNewException { switch (r.restoreVersion(classCookie)) { case 0: return; default: throw new TooNewException(); } } @Override public void postRestore(int version) { } }