diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/Texture.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/Texture.java')
| -rw-r--r-- | NET/worlds/scape/Texture.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/NET/worlds/scape/Texture.java b/NET/worlds/scape/Texture.java new file mode 100644 index 0000000..9850a38 --- /dev/null +++ b/NET/worlds/scape/Texture.java @@ -0,0 +1,102 @@ +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) { + } +} |